1
0
Fork 0
Commit graph

1761 commits

Author SHA1 Message Date
Carlos Garnacho
a88c9b9ff2 wayland: Use default cursor on tablet tools
Now that we "replace" the pointer cursor on tablet input, have it
use the default cursor so it blends in better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Sebastian Wick
abadb29132 xwayland: Relax the ownership requirements of /tmp/.X11-unix
The `ensure_x11_unix_perms` function tries to detect systems on which
/tmp/.X11-unix is owned by neither root nor ourselves because in that
case the owner can take over the socket we create (symlink races are
fixed in linux 800179c9b8a1e796e441674776d11cd4c05d61d7). This should
not be possible in the first place and systems should come with some way
to ensure that's the case (systemd-tmpfiles, polyinstantiationm …). That
check however only works if we see the root user namespace which might
not be the case when running in e.g. toolbx.

This change relaxes the requirements such that in the root user
namespace we detect and abort if a vulnerable system is detected but
unconditionally run in toolbx.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2261>
2022-02-07 16:01:26 +00:00
Olivier Fourdan
8305c7bd06 wayland/client: Restore the NOFILE limit
Make sure the restore the original NOFILE limit prior to run the
trusted Wayland client so it does not inherit from the raised value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Olivier Fourdan
b8870a11b8 xwayland: Warn when autoclose-xwayland is not usable
The experimental feature "autoclose-xwayland" requires a couple of
prerequisites:

1. Be able to (re)start Xwayland on demand, i.e. with systemd
2. Xwayland must support the terminate delay

Add a warning message if "autoclose-xwayland" was requested but any of
those prerequisites is not met.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Olivier Fourdan
6ce80ccc54 xwayland: Remove stop xserver timeout
Since commit 226afa24a - "Use Xwayland auto-terminate feature", the
callback function shutdown_xwayland_cb() does not check for the
autoclose-xwayland experimental feature anymore.

As a result, when running nested or outside of systemd,
gnome-shell/mutter would quit after 10 seconds unless some X11 window
was mapped.

But now that we rely on Xwayland's own terminate feature, there really is
no need to use any xserver timeout function anymore.

We do not need to keep track of X11 windows being created or unmapped, as
again, Xwayland does all that for us at the client level.

Remove all this code that we do not need anymore.

fixes: 226afa24a - Use Xwayland auto-terminate feature

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Olivier Fourdan
226afa24aa xwayland: Use Xwayland auto-terminate feature
When using Xwayland-on-demand (default), if the (experimental) autoclose
features is enabled, we can rely on Xwayland's auto-terminate feature
instead of explicitly killing the Xwayland process.

With it, gone is the mechanism that was added to check the X11 clients
connected and their executable to check whether we can (safely) kill
Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Olivier Fourdan
42855b69e7 xwayland: Mark our X11 connection terminatable
The connection to the Xserver for the X11 window manager part of mutter
even on Wayland may prevent the Xserver from shutting down.

Currently, what mutter does is to check the X11 clients still connected
to Xwayland using the XRes extension, with a list of X11 clients that
can be safely ignored (typically the GNOME XSettings daemon, the IBus
daemon, pulseaudio and even mutter window manager itself).

When there is just those known clients remaining, mutter would kill
Xwayland automatically.

But that's racy, because between the time mutter checks with Xwayland
the remaining clients and the time it actually kills the process, a new
X11 client might have come along and won't be able to connect to
Xwayland that mutter is just about to kill.

Because of that, the feature “autoclose-xwayland” is marked as an
experimental feature in mutter and not enabled by default.

Thankfully, the Xserver has all it takes to manage that already, and
is even capable of terminating itself once all X11 clients are gone (the
-terminate option on the command line).

With XFixes version 6, the X11 clients can declare themselves
"terminatable", so that the Xserver could simply ignore those X11
clients when checking the remaining clients and terminate itself
automatically.

Use that mechanism to declare mutter's own connection to the Xserver as
"terminatable" when Xwayland is started on demand so that it won't hold
Xwayland alive for the sole purpose of mutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Robert Mader
dea9f8bbfe wayland/surface: Make ensure_cached_state() static
There is no reason for it to be public or have a return value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
e3f0efa065 wayland/surface: Ensure to apply cached state
It is possible that we never create a cached state for a surface
even if it is synced. That is the case if `commit()` is never called.
We still need to call `apply_state()` in this case in order to run
e.g. `role_post_apply_state()` or `parent_state_applied` on subsurfaces.

So just ensure to initialize the cached state instead of bailing out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
03434e566a wayland/subsurface: Ensure cached state recursivly gets applied on set_desync()
Subsurfaces can be effectively synced indirectly via their ancestors.
Right now such indirectly synced surfaces don't apply their cached
state when their ancestor effectively becomes desync as by the time
we call `parent_state_applied()` on them, they are considered as
desync.

Thus sligthly reoder things so when the ancestors becomes desync
and applies its state, those surfaces still count as synced and
will thus apply their cached state as well.

While on it, add a check to prevent `set_desync()` to have side
effects when the target surface is not currently synced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Jonas Ådahl
a2382f3251 wayland/dma-buf: Don't warn if there was no render node
When running in KVM, the EGL driver supports querying the render node
path, but it returns NULL. Handle that better by falling back to
querying the device main device file, instead of falling back on v3 of
the protocol and logging a warning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Robert Mader
ab17c98c94 wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check
From the spec:
> This means that at commit time the supplied buffer size must be
> an integer multiple of the buffer_scale. If that's not the case,
> an invalid_size error is sent.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1938

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2188>
2022-01-07 20:46:42 +00:00
Jonas Ådahl
926c34cc89 wayland/dma-buf: Fix typo
A = was placed where a ; should have been placed. Caught by coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2215>
2022-01-07 19:31:23 +00:00
Jonas Ådahl
5523242eb9 wayland/dma-buf: Define fallback EGL_DRM_RENDER_NODE_FILE_EXT
If the EGL header is not new enough, it will not contain that relatively
new macro definition, so to avoid breaking compilation, define it
ourselves for now. Should be possible to remove after some time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2214>
2022-01-07 18:25:41 +00:00
Fernando Monteiro
12de68abf3 wayland: Drop deprecated text input
This has been replaced for text-input-v3.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2185>
2022-01-05 22:30:21 +00:00
Fernando Monteiro
a8bf9d8c68 wayland: Drop wl-shell protocol
This protocol is deprecated since a long time, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2183>
2022-01-05 21:43:29 +00:00
Jonas Ådahl
8a2fcf3be0 wayland: Use new KMS update test API to try acquiring scanout
This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
64e6bedb6b wayland/dma-buf: Add support for scanout surface feedback
Whenever a surface is promoted as a scanout candidate by
MetaCompositorNative, it'll get a CRTC set as the candidate CRTC.

When a client asks for DMA buffer surface feedback, use this property to
determine whether we should send a scanout feedback tranche.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
4c54b36126 wayland/dma-buf: Move should_send_modifiers() to the top
It's very much an auxiliary method; lets move it to where it belongs,
according to HACKING.md.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
43161c6660 compositor/native: Track what Wayland surface is a scanout candidate
For the current candidate, set the candidate CRTC on that surface. This
will later be used to send DMA buffer feedback for direct scanout purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9a47766a96 wayland/dma-buf: Add tranche priorities
Unused for now, but will be added to prioritize scanout tranches higher
than render only ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9c942a43d6 wayland/dma-buf: Make manager object a GObject
Will make certain operations easier, i.e. setting up a GQuark.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
90076cf268 wayland/surface: Remove unnecessary NULL check
This check has caused repeated confusion, as there are no current code
paths where this can ever end up in the true-branch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
2a16a750c5 wayland/dma-buf: Always advertise non-modifier fallback
This is done to explicitly tell clients that the compositor supports
implicit modifier paths (i.e. using modifier unaware API).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
7acecb1c72 wayland/dma-buf: Add basic support for DMA buffer feedback
This includes sending the default tranche, but so far only sends the
same for every surface feedback requested. Scanout tranche will be added
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
1978e93f28 wayland/dma-buf: Prepare format/modifier map up front
As the format table is setup up front, it doesn't change when this
experimental feature setting change. Make the settings documentation
reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
51308a9d78 wayland/dma-buf: Add manager struct
It'll be used to store state related to DMA buffer Wayland support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Robert Mader
9ee03fe93b wayland: Fix some code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Robert Mader
f51cccbc29 wayland/surface: Fix code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Jonas Ådahl
32affbf05a wayland/dma-buf: Fix building without native backend
The usefullnes of Wayland without the native backend is questionable,
but since it's theoretically possible, make it at least compile again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Jonas Ådahl
06c215c747 wayland/surface: Remove unnecessary resource user data changing
We're in the destructor, it's pointless to unset the userdata as we'll
never ever see a request being invoked with it ever again, since the
resource itself will be destroyed or marked as destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:19:33 +01:00
Ievgen Popovych
b596de2680 wayland/window-configuration: Fix missing horizontal maximized check
Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2187>
2021-12-28 20:21:52 +02:00
Jonas Ådahl
25ed64b61d cursor-sprite: Register all cursor sprites with the cursor tracker
This will later be used to invalidate GPU state when closing device
nodes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Robert Mader
c498ae337f wayland/surface: Do not uncoditionally process surface damage
Most clients nowadays switched to buffer damage, most notably Mesa
and Xwayland. Thus lets avoid the extra cost of allocating three
`cairo_region_t`s and doing some calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
c166811695 wayland/surface: Use correct default viewport for surface damage
If no viewport is set, the neutral viewport is the surface size
without viewport destination size applied - i.e. transform and
scale applied to the buffer size. Change it accordingly, giving
us the same values we'd return in `get_width` in this case.

As result, this only changes cases where a viewport destination
size but no viewport source rectangle is set.

The change fixes exactly such cases, e.g. the Gstreamer Wayland
sink. Can be tested with: `gst-play-1.0 --videosink=waylandsink`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
f4717d0ac5 wayland/surface: Switch order for calculating surface damage
Process surface damage in the right order, simplifying the
calculations.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Jonas Ådahl
0df12ebee6 xwayland: Don't remove /tmp/.X11-unix/X0 when running tests
When Xwayland was not initalized, we'd still clean things up. What this
accidentally meant was that the uninitialized display number 0 was
cleanud up, which very likely was main display of the host session.

What this meant in practice was that /tmp/.X11-unix/X0 was often
removed, causing every Flatpak X11 application to fail to start until
Xwayland was restarted nad the X0 socket file was restored.

Fix this in two ways: firstly only shutdown Xwayland if we ever started
it, i.e. if the X11 display policy was not 'disabled'. This should fix
the issue most of the times. Secondly only clean up the socket if it was
ever initialized. This should fix things if the socket creation failed,
as if it did, the name would be set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2162>
2021-12-19 16:52:45 +00:00
Jonas Ådahl
3602762a18 tests/wayland-unit-tests: Add test case for remapping popup with subsurface
This test reproduces the crash in
https://gitlab.gnome.org/GNOME/mutter/-/issues/1828. It does not
reproduce with 'window-actor/wayland: Remove subsurface actors on
dispose' (dd416dd3e2). applied. This test case differs slightly
from the one that came with the dd416dd3e2 as in that it uses
withdrawn popup surfaces instead of explicitly client managed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
8a43123765 xdg-shell/popup: Reset 'dismissed-by-client' state when remapping
A popup surface can be remapped multiple times using the same
wl_surface, if a new xdg_popup object is created. To properly handle
this, we need to reset the 'dismissed_by_client' boolean to false, as
otherwise we won't allow new buffer commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
José Expósito
cea5c47671 wayland/pointer: Return on scroll without client
Return early from handle_scroll_event if no client is focused to avoid
redundant calculations.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
José Expósito
d703ba56c3 wayland/pointer: Call wl_resource_get_version once
Call wl_resource_get_version once for each pointer resource.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Carlos Garnacho
d2998a8e41 wayland: Check keyboard serials for activation
We are using internal API that has the benefit of checking that the
focus surface still matches, but has the drawback that it does not
check the MetaWaylandKeyboard state.

In order to fix this, look for keyboard focus and serial matches
specifically when triggering activation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2148>
2021-12-13 14:49:14 +00:00
Georges Basile Stavracas Neto
87a66830dc cogl: Drop cogl-wayland-server.h
This header only defines one function that doesn't exist anymore,
and nothing else. It can be safely dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2145>
2021-12-07 18:34:00 -03:00
Carlos Garnacho
eda7588190 backends: Replace MetaCursorSprite::prepare-at with in-place function
Since this signal is in a hot path during input handling, it makes sense
not to have this be a signal at all, currently most of the time spent in
it is in GLib signal machinery itself.

Replace it with a function/user data pair that are set on the sprite
itself. Only the places that create an sprite are interested in hooking
one ::prepare-at behavior per sprite, so we can do with a single pair.

This makes meta_cursor_sprite_prepare_at() inexpensive enough.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
5e93708d86 wayland: Mark sprite as invalid after cursor changes
This will be used to hint the backend that the cursor surface
might need uploading again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
508c08fa09 backends: Only reload sprite cursor on changes
Let the meta_cursor_sprite_realize() function return a boolean value
telling whether there was an actual change in the sprite cursor. E.g.
the surface/icon for it changed in between.

This is used in the native backend to avoid converting/uploading again
the cursor surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
c07c50d189 wayland: Make the pointer leave non-alive surfaces
Listen to changes in MetaWindow::is-alive, so that the pointer
can logically leave the surface as soon as that happens. This
helps prevent flooding the client socket while it is stalled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +00:00
Jonas Ådahl
29141afd0f xwayland: Handle the died callback being cancelled more gracefully
If we were cancelled, it could mean we teared down, meaning fetching
manager instances will attempt to fetch past freed instances. Handle
this by waiting with the fetching until we know we weren't cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +00:00
Jonas Ådahl
ad0d70d5d5 wayland: Detach event source on tear down
No reason keeping it attached; would one continue using a main loop on
the default main context after tear down, we'd get callbacks causing
use-after-free issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +00:00