[client] wayland: fix double xdg_toplevel role assignment in libdecor path
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled

libdecor_decorate() already creates an xdg_surface and xdg_toplevel
internally for the frame. Calling xdg_surface_get_toplevel() again on
that same xdg_surface just to fetch the toplevel for icon handling
assigns the xdg_toplevel role to the underlying wl_surface a second
time, which is a protocol violation.

On GNOME Shell 50 (mutter) this is no longer tolerated: mutter
terminates the Wayland connection ("WL: error in client
communication"), and since libdecor_shellInit() waits for the initial
configure with a blocking, error-less libdecor_dispatch(-1) loop, the
client hangs forever with no window and no diagnostic output. This
made -DENABLE_LIBDECOR=ON (the default when libdecor-0 is present)
appear completely broken on current GNOME/Wayland.

Use libdecor_frame_get_xdg_toplevel() instead, which returns the
xdg_toplevel libdecor already owns, without requesting a second role
assignment.

Require libdecor-0 >= 0.1.1, which is available in Debian oldstable,
so the new accessor is guaranteed by the build dependency.
This commit is contained in:
Amit Mendapara
2026-08-03 14:54:59 +05:30
committed by Geoffrey McRae
parent e671bfd4e7
commit 3035fa6282
3 changed files with 3 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ endfunction()
# the first entry here is the default
add_desktop(xdg)
pkg_check_modules(LIBDECOR IMPORTED_TARGET libdecor-0)
pkg_check_modules(LIBDECOR IMPORTED_TARGET libdecor-0>=0.1.1)
if(LIBDECOR_FOUND)
option(ENABLE_LIBDECOR "Build with libdecor support" ON)
else()

View File

@@ -145,9 +145,7 @@ static bool libdecor_shellInit(
libdecor_frame_map(state.libdecorFrame);
// Get the xdg_toplevel for icon setting
struct xdg_surface * xdgSurface = libdecor_frame_get_xdg_surface(state.libdecorFrame);
if (xdgSurface)
wlWm.xdgToplevel = xdg_surface_get_toplevel(xdgSurface);
wlWm.xdgToplevel = libdecor_frame_get_xdg_toplevel(state.libdecorFrame);
if (fullscreen)
libdecor_frame_set_fullscreen(state.libdecorFrame, NULL);