Clear focus if focused layer surface is unmapped

This commit is contained in:
Isaac Freund 2020-04-19 14:21:51 +02:00
parent c959a426b7
commit a0c30de132
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 20 additions and 0 deletions

View file

@ -1,6 +1,7 @@
const std = @import("std"); const std = @import("std");
const c = @import("c.zig"); const c = @import("c.zig");
const Log = @import("log.zig").Log;
const Seat = @import("seat.zig").Seat; const Seat = @import("seat.zig").Seat;
const Server = @import("server.zig").Server; const Server = @import("server.zig").Server;
@ -83,6 +84,8 @@ pub const InputManager = struct {
fn handleInhibitActivate(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { fn handleInhibitActivate(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_inhibit_activate", listener.?); const self = @fieldParentPtr(Self, "listen_inhibit_activate", listener.?);
Log.Debug.log("Input inhibitor activated", .{});
// Clear focus of all seats // Clear focus of all seats
var seat_it = self.seats.first; var seat_it = self.seats.first;
while (seat_it) |seat_node| : (seat_it = seat_node.next) { while (seat_it) |seat_node| : (seat_it = seat_node.next) {
@ -95,6 +98,8 @@ pub const InputManager = struct {
fn handleInhibitDeactivate(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { fn handleInhibitDeactivate(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_inhibit_deactivate", listener.?); const self = @fieldParentPtr(Self, "listen_inhibit_deactivate", listener.?);
Log.Debug.log("Input inhibitor deactivated", .{});
self.exclusive_client = null; self.exclusive_client = null;
// Calling arrangeLayers() like this ensures that any top or overlay, // Calling arrangeLayers() like this ensures that any top or overlay,

View file

@ -76,6 +76,8 @@ pub const LayerSurface = struct {
const layer_surface = @fieldParentPtr(LayerSurface, "listen_map", listener.?); const layer_surface = @fieldParentPtr(LayerSurface, "listen_map", listener.?);
const wlr_layer_surface = layer_surface.wlr_layer_surface; const wlr_layer_surface = layer_surface.wlr_layer_surface;
Log.Debug.log("Layer surface '{}' mapped.", .{wlr_layer_surface.namespace});
layer_surface.mapped = true; layer_surface.mapped = true;
// Add listeners that are only active while mapped // Add listeners that are only active while mapped
@ -96,12 +98,25 @@ pub const LayerSurface = struct {
fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const layer_surface = @fieldParentPtr(LayerSurface, "listen_unmap", listener.?); const layer_surface = @fieldParentPtr(LayerSurface, "listen_unmap", listener.?);
Log.Debug.log("Layer surface '{}' unmapped.", .{layer_surface.wlr_layer_surface.namespace});
layer_surface.mapped = false; layer_surface.mapped = false;
// remove listeners only active while the layer surface is mapped // remove listeners only active while the layer surface is mapped
c.wl_list_remove(&layer_surface.listen_commit.link); c.wl_list_remove(&layer_surface.listen_commit.link);
c.wl_list_remove(&layer_surface.listen_new_popup.link); c.wl_list_remove(&layer_surface.listen_new_popup.link);
// If the unmapped surface is focused, clear focus
var it = layer_surface.output.root.server.input_manager.seats.first;
while (it) |node| : (it = node.next) {
const seat = &node.data;
if (seat.focused_layer) |current_focus| {
if (current_focus == layer_surface) {
seat.setFocusRaw(.{ .none = {} });
}
}
}
layer_surface.output.arrangeLayers(); layer_surface.output.arrangeLayers();
} }