Deduplicate some state

This commit is contained in:
Isaac Freund 2020-04-25 23:28:26 +02:00
parent 96c20f26fc
commit 5baa9f58e7
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
3 changed files with 7 additions and 11 deletions

View file

@ -11,9 +11,6 @@ pub const LayerSurface = struct {
output: *Output,
wlr_layer_surface: *c.wlr_layer_surface_v1,
/// True if the layer surface is currently mapped
mapped: bool,
box: Box,
layer: c.zwlr_layer_shell_v1_layer,
@ -36,8 +33,6 @@ pub const LayerSurface = struct {
self.wlr_layer_surface = wlr_layer_surface;
wlr_layer_surface.data = self;
self.mapped = false;
self.box = undefined;
self.layer = layer;
@ -79,8 +74,6 @@ pub const LayerSurface = struct {
Log.Debug.log("Layer surface '{}' mapped.", .{wlr_layer_surface.namespace});
self.mapped = true;
// Add listeners that are only active while mapped
self.listen_commit.notify = handleCommit;
c.wl_signal_add(&wlr_layer_surface.surface.*.events.commit, &self.listen_commit);
@ -101,8 +94,6 @@ pub const LayerSurface = struct {
Log.Debug.log("Layer surface '{}' unmapped.", .{self.wlr_layer_surface.namespace});
self.mapped = false;
// remove listeners only active while the layer surface is mapped
c.wl_list_remove(&self.listen_commit.link);
c.wl_list_remove(&self.listen_new_popup.link);
@ -118,6 +109,11 @@ pub const LayerSurface = struct {
}
}
// Slight hack: This is automatically set to false by wlroots after
// this callback is exited, but we need it set to false before calling
// arrangeLayers() to avoid a crash.
self.wlr_layer_surface.mapped = false;
// This gives exclusive focus to a keyboard interactive top or overlay layer
// surface if there is one.
self.output.arrangeLayers();

View file

@ -268,7 +268,7 @@ pub const Output = struct {
while (it) |node| : (it = node.prev) {
const layer_surface = &node.data;
// Only mapped surfaces may gain focus
if (layer_surface.mapped and
if (layer_surface.wlr_layer_surface.mapped and
layer_surface.wlr_layer_surface.current.keyboard_interactive)
{
break :outer layer_surface;

View file

@ -93,7 +93,7 @@ fn renderLayer(output: Output, layer: std.TailQueue(LayerSurface), now: *c.times
var it = layer.first;
while (it) |node| : (it = node.next) {
const layer_surface = &node.data;
if (!layer_surface.mapped) {
if (!layer_surface.wlr_layer_surface.mapped) {
continue;
}
var rdata = LayerSurfaceRenderData{