diff --git a/README.md b/README.md index eaba651..f67f0b9 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ # beansprout wm - ## TODOs [ ] Support multiple outputs [ ] Support multiple seats [ ] Support floating windows [ ] Support wallpapers [ ] Support a bar +[ ] Support starting programs at WM launch +[ ] Support changeable primary ratio +[ ] Support changeable primary count +[ ] Support overriding config location diff --git a/examples/config.kdl b/examples/config.kdl new file mode 100644 index 0000000..d565026 --- /dev/null +++ b/examples/config.kdl @@ -0,0 +1,10 @@ +attach_mode top + +focus_follows_pointer true +pointer_warp_on_focus_change true + +borders { + width 2 + color_focused 0x89b4fa + color_unfocused 0x1e1e2e +} diff --git a/examples/init b/examples/init deleted file mode 100755 index 96bc152..0000000 --- a/examples/init +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -./zig-out/bin/beansprout & - -/usr/bin/foot & -/usr/bin/foot & diff --git a/src/Config.zig b/src/Config.zig index 0bc177f..0edc44f 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -193,7 +193,7 @@ fn loadBordersChildBlock(config: *Config, parser: *kdl.Parser) !void { } } -/// Skips an entire child block in KDL +/// Skips an entire child block including any nested child blocks fn skipChildBlock(_: *Config, parser: *kdl.Parser) !void { log.warn("Unexpected child block. Skipping it", .{}); @@ -216,10 +216,11 @@ fn skipChildBlock(_: *Config, parser: *kdl.Parser) !void { } } -/// Convert a KDL argument into a bool or null if the string is not a bool -/// "#true" and "true" => true -/// "#false" and "false" => false -/// else => null +/// Convert a KDL argument into a bool +/// +/// if arg_str in ["#true", "true"], return true +/// if arg_str in ["#false", "false"], return false +/// else, return null fn boolFromKdlStr(_: Config, arg_str: []const u8) ?bool { if (mem.eql(u8, arg_str, "#true") or mem.eql(u8, arg_str, "true")) diff --git a/src/Seat.zig b/src/Seat.zig index fbe6839..38a460e 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -53,7 +53,9 @@ fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: * .wl_seat => |ev| { log.debug("initializing new river_seat_v1 corresponding to wl_seat: {d}", .{ev.name}); }, - .pointer_enter => |ev| seat.setWindowFocus(ev.window), + .pointer_enter => |ev| if (seat.context.config.focus_follows_pointer) { + seat.setWindowFocus(ev.window); + }, .window_interaction => |ev| seat.setWindowFocus(ev.window), else => |ev| { log.debug("unhandled event: {s}", .{@tagName(ev)}); @@ -95,18 +97,19 @@ pub fn manage(seat: *Seat) void { } } - if (seat.pending_manage.should_warp_pointer) { - const window = seat.focused orelse { - log.err("Trying to warp-on-focus-change without a focused window.", .{}); - return; - }; - // TODO - CONFIG: Allow disabling this behaviour - // Warp pointer to center of focused window; - // because the x and y coords are set during render, we need to check if - // there are new coordinates in window.pending_render. - const pointer_x: i32 = (window.pending_render.x orelse window.x) + @divTrunc(window.width, 2); - const pointer_y: i32 = (window.pending_render.y orelse window.y) + @divTrunc(window.height, 2); - seat.river_seat_v1.pointerWarp(pointer_x, pointer_y); + if (seat.pending_manage.should_warp_pointer) blk: { + if (seat.context.config.pointer_warp_on_focus_change) { + const window = seat.focused orelse { + log.err("Trying to warp-on-focus-change without a focused window.", .{}); + break :blk; + }; + // Warp pointer to center of focused window; + // because the x and y coords are set during render, we need to check if + // there are new coordinates in window.pending_render. + const pointer_x: i32 = (window.pending_render.x orelse window.x) + @divTrunc(window.width, 2); + const pointer_y: i32 = (window.pending_render.y orelse window.y) + @divTrunc(window.height, 2); + seat.river_seat_v1.pointerWarp(pointer_x, pointer_y); + } } }