Fix layer sufaces holding focus after unmap

This commit is contained in:
Isaac Freund 2020-04-19 15:15:50 +02:00
parent a0c30de132
commit 472e2b2624
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
3 changed files with 16 additions and 2 deletions

View File

@ -117,7 +117,17 @@ pub const LayerSurface = struct {
} }
} }
// This gives exclusive focus to a keyboard interactive top or overlay layer
// surface if there is one.
layer_surface.output.arrangeLayers(); layer_surface.output.arrangeLayers();
// Ensure that focus is given to the appropriate view if there is no
// other top/overlay layer surface to grab focus.
it = layer_surface.output.root.server.input_manager.seats.first;
while (it) |node| : (it = node.next) {
const seat = &node.data;
seat.focus(null);
}
} }
fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {

View File

@ -259,7 +259,10 @@ pub const Output = struct {
var it = self.layers[layer].last; var it = self.layers[layer].last;
while (it) |node| : (it = node.prev) { while (it) |node| : (it = node.prev) {
const layer_surface = &node.data; const layer_surface = &node.data;
if (layer_surface.wlr_layer_surface.current.keyboard_interactive) { // Only mapped surfaces may gain focus
if (layer_surface.mapped and
layer_surface.wlr_layer_surface.current.keyboard_interactive)
{
break :outer layer_surface; break :outer layer_surface;
} }
} }

View File

@ -161,7 +161,8 @@ pub const Seat = struct {
std.debug.assert(self.focused_layer == null); std.debug.assert(self.focused_layer == null);
current_focus.setActivated(false); current_focus.setActivated(false);
self.focused_view = null; self.focused_view = null;
} else if (self.focused_layer) |current_focus| { }
if (self.focused_layer) |current_focus| {
std.debug.assert(self.focused_view == null); std.debug.assert(self.focused_view == null);
self.focused_layer = null; self.focused_layer = null;
} }