View: fix frame perfection on unmap

This commit is contained in:
Isaac Freund 2023-03-01 23:04:42 +01:00
parent 83fe764fcd
commit ecb959f068
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 15 additions and 3 deletions

View File

@ -220,7 +220,17 @@ fn handleUnmap(listener: *wl.Listener(void)) void {
self.set_title.link.remove(); self.set_title.link.remove();
self.set_app_id.link.remove(); self.set_app_id.link.remove();
// TODO(wlroots): This enable/disable dance is a workaround for an signal
// ordering issue with the scene xdg surface helper's unmap handler that
// disables the node. We however need the node enabled for View.unmap()
// so that we can save buffers for frame perfection.
var it = self.view.surface_tree.children.iterator(.forward);
const xdg_surface_tree_node = it.next().?;
xdg_surface_tree_node.setEnabled(true);
self.view.unmap(); self.view.unmap();
xdg_surface_tree_node.setEnabled(false);
} }
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void { fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void {

View File

@ -222,9 +222,6 @@ pub fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface:
fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener); const self = @fieldParentPtr(Self, "unmap", listener);
self.surface_tree.?.node.destroy();
self.surface_tree = null;
// Remove listeners that are only active while mapped // Remove listeners that are only active while mapped
self.set_title.link.remove(); self.set_title.link.remove();
self.set_class.link.remove(); self.set_class.link.remove();
@ -232,6 +229,11 @@ fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSur
self.request_minimize.link.remove(); self.request_minimize.link.remove();
self.view.unmap(); self.view.unmap();
// Don't destroy the surface tree until after View.unmap() has a chance
// to save buffers for frame perfection.
self.surface_tree.?.node.destroy();
self.surface_tree = null;
} }
fn handleRequestConfigure( fn handleRequestConfigure(