xdg-toplevel: handle destroy before xdg-decoration

This commit is contained in:
Isaac Freund 2024-02-06 12:59:09 +01:00
parent 4685f6906d
commit 026c832ba1
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 15 additions and 5 deletions

View File

@ -52,11 +52,7 @@ pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void {
xdg_toplevel.view.pending.ssd = ssd;
}
fn handleDestroy(
listener: *wl.Listener(*wlr.XdgToplevelDecorationV1),
_: *wlr.XdgToplevelDecorationV1,
) void {
const decoration = @fieldParentPtr(XdgDecoration, "destroy", listener);
pub fn deinit(decoration: *XdgDecoration) void {
const xdg_toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data);
decoration.destroy.link.remove();
@ -66,6 +62,15 @@ fn handleDestroy(
xdg_toplevel.decoration = null;
}
fn handleDestroy(
listener: *wl.Listener(*wlr.XdgToplevelDecorationV1),
_: *wlr.XdgToplevelDecorationV1,
) void {
const decoration = @fieldParentPtr(XdgDecoration, "destroy", listener);
decoration.deinit();
}
fn handleRequestMode(
listener: *wl.Listener(*wlr.XdgToplevelDecorationV1),
_: *wlr.XdgToplevelDecorationV1,

View File

@ -193,6 +193,11 @@ pub fn destroyPopups(self: Self) void {
fn handleDestroy(listener: *wl.Listener(void)) void {
const self = @fieldParentPtr(Self, "destroy", listener);
// This can be be non-null here if the client commits a protocol error or
// if it exits without destroying its wayland objects.
if (self.decoration) |*decoration| {
decoration.deinit();
}
assert(self.decoration == null);
// Remove listeners that are active for the entire lifetime of the view