implements : rule bypass for block's floating window
Browse files
Using the click functionnality of the bar is nice but i have TUI like bluetui or pulsemixer that were always opening in my "terminal" tag. a bit annoying when i'm looking at my documentation on my browser tag. Now there is an option to bypass the rules if needed.
+1 −0 src/config/config.zig
| @@ -148,6 +148,7 @@ pub const FloatingPosition = enum { | ||
| 148 | 148 | pub const ClickAction = struct { |
| 149 | 149 | command: []const u8, |
| 150 | 150 | floating: bool = false, |
| 151 | + bypass_rules: bool = false, | |
| 151 | 152 | }; |
| 152 | 153 | |
| 153 | 154 | pub const Block = struct { |
+5 −1 src/config/lua.zig
| @@ -1252,7 +1252,11 @@ fn parseClickAction(state: *c.lua_State, idx: c_int) ?config_mod.ClickAction { | ||
| 1252 | 1252 | const floating = c.lua_toboolean(state, -1) != 0; |
| 1253 | 1253 | c.lua_settop(state, -2); |
| 1254 | 1254 | |
| 1255 | - return .{ .command = cmd.?, .floating = floating }; | |
| 1255 | + _ = c.lua_getfield(state, idx, "bypass_rules"); | |
| 1256 | + const bypass_rules = c.lua_toboolean(state, -1) != 0; | |
| 1257 | + c.lua_settop(state, -2); | |
| 1258 | + | |
| 1259 | + return .{ .command = cmd.?, .floating = floating, .bypass_rules = bypass_rules }; | |
| 1256 | 1260 | } |
| 1257 | 1261 | return null; |
| 1258 | 1262 | } |
+8 −1 src/wm/core.zig
| @@ -40,7 +40,14 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind | ||
| 40 | 40 | |
| 41 | 41 | if (client.monitor == null) { |
| 42 | 42 | client.monitor = wm.selected_monitor; |
| 43 | - applyRules(client, wm); | |
| 43 | + if (wm.next_spawn_bypass_rules) { | |
| 44 | + if (client.monitor) |monitor| { | |
| 45 | + client.tags = monitor.tagset[monitor.sel_tags]; | |
| 46 | + } | |
| 47 | + wm.next_spawn_bypass_rules = false; | |
| 48 | + } else { | |
| 49 | + applyRules(client, wm); | |
| 50 | + } | |
| 44 | 51 | } |
| 45 | 52 | |
| 46 | 53 | if (wm.next_spawn_floating) { |
+1 −0 src/wm/handlers.zig
| @@ -211,6 +211,7 @@ fn handleButtonPress(event: *xlib.XButtonEvent, wm: *WindowManager) void { | ||
| 211 | 211 | core.view(tag_mask, wm); |
| 212 | 212 | } else if (bar.handleBlockClick(event.x)) |click_action| { |
| 213 | 213 | wm.next_spawn_floating = click_action.floating; |
| 214 | + wm.next_spawn_bypass_rules = click_action.bypass_rules; | |
| 214 | 215 | actions.spawnCommand(wm, click_action.command); |
| 215 | 216 | } |
| 216 | 217 | return; |
+1 −0 src/wm/wm.zig
| @@ -85,6 +85,7 @@ pub const WindowManager = struct { | ||
| 85 | 85 | |
| 86 | 86 | running: bool, |
| 87 | 87 | next_spawn_floating: bool = false, |
| 88 | + next_spawn_bypass_rules: bool = false, | |
| 88 | 89 | last_motion_monitor: ?*Monitor, |
| 89 | 90 | |
| 90 | 91 | /// Initialises the window manager |