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.
This commit is contained in:
Leon Henrik Plickat 2021-12-10 23:40:48 +01:00 committed by GitHub
parent 93afdb32bf
commit d93ee2c27e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -255,16 +255,25 @@ fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.P
} }
}, },
.layer_surface => |layer_surface| { .layer_surface => |layer_surface| {
self.seat.focusOutput(layer_surface.output);
// If a keyboard inteactive layer surface has been clicked on, // If a keyboard inteactive layer surface has been clicked on,
// give it keyboard focus. // give it keyboard focus.
if (layer_surface.wlr_layer_surface.current.keyboard_interactive == .exclusive) { if (layer_surface.wlr_layer_surface.current.keyboard_interactive == .exclusive) {
self.seat.focusOutput(layer_surface.output);
self.seat.setFocusRaw(.{ .layer = layer_surface }); self.seat.setFocusRaw(.{ .layer = layer_surface });
} else {
self.seat.focus(null);
} }
server.root.startTransaction();
}, },
.xwayland_unmanaged => assert(build_options.xwayland), .xwayland_unmanaged => assert(build_options.xwayland),
} }
_ = self.seat.wlr_seat.pointerNotifyButton(event.time_msec, event.button, event.state); _ = 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();
} }
} }