tony / oxwm

Added feature for beamy to use oxwm. Browse files
tonybanters committed 2026-03-23 parent d7c5cd2 commit f72f06dc4cda9821f6ee375f220bce7e7ae88348
Showing 5 changed files with 102 additions and 0 deletions. UnifiedSplit
+1 −0 src/config/config.zig
@@ -131,6 +131,7 @@ pub const Config = struct {
131 auto_tile: bool = false, 131 auto_tile: bool = false,
132 tag_back_and_forth: bool = false, 132 tag_back_and_forth: bool = false,
133 hide_vacant_tags: bool = false, 133 hide_vacant_tags: bool = false,
134 + tiled_resize_mode: bool = false,
134 135
135 layout_tile_symbol: []const u8 = "[]=", 136 layout_tile_symbol: []const u8 = "[]=",
136 layout_monocle_symbol: []const u8 = "[M]", 137 layout_monocle_symbol: []const u8 = "[M]",
+10 −0 src/config/lua.zig
@@ -315,6 +315,9 @@ fn registerMiscFunctions(state: *c.lua_State) void {
315 c.lua_pushcfunction(state, luaAutoTile); 315 c.lua_pushcfunction(state, luaAutoTile);
316 c.lua_setfield(state, -2, "auto_tile"); 316 c.lua_setfield(state, -2, "auto_tile");
317 317
318 + c.lua_pushcfunction(state, luaTiledResizeMode);
319 + c.lua_setfield(state, -2, "tiled_resize_mode");
320 +
318 c.lua_pushcfunction(state, luaQuit); 321 c.lua_pushcfunction(state, luaQuit);
319 c.lua_setfield(state, -2, "quit"); 322 c.lua_setfield(state, -2, "quit");
320 323
@@ -1053,6 +1056,13 @@ fn luaAutoTile(state: ?*c.lua_State) callconv(.c) c_int {
1053 return 0; 1056 return 0;
1054 } 1057 }
1055 1058
1059 +fn luaTiledResizeMode(state: ?*c.lua_State) callconv(.c) c_int {
1060 + const cfg = config orelse return 0;
1061 + const s = state orelse return 0;
1062 + cfg.tiled_resize_mode = c.lua_toboolean(s, 1) != 0;
1063 + return 0;
1064 +}
1065 +
1056 fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int { 1066 fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int {
1057 const cfg = config orelse return 0; 1067 const cfg = config orelse return 0;
1058 const s = state orelse return 0; 1068 const s = state orelse return 0;
+85 −0 src/wm/actions.zig
@@ -572,6 +572,12 @@ pub fn resizemouse(wm: *WindowManager) void {
572 572
573 core.restack(monitor, wm); 573 core.restack(monitor, wm);
574 574
575 + // If tiled_resize_mode is enabled and window is tiled, adjust mfact instead
576 + if (wm.config.tiled_resize_mode and !client.is_floating) {
577 + resizemouseTiled(wm, monitor);
578 + return;
579 + }
580 +
575 if (!client.is_floating) { 581 if (!client.is_floating) {
576 client.is_floating = true; 582 client.is_floating = true;
577 } 583 }
@@ -635,6 +641,85 @@ pub fn resizemouse(wm: *WindowManager) void {
635 core.arrange(monitor, wm); 641 core.arrange(monitor, wm);
636 } 642 }
637 643
644 +/// Resize tiled windows by adjusting mfact with mouse drag (like Super+H/L but with mouse)
645 +fn resizemouseTiled(wm: *WindowManager, monitor: *Monitor) void {
646 + const grab_result = xlib.XGrabPointer(
647 + wm.display.handle,
648 + wm.display.root,
649 + xlib.False,
650 + xlib.ButtonPressMask | xlib.ButtonReleaseMask | xlib.PointerMotionMask,
651 + xlib.GrabModeAsync,
652 + xlib.GrabModeAsync,
653 + xlib.None,
654 + wm.cursors.resize,
655 + xlib.CurrentTime,
656 + );
657 +
658 + if (grab_result != xlib.GrabSuccess) {
659 + return;
660 + }
661 +
662 + // Get initial pointer position
663 + var root_return: xlib.Window = undefined;
664 + var child_return: xlib.Window = undefined;
665 + var root_x: c_int = undefined;
666 + var root_y: c_int = undefined;
667 + var win_x: c_int = undefined;
668 + var win_y: c_int = undefined;
669 + var mask_return: c_uint = undefined;
670 +
671 + _ = xlib.XQueryPointer(
672 + wm.display.handle,
673 + wm.display.root,
674 + &root_return,
675 + &child_return,
676 + &root_x,
677 + &root_y,
678 + &win_x,
679 + &win_y,
680 + &mask_return,
681 + );
682 +
683 + const start_x = root_x;
684 + const initial_mfact = monitor.mfact;
685 +
686 + const total_width: f32 = @floatFromInt(monitor.win_w - 2 * monitor.gap_outer_v - monitor.gap_inner_v);
687 +
688 + var event: xlib.XEvent = undefined;
689 + var done = false;
690 + var last_time: c_ulong = 0;
691 +
692 + while (!done) {
693 + _ = xlib.XNextEvent(wm.display.handle, &event);
694 +
695 + switch (event.type) {
696 + xlib.MotionNotify => {
697 + const motion = &event.xmotion;
698 + if ((motion.time - last_time) < (1000 / 60)) {
699 + continue;
700 + }
701 + last_time = motion.time;
702 +
703 + const delta_x: f32 = @floatFromInt(motion.x_root - start_x);
704 + const mfact_delta = delta_x / total_width;
705 + const new_mfact = initial_mfact + mfact_delta;
706 +
707 + if (new_mfact >= 0.05 and new_mfact <= 0.95) {
708 + monitor.mfact = new_mfact;
709 + monitor.pertag.mfacts[monitor.pertag.curtag] = new_mfact;
710 + core.arrange(monitor, wm);
711 + }
712 + },
713 + xlib.ButtonRelease => {
714 + done = true;
715 + },
716 + else => {},
717 + }
718 + }
719 +
720 + _ = xlib.XUngrabPointer(wm.display.handle, xlib.CurrentTime);
721 +}
722 +
638 /// Config-loading callback for wm.reloadConfig(). 723 /// Config-loading callback for wm.reloadConfig().
639 /// Re-initialises Lua and loads the config file (or falls back to defaults). 724 /// Re-initialises Lua and loads the config file (or falls back to defaults).
640 pub fn reloadLoadConfig(wm: *WindowManager) void { 725 pub fn reloadLoadConfig(wm: *WindowManager) void {
+2 −0 templates/config.lua
@@ -214,6 +214,8 @@ oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
214 -- Decrease/Increase master area width 214 -- Decrease/Increase master area width
215 oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5)) 215 oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5))
216 oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5)) 216 oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5))
217 +-- Enable tiled resize mode: Mod+RMB drag adjusts mfact instead of floating
218 +-- oxwm.tiled_resize_mode(true)
217 -- Increment/Decrement number of master windows 219 -- Increment/Decrement number of master windows
218 oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1)) 220 oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1))
219 oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1)) 221 oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1))
+4 −0 templates/oxwm.lua
@@ -41,6 +41,10 @@ function oxwm.set_tags(tags) end
41 ---@param enabled boolean Enable or disable auto-tiling 41 ---@param enabled boolean Enable or disable auto-tiling
42 function oxwm.auto_tile(enabled) end 42 function oxwm.auto_tile(enabled) end
43 43
44 +---Enable or disable tiled resize mode (Mod+RMB adjusts mfact instead of floating)
45 +---@param enabled boolean Enable or disable tiled resize mode
46 +function oxwm.tiled_resize_mode(enabled) end
47 +
44 ---Set layout symbol override 48 ---Set layout symbol override
45 ---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle") 49 ---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle")
46 ---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") 50 ---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]")