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

commit3080999a86df5203f126c9888df657cfa979cd91
parent7877292c37
authorIsaac Freund <[email protected]>
date2020-04-18 21:15
Grab seats focused on the output for layer shell

 src/output.zig | 10 ++++++++--
 src/seat.zig   |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/output.zig b/src/output.zig
index c8c4e44..3475f8c 100644
--- a/src/output.zig
+++ b/src/output.zig
@@ -252,8 +252,8 @@ pub const Output = struct {
             self.arrangeLayer(self.layers[layer], full_box, &usable_box, false);
         }
 
-        // If there is any layer surface in the top or overlay layers which requests
-        // keyboard interactivity, give it focus.
+        // Find the topmost layer surface in the top or overlay layers which
+        // requests keyboard interactivity if any.
         const topmost_surface = outer: for (layer_idxs[0..2]) |layer| {
             // Iterate in reverse order since the last layer is rendered on top
             var it = self.layers[layer].last;
@@ -268,6 +268,12 @@ pub const Output = struct {
         var it = self.root.server.input_manager.seats.first;
         while (it) |node| : (it = node.next) {
             const seat = &node.data;
+
+            // Only grab focus of seats which have the output focused
+            if (seat.focused_output != self) {
+                continue;
+            }
+
             if (topmost_surface) |to_focus| {
                 // If we found a surface that requires focus, grab the focus of all
                 // seats.
diff --git a/src/seat.zig b/src/seat.zig
index 7407474..cb107fc 100644
--- a/src/seat.zig
+++ b/src/seat.zig
@@ -155,7 +155,7 @@ pub const Seat = struct {
             // Focus the layer surface
             self.sendKeyboardEnter(layer_to_focus.wlr_layer_surface.surface);
             self.focused_layer = layer_to_focus;
-            self.focused_output = layer_to_focus.output;
+            std.debug.assert(self.focused_output == layer_to_focus.output);
         } else {
             // If there is a layer currently focused, unfocus it
             if (self.focused_layer != null) {