Removed debugs and added docs to lsp file for systray
Browse files
+0 −6 src/bar/systray.zig
| @@ -72,7 +72,6 @@ pub const Systray = struct { | ||
| 72 | 72 | |
| 73 | 73 | const current_owner = xlib.c.XGetSelectionOwner(display, self.manager_atom); |
| 74 | 74 | if (current_owner != xlib.None) { |
| 75 | - std.debug.print("systray: another systray is already running\n", .{}); | |
| 76 | 75 | allocator.destroy(self); |
| 77 | 76 | return null; |
| 78 | 77 | } |
| @@ -102,7 +101,6 @@ pub const Systray = struct { | ||
| 102 | 101 | |
| 103 | 102 | _ = xlib.c.XSetSelectionOwner(display, self.manager_atom, self.window, xlib.CurrentTime); |
| 104 | 103 | if (xlib.c.XGetSelectionOwner(display, self.manager_atom) != self.window) { |
| 105 | - std.debug.print("systray: failed to acquire selection ownership\n", .{}); | |
| 106 | 104 | _ = xlib.c.XDestroyWindow(display, self.window); |
| 107 | 105 | allocator.destroy(self); |
| 108 | 106 | return null; |
| @@ -125,7 +123,6 @@ pub const Systray = struct { | ||
| 125 | 123 | _ = xlib.XMapWindow(display, self.window); |
| 126 | 124 | _ = xlib.XSync(display, xlib.False); |
| 127 | 125 | |
| 128 | - std.debug.print("systray: initialized on screen {d}\n", .{screen}); | |
| 129 | 126 | return self; |
| 130 | 127 | } |
| 131 | 128 | |
| @@ -272,7 +269,6 @@ pub const Systray = struct { | ||
| 272 | 269 | |
| 273 | 270 | var wa: xlib.XWindowAttributes = undefined; |
| 274 | 271 | if (xlib.XGetWindowAttributes(self.display, icon_win, &wa) == 0) { |
| 275 | - std.debug.print("systray: failed to get window attributes for icon 0x{x}\n", .{icon_win}); | |
| 276 | 272 | return; |
| 277 | 273 | } |
| 278 | 274 | |
| @@ -315,7 +311,6 @@ pub const Systray = struct { | ||
| 315 | 311 | } |
| 316 | 312 | |
| 317 | 313 | self.arrangeIcons(); |
| 318 | - std.debug.print("systray: docked icon 0x{x} (size {}x{})\n", .{ icon_win, icon.width, icon.height }); | |
| 319 | 314 | } |
| 320 | 315 | |
| 321 | 316 | pub fn handleConfigureRequest(self: *Systray, ev: *xlib.XConfigureRequestEvent) bool { |
| @@ -403,7 +398,6 @@ pub const Systray = struct { | ||
| 403 | 398 | if (icon.window == win) { |
| 404 | 399 | _ = self.icons.orderedRemove(i); |
| 405 | 400 | self.arrangeIcons(); |
| 406 | - std.debug.print("systray: removed icon 0x{x}\n", .{win}); | |
| 407 | 401 | return true; |
| 408 | 402 | } |
| 409 | 403 | } |
+9 −1 src/wm/wm.zig
| @@ -420,6 +420,7 @@ pub const WindowManager = struct { | ||
| 420 | 420 | var current_monitor = self.monitors; |
| 421 | 421 | var last_bar: ?*Bar = null; |
| 422 | 422 | var is_first_bar = true; |
| 423 | + const want_systray = configHasSystray(self.config); | |
| 423 | 424 | |
| 424 | 425 | while (current_monitor) |monitor| { |
| 425 | 426 | const bar = Bar.create( |
| @@ -428,7 +429,7 @@ pub const WindowManager = struct { | ||
| 428 | 429 | self.display.screen, |
| 429 | 430 | monitor, |
| 430 | 431 | self.config, |
| 431 | - is_first_bar, | |
| 432 | + is_first_bar and want_systray, | |
| 432 | 433 | ) orelse { |
| 433 | 434 | current_monitor = monitor.next; |
| 434 | 435 | continue; |
| @@ -721,6 +722,13 @@ pub const WindowManager = struct { | ||
| 721 | 722 | } |
| 722 | 723 | }; |
| 723 | 724 | |
| 725 | +fn configHasSystray(config: Config) bool { | |
| 726 | + for (config.blocks.items) |block| { | |
| 727 | + if (block.block_type == .systray) return true; | |
| 728 | + } | |
| 729 | + return false; | |
| 730 | +} | |
| 731 | + | |
| 724 | 732 | /// Converts a config block description into a live status bar block. |
| 725 | 733 | pub fn configBlockToBarBlock(cfg: config_mod.Block) blocks_mod.Block { |
| 726 | 734 | var block = switch (cfg.block_type) { |
+5 −0 templates/oxwm.lua
| @@ -324,6 +324,11 @@ function oxwm.bar.block.static(config) end | ||
| 324 | 324 | ---@return table Block configuration |
| 325 | 325 | function oxwm.bar.block.battery(config) end |
| 326 | 326 | |
| 327 | +---Create a system tray block. Including this block enables the tray on the first bar; omitting it disables the tray entirely. | |
| 328 | +---@param config {color: string|integer, underline: boolean}? Optional appearance config (only color and underline are used) | |
| 329 | +---@return table Block configuration | |
| 330 | +function oxwm.bar.block.systray(config) end | |
| 331 | + | |
| 327 | 332 | ---Set normal tag color scheme (unselected, no windows) |
| 328 | 333 | ---@param foreground string|integer Foreground color |
| 329 | 334 | ---@param background string|integer Background color |