LayerSurface: handle focus when switching outputs

Currently if a layer surface is focused and the user focuses a different
output the layer surface remains focused. However, updating focus on
layer surface unmap only considers seats that have the layer surface's
output focused.

To fix this there are 3 approaches I see:

1. Unfocus all layer surfaces on the old output when switching output
focus, focus any layer surfaces on the new output.

2. Disallow switching output focus while a layer surface is focused.

3. Stop caring about output focus when determining which layer surface
should gain/lose focus.

I've taken the 3rd option here as it is significantly simpler to
implement and maintain but still feels reasonably intuitive.
This commit is contained in:
Isaac Freund 2023-03-16 11:03:33 +01:00
parent 50c6ae245f
commit 133b88c266
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 1 additions and 3 deletions

View File

@ -166,9 +166,6 @@ fn handleKeyboardInteractiveExclusive(output: *Output) void {
while (it) |node| : (it = node.next) {
const seat = &node.data;
// Only grab focus of seats which have the output focused
if (seat.focused_output != output) continue;
if (topmost_surface) |to_focus| {
// If we found a surface that requires focus, grab the focus of all
// seats.

View File

@ -152,6 +152,7 @@ pub fn focus(self: *Self, _target: ?*View) void {
// While a layer surface is exclusively focused, views may not receive focus
if (self.focused == .layer) {
const wlr_layer_surface = self.focused.layer.wlr_layer_surface;
assert(wlr_layer_surface.mapped);
if (wlr_layer_surface.current.keyboard_interactive == .exclusive and
(wlr_layer_surface.current.layer == .top or wlr_layer_surface.current.layer == .overlay))
{