This used to work for me some time ago. Now anything, based on gtk+:2 fails with "Gtk-WARNING **: 15:39:36.909: cannot open display: :0" Since I run sway with XWayland on, I have custom function, set up in .bashrc to set the environment. So by using go_wl or go_x11 i can preset environment vars to enter either wayaland-based or xorg-based wm. This works for me fine, except for GTK+:2-based apps. I tried it with simple "hello world" GTK2 example. It fails in exact same way. I tried debugging it and it fails during initialization phase. During gtk_init, flow enters gtk_init_check, where gdk_display_open_default_libgtk_only fails and errors out. **************** function go_wl() { export DISPLAY=":0" # unset DISPLAY TERM=alacritty export WAYLAND_DISPLAY="wayland-1" # unset WAYLAND_DISPLAY WLR_BACKENDS="drm,libinput" export WAYLAND_DEBUG=1 export WLR_BACKENDS export XDG_RUNTIME_DIR=/run/user/1000 export XDG_SESSION_TYPE=wayland export SDL_VIDEODRIVER=wayland # export QT_QPA_PLATFORM=wayland-eg # export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 export ELM_DISPLAY=wl export ECORE_EVAS_ENGINE=wayland_egl export ELM_ENGINE=wayland_egl # export ELM_ACCEL=opengl export GDK_BACKEND=wayland export GTK_BACKEND=wayland # unset GDK_BACKEND export DBUS_SESSION_BUS_ADDRESS export DBUS_SESSION_BUS_PID export MOZ_ENABLE_WAYLAND=1 # unset WAYLAND_DISPLAY # MOZ_ENABLE_WAYLAND=1 export _JAVA_AWT_WM_NONREPARENTING=1 # export JAVA_HOME="/usr/lib/jvm/openjdk-8" } ***********************
Created attachment 745500 [details] emerge --info
Created attachment 745503 [details] hello-world GTK2 test
If it matters, I'm using: gui-libs/wlroots-9999 gui-wm/sway-9999-r4 ( 9999 failed to build, so I tweaked it) dev-libs/wayland-9999 dev-libs/wayland-protocols-9999
fwiw, it works fine for me with gtk2 apps still under GNOME. Your GDK_BACKEND settings are a bit excessive there - if a gtk3 app disables wayland usage, because it still has required X specific code in there, it won't start for you. However, this is unrelated to gtk2 woes, as gtk2 doesn't have GDK_BACKEND. GTK_BACKEND isn't a thing. I feel it's probably some environment issue, but I can't spot what it could be. Does it work in a fuller wayland DE without such big environment overrides? Or even with sway without this go_wl stuff?
it behaves the same way even if I erase most of the settings except XDG_RUNTIME_DIR ( it needs that to start). And it behaves the same way under Weston or Enlightenment ( v0.24.2-r2 ). WRT GDK_BACKEND setting, it behaves the same way without it.
I've just debugged it up to a point where gtk2 goes trough XOpenDisplay and xcb_connect to _xcb_open_abstract, where it tries to connect to Xorg/XWayland server through the unix socket"/tmp/.X11-unix/X0" and fails. After sway starts, map "/tmp/X11-unix" exists, but it's empty.