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

commitd07a74f99e913bd9dc6475efe82f76f3d3b0a0f2
parent9ebd923484
authorIsaac Freund <[email protected]>
date2020-04-17 13:22
Fix focus handling of newly mapped Views

 src/view.zig | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/view.zig b/src/view.zig
index 08b168f..6af7fe2 100644
--- a/src/view.zig
+++ b/src/view.zig
@@ -148,8 +148,14 @@ pub const View = struct {
         c.wl_signal_add(&view.wlr_xdg_surface.surface.*.events.commit, &view.listen_commit);
 
         view.mapped = true;
-        // TODO: remove this hack
-        root.server.input_manager.seats.first.?.data.focus(view);
+
+        // Focus the newly mapped view. Note: if a seat is focusing a different output
+        // it will continue to do so.
+        var it = root.server.input_manager.seats.first;
+        while (it) |seat_node| : (it = seat_node.next) {
+            seat_node.data.focus(view);
+        }
+
         view.output.root.arrange();
     }