oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

Fixed modkey not working for click + drag.

Commit
0bfefa9559c20f1fcb9d10bdcbdbffc42653da47
Parent
5b0eb5f
Author
tonybanters <tonybanters@gmail.com>
Date
2026-02-10 08:38:31

Diff

diff --git a/src/config/lua.zig b/src/config/lua.zig
index 92f511d..924e013 100644
--- a/src/config/lua.zig
+++ b/src/config/lua.zig
@@ -997,6 +997,18 @@ fn lua_set_modkey(state: ?*c.lua_State) callconv(.c) c_int {
     const s = state orelse return 0;
     if (get_string_arg(s, 1)) |modkey_str| {
         cfg.modkey = parse_single_modifier(modkey_str);
+        cfg.add_button(.{
+            .click = .client_win,
+            .mod_mask = cfg.modkey,
+            .button = 1,
+            .action = .move_mouse,
+        }) catch {};
+        cfg.add_button(.{
+            .click = .client_win,
+            .mod_mask = cfg.modkey,
+            .button = 3,
+            .action = .resize_mouse,
+        }) catch {};
     }
     return 0;
 }
diff --git a/src/main.zig b/src/main.zig
index 6563ceb..959ff69 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -193,11 +193,11 @@ pub fn main() !void {
             apply_config_values();
         } else {
             std.debug.print("no config found, using defaults\n", .{});
-            setup_default_keybinds();
+            initialize_default_config();
         }
     } else {
         std.debug.print("failed to init lua, using defaults\n", .{});
-        setup_default_keybinds();
+        initialize_default_config();
     }
 
     var display = Display.open() catch |err| {
@@ -447,7 +447,7 @@ fn make_keybind_str(mod: u32, key: u64, action: config_mod.Action, str_arg: []co
     return kb;
 }
 
-fn setup_default_keybinds() void {
+fn initialize_default_config() void {
     const mod_key: u32 = 1 << 6;
     const shift_key: u32 = 1 << 0;
     const control_key: u32 = 1 << 2;
@@ -483,6 +483,9 @@ fn setup_default_keybinds() void {
         config.add_keybind(make_keybind_int(mod_key | control_key, keysym, .toggle_view_tag, tag_index)) catch {};
         config.add_keybind(make_keybind_int(mod_key | control_key | shift_key, keysym, .toggle_tag, tag_index)) catch {};
     }
+
+    config.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 1, .action = .move_mouse }) catch {};
+    config.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 3, .action = .resize_mouse }) catch {};
 }
 
 fn grab_keybinds(display: *Display) void {
@@ -987,6 +990,7 @@ fn reload_config(display: *Display) void {
     ungrab_keybinds(display);
 
     config.keybinds.clearRetainingCapacity();
+    config.buttons.clearRetainingCapacity();
     config.rules.clearRetainingCapacity();
     config.blocks.clearRetainingCapacity();
 
@@ -1007,7 +1011,7 @@ fn reload_config(display: *Display) void {
         apply_config_values();
     } else {
         std.debug.print("reload failed, restoring defaults\n", .{});
-        setup_default_keybinds();
+        initialize_default_config();
     }
 
     bar_mod.destroy_bars(gpa.allocator(), display.handle);