Fix issues when there are both Wayland and X11 displays
If xfce4-terminal is start on an X11 display, but later another window is opened on a Wayland display, gdk_display_get_default() will return the X11 display, but gtk_widget_get_display() will return the Wayland display. If we then try to call X11 functions on the Wayland display, we'll get a crash.
This can happen if you start xfce4-terminal in your X11 session, but then later start a nested Wayland session inside it (or even start a Wayland compositor on another VT). If you then run xfce4-terminal again in a context where GDK will initialize the Wayland display, and the original xfce4-terminal process is reachable via dbus, the "X11 terminal" will open a new display connection to the Wayland display.
There are also some other areas where there might not be actual crashes, but the wrong display will get used, and I attempted to fix them up. There might be some others; there are still some calls to gdk_display_get_default()
(some behind WINDOWING_IS_*()
), but I think they should be mostly harmless to leave alone.
Closes #336 (closed)