tony / oxwm

Fixed modkey not working for click + drag. Browse files
tonybanters committed 2026-02-10 parent 5b0eb5f commit 0bfefa9559c20f1fcb9d10bdcbdbffc42653da47
Showing 2 changed files with 20 additions and 4 deletions. UnifiedSplit
+12 −0 src/config/lua.zig
@@ -997,6 +997,18 @@ fn lua_set_modkey(state: ?*c.lua_State) callconv(.c) c_int {
997 const s = state orelse return 0; 997 const s = state orelse return 0;
998 if (get_string_arg(s, 1)) |modkey_str| { 998 if (get_string_arg(s, 1)) |modkey_str| {
999 cfg.modkey = parse_single_modifier(modkey_str); 999 cfg.modkey = parse_single_modifier(modkey_str);
1000 + cfg.add_button(.{
1001 + .click = .client_win,
1002 + .mod_mask = cfg.modkey,
1003 + .button = 1,
1004 + .action = .move_mouse,
1005 + }) catch {};
1006 + cfg.add_button(.{
1007 + .click = .client_win,
1008 + .mod_mask = cfg.modkey,
1009 + .button = 3,
1010 + .action = .resize_mouse,
1011 + }) catch {};
1000 } 1012 }
1001 return 0; 1013 return 0;
1002 } 1014 }
+8 −4 src/main.zig
@@ -193,11 +193,11 @@ pub fn main() !void {
193 apply_config_values(); 193 apply_config_values();
194 } else { 194 } else {
195 std.debug.print("no config found, using defaults\n", .{}); 195 std.debug.print("no config found, using defaults\n", .{});
196 - setup_default_keybinds(); 196 + initialize_default_config();
197 } 197 }
198 } else { 198 } else {
199 std.debug.print("failed to init lua, using defaults\n", .{}); 199 std.debug.print("failed to init lua, using defaults\n", .{});
200 - setup_default_keybinds(); 200 + initialize_default_config();
201 } 201 }
202 202
203 var display = Display.open() catch |err| { 203 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
447 return kb; 447 return kb;
448 } 448 }
449 449
450 -fn setup_default_keybinds() void { 450 +fn initialize_default_config() void {
451 const mod_key: u32 = 1 << 6; 451 const mod_key: u32 = 1 << 6;
452 const shift_key: u32 = 1 << 0; 452 const shift_key: u32 = 1 << 0;
453 const control_key: u32 = 1 << 2; 453 const control_key: u32 = 1 << 2;
@@ -483,6 +483,9 @@ fn setup_default_keybinds() void {
483 config.add_keybind(make_keybind_int(mod_key | control_key, keysym, .toggle_view_tag, tag_index)) catch {}; 483 config.add_keybind(make_keybind_int(mod_key | control_key, keysym, .toggle_view_tag, tag_index)) catch {};
484 config.add_keybind(make_keybind_int(mod_key | control_key | shift_key, keysym, .toggle_tag, tag_index)) catch {}; 484 config.add_keybind(make_keybind_int(mod_key | control_key | shift_key, keysym, .toggle_tag, tag_index)) catch {};
485 } 485 }
486 +
487 + config.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 1, .action = .move_mouse }) catch {};
488 + config.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 3, .action = .resize_mouse }) catch {};
486 } 489 }
487 490
488 fn grab_keybinds(display: *Display) void { 491 fn grab_keybinds(display: *Display) void {
@@ -987,6 +990,7 @@ fn reload_config(display: *Display) void {
987 ungrab_keybinds(display); 990 ungrab_keybinds(display);
988 991
989 config.keybinds.clearRetainingCapacity(); 992 config.keybinds.clearRetainingCapacity();
993 + config.buttons.clearRetainingCapacity();
990 config.rules.clearRetainingCapacity(); 994 config.rules.clearRetainingCapacity();
991 config.blocks.clearRetainingCapacity(); 995 config.blocks.clearRetainingCapacity();
992 996
@@ -1007,7 +1011,7 @@ fn reload_config(display: *Display) void {
1007 apply_config_values(); 1011 apply_config_values();
1008 } else { 1012 } else {
1009 std.debug.print("reload failed, restoring defaults\n", .{}); 1013 std.debug.print("reload failed, restoring defaults\n", .{});
1010 - setup_default_keybinds(); 1014 + initialize_default_config();
1011 } 1015 }
1012 1016
1013 bar_mod.destroy_bars(gpa.allocator(), display.handle); 1017 bar_mod.destroy_bars(gpa.allocator(), display.handle);