diff --git a/README.md b/README.md index f94156e..8599441 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ installed: - [zig](https://ziglang.org/download/) 0.8.0 - wayland - wayland-protocols -- [wlroots](https://github.com/swaywm/wlroots) 0.13.0 +- [wlroots](https://github.com/swaywm/wlroots) 0.14.0 - xkbcommon - libevdev - pixman diff --git a/deps/zig-wlroots b/deps/zig-wlroots index c85fe79..c5f7594 160000 --- a/deps/zig-wlroots +++ b/deps/zig-wlroots @@ -1 +1 @@ -Subproject commit c85fe796d932731ead64e916c90fdfc3d1e1269a +Subproject commit c5f759484ec2bb6afdee54053f5b0aaccf060131 diff --git a/river/DragIcon.zig b/river/DragIcon.zig index ac2896c..e61d06f 100644 --- a/river/DragIcon.zig +++ b/river/DragIcon.zig @@ -47,10 +47,7 @@ pub fn init(drag_icon: *DragIcon, seat: *Seat, wlr_drag_icon: *wlr.Drag.Icon) vo wlr_drag_icon.events.unmap.add(&drag_icon.unmap); wlr_drag_icon.surface.events.new_subsurface.add(&drag_icon.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_drag_icon.surface.subsurfaces.iterator(.forward); - while (it.next()) |s| Subsurface.create(s, .{ .drag_icon = drag_icon }); + Subsurface.handleExisting(wlr_drag_icon.surface, .{ .drag_icon = drag_icon }); } fn handleDestroy(listener: *wl.Listener(*wlr.Drag.Icon), wlr_drag_icon: *wlr.Drag.Icon) void { diff --git a/river/LayerSurface.zig b/river/LayerSurface.zig index 5b18991..6f73c4d 100644 --- a/river/LayerSurface.zig +++ b/river/LayerSurface.zig @@ -66,10 +66,7 @@ pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1 // we do want our listener called in order to send the initial configure. handleCommit(&self.commit, wlr_layer_surface.surface); - // 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 }); + Subsurface.handleExisting(wlr_layer_surface.surface, .{ .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 e52307e..a5ae6e4 100644 --- a/river/Subsurface.zig +++ b/river/Subsurface.zig @@ -71,10 +71,18 @@ pub fn create(wlr_subsurface: *wlr.Subsurface, parent: Parent) void { 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); + Subsurface.handleExisting(wlr_subsurface.surface, parent); +} + +/// Create Subsurface structs to track subsurfaces already present on the +/// given surface when river becomes aware of the surface as we won't +/// recieve a new_subsurface event for them. +pub fn handleExisting(surface: *wlr.Surface, parent: Parent) void { + var below_it = surface.subsurfaces_below.iterator(.forward); + while (below_it.next()) |s| Subsurface.create(s, parent); + + var above_it = surface.subsurfaces_above.iterator(.forward); + while (above_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 8918488..e243b4b 100644 --- a/river/XdgPopup.zig +++ b/river/XdgPopup.zig @@ -77,10 +77,7 @@ pub fn create(wlr_xdg_popup: *wlr.XdgPopup, parent: Parent) void { 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); + Subsurface.handleExisting(wlr_xdg_popup.base.surface, 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 ca360c3..0b9dcaa 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -68,10 +68,7 @@ pub fn init(self: *Self, view: *View, xdg_surface: *wlr.XdgSurface) void { 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 }); + Subsurface.handleExisting(xdg_surface.surface, .{ .view = view }); } pub fn deinit(self: *Self) void {