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

commit5a21eff3cc233e831dd52d37f9c97c6ae673ff93
parent6fdaeaf0b3
authorIsaac Freund <[email protected]>
date2026-04-06 12:54
Xwayland: add missing null check

Apparently the parent might be an override redirect window, for which
river leaves the data pointer null.

This was reported to happen in practice with a steam game launched with
gamemoderun.

 river/Window.zig | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/river/Window.zig b/river/Window.zig
index 5963a59..1dfab9f 100644
--- a/river/Window.zig
+++ b/river/Window.zig
@@ -1103,7 +1103,10 @@ pub fn getParent(window: *Window) ?*Window {
         },
         .xwayland => |xwindow| {
             const parent_xsurface = xwindow.xsurface.parent orelse return null;
-            const parent_xwindow: *XwaylandWindow = @ptrCast(@alignCast(parent_xsurface.data));
+            // It seems that the parent may be an Override Redirect window, which
+            // have null data.
+            const parent_data = parent_xsurface.data orelse return null;
+            const parent_xwindow: *XwaylandWindow = @ptrCast(@alignCast(parent_data));
             return parent_xwindow.window;
         },
         .destroying => return null,