Implement Xwayland support
In order to support clients that do not use a toolkit that has a Wayland backend, we have to implement XWayland support. XWayland is a rootless X11 server that runs as a Wayland client. X11 clients connect to XWayland just as they'd connect to a regular Xorg instance, and XWayland (more or less) converts the X11 protocol requests into Wayland protocol requests. XWayland support – perhaps surprisingly – requires the Wayland compositor to integrate a more-or-less fully-functional X11 window manager. Smithay has an xwayland module that handles a lot of the boring, boilerplate stuff, but there will be some work to be done to integrate that into our own window management logic. Collecting some (so far non-exhaustive) specifics: - [x] Window cycling include/not include skip-taskbar and skip-pager windows. (`cycle_minimum`) - [x] Handle `_GTK_FRAME_EXTENTS` in the window positioning code. This values is used for CSD windows so the client can tell the WM about things like drop shadows etc. Ideally Smithay should handle it (and return the full extents in `SpaceElement::bbox()`, like is the case for xdg-toplevels), and then we won't need to special-case it. - [x] Add support for focus-stealing prevention (`prevent_focus_stealing`). On X11, that's done with `_NET_USER_TIME`, with focus passing depending on comparing the timestamp on the currently-focused window with the window that wants focus. This won't work when trying to transfer focus from a Wayland window to X11, but we can do X11->X11. - [x] Support `WM_TAKE_FOCUS` - [x] Set XSETTINGS on the X11 root window, and update it whenever any of our XSETTINGS-related xfconf properties change. The `Xwm` struct has a `set_xsettings()` method on it, so I don't even need to manually construct the window property. - [x] Set the `Xwm` cursor when the cursor theme changes. - [x] If the XWayland server crashes, try to restart it. - Root window properties: - [x] Set `_NET_NUMBER_OF_DESKTOPS` on the root window to the workspace count. - [x] Set `_NET_CURRENT_DESKTOP` on the root window to the index of the current workspace. - [x] Set `_NET_DESKTOP_NAMES` to an array of workspace name strings. - [x] Set `_NET_DESKTOP_GEOMETRY` on the root window to full compositor space size. - [x] Set `_NET_DESKTOP_LAYOUT` on the root window to the row/col layout of workspaces. EWMH says a pager should be the one to set this, but in the Wayland world xfwl4 should just act as a pager, since it controls layout anyway. - [x] Set `_NET_DESKTOP_VIEWPORT` on the root window to `(0, 0)`. (We won't support viewports, but EWMH requires this is set.) - [x] Set `_NET_WORKAREA` based on layer-shell exclusive zones. - [x] Ensure `_NET_ACTIVE_WINDOW` is updated properly when focus changes. - [x] Set `_NET_SUPPORTING_WM_CHECK`. - [x] Set `_NET_SHOWING_DESKTOP` to reflect the state of the "show desktop" feature. https://github.com/Smithay/smithay/pull/2011 - Client window properties: - [x] Set `_NET_WM_DESKTOP` on each client window to the workspace number the window is on. - [x] Set `_NET_FRAME_EXTENTS` on decorated X11 windows to tell them the extents of their decorations. - `_NET_WM_STATE`: - [x] Add support for `_NET_WM_STATE_STICKY` to smithay. https://github.com/Smithay/smithay/pull/1995 - [x] Add support for `_NET_WM_STATE_SHADED` to smithay. https://github.com/Smithay/smithay/pull/1995 - [x] Add support for `_NET_WM_STATE_DEMANDS_ATTENTION` to smithay. (`urgent_blink`, `repeat_urgent_blink`) https://github.com/Smithay/smithay/pull/1995 - [x] Set `_NET_WM_STATE_ABOVE` when appropriate (needs smithay update). - [x] Set `_NET_WM_STATE_BELOW` when appropriate (needs smithay update). - [x] Ensure `_NET_WM_STATE_FOCUSED` is set on the active window. - [x] Ensure `_NET_WM_ALLOWED_ACTIONS` is set up properly (might make sense to add this support to smithay). - [x] Own the `_NET_DESKTOP_LAYOUT0` selection. - [x] Set `_NET_SUPPORTED` on the root window. Smithay already sets this, but the list doesn't (and can't) include everything we actually do support. - [x] Set xft-related properties in the x11 resource manager. - [x] Set xcursor-related properties in the x11 resource manager. - [x] Update xwayland client scale when output scale changes. - [x] Handle `_NET_WM_STATE_HIDDEN` on map. - [x] Handle `_NET_WM_STATE_FULLSCREEN` on map. - [x] Handle `_NET_WM_STATE_ABOVE` on map. - [x] Handle `_NET_WM_STATE_BELOW` on map. - [x] Handle `_NET_WM_STATE_MAXIMIZED_*` on map. - [x] Handle `_NET_WM_STATE_STICKY` on map. - [x] Handle `_NET_WM_STATE_SHADED` on map. * Support `_NET_WM_SYNC_REQUEST` & `_NET_WM_SYNC_REQUEST_COUNTER`. - [ ] Add protocol plumbing to smithay. https://github.com/Smithay/smithay/pull/2018 - [ ] Final implementation in xfwl4. * Support `_NET_WM_PING`. - [x] Add protocol plumbing to smithay. https://github.com/Smithay/smithay/pull/2020 - [x] Final implementation in xfwl4. - [x] Support `_NET_REQUEST_FRAME_EXTENTS`. - [x] Add support for `_NET_WM_OPAQUE_REGION` to smithay. https://github.com/Smithay/smithay/pull/2016 - [x] Support `_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED.` - [x] Support `_NET_WM_USER_TIME_WINDOW`. - [x] Support `_NET_WM_WINDOW_OPACITY_LOCKED`. - [x] Support size/resize increments. - [x] Support the `_GTK_SHOW_WINDOW_MENU` client message. * Maybe implement these (these are possibly of limited utility on Wayland): - [x] Support `_NET_CLIENT_LIST` & `_NET_CLIENT_LIST_STACKING` (only useful for X11 pagers). - [x] Support `_NET_CLOSE_WINDOW` (only useful for X11 pagers). * Possibly not implementable, or just not needed: * `_NET_WM_FULLSCREEN_MONITORS` (Wayland doesn't really have the concept of fullscreening across more than one output). * `_NET_WM_ICON_NAME` (a sort of "abbreviated name" that taskbars etc. can use if the real window title is very long; apps don't really use this anymore, and even if some old ones do, not having this doesn't really change the UX). * `_NET_WM_ICON_GEOMETRY` (would e.g. let xfdesktop set this on windows to tell the compositor where it can do a "minimize-to" animation when xfdesktop is in minimized window icons mode; but honestly I doubt something like this would ever get implemented). * `_NET_WM_STRUT` & `_NET_WM_STRUT_PARTIAL` (only useful for X11 docks; I don't think we need to support these, and doing so would be invasive). - [x] Fix pointer input bug. Sometimes windows can get into a state where some (0, 0)-anchored rectangular region of the window has properly working input, but once you get out of that region, the window behaves as if the pointer is stuck on the right/bottom edge of that region.
issue