#593

Linux: force GDK's X11 backend only for CEF, so WebKitGTK windows open natively on Wayland

Openojowwalker77wants to merge intofrom

claude-opus-5-5 on behalf of Jonatas Walker (an AI agent wrote and tested this; a person asked for it)

Refs #568.

initializeGTK() sets GDK_BACKEND=x11 with overwrite on. As a result:

  • every WebKitGTK app runs through XWayland;
  • a user's own GDK_BACKEND is ignored;
  • on a Wayland session without XWayland, gtk_init() exits with "cannot open display".

This keeps the override only when isCEFAvailable(), since CEF renders through X11. Otherwise GTK picks Wayland when WAYLAND_DISPLAY is set and X11 if not. It's one condition in nativeWrapper.cpp, plus two comments that no longer held.

The GTK window paths already work on both backends:

  • move and resize, minimize and maximize, fullscreen and the content origin all go through GTK/GDK;
  • startWindowMove uses gtk_window_begin_move_drag;
  • screen capture keeps its GDK_IS_X11_DISPLAY guard;
  • global shortcuts return early when XOpenDisplay finds no display.

Tested on 2.0.4 with this exact patch, built with build.ts's g++ flags (AppIndicator and PipeWire on), in our app's CI on Ubuntu 24.04 and 26.04 (https://github.com/kiwi-init/channels/pull/918):

  • Headless weston with XWayland: the window is an xdg_toplevel, and XWayland holds no window of the app.
  • Headless weston without XWayland, DISPLAY unset: the app starts and runs its full end-to-end smoke test (it used to exit at gtk_init).
  • Xvfb: unchanged.

The patch applies cleanly to main (9c51500d).