Revert "Deduplicate some state"

I changed my mind, it's cleaner to keep things like this and will be
consistent with views.
This commit is contained in:
Isaac Freund 2020-04-26 01:59:54 +02:00
parent 5baa9f58e7
commit f133d0b391
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
3 changed files with 11 additions and 7 deletions

View file

@ -11,6 +11,9 @@ 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,
@ -33,6 +36,8 @@ 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;
@ -74,6 +79,8 @@ 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);
@ -94,6 +101,8 @@ 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);
@ -109,11 +118,6 @@ 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.wlr_layer_surface.mapped and
if (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.wlr_layer_surface.mapped) {
if (!layer_surface.mapped) {
continue;
}
var rdata = LayerSurfaceRenderData{