Fixes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*.so
|
||||
*.vim
|
||||
*p.yml
|
||||
|
||||
16
X-kutu.c
16
X-kutu.c
@@ -54,13 +54,15 @@ void cleanup(void) {
|
||||
xcb_disconnect(conn);
|
||||
}
|
||||
|
||||
// Keybind function to setup a key grab if the keycode is clicked along with the MOD key
|
||||
// Keybind function to setup a key grab if the keycode is clicked along with the
|
||||
// MOD key
|
||||
void add_keybind(int key) {
|
||||
xcb_grab_key(conn, 0, scr->root, MOD, key, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC);
|
||||
}
|
||||
|
||||
// Mousebind function to setup a mouse button grab if the button is clicked along with the MOD key
|
||||
// Mousebind function to setup a mouse button grab if the button is clicked
|
||||
// along with the MOD key
|
||||
void add_mousebind(int button) {
|
||||
xcb_grab_button(conn, 0, scr->root,
|
||||
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
|
||||
@@ -68,7 +70,8 @@ void add_mousebind(int button) {
|
||||
button, MOD);
|
||||
}
|
||||
|
||||
// Deploy function to initialize the X connection, set up event masks, and prepare the window manager
|
||||
// Deploy function to initialize the X connection, set up event masks, and
|
||||
// prepare the window manager
|
||||
int deploy(void) {
|
||||
uint32_t values[2];
|
||||
int mask;
|
||||
@@ -98,7 +101,7 @@ void free_geometry(Geometry *g) { free(g); }
|
||||
// The caller is responsible for freeing the returned array
|
||||
Geometry *xrandr_get_monitors(void) {
|
||||
// TODO: Loop through monitors and return their geometries
|
||||
return all;
|
||||
// return all;
|
||||
}
|
||||
|
||||
// Set input focus to a window
|
||||
@@ -168,7 +171,8 @@ Geometry get_screen(void) {
|
||||
}
|
||||
|
||||
// Warp the pointer to a specific position in a window
|
||||
// Can be used with get_geometry to warp to a specific position in a window (eg. the center)
|
||||
// Can be used with get_geometry to warp to a specific position in a window (eg.
|
||||
// the center)
|
||||
void warp_pointer(xcb_window_t win, int x, int y) {
|
||||
xcb_warp_pointer(conn, XCB_NONE, win, 0, 0, 0, 0, x, y);
|
||||
xcb_flush(conn);
|
||||
@@ -304,4 +308,4 @@ Event wait_for_event(void) {
|
||||
xcb_flush(conn);
|
||||
free(ev);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
34
kutu.rb
34
kutu.rb
@@ -67,7 +67,6 @@ end
|
||||
|
||||
if X.deploy < 0
|
||||
raise "Failed to deploy X"
|
||||
exit 1
|
||||
end
|
||||
|
||||
at_exit { X.cleanup }
|
||||
@@ -98,12 +97,12 @@ class Node
|
||||
end
|
||||
end
|
||||
|
||||
class Window << Node
|
||||
class Window < Node
|
||||
attr_accessor :window_id
|
||||
|
||||
def initialize(window_id)
|
||||
@window_id = window_id
|
||||
super()
|
||||
super
|
||||
end
|
||||
|
||||
def each_leaf(&block)
|
||||
@@ -111,11 +110,12 @@ class Window << Node
|
||||
end
|
||||
end
|
||||
|
||||
class WindowBlock << Node
|
||||
class WindowBlock < Node
|
||||
attr_accessor :children, :direction, :size
|
||||
|
||||
def initialize()
|
||||
@children = []
|
||||
super
|
||||
end
|
||||
|
||||
def add_node(node)
|
||||
@@ -129,11 +129,11 @@ class WindowBlock << Node
|
||||
end
|
||||
end
|
||||
|
||||
class RootWindowBlock << WindowBlock
|
||||
class RootWindowBlock < WindowBlock
|
||||
attr_accessor :x, :y, :width, :height
|
||||
|
||||
def initialize(workspace)
|
||||
super()
|
||||
super
|
||||
@x = workspace.x
|
||||
@y = workspace.y
|
||||
@width = workspace.width
|
||||
@@ -155,7 +155,7 @@ class Workspace
|
||||
def windows
|
||||
windows = []
|
||||
@untiled_windows.each { |w| windows << w }
|
||||
@tiled_root_block.each_leaf() { |w| windows << w }
|
||||
@tiled_root_block.each_leaf { |w| windows << w }
|
||||
windows
|
||||
end
|
||||
|
||||
@@ -172,7 +172,7 @@ class Workspace
|
||||
def close_all
|
||||
@windows.each_key do |window|
|
||||
X.kill window
|
||||
self.remove window
|
||||
remove window
|
||||
end
|
||||
end
|
||||
|
||||
@@ -229,7 +229,7 @@ loop do
|
||||
event = X.wait_for_event
|
||||
case EVENT_TYPES[event[:type]]
|
||||
when :create
|
||||
if event[:override_redirect] == 0
|
||||
if event[:override_redirect].zero?
|
||||
X.subscribe event[:window]
|
||||
X.focus event[:window]
|
||||
$workspaces[:main].add event[:window]
|
||||
@@ -250,19 +250,17 @@ loop do
|
||||
$mouse_window = event[:window]
|
||||
$mouse_pos_start = X.get_pointer
|
||||
$geom_start = X.get_geometry event[:window]
|
||||
if $mousebind_actions[event[:btn]]
|
||||
$mousebind_actions[event[:btn]].call(event)
|
||||
end
|
||||
$mousebind_actions[event[:btn]]&.call(event)
|
||||
when :mouse_drag
|
||||
screen_bounds = $monitors[0]
|
||||
screen_bounds = X.get_screen # TODO: use monitor
|
||||
mouse_pos = X.get_pointer
|
||||
dx = mouse_pos[:x] - $mouse_pos_start[:x]
|
||||
dy = mouse_pos[:y] - $mouse_pos_start[:y]
|
||||
if $mouse_state == 1
|
||||
new_x = [[$geom_start[:x] + dx, screen_bounds[:x]].max,
|
||||
screen_bounds[:x] + screen_bounds[:width] - $geom_start[:width]].min
|
||||
screen_bounds[:x] + screen_bounds[:width] - $geom_start[:width]].min
|
||||
new_y = [[$geom_start[:y] + dy, screen_bounds[:y]].max,
|
||||
screen_bounds[:y] + screen_bounds[:height] - $geom_start[:height]].min
|
||||
screen_bounds[:y] + screen_bounds[:height] - $geom_start[:height]].min
|
||||
X.move_window $mouse_window, new_x, new_y
|
||||
elsif $mouse_state == 3
|
||||
X.resize_window $mouse_window,
|
||||
@@ -279,12 +277,10 @@ loop do
|
||||
$geom_start = nil
|
||||
end
|
||||
when :key_press
|
||||
if $keybind_actions[event[:btn]]
|
||||
$keybind_actions[event[:btn]].call(event)
|
||||
end
|
||||
$keybind_actions[event[:btn]]&.call(event)
|
||||
when :key_release
|
||||
# TODO
|
||||
when :configured
|
||||
# TODO
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user