From 1c7f927e26f06900f1701aca29eb66f11d39edfd Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Oct 2026 11:23:45 +0300 Subject: [PATCH] Launch Lazarus through Xwayland under WSLg The WSLg compositor (weston, WSLg 1.0.79) crashes with SIGSEGV when a window that has a transient child is destroyed. GTK3 talks to it directly over Wayland by default, and the IDE's first-run setup does exactly this, so every Linux window in the session disappears together with the IDE. A plain GTK3 program reproduces the crash; Xwayland is not affected. Select GDK_BACKEND=x11 when /mnt/wslg exists and the user has not chosen a backend. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 ++++ lazarus | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c87a7aa7..e458f34f 100644 --- a/README.md +++ b/README.md @@ -431,6 +431,10 @@ Do not add `-dUNICODERTL` or reuse the application's `.mooncompiler` profile when building the IDE/LCL. These select different string ABIs; adding a define to the Lazarus command line cannot change an already compiled RTL. +Under WSLg, `./lazarus` selects the GTK X11 backend (Xwayland) unless +`GDK_BACKEND` is already set: the WSLg compositor crashes when a window that has +a transient child is destroyed, and the IDE does this on its first run. + Since 2.5.2, the IDE profile preserves the FPC `TStringList` insertion hooks used by Lazarus subclasses. The Unicode application profile retains the Delphi insertion contract. Both profiles are checked independently in CI. diff --git a/lazarus b/lazarus index 1e840630..10e73684 100755 --- a/lazarus +++ b/lazarus @@ -16,4 +16,9 @@ export PP="$IDE_FPC" export PPC_CONFIG_PATH="$IDE_TOOLCHAIN/etc" export LAZARUSDIR="$LAZARUS_SOURCE" unset FPCDIR +# The WSLg compositor crashes when a window that has a transient child is +# destroyed, which the IDE does on its first run; Xwayland is not affected. +if [[ -z ${GDK_BACKEND-} && -d /mnt/wslg ]]; then + export GDK_BACKEND=x11 +fi exec "$LAZARUS_EXE" "--pcp=$PRIMARY_CONFIG" "$@"