Commit Graph

70 Commits

Author SHA1 Message Date
Grigory Kirillov 0867dd4e6b xwayland: add support for _NET_WM_WINDOW_TYPE_DESKTOP atom 2024-01-25 19:27:37 +03:00
John Lindgren af165acb42 xwayland: add wlr_xwayland_set_workareas()
This function allows compositors to set the _NET_WORKAREA property on
the root window. XWayland clients use _NET_WORKAREA to determine how
much of the screen is not covered by panels/docks. The property is used
for example by Qt to determine areas of the screen that popup menus
should not overlap (see QScreen::availableVirtualGeometry).
2023-10-26 15:05:08 -04:00
Kirill Primak a09d649439 docs: replace the less commonly used "::" with "." 2023-10-02 22:10:16 +03:00
Kirill Primak 3dc646ea88 Add some missing includes/declarations 2023-06-05 21:06:19 +00:00
Kirill Primak ad51983b23 xwm: make atom_map static 2023-03-09 18:51:47 +00:00
John Lindgren 068280201a xwayland: Read and publish _NET_WM_STRUT_PARTIAL property
This is needed for compositors that want to reserve space for
XWayland panels.  Such a feature can be useful in a "transitional"
setup, where only the X11 window manager and compositor is replaced
but other components of an X11 desktop environment are still used.

This change simply reads the X11 property; the compositor is free
to ignore it.  Thus, compositors that don't want to support such a
"transitional" feature are not impacted.

v2: Update xwayland_surface_associate()
2023-02-13 12:57:20 -05:00
Simon Ser 86fc2199f8 build: unify naming for HAVE_* defines
We sometimes used HAS_, sometimes polluted the LIBINPUT_ namespace,
etc.
2022-12-06 22:39:45 +00:00
Simon Ser 4da9b32a15 xwayland: use internal_config
Avoids the need to have a separate config.h, and removes C compiler
arguments.
2022-12-06 22:39:45 +00:00
Simon Ser 6c897756b6 build: use a configuration file for internal features
This avoids re-building the whole project when switching one
Meson option. This shrinks down the compiler invocation command
line, making it more readable and making it easier to inspect
which flags are passed in (the generated file can be opened).
Additionally this is more consistent with our external feature
handling, which uses <wlr/config.h> already.
2022-12-06 22:39:45 +00:00
Simon Ser 4ff46e6cf9 xwayland/xwm: add support for xwayland-shell-v1 2022-11-18 15:35:20 +00:00
Simon Ser cde3700386 xwayland: use dict to collect supported features 2022-05-23 09:49:58 +02:00
Joshua Ashton 02e648c1b2 xwayland: Add support for -force-xrandr-emulation 2022-05-23 07:30:28 +00:00
Simon Ser f575e445ec xwayland: terminate when no client is connected
Automatically shutdown Xwayland 10s after all X11 clients have
gone away.
2022-05-07 19:25:44 +00:00
Simon Ser 352064d76d xwayland: add wlr_xwayland_server_options.terminate_delay
This allows users to specify a delay after which the Xwayland process
terminates itself when there are no more X11 clients connected.
2022-05-07 19:25:44 +00:00
Simon Ser 3e801d68f2 xwayland: add support for -noTouchPointerEmulation
This allows compositors to handle touch pointer emulation manually,
instead of having Xwayland do it [1].

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/691
2021-11-02 12:02:51 +01:00
Simon Ser 0c5ff5efab build: simplify get_variable calls
With recent-ish Meson we can stop repeating the variable name for
each provider.
2021-09-21 11:35:08 -06:00
Guido Günther e479dc1ef0 xwayland: Allow to retrieve startup-id via _NET_STARTUP_INFO
A launchee notifies with a "remove"¹ message when done starting up.
Catch these and forward to the compositor. This allows the compositor to
end the startup sequence that might have been started by another
protocol like xdg-activation.

We don't handle other messages since we expect the launcher to use a
wayland protocol like xdg-activation.

While `_NET_STARTUP_ID` helps to associate toplevels with startup-ids
this signals the end of the startup sequence.

1) https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt
2021-09-11 09:53:23 +02:00
Guido Günther de1522aeee xwayland: Allow to retrieve _NET_STARTUP_ID
This is use for startup notifications per startup-notifiation spec

https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt
2021-08-20 10:44:22 +02:00
Tudor Brindus ae2f3ecb68 xwm: implement _NET_CLIENT_LIST_STACKING
This property is present on all modern X11 instances. The nonpresence of
it requires applications to fall back to XQueryTree-based logic to
determine stacking logic (e.g., to determine what surface should get
Xdnd events).

These code paths are effectively untested nowadays, so this makes it
more likely for wlroots to "break" applications. For instance, the
XQueryTree fallback path has been broken in Chromium for the last 10
years.

It's easy enough to maintain this property, so let's just do it.

Fixes #2889.
2021-05-31 10:41:29 +02:00
Aleksei Bavshin e0f239fa28 xwayland: query window PIDs via XResQueryClientIds
`_NET_WM_PID` is unreliable: it is optional and even if set it may
contain PIDs from sandbox namespaces or remote systems.
Prefer XRes v1.2 QueryClientIds method which returns PIDs as seen by the
Xwayland server.
2021-04-23 09:55:01 +02:00
Simon Ser 1eb38e0015 Remove WLR_HAS_XCB_ERRORS
wlroots' dependency on this library doesn't change the features
exposed to compositors. It's purely a wlroots implementation detail.
Thus downstream compositors shouldn't really care about it.

Introduce an "internal_features" dictionary to store the status of
such internal dependencies.
2021-04-09 21:54:38 +02:00
Simon Ser 55aaeb25c5 build: use get_variable instead of get_pkgconfig_variable
This fixes the following warning:

    WARNING: Project targeting '>=0.56.0' but tried to use feature deprecated since '0.56.0': Dependency.get_pkgconfig_variable. use Dependency.get_variable(pkgconfig : ...) instead
2021-04-06 20:35:00 +02:00
Simon Ser de5347d0f2 xwayland: require xcb-icccm
This dependency is already required by many other widely used X11
programs, such as i3, Qt, and other XWMs. So it should be available
on most systems.

X11 support can be pretty broken without xcb-icccm, with focus issues
for instance. Let's just remove this --please-break-my-desktop footgun
option.
2021-03-29 12:24:26 +02:00
Simon Ser e6f6e1ad0a xwayland: use -listenfd if available
Xwayland's -listen option was deprecated in [1] in favor of -listenfd.

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/593
2021-03-03 19:04:47 +01:00
Simon Ser eec2e1d3b1 xwayland: check executable exists on init
Instead of walking PATH like a previous proposal [1], this one
checks that the Xwayland path specified in the pkg-config file
exists.

I think this is a reasonable compromise:

- Users that don't have Xwayland installed system-wide won't get
  a bogus DISPLAY env variable set up.
- Users that have WLR_XWAYLAND set won't be affected by this check.
- Users that have Xwayland installed system-wide and a different
  Xwayland in their PATH still get their custom Xwayland.
- Users that don't have Xwayland installed system-wide but have it
  somewhere else in PATH are left out. But this is pretty niche,
  and they can just set WLR_XWAYLAND.

[1]: https://github.com/swaywm/wlroots/pull/2314
2021-03-03 18:19:12 +01:00
Manuel Stoeckl 79be26ff1f xwayland/xwm: make atom_map const 2021-02-05 10:04:20 +01:00
Tudor Brindus 2fa257313a xwayland/selection: use one target window per selection
Previously, the clipboard and primary selections shared the same window.
This was racey, and could have led to pasting failures.

On xfixes selection owner change notification, the logic for requesting
the supported mimetypes of the new owner's selection looks like:

  xcb_convert_selection(
    xwm->xcb_conn,
    selection->window,
    selection->atom,
    xwm->atoms[TARGETS],
    xwm->atoms[WL_SELECTION],
    selection->timestamp
  );

This means ask the selection owner to write its TARGETS for the
`selection->atom` selection (one of PRIMARY, CLIPBOARD, DND_SELECTION)
to `selection->window`'s WL_SELECTION atom.

However, `selection->window` is shared for both PRIMARY and CLIPBOARD
selections, and WL_SELECTION is used as the target atom in both cases.
So, there's a race when both selections change at the same time.

The CLIPBOARD selection might support mimetypes {A, B, C}, and the
PRIMARY only {A, B}. If the ConvertSelection requests/responses "cross
on the wire", so to speak, wlroots can end up believing that the PRIMARY
selection also supports C.

A Wayland client may then ask for the PRIMARY selection in C format,
which will fail with "convert selection failed".

This commit fixes this by using a separate window for PRIMARY and
CLIPBOARD target requests, so that WL_SELECTION can be used as the
target atom in both cases.
2021-02-04 17:06:14 +01:00
Tudor Brindus 7964a313e8 xwayland/selection: use one X11 window per incoming transfer
This commit introduces logic for using a new X11 window for each
incoming transfer, rather than having a global window for each selection
source.

This eliminates a whole class of bugs involving multiple concurrent
incoming transfers.

For now, we retain the outgoing transfer queue, and the selection
source-specific windows to support it. Source-specific windows are no
longer used in the incoming path, and will be removed in a future PR.

Refs #1497.
2021-02-04 13:33:59 +01:00
Tudor Brindus dd4c8aa45e xwayland/selection: make xwm_selection_init take a wlr_xwm_selection *
This makes it consistent with xwm_selection_finish.
2021-01-31 19:17:04 +01:00
Tudor Brindus b3d782f818 xwayland/selection: introduce `xwm_selection_transfer_init`
Currently, all this does is initialize `wl_client_fd` to -1, so that
comparisons with 0 are meaningful.
2021-01-31 19:17:04 +01:00
Tudor Brindus aa86a022fa xwayland/selection: make xwm_selection_finish take a wlr_xwm_selection *
Previously it took a wlr_xwm *, which was a bit surprising in that it
freed members of wlr_xwm *, not just its respective selections.
2021-01-31 19:17:04 +01:00
Tudor Brindus b6ba595862 xwayland/selection: destroy all selections on Xwayland restart
Previously, Xwayland could restart, and we'd get events for transfers
pointing to the previous (now freed) xwm instance. This led to
use-after-free segfaults.

Closes #2565.
2021-01-31 10:24:59 +01:00
Tudor Brindus 703c17ae41 xwayland/selection: refactor remaining incremental transfer code 2021-01-29 10:18:03 +01:00
Tudor Brindus 23148d283f xwayland/selection: extract out property requests
Apart from reducing duplication, this has the positive side-effect of
allowing all deallocs to use
`xwm_selection_transfer_destroy_property_reply`, as opposed to the
latter and a mix of ad-hoc `free`s.
2021-01-29 10:18:03 +01:00
Simon Ser 5a2ef794dc xwayland: drop unused enum net_wm_state_action 2021-01-27 10:47:16 +01:00
Tudor Brindus e75f483aeb xwayland/selection: rename Wayland-facing data and helpers
Previously, wlr_xwm_selection_transfer.source_fd meant:

- the source of data in a Wayland -> X11 copy (good)
- the destination of data in a X11 -> Wayland copy (confusing)

This made reading through xwayland/selection/incoming.c difficult: in
many places, "source" actually means "destination".
2021-01-25 21:02:55 +01:00
Ilia Bozhinov 74f7be7287 xwayland: do not allow apps to change focus after wlroots request 2020-07-30 13:40:36 +02:00
Scott Moreau 6d0ee53e1a xwm: Set _NET_WM_STATE_FOCUSED property for the focused surface
Certain clients require this property to be set for expected behavior.
Most notably, steam client CSD maximize button no longer worked
after unmaximizing once, unless the state was changed by another
method. The state is unset whenever another surface gains focus.
2020-07-27 14:26:30 +02:00
Tobias Langendorf bd387da62d xwm: add support for xwayland minimize 2020-07-21 13:20:17 +02:00
John Chadwick 58bcec9d94 xwm: end transfers when the requestor is destroyed
This improves the failure cases when incremental transfers fail to
complete successfully for one reason or another.
2020-07-03 09:42:36 +02:00
Simon Ser 27609ba0d9 xwayland: split server
Split the server part of wlr_xwayland into wlr_xwayland_server. This
allows compositors to implement their own XWM when wlroots' isn't a good
fit.
2020-05-19 22:07:47 +02:00
Simon Ser 4bb391c896 xwayland: remove underscore prefix from atom names
Previously, some atoms had a leading underscore, others didn't. Be more
consistent and never use a leading underscore (symbols with a leading
underscore followed by an upper-case letter are reserved).
2020-03-06 21:34:44 +01:00
Simon Ser 175af4f74f xwayland: remove duplicate _NET_WM_NAME entry 2020-03-06 21:34:44 +01:00
Simon Ser 68a69ee079 xwayland: use explicit indexes when initializing atom_map
It's very easy to break the mapping between the atom_name enum and the
atom_map array. Use explicit indexes to prevent issues.
2020-03-06 21:34:44 +01:00
Uli Schlachter e7d9cf5815 xwm: Add _NET_CLIENT_LIST support
Fixes: https://github.com/swaywm/wlroots/issues/1469
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-15 11:08:54 +01:00
emersion 4cb0697e57 data-device, primary-selection: add request_set_selection
This makes compositors able to block and/or customize set_selection requests
coming from clients. For instance, it's possible for a compositor to disable
rich selection content (by removing all MIME types except text/plain). This
commit implements the design proposed in [1].

Two new events are added to wlr_seat: request_set_selection and
request_set_primary_selection. Compositors need to listen to these events and
either destroy the source or effectively set the selection.

Fixes https://github.com/swaywm/wlroots/issues/1138

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2019-01-24 11:38:23 +01:00
emersion 9f0720c03a
primary-selection: introduce wlr_primary_selection_source
This is a common interface that can be used for all primary selection
protocols, as discussed in [1]. A new function wlr_seat_set_primary_selection
is added to set the primary selection for all protocols.

The seat now owns again the source, and resets the selection to NULL when
destroyed.

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2018-11-29 19:40:28 +01:00
emersion 811a4d997b
Rename wlr_primary_selection to wlr_gtk_primary_selection 2018-11-23 11:58:56 +01:00
emersion 51bfdd620e
Use #if instead of #ifdef for wlroots config data
This prevents some annoying issues when e.g. not including wlr/config.h or
making a typo in the guard name.
2018-11-12 10:12:46 +01:00
emersion f745befc06
xwayland: fix typo to enable transparency
We spent literally hours trying to debug this. Turns out it's a typo.

Kill me.
2018-10-27 11:59:27 +02:00