From e785b6e477fbeb9e8c33159eb9c74240eef9969b Mon Sep 17 00:00:00 2001 From: Basil Keeler Date: Sat, 28 Mar 2026 21:25:42 -0500 Subject: [PATCH] Add config option for primary_output_follows_pointer + document it Closes: #6 --- docs/CONFIGURATION.md | 3 +++ man/beansprout.5.scd | 4 ++++ src/Config.zig | 13 +++++++++++++ src/Seat.zig | 13 ++++++++----- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index b8923a2..c30ddb5 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -37,6 +37,9 @@ primary_ratio 0.55 // Whether mousing over a new window should move focus focus_follows_pointer #true +// Whether mousing over a new output should move output focus (i.e. the output new windows spawn on) +output_focus_follows_pointer #true + // Whether the focus should warp to the center of newly-focused windows pointer_warp_on_focus_change #true diff --git a/man/beansprout.5.scd b/man/beansprout.5.scd index 84acf1f..b480ef7 100644 --- a/man/beansprout.5.scd +++ b/man/beansprout.5.scd @@ -41,6 +41,10 @@ This is useful for sharing a config file across machines. Nodes without a Whether mousing over a new window should move focus. (Default: *true*) +*output_focus_follows_pointer* _bool_ + Whether mousing over a new output should move output focus (i.e. the output new windows spawn on) + (Default: *true*) + *pointer_warp_on_focus_change* _bool_ Whether the pointer should warp to the center of newly-focused windows. (Default: *true*) diff --git a/src/Config.zig b/src/Config.zig index 90cce78..51e5fd6 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -35,6 +35,8 @@ primary_side: PrimarySide = .left, attach_mode: AttachMode = .top, /// Should focus change when the cursor moves onto a new window focus_follows_pointer: bool = true, +/// Should the output that windows spawn on change to follow the pointer +output_focus_follows_pointer: bool = true, /// Should the pointer warp to the center of newly-focused windows pointer_warp_on_focus_change: bool = true, @@ -74,6 +76,7 @@ const NodeName = enum { single_window_ratio, primary_side, focus_follows_pointer, + output_focus_follows_pointer, pointer_warp_on_focus_change, wallpaper_image_path, // Sections with child blocks @@ -287,6 +290,16 @@ fn load(config: *Config, reader: *Io.Reader) !void { continue; } }, + .output_focus_follows_pointer => { + const output_focus_follows_pointer_str = utils.stripQuotes(node.arg(&parser, 0) orelse ""); + if (helpers.boolFromKdlStr(output_focus_follows_pointer_str)) |output_focus_follows_pointer| { + config.output_focus_follows_pointer = output_focus_follows_pointer; + logDebugSettingNode(name, output_focus_follows_pointer_str); + } else |_| { + logWarnInvalidNodeArg(name, output_focus_follows_pointer_str); + continue; + } + }, .pointer_warp_on_focus_change => { const pointer_warp_on_focus_change_str = utils.stripQuotes(node.arg(&parser, 0) orelse ""); if (helpers.boolFromKdlStr(pointer_warp_on_focus_change_str)) |pointer_warp_on_focus_change| { diff --git a/src/Seat.zig b/src/Seat.zig index 22b0fb8..ea9455f 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -111,11 +111,14 @@ fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: * .pointer_position => |ev| { seat.pointer_pos.x = ev.x; seat.pointer_pos.y = ev.y; - // Iterate over every display and check if the curser is inside it - var it = seat.context.wm.outputs.iterator(.forward); - while (it.next()) |output| { - if (utils.isPosInRect(seat.pointer_pos, output.geometry)) { - seat.focused_output = output; + if (seat.context.config.output_focus_follows_pointer) { + // Iterate over every display and check if the curser is inside it + var it = seat.context.wm.outputs.iterator(.forward); + while (it.next()) |output| { + if (utils.isPosInRect(seat.pointer_pos, output.geometry)) { + seat.focused_output = output; + break; + } } } },