layer-shell: fix regression from wlroots 0.15 update

The way wlroots handles the layer surface configure flow has changed a
bit and river's logic needs updating.
This commit is contained in:
Isaac Freund 2021-12-21 19:36:22 +00:00
parent f2fc9aca18
commit c34d850397
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 14 additions and 14 deletions

2
deps/zig-wlroots vendored

@ -1 +1 @@
Subproject commit e2be6fbcc25694e111defdd41de9096802bf049a Subproject commit 9e2fc0dd6dfbd47c56fe10e260255e13cc5f114d

View File

@ -21,6 +21,7 @@ const std = @import("std");
const assert = std.debug.assert; const assert = std.debug.assert;
const wlr = @import("wlroots"); const wlr = @import("wlroots");
const wl = @import("wayland").server.wl; const wl = @import("wayland").server.wl;
const zwlr = @import("wayland").server.zwlr;
const server = &@import("main.zig").server; const server = &@import("main.zig").server;
const util = @import("util.zig"); const util = @import("util.zig");
@ -36,7 +37,7 @@ output: *Output,
wlr_layer_surface: *wlr.LayerSurfaceV1, wlr_layer_surface: *wlr.LayerSurfaceV1,
box: Box = undefined, box: Box = undefined,
state: wlr.LayerSurfaceV1.State, layer: zwlr.LayerShellV1.Layer,
destroy: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleDestroy), destroy: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleDestroy),
map: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleMap), map: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleMap),
@ -49,7 +50,7 @@ pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1
self.* = .{ self.* = .{
.output = output, .output = output,
.wlr_layer_surface = wlr_layer_surface, .wlr_layer_surface = wlr_layer_surface,
.state = wlr_layer_surface.current, .layer = wlr_layer_surface.current.layer,
}; };
wlr_layer_surface.data = @ptrToInt(self); wlr_layer_surface.data = @ptrToInt(self);
@ -100,7 +101,7 @@ fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wl
wlr_layer_surface.surface.sendEnter(wlr_layer_surface.output.?); wlr_layer_surface.surface.sendEnter(wlr_layer_surface.output.?);
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self); const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
self.output.getLayer(self.state.layer).append(node); self.output.getLayer(self.layer).append(node);
self.output.arrangeLayers(.mapped); self.output.arrangeLayers(.mapped);
} }
@ -111,7 +112,7 @@ fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *
// Remove from the output's list of layer surfaces // Remove from the output's list of layer surfaces
const self_node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self); const self_node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
self.output.layers[@intCast(usize, @enumToInt(self.state.layer))].remove(self_node); self.output.layers[@intCast(usize, @enumToInt(self.layer))].remove(self_node);
// If the unmapped surface is focused, clear focus // If the unmapped surface is focused, clear focus
var it = server.input_manager.seats.first; var it = server.input_manager.seats.first;
@ -144,23 +145,22 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), wlr_surface: *wlr.Surface)
// If a surface is committed while it is not mapped, we may need to send a configure. // If a surface is committed while it is not mapped, we may need to send a configure.
if (!self.wlr_layer_surface.mapped) { if (!self.wlr_layer_surface.mapped) {
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self); const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
self.output.getLayer(self.state.layer).append(node); self.layer = self.wlr_layer_surface.current.layer;
self.output.getLayer(self.layer).append(node);
self.output.arrangeLayers(.unmapped); self.output.arrangeLayers(.unmapped);
self.output.getLayer(self.state.layer).remove(node); self.output.getLayer(self.layer).remove(node);
return; return;
} }
const new_state = &self.wlr_layer_surface.current; if (self.wlr_layer_surface.current.committed != 0) {
if (!std.meta.eql(self.state, new_state.*)) {
// If the layer changed, move the LayerSurface to the proper list // If the layer changed, move the LayerSurface to the proper list
if (self.state.layer != new_state.layer) { if (self.wlr_layer_surface.current.layer != self.layer) {
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self); const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
self.output.getLayer(self.state.layer).remove(node); self.output.getLayer(self.layer).remove(node);
self.output.getLayer(new_state.layer).append(node); self.layer = self.wlr_layer_surface.current.layer;
self.output.getLayer(self.layer).append(node);
} }
self.state = new_state.*;
self.output.arrangeLayers(.mapped); self.output.arrangeLayers(.mapped);
server.root.startTransaction(); server.root.startTransaction();
} }