From d93ee2c27e66522e1a3d20ad26a4a19733f28aab Mon Sep 17 00:00:00 2001 From: Leon Henrik Plickat Date: Fri, 10 Dec 2021 23:40:48 +0100 Subject: [PATCH] Cursor: improve output focus handling on button press This patch allows to focus outputs by clicking on the empty background and by clicking on layer surfaces without keyboard interactivity. This makes it possible to use the cursor to focus outputs with no visible views. This also fixes problems with pointer interactive layer surfaces (for example launchers and docks) on non-focused outputs. --- river/Cursor.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/river/Cursor.zig b/river/Cursor.zig index e67e7d5..74f586e 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -255,16 +255,25 @@ fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.P } }, .layer_surface => |layer_surface| { + self.seat.focusOutput(layer_surface.output); // If a keyboard inteactive layer surface has been clicked on, // give it keyboard focus. if (layer_surface.wlr_layer_surface.current.keyboard_interactive == .exclusive) { - self.seat.focusOutput(layer_surface.output); self.seat.setFocusRaw(.{ .layer = layer_surface }); + } else { + self.seat.focus(null); } + server.root.startTransaction(); }, .xwayland_unmanaged => assert(build_options.xwayland), } _ = self.seat.wlr_seat.pointerNotifyButton(event.time_msec, event.button, event.state); + } else if (server.root.output_layout.outputAt(self.wlr_cursor.x, self.wlr_cursor.y)) |wlr_output| { + // If the user clicked on empty space of an output, focus it. + const output = @intToPtr(*Output, wlr_output.data); + self.seat.focusOutput(output); + self.seat.focus(null); + server.root.startTransaction(); } }