git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit45a5b769e260837321537a6b5c45ed2f1dea1132
parent39c7dba952
authorIsaac Freund <[email protected]>
date2024-08-07 11:55
rwm: clean up place_above/below

I suspect specifying that placing a node above/below itself is a no-op
will slightly reduce global complexity in some cases. I don't think it
matters much either way.

 protocol/river-window-management-v1.xml | 14 ++++++++++----
 river/WmNode.zig                        |  4 ++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/protocol/river-window-management-v1.xml b/protocol/river-window-management-v1.xml
index d990c53..a3e8763 100644
--- a/protocol/river-window-management-v1.xml
+++ b/protocol/river-window-management-v1.xml
@@ -614,7 +614,7 @@
         be made fullscreen and allows them to provide an output preference.
 
         The window manager is free to honor this request using
-        river_window_v1.set_fullscreen or ignore it.
+        river_window_v1.fullscreen or ignore it.
 
         This event is double-buffered state and will be followed by a
         river_window_manager_v1.update event.
@@ -629,7 +629,7 @@
         fullscreen.
 
         The window manager is free to honor this request using
-        river_window_v1.unset_fullscreen or ignore it.
+        river_window_v1.exit_fullscreen or ignore it.
 
         This event is double-buffered state and will be followed by a
         river_window_manager_v1.update event.
@@ -814,7 +814,10 @@
 
     <request name="place_above">
       <description summary="place node above another node">
-        This request places the node above another node in the scene graph.
+        This request places the node directly above another node in the
+        compositor's render list.
+
+        Attempting to place a node above itself has no effect.
 
         This request is double-buffered state and will not be applied until the
         next river_window_manager_v1.commit request.
@@ -824,7 +827,10 @@
 
     <request name="place_below">
       <description summary="place node below another node">
-        This request places the node below another node in the scene graph.
+        This request places the node directly below another node in the
+        compositor's render list.
+
+        Attempting to place a node below itself has no effect.
 
         This request is double-buffered state and will not be applied until the
         next river_window_manager_v1.commit request.
diff --git a/river/WmNode.zig b/river/WmNode.zig
index c8ccd51..8bcff18 100644
--- a/river/WmNode.zig
+++ b/river/WmNode.zig
@@ -112,6 +112,8 @@ fn handleRequest(
             const other_data = args.other.getUserData() orelse return;
             const other: *WmNode = @ptrCast(@alignCast(other_data));
 
+            if (other == node) return;
+
             node.link_uncommitted.remove();
             other.link_uncommitted.insert(&node.link_uncommitted);
         },
@@ -119,6 +121,8 @@ fn handleRequest(
             const other_data = args.other.getUserData() orelse return;
             const other: *WmNode = @ptrCast(@alignCast(other_data));
 
+            if (other == node) return;
+
             node.link_uncommitted.remove();
             other.link_uncommitted.prev.?.insert(&node.link_uncommitted);
         },