From 0e9dc089d14e2b5c923d483c62d342af29493cf0 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 5 Jun 2021 19:30:43 +0000 Subject: [PATCH] render: track subsurfaces created before role assignment --- river/LayerSurface.zig | 5 +++++ river/Subsurface.zig | 5 +++++ river/XdgPopup.zig | 5 +++++ river/XdgToplevel.zig | 15 ++++++++++----- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/river/LayerSurface.zig b/river/LayerSurface.zig index 2968895..3031cee 100644 --- a/river/LayerSurface.zig +++ b/river/LayerSurface.zig @@ -69,6 +69,11 @@ pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1 wlr_layer_surface.events.unmap.add(&self.unmap); wlr_layer_surface.events.new_popup.add(&self.new_popup); wlr_layer_surface.surface.events.new_subsurface.add(&self.new_subsurface); + + // There may already be subsurfaces present on this surface that we + // aren't aware of and won't receive a new_subsurface event for. + var it = wlr_layer_surface.surface.subsurfaces.iterator(.forward); + while (it.next()) |s| Subsurface.create(s, .{ .layer_surface = self }); } fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void { diff --git a/river/Subsurface.zig b/river/Subsurface.zig index 33dd279..0f6f544 100644 --- a/river/Subsurface.zig +++ b/river/Subsurface.zig @@ -63,6 +63,11 @@ pub fn create(wlr_subsurface: *wlr.Subsurface, parent: Parent) void { wlr_subsurface.events.map.add(&subsurface.map); wlr_subsurface.events.unmap.add(&subsurface.unmap); wlr_subsurface.surface.events.new_subsurface.add(&subsurface.new_subsurface); + + // There may already be subsurfaces present on this surface that we + // aren't aware of and won't receive a new_subsurface event for. + var it = wlr_subsurface.surface.subsurfaces.iterator(.forward); + while (it.next()) |s| Subsurface.create(s, parent); } fn handleDestroy(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsurface) void { diff --git a/river/XdgPopup.zig b/river/XdgPopup.zig index 0f5b97d..cb7740c 100644 --- a/river/XdgPopup.zig +++ b/river/XdgPopup.zig @@ -74,6 +74,11 @@ pub fn create(wlr_xdg_popup: *wlr.XdgPopup, parent: Parent) void { wlr_xdg_popup.base.events.unmap.add(&self.unmap); wlr_xdg_popup.base.events.new_popup.add(&self.new_popup); wlr_xdg_popup.base.surface.events.new_subsurface.add(&self.new_subsurface); + + // There may already be subsurfaces present on this surface that we + // aren't aware of and won't receive a new_subsurface event for. + var it = wlr_xdg_popup.base.surface.subsurfaces.iterator(.forward); + while (it.next()) |s| Subsurface.create(s, parent); } fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), wlr_xdg_surface: *wlr.XdgSurface) void { diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index 4b597dd..39b2dc1 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -64,11 +64,16 @@ pub fn init(self: *Self, view: *View, xdg_surface: *wlr.XdgSurface) void { xdg_surface.data = @ptrToInt(self); // Add listeners that are active over the view's entire lifetime - self.xdg_surface.events.destroy.add(&self.destroy); - self.xdg_surface.events.map.add(&self.map); - self.xdg_surface.events.unmap.add(&self.unmap); - self.xdg_surface.events.new_popup.add(&self.new_popup); - self.xdg_surface.surface.events.new_subsurface.add(&self.new_subsurface); + xdg_surface.events.destroy.add(&self.destroy); + xdg_surface.events.map.add(&self.map); + xdg_surface.events.unmap.add(&self.unmap); + xdg_surface.events.new_popup.add(&self.new_popup); + xdg_surface.surface.events.new_subsurface.add(&self.new_subsurface); + + // There may already be subsurfaces present on this surface that we + // aren't aware of and won't receive a new_subsurface event for. + var it = xdg_surface.surface.subsurfaces.iterator(.forward); + while (it.next()) |s| Subsurface.create(s, .{ .view = view }); } pub fn deinit(self: *Self) void {