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