Commit Graph

18376 Commits

Author SHA1 Message Date
Simon Ser c06ba33280 xwayland: generate pkg-config file from Meson
Remove the xwayland.pc.in file:

- This avoids writing down each pkg-config variable twice: once in
  the Meson files to set the configuration data, once in the .pc.in
  file to print it.
- We'll be able to re-use the same variables for use as a
  subproject.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-02-13 16:14:19 +00:00
Olivier Fourdan 0c93394d72 xwayland: Use wl_output.name for XRandR
If wl_output provides us with an output name, use that as well.

If we have both xdg_output.name and wl_output.name (from version >= 4),
prefer the latter.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>#
See-also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/189
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-13 14:41:05 +01:00
Olivier Fourdan b63ef10f18 xwayland: Pass the wl_output version
With the wl_output protocol, the actual bind to the interface is done in
xwl_output_create().

Pass the version number from the registry so we can bind to the minimum
version.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-13 14:41:05 +01:00
Olivier Fourdan 3c07a01c42 xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.

Luckily, xdg-output provides us with a name for the outputs.

Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.

So we could use the xdg-output name for the XRandR reported name for the
output.

Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.

So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.

Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-13 14:41:05 +01:00
Olivier Fourdan ddcbb46f97 xwayland: Tell RR has changed only when done
Since commit 204f10c2, we notify XRandR clients that the randr
configuration has changes as soon as an new output is created.

Yet, this might be premature, considering that at that point, we are
still to receive the wl_output and xdg-output events that will most
likely change the setup.

So instead of calling RRTellChanged() from xwl_output_create(), wait
until we get to call apply_output_change(), which occurs after the done
events from both xdg-output and wl_output are received.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-13 14:41:05 +01:00
Simon Ser 5aebc01096 xwayland: fix GBM on driver without explicit modifiers
Some drivers (e.g. AMD GFX8-) don't support explicit format
modifiers. On these drivers, gbm_bo_create_with_modifiers()
will fail. This results in "Error getting buffer" in the logs
later on with all X11 windows staying invisible.

Fallback to the modifier-less API gbm_bo_create() in that case.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-02-13 13:26:59 +00:00
Michel Dänzer d01a075d59 xwayland: Do not use "XWayland" spelling in code identifiers
Let's not give people any excuse for this spelling.
2023-02-13 13:02:55 +00:00
Michel Dänzer b5aa70503a xwayland: Spell XWAYLAND consistently in debug messages 2023-02-13 13:02:55 +00:00
Michel Dänzer df75d90a2c xwayland: Spell Xwayland consistently in error messages 2023-02-13 13:02:55 +00:00
Minh Phan ba644a64a4 xwayland/window: Do not double add window to damage list
The window might be retained in the damage list after
`xwl_screen_post_damage` in certain conditions. This means we need to
check if the window is already in the list to avoid adding the same
window twice which will lead to list corruption resulting in server freeze
in `xwl_screen_post_damage`.

Signed-off-by: Minh Phan <phanquangminh217@gmail.com>
2023-02-10 14:57:59 +00:00
Olivier Fourdan e196535abb dix: Clear device sprite after free in AttachDevice()
The code in AttachDevice() may free the dev->spriteInfo->sprite under
some circumstances and later call GetCurrentRootWindow() which uses
the same dev->spriteInfo->sprite.

While it seems unlikely that this is actually an issue, considering the
cases where one or the other get called, it still makes the code look
suspicious.

Make sure to clear set dev->spriteInfo->sprite to NULL  immediately
after it's freed to avoid any confusion, even if only to clarify the
code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1436
2023-02-09 23:54:11 +00:00
Olivier Fourdan 2f8778ca68 xwayland: wl_pointer.axis_v120 is no longer optional
With Wayland 1.21 being our baseline, we do not need to compile
wl_pointer.axis_v120 conditionally.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-02-09 22:57:00 +00:00
Olivier Fourdan f99bd03165 build: Bump Wayland dependency to 1.21
Wayland 1.21 was released on June 30, 2022 and our CI already installs
Wayland 1.21 so let's just require the version we actually use in our
CI.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-02-09 22:57:00 +00:00
Dave Airlie 86598739ba glamor: handle EXT_gpu_shader4 in dual source blend paths
Fixes: a955286869 ("glamor: add EXT_gpu_shader4 support")
Acked-by: Emma Anholt <emma@anholt.net>
2023-02-10 07:38:11 +10:00
Peter Hutterer 0ba6d8c370 Xi: fix potential use-after-free in DeepCopyPointerClasses
CVE-2023-0494, ZDI-CAN-19596

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-02-07 10:07:18 +10:00
Olivier Fourdan a7ee25f67d xwayland: Commit surface changes with libdecor configure
With libdecor, when the state changes (in the configure handler), we
need to commit the libdecor frame but also the wl_surface, otherwise
the surface is left in a uncommitted state until a wl_surface commit
eventually occurs later.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Fixes: c74c6add3e - xwayland: add optional support for libdecor
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2023-02-03 11:06:55 +01:00
Jeremy Huddleston Sequoia 0ea9b59589 darwin: Implement DetermineClientCmd for macOS
Withoug a proper implementation of DetermineClientCmd, clients that
connect via an ssh tunnel are miscategorized as local.  This results
in failures when we try to use SCM_RIGHTS (eg: in MIT-SHM).

Fixes: https://github.com/XQuartz/XQuartz/issues/314
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-26 17:51:16 +00:00
Jeremy Huddleston Sequoia 8a4ab22873 os: Use LOCAL_PEERPID from sys/un.h if it is available to detemine the pid when falling back on getpeereids()
This provides a way to determine the pid of a peer connection on
systems like darwin that do not support getpeerucred() nor
SO_PEERCRED.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-26 17:51:16 +00:00
Jeremy Huddleston Sequoia 165d5c1260 os: Update GetLocalClientCreds to prefer getpeerucred() or SO_PEERCRED over getpeereid()
GetLocalClientCreds() was preferring getpeereid() above other implementations.

getpeereid(), however, only returns the effective uid and gid of the peer,
leaving the pid unset.  When this happens, we are unable to use the pid to
determine the peer's command line arguments and incorrectly treat ssh-tunneled
traffic as local.

To address this, we now prioritize getpeerucred() or SO_PEERCRED as those two
implementations will return the pid in addition to uid and gid.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-26 17:51:16 +00:00
Jeremy Huddleston Sequoia 2577291f01 os: Update AllocNewConnection() debug logging to include whether or not the client is local
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-26 17:51:16 +00:00
Mike Gorse 2ef5ef57bd dix: Use CopyPartialInternalEvent in EnqueueEvent
The event might be a DeviceEvent allocated on the stack, in
AccessXKeyboardEvent for instance. Fixes out-of-bounds read.

Signed-off-by: Mike Gorse <mgorse@suse.com>
2023-01-25 02:02:48 +00:00
orbea d266274ca9 meson: wayland_client_dep is false when wayland is disabled
Signed-off-by: orbea <orbea@riseup.net>
2023-01-24 17:05:45 -08:00
Tamura Dai f33962966f Xephyr: fix help output.
"-mouse" require two commas before options.

Signed-off-by: Tamura Dai <kirinode0@gmail.com>
2023-01-22 22:35:59 +00:00
Austin Shafer d67383a695 xwayland: Send PresentCompleteModeSuboptimalCopy if dmabuf feedback was resent
If the dmabuf protocol's feedback object gave us a new list of
modifiers, send PresentCompleteModeSuboptimalCopy to the client
to inform them that they need to call GetSupportedModifiers.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-01-20 17:56:54 +00:00
Austin Shafer 9865a2321f dri3: Don't compute intersection with drawable modifiers
In dri3_get_supported_modifiers we were previously intersecting
the drawable mods and the screen mods. This meant all screen mods
were returned, but the ones compatible with the drawable were
returned in the drawable mods list and the rest are returned in
the screen mods list.

This is a problem with linux_dmabuf v4 since the drawable mods may
contain different mods not found in the screen mods (such as scanout
entries). This change removes the intersection, and just returns
the drawable/screen mod lists directly.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-01-20 17:56:54 +00:00
Austin Shafer f0415beb9f xwayland: Add proper support for telling if a format/mod is supported
This adds to xwl_glamor_is_modifier_supported, where if feedback
is in use we will check that the format/mod is allowed in any
device advertised by the compositor.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>

[ Michel Dänzer:
* Move dev_formats declaration to where it's used in
  xwl_feedback_is_modifier_supported
* Add curly braces around multi-line statement in
  xwl_glamor_is_modifier_supported ]
2023-01-20 17:56:54 +00:00
Austin Shafer d61eb4dd98 xwayland: Return default feedback in xwl_screen
If protocol version 4 of linux_dmabuf is in use, then the compositor
may not return anything with the modifiers event. We instead
will return the formats/mods reported for the main device.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>

[ Michel Dänzer:
* Move main_dev declaration to where it's used in
  xwl_glamor_get_formats
* Add empty line between variable declaration and comment ]
2023-01-20 17:56:54 +00:00
Austin Shafer 43b35b4efe xwayland: Make helper for returning a list of formats
This adds xwl_get_formats

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>

[ Michel Dänzer:
* Remove unused variable i from xwl_glamor_get_formats ]
2023-01-20 17:56:54 +00:00
Austin Shafer d2e107b260 xwayland: Add get_drawable_modifiers implementation
This reads from the format list, which is not yet filled in.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-01-20 17:56:54 +00:00
Austin Shafer 9f34807752 xwayland: Add get_main_device helper to GBM
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-01-20 17:56:54 +00:00
Austin Shafer bddfe190de xwayland: Implement linux_dmabuf_feedback event handlers
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>

[ Michel Dänzer:
* Sort protocol #includes lexically.
* memcpy to &xwl_feedback->main_dev directly in
  xwl_dmabuf_feedback_main_device. ]
2023-01-20 17:56:54 +00:00
Austin Shafer 2930eb113b xwayland: Move xwl_format array management to its own function
This creates xwl_add_format_and_mod_to_list, which is a helper
that adds a format/mod combo to a xwl_format* list. This will
be used by both the modifier event handling and the tranche
format handling.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-01-20 17:56:54 +00:00
Jeremy Huddleston Sequoia 16e7cdba48 rootless: Use screen_x and screen_y instead of pixmap pointer hacks
This updates rootless to treat pixmaps consistently with COMPOSITE,
using the screen_x and screen_y values rather than doing hacky math.

This will allow for proper bounds checking on a given PixmapRec.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 820b1dc461 rootless: Dead code removal (RootlessResizeCopyWindow)
This should no longer be necessary since we only support implementations
that handle preserving the bits across resize.  We can use
RootlessNoCopyWindow instead.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 40c56932a5 rootless: Remove an unnecessary memory copy when handling resize with gravity RL_GRAVITY_NONE (border width changes)
This should no longer be necessary since we only support implementations that handle preserving the bits across resize

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia a06cea245b rootless: Dead code removal (resize_after in StartFrameResize / FinishFrameResize)
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 1b36a10bd4 rootless: Remove the special case for northwest gravity in StartFrameResize
I don't see a reason why we would want to preserve pixels that are going to
not be visible anyways.  The rootless implementation already handles
preserving the relevant bits for us.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 305e627c01 rootless: Use RL_GRAVITY_NORTH_WEST for min/max/zoom resizing
If none of the four corners is fixed, we can use RL_GRAVITY_NORTH_WEST weighting
for the operation to let the implementation presetve the window bits for us.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 65ee3248f5 rootless: Ensure gResizeDeathPix is stored in locally-managed memory rather than re-using the implementation's backing store
The implementation owns the pointer during RootlessStopDrawing and
RootlessStartDrawing and is free to (does) change it.  Rootless
cannot assume ownership of this memory region.  This is possibly
the cause of some hard to diagnose crashes in XQuartz over the
years.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia f71ef2f02f rootless: Remove option to disable ROOTLESS_RESIZE_GRAVITY
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Jeremy Huddleston Sequoia 20f5b270d3 rootless: Fixup some format errors in debug logging
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-20 17:10:54 +00:00
Ivan A. Melnikov 711d491729 glamor: Don't initialize on softpipe
There are systems where softpipe is the default renderer,
e.g. when llvmpipe is not is not available. Using glamor
on such systems is never a good idea.

This mirrors what commit 0a9415cf79
did for llvmpipe.

Closes: #1417

Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
2023-01-19 20:06:04 +00:00
Michel Dänzer 5c18e25e12 ci: Export LP_NUM_THREADS=0 for meson test
This prevents the Mesa llvmpipe driver from spawning (potentially lots
of) worker threads.

Suggested by Daniel Stone on IRC.
2023-01-19 15:11:17 +01:00
Michel Dänzer 81d91f7d01 ci: Move dist testing to a separate job
Multiple reasons, in particular:

* Doing it in every build & test job duplicates effort, resulting in
  the pipeline taking longer than necessary.
* We cannot limit the number of test processes spawned by meson dist.
* There's little point running tests for dist anyway, we just want to
  make sure we can build & install from the generated tarball.
2023-01-19 15:08:57 +01:00
Michel Dänzer b2dee689fa ci: Use "meson test" instead of "ninja test"
This lets us actually limit the number of test processes spawned in
parallel.

(ninja test runs meson test without --num-processes, so it ends up
spawning as many processes in parallel as there are CPU cores)
2023-01-19 15:07:57 +01:00
Peter Hutterer 3a02f56b43 xwayland: hook up wl_pointer.axis_v120 events
For details on the protocol itself see the Wayland merge request:
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72

The v120 event has a value base of 120, so one wheel detent is 120, half a
wheel is 60, etc. This is the API Windows has been using since Vista but it
requires HW support from the device. Logitech mice and many Microsoft mice of
the last decade or so have support and it's enabled in the kernel since v5.0.

The new events replace wl_pointer.axis_discrete events, once you bind to
wl_pointer >= 8 you only get the v120 events. So backwards compatibility
is simple, we just multiply the discrete events if we get them and
treat everything as 120 event internally.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-18 13:33:54 +10:00
Peter Hutterer 2f0d39e1f1 xwayland: use a define for the horiz/vert scroll valuators
Slightly more readable and less prone to copy/paste errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-18 12:49:08 +10:00
Jeremy Huddleston Sequoia 66e7b7349d Revert "meson: Don't build COMPOSITE for XQuartz"
This will allow us to remove build-time conditionalization on COMPOSITE
while still allowing XQuartz to disable it and use ROOTLESS.

This reverts commit 9c03733669.
2023-01-17 15:17:45 -08:00
Jeremy Huddleston Sequoia 2567388a29 xquartz: Disable COMPOSITE at runtime
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-17 15:17:45 -08:00
Jeremy Huddleston Sequoia 15077090d3 xquartz: Update the about box copyright to 2023
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2023-01-17 07:33:38 -08:00