Rearrange files.

This commit is contained in:
2025-10-05 20:06:47 +01:00
parent c6eb56ef29
commit da0af70b1e
13 changed files with 119 additions and 51 deletions

View File

@@ -15,7 +15,7 @@ fi
mkdir -p "$DIR/build"
gcc -shared -fPIC -Wall -Wextra -o "$DIR/build/X-kutu.so" "$DIR/X-kutu.c" $XCB
gcc -shared -fPIC -Wall -Wextra -o "$DIR/build/X-kutu.so" "$DIR/src/c/X-kutu.c" $XCB
if [ ! -f "$DIR/build/X-kutu.so" ]; then
echo "Error: compilation failed." >&2

18
kutu.rb
View File

@@ -2,7 +2,7 @@
# Require X-kutu library for all x11 functions
require_relative "./src/X-kutu"
require_relative "./src/ruby/X-kutu"
# Initialize X
@@ -16,10 +16,10 @@ end
# Require modules
require_relative "./src/utils"
require_relative "./src/node"
require_relative "./src/workspace"
require_relative "./src/events"
require_relative "./src/ruby/utils"
require_relative "./src/ruby/node"
require_relative "./src/ruby/workspace"
require_relative "./src/ruby/events"
# Cleanup on exit
@@ -50,9 +50,15 @@ $rect = {}
refresh_monitors!
# Run startup script
pid = spawn File.join(__dir__, "/src/shell/startup.sh")
Process.detach pid
# Add keybinds
load File.join(__dir__, "/src/bindings.rb")
load File.join(__dir__, "/src/ruby/bindings.rb")
# Initialize workspaces

View File

@@ -1,23 +1,5 @@
#define CLEANMASK(m) ((m & ~0x80))
// Definitions for modifier keys
#define SUPER XCB_MOD_MASK_4
#define ALT XCB_MOD_MASK_1
#define CTRL XCB_MOD_MASK_CONTROL
#define SHIFT XCB_MOD_MASK_SHIFT
// Change this to change the modifier key you want to use
#define MOD SUPER
// Standard headers
#include <err.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
// XCB header
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
// Self-header
#include "X-kutu.h"
// Global variables
// Connection to X server
@@ -27,28 +9,6 @@ xcb_screen_t *scr;
// Currently focused window
xcb_window_t focuswin;
// Geometry structure for rectangles and positions
typedef struct Geometry {
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} Geometry;
// Event structure to represent various X events
typedef struct Event {
int32_t type;
uint32_t window;
int8_t override_redirect;
uint32_t btn;
int32_t x;
int32_t y;
uint32_t height;
uint32_t width;
uint32_t state;
int8_t is_root;
} Event;
// Cleanup function to close the X connection on exit
void cleanup(void) {
if (conn != NULL)

94
src/c/X-kutu.h Normal file
View File

@@ -0,0 +1,94 @@
#ifndef X_KUTU_H
#define X_KUTU_H
// Standard headers
#include <err.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
// XCB headers
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
// Macro to clean modifier masks
#define CLEANMASK(m) ((m & ~0x80))
// Definitions for modifier keys
#define SUPER XCB_MOD_MASK_4
#define ALT XCB_MOD_MASK_1
#define CTRL XCB_MOD_MASK_CONTROL
#define SHIFT XCB_MOD_MASK_SHIFT
// Change this to change the modifier key you want to use
#define MOD SUPER
// Forward declarations of global variables
extern xcb_connection_t *conn;
extern xcb_screen_t *scr;
extern xcb_window_t focuswin;
// Geometry structure for rectangles and positions
typedef struct Geometry {
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} Geometry;
// Event structure to represent various X events
typedef struct Event {
int32_t type;
uint32_t window;
int8_t override_redirect;
uint32_t btn;
int32_t x;
int32_t y;
uint32_t height;
uint32_t width;
uint32_t state;
int8_t is_root;
} Event;
// Function prototypes
int deploy(void);
void cleanup(void);
void add_keybind(int key);
void add_mousebind(int button);
xcb_window_t get_focus(void);
xcb_window_t get_root(void);
void focus(xcb_window_t win);
void subscribe(xcb_window_t win);
void kill(xcb_window_t window);
void destroy(xcb_window_t win);
void show(xcb_window_t window);
void hide(xcb_window_t window);
void send_to_top(xcb_window_t win);
Geometry get_geometry(xcb_window_t win);
Geometry get_pointer(void);
Geometry get_screen(void);
void free_geometry(Geometry *g);
void warp_pointer(xcb_window_t win, int x, int y);
void move_window(xcb_window_t win, int x, int y);
void resize_window(xcb_window_t win, int width, int height);
xcb_size_hints_t get_wm_n_hints(xcb_window_t win);
xcb_icccm_wm_hints_t get_wm_hints(xcb_window_t win);
char *get_wm_name(xcb_window_t win);
uint8_t get_wm_transient_for(xcb_window_t win);
void set_wm_state(xcb_window_t win, int state);
xcb_window_t draw_rectangle(int x, int y, int width, int height,
uint32_t color);
void grab_pointer(xcb_window_t win);
void ungrab_pointer(void);
Event wait_for_event(void);
#endif // X_KUTU_H

View File

@@ -2,7 +2,7 @@ require "ffi"
module X
extend FFI::Library
ffi_lib File.join(__dir__, "../build/X-kutu.so")
ffi_lib File.join(__dir__, "../../build/X-kutu.so")
typedef :uint32, :xcb_window_t
typedef :uint32, :xcb_pixmap_t

View File

@@ -3,7 +3,7 @@ keybind(24) do |event|
end
keybind(25) do |_event|
pid = spawn("kitty")
pid = spawn "kitty"
Process.detach pid
end
@@ -12,6 +12,11 @@ keybind(26) do |_event|
exit 1
end
keybind(55) do |_event|
pid = spawn "rofi -modi 'clipboard:greenclip print' -show clipboard -run-command '{cmd}'"
Process.detach pid
end
mousebind 1

3
src/shell/startup.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
picom --config ~/.config/i3/picom.conf