git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit64dd76eb2c66ce41a64ebf5182f0d341920f73cb
parentcdeb597754
authorWouter van Heijst <[email protected]>
date2024-01-06 13:54
Cursor: Focus follows cursor focuses empty outputs

When `focus-follows-cursor` is set and the cursor moves onto an output
where no views are present on the currently visible tags, focus the
output itself instead of an individual view.

This is useful e.g. when you want to spawn a terminal on your empty
monitor or switch it to a different tag.  Previously such changes would
happen to the monitor on which you previous focus was, despite the
cursor being somewhere else.

 river/Cursor.zig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/river/Cursor.zig b/river/Cursor.zig
index e74b300..f281876 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -909,6 +909,9 @@ pub fn checkFocusFollowsCursor(self: *Self) void {
             self.seat.focus(view);
             server.root.applyPending();
         }
+    } else {
+        // The output doesn't contain any views, just focus the output.
+        self.updateOutputFocus(self.wlr_cursor.x, self.wlr_cursor.y);
     }
 }