1
0
Fork 0
Commit graph

1763 commits

Author SHA1 Message Date
Carlos Garnacho
ec390b68c5 wayland: Implement the xdg-activation protocol
This protocol implements the IPC necessary to focus application
windows across launcher/launchee. Add support for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1845>
2021-07-09 09:34:28 +00:00
Jonas Ådahl
10c4bc6e3f drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice
The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Christian Rauch
aacdc0b6f1 wayland: Apply states without needing a newly attached buffer
Applying some states, such as the minimum and maximum toplevel size, do not
require a new buffer and can operate on the old buffer. Requiring a client
to commit a new buffer just to change such states prevents setting limits
on an already existing surface buffer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>
2021-07-06 09:11:10 +00:00
Jonas Ådahl
9542c713ad window/wayland: Replace constraint side effect peeking with state checks
When the MetaWindow resize machinery for toplevels ended up in the
Wayland window implementation, we tried to avoid configuring
not-yet-mapped windows that just had its zero sized dimension pass
through the constraint machinery, resulting in a 1x1 sized window.

If we'd properly set up the min size metadata earlier, that 1x1 would
likely be the minimum size set of a window, which makes things harder to
predict when peeking at side effects.

However, what the side effect peeking intends to do, as documented in
the comment, was to figure out when the client hadn't committed any
buffer yet, i.e. during the initial map, and in those cases avoid
sending that nasty 1x1 size, resulting in silly window sizes. A more
robust way to detect this is instead checking when we shouldn't really
try resize things our own way, and in those cases early out as was done
before.

This means that, for a yet to me mapped window, we only ever want to
send an initial non-zero configuration when 1) it's initially maximized,
2) initially fullscreen, or 3) initially tiled in any way, as those are
the situations where the compositor is the one deciding the size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1912>
2021-07-05 10:27:58 +00:00
JoseExposito
dc919998b1 wayland/pointer-gestures: Fix swipe cancellation
The cancel phase for swipe gestures was not being handled, hence,
Wayland "end" events where not sent to clients when the gesture was
cancelled.

A swipe gesture is cancelled when extra finger(s) are put down on the
touchpad in the middle of the gesture or when some, but not all, of the
fingers are put up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1857>
2021-06-15 22:22:30 +00:00
Carlos Garnacho
fcdda41def wayland: Make implicit grabs during popups be owner_events=TRUE
Getting crossing events is necessary between client surfaces while
there is a popup grab in effect (e.g. allow press-drag-release in
menus), we should only stick with the focus surface while the pointer
is outside any client surface.

This partially undoes commit 79050004b0 (or, at least, mutter no
longer fixes the bug it claimed to fix). This will be addressed in
gtk4.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1885>
2021-06-09 19:00:15 +00:00
Carlos Garnacho
4ed05830e2 wayland: Close pipe file descriptors after use
Both ends were being leaked here, one directly, other through the
GIOChannel.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4302
(just maybe)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1870>
2021-05-25 16:31:07 +00:00
Jonas Ådahl
301d2c55c6 wayland: Make init and shutdown symmetric
We first initialized the Wayland infrastructure, then the display, but
on shutdown, we first teared down the Wayland infrastructure, then the
display.

Make things a bit more symmetric and tear down the display before
Wayland. This however means we need to tear down some things Wayland a
bit earlier than the rest. For now this is a separate function, but
eventually, it can be replaced with a signal shared by the backend's
'prepare-shutdown' signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
dc97163bcd xwayland: Pass MetaWaylandCompositor pointer when initializing
This way we can initialize without having any way to retrieve it via
some global variable. This isn't needed now, but will be once Wayland
infrastructure initializiation is done in a single step.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
d03c194552 wayland/output: Use the passed compositor pointer
This is especially important as we might end up here when initializing
the Wayland infrastructure. Later that will be done in one step, meaning
the "get_default()" function will not work properly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
5bc8823701 xwayland: Don't fetch global when shutting down DND
It might not be there when shutting down, so get it from a more managed
place. Note that this isn't strictly needed right now, but eventually,
the MetaWaylandCompositor pointer will be cleared using a g_clear*()
helper, which clears the pointer before freeing the instance, which
wouldn't work here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
b578a534a3 clutter: Remove Wayland server helper
It's a wrapper around a similar Cogl API we don't use anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
14eba8bb8f wayland: Bind Wayland EGL display ourselves
This will allow us less awkward startup, where previously we had to
pre-initialize Wayland very early so Cogl could bind the Wayland display
when it initialized. Move things around so we bind the Wayland EGL
display when initializing the rest of Wayland infrastructure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
6c1793b7d3 Rename MetaDisplayPolicy to MetaX11DisplayPolicy
This lack of X11 in the name was a bit confusing, since this is about
the X11 policy, not some policy of MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Olivier Fourdan
b03ccfff4d xwayland: Check the condition on displayfd ready
The callback on_displayfd_ready() would unconditionally set the return
value to TRUE, regardless of the condition.

Use the GIO condition to determine if there was data written and adjust
the return value accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1851>
2021-05-11 15:49:25 +00:00
Jonas Ådahl
4490d4524b xwayland: Handle shutting down without having started
We initialize, but might not start, e.g. when a test case just needs a
backend and doesn't start mutter. When cleaning up, we'll still try to
clean up Xwayland integration, and this commit handles cleaning up
without having made the mess.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1856>
2021-05-06 17:55:32 +02:00
Jonas Ådahl
1a43312b96 wayland: Tear down seat too when shutting down
The functionality was mostly there, but not hooked up to anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
9827687ca1 wayland/seat: Unset resource user data when disabling
We make objects inert when disabling the seat, but we requests may still
have effect. This is especially bad if disabling is followed by
destroying, but also means e.g. set_cursor() not doing an early out
after the pointer capability was disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
8303752e32 wayland/keyboard: Don't free NULL anonymous file
Use g_clear_pointer() instead, as meta_anonymous_file_free() rightfully
doesn't like being passed NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c614cc3e82 wayland: Terminate Xwayland when shutting down
This is less confusing to Xwayland than suddenly loosing the Wayland
socket connection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
799c6dcf2f main: Tear down Wayland support before MetaDisplay
MetaDisplay does a lot of things, and is a central part to anything
window management. To let Wayland units have an easier time tearing
down, make it so that the Wayland infrastructure is terminated before
MetaDisplay.

This also makes sure that X11 support is turned off, so that we don't
stumble upon Xwayland terminating due to the Wayland socket connection
being broken. Will mitigate that in a better way in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b71f52ff32 xwayland: Set libX11 error handlers to no-ops before terminating
We might not be the only entity holding on to the X11 GdkDisplay,
meaning the X11 connection will stay alive indefinitely, e.g. if the gjs
context has some reference to it.

Avoid running into issues due to X11 connection errors by setting the
libX11 handlers to no-ops, so when we are terminating; that means the
GDK X11 connection can stay "alive" until its too late, and we'll just
silently ignore any connection errors that may happen due to the
lingering GDK display reference.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
0a12f1c9c6 wayland: Clean up Wayland clients and display on shutdown
This will clean up Wayland related objects, e.g. surfaces and buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Robert Mader
96f2da9fb0 wayland/data-device: Clear existing data device resource from list
Compositor behaviour when calling `wl_data_device_manager_get_data_device`
for the same seat multiple times is not very clearly defined in
the spec and both Mutter and Weston currently don't handle
the DnD case properly.

While Weston handles DnD only for the last created data device,
Mutter, because of some internal reshuffling, ends up toggling
between two devices.

Properly handling this case requires some bigger changes. So
in order to behave predictable and in line with Weston,
only take the last created data device into account while
still keeping the previous created ones around.

The main affect client here is Firefox, which gets very
confused by the toggling behaviour and becomes more stable
with this patch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1841>
2021-04-30 22:38:39 +02:00
Robert Mader
6e00e5e6e7 wayland/subsurface: Avoid placement ops for detached subsurfaces
If a subsurface first gets reordered and afterwards detached from
the parent before the parent surface got commited, we currently
would end up reattaching the subsurface to its previous parent.

While clients should avoid this behaviour, it's legit according
to the spec.

We already prevent similar cases where the subsurface is destroyed -
extend that check to detaching, which includes the destroy case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1831>
2021-04-19 11:55:49 +00:00
Aleksandr Mezin
90e3d9782d Revert "wayland/window: Correct detection whether to send configure"
It breaks more than it fixes.

After commit [1] Shell doesn't trigger the original issue [2] anymore.

[1]: ba0b9239d3
[2]: https://gitlab.gnome.org/GNOME/mutter/-/issues/1627

This reverts commit 236e9ec68f.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1723

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1804>
2021-04-14 06:36:09 +00:00
Robert Mader
a09c914230 wayland/actor-surface: Call ensure_size_valid() on shaped-texture
Use the new API to make sure the shaped texture has a valid size
during the next layout phase.

This is needed here because, quoting the previous commit:

When the texture size is invalidated using `invalidate_size()`, the new
size will only get calculated the next time `update_size()` is
called. This happens e.g. in `meta_shaped_texture_get_preferred_size()`
via `ensure_size_valid()`.

`update_size()` can chain up to `clutter_content_invalidate_size()`
as well as emitting a `size-changed` signal. If this happens during
layout, the result is a 'change the layout conditions during layout'
issue, causing heavy breakage in e.g. the Shell overview.

To fix this, expose `ensure_size_valid()` as API so callers can make
sure the texture has a valid size without creating redundant size
invalidations calls.

Note that if a buffer with a new size is attached we already trigger
`update_size()` explicitely, avoiding such situations.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Carlos Garnacho
4bee25d8e6 wayland: Cancel selection data sources that are set while unfocused
If a client is naive enough to assume that it can set the selection while
it has got no surfaces, mutter will simply ignore the request and leave
the selection unchanged.

This is good and the expected behavior, however the poor client that did
this will enter in an inconsistent state where it "claimed" the selection,
but nobody told it that the wl_data_source is not current.

So, when the client is focused the next time, it will receive wl_data_offers
as usual, but it will still think all the time that it is owning the
selection. In the case of GTK, that takes client-side shortcuts, so any
attempted paste will still bring back the client-side aborted selection.

To fix this, cancel the selection right away if it happened while unfocused,
the client will be able to undo its own failed selection, and not assume
that future offers are its own.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1469
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1772>
2021-03-23 17:07:31 +00:00
Daniel van Vugt
3555f65b75 wayland-dma-buf: Add support for DRM_FORMAT_ABGR2101010
It seems to be the preferred format of the Mesa V3D driver on
Raspberry Pi 4. If the compositor doesn't advertise it then Mesa will
fallback from `zwp_linux_dmabuf_v1` to `wl_drm`, incorrectly. Meaning
it will keep using a buffer with modifiers on an interface that does
not have modifiers.

Add support for `DRM_FORMAT_ABGR2101010`. It works, and prevents Mesa
from taking its broken fallback path.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1520
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1798>
2021-03-23 16:40:40 +00:00
Olivier Fourdan
1f1bf4cd9d xwayland: Check permissions on /tmp/.X11-unix
For Xwayland, mutter creates the sockets in the standard /tmp/.X11-unix
directory.

Yet, if that directory already exists, it may have been created by
another user with full control over the created socket.

To avoid that issue, if the directory /tmp/.X11-unix already exists,
check that the permissions are as we expect, i.e. the directory belongs
to either root or the user herself, is writable and has the sticky bit.

Thanks to fabian@ritter-vogt.de for reporting that issue.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1708

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1787>
2021-03-18 17:43:02 +01:00
Olivier Fourdan
7b5e855032 xwayland: Use defines for X11 directory and path
Rather than repeating the same strings for X11 directory and path all
around the code, use a define.

No functional change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1787>
2021-03-18 17:43:02 +01:00
Robert Mader
2ef6490323 wayland/surface: Do not free placement ops of cached state
The list gets freed in `meta_wayland_surface_state_clear()`
if the pointer is still set.

Fixes ba8499f9ec

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1783>
2021-03-15 12:49:45 +00:00
Robert Mader
ba8499f9ec wayland/subsurface: Move placement ops to the parents pending state
Unlike other subsurface state, placement operations need to get
applied in order. As per spec:

```
Requests are handled in order and applied immediately to a pending
state. The final pending state is copied to the active state the
next time the state of the parent surface is applied.
```

Having placement operations being part of the subsurface state
makes it difficult to support arbitrary orderings. Make them
part of the parents surface pending state instead.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1768>
2021-03-14 00:38:18 +01:00
Aleksandr Mezin
236e9ec68f wayland/window: Correct detection whether to send configure
When deciding if `configure` event should be sent,
`meta_window_wayland_move_resize_internal` compares requested window size
with `window->rect` size. However, `window->rect` is only updated when `commit`
is received. So the following sequence produces incorrect result:

1. a window initially has size `size1`
2. `move_resize_internal` is called with `size2`. `configure` is sent
3. `move_resize_internal` is called with `size1` to restore original size,
but `commit` for `size2` haven't arrived yet. So `window->rect` still has size
`size1`, and thus new `configure` is not sent
4. `commit` for `size2` arrives, window changes size to `size2`

Expected window size in the end: `size1`
Actual: `size2`

To fix the issue, take size from pending `configure` events into account.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1627

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1755>
2021-03-12 16:25:10 +00:00
Ivan Molodetskikh
82af1fb87e wayland: Send presentation feedbacks to cursors
This commit assumes that cursor surfaces work in a "mailbox" fashion. If
they are painted multiple times before a successful flip, all commits
but the last get discarded, and the last commit gets presented after the
flip succeeds. This is more or less how it works in the atomic backend,
and also more or less how it works in other backends, with the exception
that the cursor painting might fail without any way of knowing. This
assumption is still better than unconditionally discarding all cursor
surface feedbacks as if the cursor painting always fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
cd9ae13465 backend: Pass stage view to cursor-painted signal
Will be used for presentation-time handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
2ce3a050f0 wayland: Wire up presentation-time machinery
- add surfaces to the presentation list,
- move their feedbacks to the map in on-after-update,
- fire the feedbacks in on_presented().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
f0c2200466 wayland: Store map of ready presentation feedbacks
These are feedbacks for updates that were drawn or otherwise displayed
on screen, and need to be fired as soon as their presentation happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
0c3490223e wayland: Store list of presentation-time surfaces
These are surfaces that might have registered presentation-time
callbacks, similar to the frame callback surface list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
bb57f35296 wayland: Add presentation_feedback_present()
Regarding the sequence = 0 fallback: in some cases (moving a cursor
plane on atomic amdgpu) we get sequence = 0 in the page flip callback.
This seems like an amdgpu bug, so work around it by assuming a sequence
delta of 1 (it is equal to 1 because of the sequence != 0 check above).

Sequence can also legitimately be 0 if we're lucky during the 32-bit
overflow, in which case assuming a delta of 1 will give more or less
reasonable values on this and next presentation, after which it'll be
back to normal.

Sequence is also 0 on mode set fallback and when running nested, in
which case assuming a delta of 1 every frame is the best we can do.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
dccc60ec3e wayland: Implement stub presentation-time
The presentation-time protocol allows surfaces to get accurate
timestamps of when their contents were shown on screen.

This commit implements a stub version of the protocol which correctly
discards all presentation feedback objects (as if the surface contents
are never shown on screen). Subsequent commits will implement sending
the presented events to surfaces shown on screen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Philip Withnall
bec456ba0a xwayland: Fix some FD leaks on error paths
If `meta_xwayland_start_xserver()` returned via an error path, some of
the socket FDs were leaked.

Fix that, and add `steal_fd()` calls to make it clearer that FDs passed
to `g_subprocess_launcher_take_fd()` are transferred to it. There were
no bugs with how `GSubprocessLauncher` was being used.

Spotted while working on
https://gitlab.gnome.org/GNOME/glib/-/issues/2332.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1738>
2021-02-24 14:17:07 +00:00
Olivier Fourdan
6438919a89 window: Add "is_focus_async" API
X11 clients can use different models of input handling, of which some
may not result focus being set synchronously.

For such clients, meta_focus_window() will not change the focus itself
but rely on the client itself to set the input focus on the desired
window.

Add a new MetaWindow API to check when dealing with such a window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1716>
2021-02-23 11:08:59 +00:00
Robert Mader
6eeeffdc68 src: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Carlos Garnacho
698fe3f1a9 wayland: Avoid automatically decoupling source/offer after grab
In the case that DnD is performed and succeeds, we want to release
the grab early, and let the transfer IPC happen in the back. For
that to happen without a hitch, drag source and offer must be left
related to each other after undoing the grab, even though the default
ungrabbing code does that automatically (indirectly, by unsetting the
drag focus).

In these cases, we used to manually unset the current source, so
this decoupling was skipped. Notably, one missed case is X11 DnD,
so we might end up with the situation there that DnD did succeed,
transfer is ongoing, but the source and offer are already decoupled,
this confused the machinery and missed the finishing XdndFinished
to be emitted to the X11 drag source.

The prior commits prepared for this source/offer decoupling being
a manual operation, this commit avoids doing this automatically
when ungrabbing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
0f9dc84d3b wayland: Manually detach source/offer on failure paths
Adapt more paths to manual detaching of source/offer. This is still
done automatically when the grab is finished.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
8e01ea1e04 wayland: Plug XDnD drag source leak
This object is just being detached, with no code unref'ing it. Do
this whenever the XDnD selection goes unowned, usually a good
indication that the drag source no longer is one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
3799606fc2 wayland: Make XDnD grab unlink source/offer manually
This currently happens by default whenever the grab is finished.
We want to eventually do this manually everywhere, so start here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Dor Askayo
80fd030f10 onscreen/native: Move function declaration to the correct header file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Robert Mader
04eeeb78d1 wayland/dnd-surface: Use new API to set geometry scale of feedback actor
The removed parts are now all handled in MetaFeedbackActor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Jonas Ådahl
cda26b493e wayland: Only use async configured geometry if actually changed
When (un)maximizing, (un)fullscreening, the move/resize action is
flagged with 'ACTION_MOVE' and 'ACTION_RESIZE' , while e.g.
'appears-focus' does not.

When a client misbehaved and didn't immediately reply to a configure
request with a commit with the corresponding ack_configure, the
following commit would trigger a oddly timed move, making the window
appear to move back to a previous position.

Avoid this issue by only carrying over the target window position if the
configuration actually contained a new position.

We cannot only rely on the flags however, as e.g. a new position should
be respected during interactive resize, even though only 'ACTION_RESIZE'
is passed in such scenarios.

Do the same for the size, except if the window state dictates that the
size is fixed to a certain size, e.g. being fullscreen or maximized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1445>
2021-01-30 09:49:13 +00:00
Sebastian Keller
c9aa43aa7a wayland/gtk-shell: Add an explicit gtk-shell surface release request
Previously the wl_resource and MetaWaylandGtkSurface corresponding to
any client gtk_surface have been kept around until the exit of the
client due to the client side destroy method not signaling the
destruction to the server. Ideally the protocol would have specified a
destroy request marked as destructor to handle this automatically,
however this is no longer possible due to the destroy method being
implicitly generated in the absence of an explicit request in the
protocol. Adding a destroy request marked as destructor now would
generate a new destroy method that unconditionally would send the
request to the server, which would break clients running on servers not
supporting that request.

So instead of modifying the destroy request add a new "release"
destructor, that indicates to the server that it can release the
resource. This can be optionally be used by clients depending on the
server protocol version.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Sebastian Keller
b41c4aec26 wayland/gtk-shell: Fix MetaWaylandGtkSurface leak on surface destroy
The MetaWaylandSurface corresponding to a MetaWaylandGtkSurface can be
destroyed before the MetaWaylandGtkSurface is destroyed. In its destroy
function MetaWaylandSurface however was unsetting the destructor of the
correspnding resource along with the gtk_surface1 interface
implementation. This was done to prevent further gtk_surface1 requests
on a NULLed MetaWaylandSurface, if it has been destroyed before the
MetaWaylandGtkSurface.

It would be enough to just unset the resource implementation, while
keeping the destructor to fix this leak. However the following commit
will rely on the implementation being available after the
MetaWaylandSurface has been destroyed. So instead introduce NULL checks
for all functions that can be called on the gtk_surface1 interface and
do not unset the implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Jonas Ådahl
d8e75027a4 xwayland: Split Xwayland display name getter into two
One for the public channel, and one for the private maintainance
channel. Use the public one for test clients, otherwise tests become
flaky, and the private one for MetaX11Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
84bde805fe native: Consolidate DRM buffer management to MetaDrmBuffer types
This commit consolidates DRM buffer management to the MetaDrmBuffer
types, where the base type handles the common functionality (such as
managing the framebuffer id using drmModeAdd*/RMFb()), and the sub types
their corresponding type specific behavior.

This means that drmModeAdd*/RmFB() handling is moved from meta-gpu-kms.c
to meta-drm-buffer.c; dumb buffer allocation/management from
meta-renderer-native.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Olivier Fourdan
22b926eea7 xwayland: Check for listenfd option
Current Xwayland has marked the command line option "-listen" as
deprecated in favor of "-listenfd".

Use the pkg-config variable "have_listenfd" (if available) from Xwayland
to determine if we should use that option, to avoid a deprecation
warning when spawning Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1682>
2021-01-22 11:40:30 +01:00
Olivier Fourdan
26cc51a1a5 xwayland: Do not retry the same display
Mutter listens to two display connections, one for regular X11 clients
and another one for the so called "managed services".

Once an available display number is found for the regular X11 clients,
mutter would then redo the work to find another available display number
for the managed services.

Yet, it does so starting from the same initial display, which is a waste
of time since it just tried all displays to find the first available
one, so all these, including the regular display it just took, are now
in use.

So instead of starting over from the beginning when looking for a
display available for the managed services, continue from the next
display immediately after the one we found precedently.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1680>
2021-01-21 18:08:48 +01:00
Olivier Fourdan
eb06d9e165 xwayland: Do not rely on X-lock files
Some X11 servers may not always create a lock file, yet mutter uses the
lock file to find a possible display number and then tries to bind to
the socket corresponding to that display number.

If it fails to bind, it will simply bail out. As a result, if an X11
server is already listening on that display but hadn't created a lock
file, mutter won't be able to start Xwayland.

To avoid that possible issue, make mutter retry with another display
for a given number of tries when binding fails even though the display
was supposed to be available based on the lock file presence.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1604
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 12:57:07 +01:00
Olivier Fourdan
f6b4665b02 xwayland: Check for X11 unix directory only once
The function choose_xdisplay() calls open_display_sockets() which calls
ensure_x11_unix_dir().

We don't need to do that from within the loop though, as the directory
/tmp/.X11-unix is the same regardless of the display number.

Move the call to ensure_x11_unix_dir() from open_display_sockets() to
choose_xdisplay() prior to enter the display loop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
Olivier Fourdan
1bd42e8779 xwayland: Propagate error if display sockets failed
In case of failure to open the display sockets, we would not propagatre
the error which can cause a crash when trying to show the error message.

Properly propagate the error to avoid the crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
James Henstridge
063db30c50 xwayland: Start Xwayland on connection to either public X11 socket
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1454
(cherry picked from commit 7b2815077fa1053069e00c0a21b2c3038f4b0d1c)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
James Henstridge
df4b6d4ca5 Revert "wayland: Drop Xwayland abstract socket"
This reverts commit e2123768f6.  Various
container/chroot (e.g. Snaps, pressure-vessel) systems still depend on
the presence of the abstract X11 socket.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1613
(cherry picked from commit ea2192c4899ac7897efca31e8e85c157895950ac)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
Carlos Garnacho
5671888775 wayland: Handle forced Xwayland shutdown elegantly
In the shutdown paths we check with the X11 display whether there's
remaining clients. However this happens in paths that happen after
the MetaX11Display vanished in the case of Xwayland crash.

Since in that situation the clients are forcibly vanishing too,
skip the client check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1677>
2021-01-20 16:55:08 +01:00
Olivier Fourdan
3fc603edd3 xwayland: Make autoclose-xwayland an exp. feature
Closing automatically Xwayland once all relevant X11 clients are gone is
inherently racy, if a new client comes along right at the time we're
killing Xwayland.

Fixing the possible race conditions between mutter, Xwayland and the X11
clients may take some time.

Meanwhile, make that an experimental feature "autoclose-xwayland".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1673>
2021-01-19 09:33:33 +01:00
Olivier Fourdan
e5347af000 xwayland: Check X11 clients prior to terminate Xwayland
Currently, mutter checks for the presence of X11 windows to decide
whether or not Xwayland can be terminated, when Xwayland is started on
demand.

Unfortunately, not all X11 clients will map a window all the time, an
X11 client may keep the X11 connection opened after closing all its
windows. In that case, we may terminate Xwayland while there are some
X11 client connected still, and terminating Xwayland will also kill
those X11 clients.

To avoid that issue, check the X11 clients actually connected using the
XRes extension. The XRes extension provides the PID of the (local) X11
clients connected to the Xserver, so we need to match that against the
actual executable names, and compare with a list of known executables
that we can safely ignore, such as ibus-x11 or gsd-xsettings.

We also check against our own executable name, considering that the X11
window manager is also an X11 client connected to the Xserver.

Also, XRes returning the PID of local clients only is not a problem
considering that Xwayland does not listen to remote connections.
However, if the user spawns a client remotely on another system using
ssh tunneling (ssh -X), only clients which actually map a window will
be accounted for.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1537
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1671>
2021-01-18 17:52:22 +01:00
Carlos Garnacho
98ef6d0d05 wayland: Ensure pointer constraint region consistency
Changes in games between fullscreen and windowed modes may trigger
chaotic situations where the buffer and the frame size temporarily
disagree, producing rectangles with negative width/height. This is
usually followed by other updates that bring the pointer constraint
up to date.

This makes cairo panic and return an "error" empty region, which breaks
deeper down when using the region rectangles to apply the pointer
constraint.

If we hit this situation, ignore the frame rectangle, and just go with
the buffer rectangle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1655>
2021-01-12 12:32:24 +01:00
Carlos Garnacho
65e7b9ae3a wayland: Repick (again) on pointer motion
Unfortunately there's situations where we can't fully rely on only
crossing events here. One such situation is pointer visibility changes
due to touch interaction, or e.g. after closing the lid.

In these situations the pointer position stays the same, picks the
same actor, yet we want to see the right surface as the pointer focus
again in the wayland side.

This used to happen on the first motion event after the pointer
visibility change before commit ad3f2b0b86, use motion events again
for picking so we don't break these usecases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Carlos Garnacho
d39d4d124e wayland: Do not account touch crossing events for pointer
These events may be emitted for touchpoints (in which case they contain
an event sequence). Ignore those as they are not relevant for pointer
picking, and shouldn't influence its focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Carlos Garnacho
17afb88a0c wayland: Drop needless includes
These includes are now unused, no need to make it look as if we still
had layering breaks here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
ad3f2b0b86 wayland: Only repick pointer on crossing events
These are the only situations where it makes sense to determine a new
focus surface.

Suggested-by: Jonas Dreßler <verdre@v0yd.nl>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
ce6b91bb64 wayland: Drop meta_wayland_compositor_repick()
This is now unused, thus the whole call chain from this function
to meta_wayland_pointer_repick() can be removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
a64dba4d7a compositor: Trigger repick after window effects here
Just because of implementation details, this is only relevant to Wayland,
and is done via ::effects-completed handlers there. Ideally, Clutter should
notice by itself about effects starting, finishing, and affecting picking.
Doing this in generic code seems slightly cleaner in the interim.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
717e5d969a wayland: Avoid repick_for_event() call
We can also tell the stage to emit crossing events, which will be
handled in place (i.e. not queued), and yield the same result.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:45 +01:00
Carlos Garnacho
1f17a7ffef wayland: Do not query seat for pointer coordinates
In the wayland code we are in synchronization with the events that
the ClutterStage is managing at the moment. Asking the ClutterSeat for
the pointer position gets ahead of the current events, and may result
in imprecise coordinates sent in wl_pointer.enter.

To be in consistence with the motion events that might be already
queued, we should ask the stage for the last known coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:29:41 +01:00
Carlos Garnacho
0021fe173b wayland: Don't use CLUTTER_LEAVE source actor for repick
This is the actor receiving the event, therefore precisely not the
actor the pointer is on. We should avoid this event's source here,
use the related actor (i.e. the one being entered) instead.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1584
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:29:12 +01:00
Carlos Garnacho
3d82da23ec wayland: Don't explicitly repick on wl_surface destructor
As the crash at https://gitlab.gnome.org/GNOME/mutter/-/issues/1584
shows, this is already handled indirectly via the surface actor destruction
paths (especifically, through changes in its reactiveness). We don't
need repeating the operation here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-22 18:27:37 +01:00
Jonas Dreßler
ae6d83fb47 clutter: Switch to storing device->actor associations in ClutterStage
As planned and prepared with the last commits, let ClutterStage take
care of tracking input devices and their respective actors. This means
we now can remove the old infrastructure for this from
ClutterInputDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 16:17:00 +01:00
Aleksandr Mezin
4f544b6362 xwayland: Set xrandr primary output
To find XWayland output that should be the primary one, iterate through all
XWayland outputs, and compare their geometry to the geometry of the primary
logical monitor.

To avoid possible race conditions (Mutter's monitor configuration already
updated, but Xrandr not yet), set the output both after Randr notifications and
after 'monitors-changed' signal.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1407

Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1558>
2020-12-11 13:44:45 +00:00
Jonas Ådahl
357f3250cb xwayland: Make sure /tmp/.X11-unix/ exists
When we're running under a polyinstantiated SELinux environment, we'll
likely start with an isolated and empty /tmp, meannig no /tmp/.X11-unix
directory to add things to. To make it possible to still function in
this kind of setup, make sure said directory exists.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1626>
2020-12-10 17:10:32 +01:00
Jonas Ådahl
d940911478 xwayland: Don't spew warnings when looking for X11 displays
It's not important, so only show it when doing MUTTER_DEBUG=wayland.
Instead report what display numbers were eventually found.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1625>
2020-12-10 15:00:53 +00:00
Jonas Ådahl
4ef34ed68f xwayland: Clean up error reporting
Instead of g_warning() everywhere, use GError.

This also removes the already unused 'fatal' boolean that was still
passed around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1625>
2020-12-10 15:00:53 +00:00
Carlos Garnacho
b88790554b clutter: Move relative motion information to ClutterEvent
Instead of using native backend platform data specifically, store
this info in ClutterMotionEvent. This includes time in usec since
it's just used for motion events, in the future it could make sense
to make these general to all events again, but it could make sense
to make ClutterEvent structs private before.

In order to express that a motion event has relative motion info,
the CLUTTER_EVENT_FLAG_RELATIVE_MOTION event flag has been added
for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
4db5b95aac wayland: Drop HAVE_BACKEND_NATIVE checks in wl_touch implementation
This file doesn't really do anything much backend-dependent anymore, we
can drop these checks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
eaa04ecee5 backends: Unify touch sequence to slot conversion
We had code in both backends that sort of independently associated
sequences to slots. Make both transform slots to sequences the same
way, so they may share the implementation convert those back to slots.

This helper now lives in Clutter API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
9f5c453fc7 clutter: Move evdev evcode data to Clutter button/key events
We have this as platform-dependent data in the native backend, and
a bunch of fallback code done in place in the evcode users. Stop
making this platform-dependent data, and move it to the relevant
ClutterEvents.

The fallback code for the X11 backend case is about the same, but
now it is done directly by the X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Jonas Ådahl
a40ab5650b wayland/xdg-shell: Warn on invalid effective geometry
It isn't allowed to provide empty window geometries; warn if a client
violates this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1557>
2020-12-03 21:39:13 +00:00
Jonas Ådahl
a54970805d wayland/subsurface: Don't include buffer-less subsurfaces in geometry
We'd get a wierd looking geometry if there were subsurfaces added
without buffers as we'd pick up on their positions even though they were
empty.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1557>
2020-12-03 21:39:13 +00:00
Jonas Ådahl
d2c798838e wayland/xdg-shell: Warn when invalid geometry is set
A client is not allowed to send an empty window geometry, and it is
specified that if it does so an error should be raised. Respect this
rule, ignore bogus geometries sent by clients with a warning.

Also add a soft assert that we don't try to "resend" a configuration
that was never sent, as doing so would result in SIGFPE as the geometry
scale is 0.

This fixes a SIGFPE crash occurring when a client did this.

Related: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2808
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1527
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1557>
2020-12-03 21:39:13 +00:00
Olivier Fourdan
79d4d7a4ff xwayland: Fix XIOErrorExitHandler warning
The XIOErrorExitHandler expects (Display *, void *) whereas mutter uses
(Display *, MetaX11Display *).

That causes a warning at build time:

  warning: passing argument 2 of ‘XSetIOErrorExitHandler’ from
           incompatible pointer type [-Wincompatible-pointer-types]
    813 |   XSetIOErrorExitHandler (xdisplay, x_io_error_exit, display);

Actually, the MetaX11Display is not even used, so we can just use the
expected API and ignore the value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1621>
2020-12-03 13:58:08 +00:00
Jonas Ådahl
c56433d6ee wayland/buffer: Trace instrument buffer-attach
While browsing sysprof profiling reports, I saw surface-commit taking
significant times sometimes; trace attach too, to see whether such
things are due to e.g. texture uploads.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1616>
2020-12-01 11:41:11 +00:00
Carlos Garnacho
f117a157dc clutter: Add vmethod to find out group for pad features
Do it so the wayland bits don't have to access native input devices
internals. The data is still readonly, idempotent, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
168ceb9905 backends: Forward event axes as array of ClutterInputAxes elements
Instead of encoding arrays in ways that we need the ClutterInputDevice
to decode them, use ClutterInputAxes as the array index.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e772f62ea7 clutter: Make axes part of the device tool
This info can be construct-only there, as opposed to devices.
Move this info to tools, so we can drop it from devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
d58e082500 clutter: Drop clutter_input_device_get_modifier_state() API
This is using ClutterSeat state queries underneath, let the only
caller do that, and drop this call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c6849a66e8 clutter: Drop clutter_input_device_get_coords() method
This is not device state anymore. It uses ClutterSeat API underneath,
so let callers do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
5f30d1b8ac backends: Split pad action mapping to a separate object
This now lives in the core, and will get updated from events in the
UI thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
00cbcb7ba1 core: Centralize cursor renderer and tracker updates
These use now more of a "pull" model, where they receive update
notifications and the relevant input position is queried, instead
of the coordinates being passed along.

This allows to treat cursor renderers all the same independently
of the device they track. This notifying of position changes should
ideally be more backend-y than core-y, a better location will be
figured out in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c93bea9f59 wayland: Move away from meta_cursor_renderer_get_position()
Fetch the cursor renderer device, and query its position instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
de0848b28b backends: Use graphene_point_t on meta_cursor_tracker_get_pointer()
It's nicer to propagate along.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
cd02286b87 backends/native: Manage tablet cursors in backend
Instead of letting the wayland bits maintain an always-software
cursor renderer, let the cursor renderer be managed by the backend,
and only hook to it (as we do for pointer cursor) in the wayland
bits.

ATM, make the cursor renderer still always-software, although
ideally we should allow moving the HW cursor management between
renderers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
0d83fcc870 wayland: Look up cursor renderer for device on MetaWaylandPointer
Make it explicitly look up the pointer device, instead of implicitly
relying on it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
d41dbf92ea wayland: Replace cursor renderer usage with cursor tracker
We just want to know the pointer position, let's use something else
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e721fde259 backends: Add argument for best scale on MetaCursorSprite::prepare-at
Instead of letting implementations poke backend internals from various
places, give that information right away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
8a8d47725c backends: Delegate pointer confinements to an impl object
Split pointer confinements in 2 objects, one set from the upper layers
containing its definition, and another managed by the backend that
applies it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Robert Mader
c78b03bd50 wayland/compositor: Only emit frame callbacks for the primary stage view
Since we schedule frames for each stage view seperately now, surfaces receive
frame callbacks for each stage view they are visible on.

Only emit frame callbacks for the primary stage view.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1468>
2020-11-19 19:44:43 +01:00
Olivier Fourdan
8bf399ff0c xwayland: Match applications without WM_CLASS nor WM_NAME
For X11 grabs, the pattern matching mechanism would simply ignore
applications which have neither WM_CLASS nor WM_NAME set.

When dealing with an override redirect window however, it is not
uncommon that these window have neither value set as these window are
supposed to be ignored by the window manager.

When the WM_CLASS or the WM_NAME is not set by the client, assume the
value is empty so the pattern matching can allow for these.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1249

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1254>
2020-11-06 15:57:23 +01:00
Robert Mader
4e9a67acc6 wayland/subsurface: Check for circular relationships
If a subsurface is equal to or an ancestor of the parent surface
we currently crash. Check for that case and terminate the client.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1521
2020-11-05 21:16:27 +01:00
Jonas Ådahl
eaa6efef56 wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.

This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.

In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 10:24:25 +01:00
Carlos Garnacho
a76a47fbde clutter: Pass timestamp to clutter_input_device_set_actor()
This function emits crossing events, so needs a (most times truthful)
timestamp. Make it explicit instead of fetching it from the device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
6a6894a397 clutter: Specify stage on clutter_input_device_update() function
This is the function performing the picking, tell it explicitly the
stage it should happen on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
f00e567417 wayland: Use Clutter event to handle touch cancel
The semantics for libinput events are not as expected here. Besides
it's pointless, as those should arrive per-slot in a burst, and we
cancel on the first event.

We can simply use the Clutter event for this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
3a65ee7c6a wayland: Simplify wl_touch.frame handling
We want to coalesce multiple touch events into the same wl_touch.frame
event. Instead of poking internals to peek the touch events (and their
slots) coming at us before we handle them, simplify things by queueing
the event at a slightly lower priority than events, so we are ensured
to handle all pending input events before sending the event.

If there's no pending events, we can just send the frame event. As it
doesn't make sense to hold any longer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Christian Rauch
a93ef84d57 wayland/window: Provide prior floating window dimensions
Implements the "prior window window geometry dimensions" as described in
the documentation of 'xdg_toplevel' request 'unset_maximized':
"If available and applicable, the compositor will include the window
geometry dimensions the window had prior to being maximized in the
configure event."
and 'unset_fullscreen':
"The compositor may include the previous window geometry dimensions in
the configure event, if applicable."

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/792.
2020-10-22 16:29:09 +00:00
Carlos Garnacho
f4a1dcfc93 wayland: Set IO error exit handler
If this call is available, we can turn libX11 IO errors (fatal by definition)
into something we can recover from. Try to dispose all X11 resources and close
the display instead, so the compositor can survive the event.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1447
2020-10-21 18:57:13 +02:00
Carlos Garnacho
1b39b92fa5 xwayland: Protect against MetaX11Display abruptly closing
If the MetaX11Display abruptly closed when X11 windows were present,
we would still try to deal with them while freezing/thawing for the
"fade out" animation.

At the bottom of that, the X server may be gone, just try to cope
with it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1447
2020-10-21 18:57:12 +02:00
Jonas Ådahl
cd52288ddc wayland: Allow specifying Wayland display name from command line
Useful to avoid warnings when starting when there is already an active
Wayland compositor in the session.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1515
2020-10-20 21:16:30 +00:00
Daniel van Vugt
345976192d wayland-buffer: Add debug logging of pixel format in use
Enable it with environment `MUTTER_DEBUG=wayland`.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1387
2020-10-20 09:53:53 +00:00
Daniel van Vugt
e480d0c71e wayland-dma-buf: Add debug logging of pixel format in use
Enable it with environment `MUTTER_DEBUG=wayland`.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1387
2020-10-20 09:53:52 +00:00
Robert Mader
554f7984e9 window/wayland: Offset position with size mismatch when finishing a resize
Analogous to commit 8bdd2aa7db, calculate the size missmatch offset
also when finishing a resize.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/396
2020-10-19 11:16:12 +02:00
Robert Mader
ae0d48b6fd wayland/subsurface: Only show subsurface if parent is mapped
The spec states:
```
A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
and the parent surface is mapped. The order of which one happens
first is irrelevant. A sub-surface is hidden if the parent becomes hidden,
or if a NULL wl_buffer is applied. These rules apply recursively
through the tree of surfaces.
```

In the past we relied on Clutter actor behaviour to realize the recursive
part - which then broke in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/664
when we changed the actor hierachy in regards to subsurfaces.

Explicitly encode the desired behaviour in `MetaWaylandSubsurface`, fixing
the issue and making it future proof.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1384
2020-10-14 18:55:21 +02:00
Julius Lehmann
433b59f74a wayland: Don't send proximity_in for new resources
Mutter sends a proximity-in event before the required tablet tool
resource is properly allocated on the client. This is violating the
Wayland protocol. Because libwayland ignores events for objects it
doesn't know yet, this is not noticeable in most applications. However,
if https://gitlab.freedesktop.org/wayland/wayland/-/issues/176 gets
fixed, these applications would likely crash immediately. Therefore this
PR removes the responsible code which, again, shouldn't have any effect
on client applications as they ignore this event anyway.

Relevant part of the spec:

    This event can be received when the tool has moved from one surface to
    another, or when the tool has come back into proximity above the
    surface.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1427
2020-10-12 09:37:19 +00:00
Jonas Ådahl
2c95e08998 Remove misplaced line break in g_* logging functions
They resulted in empty lines in the log.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Jonas Ådahl
7266e516a1 wayland: Don't include newline in client error events
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Jonas Ådahl
313e3e771c Make meta_* logging utilities not require line break
Unlike g_* logging utilities, the meta_* counterparts behave like odd
printf() functions. Lets change that so they fit better into how logging
is done everywhere else.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Jonas Ådahl
8bdd2aa7db window/wayland: Offset position with size mismatch when resizing
When we resize a window we send it configure requests with size
suggestion. Some clients, e.g. gnome-terminal will limit its size to a
discrete set given the font size resulting in the size often not being
respected completely, but used as a hint to find a size as large as
possible but not larger than the configured size.

When doing an interactive resize dragging the right or top side of a
window, this caused issues with the configured window size not matching
the one used by the client, as the configured position wouldn't be
correct for the actual size. Fix this by offsetting the position given
the size mismatch offset, making the position again in sync with the
size.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1477
2020-10-07 16:49:35 +02:00
Sergio Costas
5afdbc669d wayland/client: Free GSubprocessLauncher after spawning
A Meta.WaylandClient() object has a GSubprocessLauncher object
passed externally. Currently this object is kept while the
WaylandClient object exists, but is is only needed until the call
to spawn is made.

This patch frees that GSubprocessLauncher just after that call,
thus freeing those resources.

Fix https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1462
2020-10-02 15:37:52 +00:00
Robert Mader
71f03a718d wayland/actor-surface: Always set opaque region on alpha-less textures
Wayland clients using buffers without alpha channel are not expected to
set an opaque region. However, we rely on the opaque region for the fast
painting path in `MetaShapedTexture`.

Thus, make sure to always set an opaque region internally in those cases.
For X11 clients, wo do so already.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1463
2020-10-02 15:09:12 +00:00
Sergio Costas
533882ab77 wayland: Fix refcount error
The Meta.WaylandClient constructor receives a GSubprocessLauncher
as a parameter, and stores it internally. Unfortunately, its
refcount value isn't increased, which results in the object being
released twice.

This patch fixes this bug.

Fix https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1454
2020-09-29 20:44:25 +00:00
Karol Herbst
9b9b912765 backends: force enable modifiers on tagged devices
Some devices can't scanout to linear buffers directly as the hw is not
capable of eg rendering into a linear depth buffer.

Add code to force kms-modifiers on udev taged devices.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1443
2020-09-28 14:00:44 +02:00
Robert Mader
82fffacbae wayland: Add versions to primary selection protocols
Just so we follow convention - those versions are unlikely to ever change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1452
2020-09-27 17:20:23 +02:00
Jonas Ådahl
db7967327a wayland/window: Always flag acked move/resize as 'moved' if moved
We only did this if we weren't currently doing an interactive resize,
but since the finish_move_resize() is not the actual interactive resize
but the acknowledgment of the configure event that was emitted as a
result, we shouldn't limit ourself to the same flags used during resize.

This fixes temporarly "stuck" position of attached modal dialogs while
they are being resized.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1446
2020-09-18 11:37:23 +00:00
Carlos Garnacho
e2123768f6 wayland: Drop Xwayland abstract socket
This is unnecessary, and even counter productive with flatpak applications,
as there is a bind mount between the application and the socket.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1289

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1424
2020-08-31 19:46:27 +00:00
Florian Müllner
6b04b2ff60 clutter/backends: Rename master and slave devices
Just because X11/XI uses a particular terminology doesn't mean we
have to use the same terms in our own API. The replacement terms
are in line with gtk@1c856a208, which seems a better precedent
for consistency.

Follow-up to commit 17417a82a5.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1425
2020-08-31 21:07:03 +02:00
Carlos Garnacho
8cc95e44f4 wayland: Reword comment
This is no longer directly related to DBus messages, but our own event
queue. Change the wording and use CLUTTER_PRIORITY_EVENTS to make it
bolder, even though it's the same than G_PRIORITY_DEFAULT.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286
2020-08-31 08:40:12 +00:00
Carlos Garnacho
6f316345be wayland: Flush text_input.done event after IM key event
We set an idle to coalesce multiple IM events together, as the protocol
requires us to send them in one frame, and unfortunately there is no
idea about whether more IM events are upcoming.

One good hint though are key events generated from the IM, we want to
apply all IM changes before the key event is processed, so make it sure
that the .done event is flushed before the key event is handled.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286
2020-08-31 08:40:12 +00:00
Carlos Garnacho
fb6ff75a97 clutter: Prepare input focus for IM event delivery
The clutter_input_focus_filter_key_event() function has been made
a more generic filter_event(). Besides its old role about letting
key events go through the IM, it will also process the IM events
that are possibly injected as a result.

Users have been updated to these changes.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286
2020-08-31 08:40:12 +00:00
Jonas Dreßler
0b9a71ea3c wayland/surface: Don't update outputs recursively on mapped changes
There's no need to update the outputs recursively in case the actor gets
mapped or unmapped. That's because mapping happens recursively itself,
so if a window with multiple subsurfaces is shown, all subsurfaces will
receive a "notify::mapped" signal.

Since this was the only remaining user of
meta_wayland_surface_update_outputs_recursively(), we can now remove
that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358
2020-08-29 12:40:11 +00:00
Jonas Dreßler
35f847ac6d wayland/surface: Don't update outputs on all geometry changes
Since we now listen to the "stage-views-on-changed" signal (which
"catches" all the changes we want) on MetaWaylandActorSurfaces for
updating the wl_outputs the surface is on, we no longer need to call
meta_wayland_surface_update_outputs_recursively() on all geometry
changes, so remove that signal handler.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358
2020-08-29 12:40:11 +00:00
Jonas Dreßler
abdbc14ca8 wayland/actor-surface: Update outputs on stage-views changes
ClutterActors new "stage-views-changed" signal fits pretty well for the
updating of wl_outputs a MetaWaylandActorSurface is on: With that signal
we get notified if the surface moved to a different CRTC, of which every
output has at least one.

So start listening to that signal, which fixes a bug where the wl_output
of a surface changes, but its allocation remains the same (which means
no signals triggering an update of the outputs will be emitted) and no
enter/leave events for the new wl_outputs are sent to the client. This
can happen when a monitor is hotplugged but the new allocation is
exactly the same as the old one even though it's on a different monitor.

Since the "stage-views-on-changed" signal will also get emitted when a
parent actor of the surface is moved, this means we can now remove the
call to meta_wayland_surface_update_outputs_recursively() on window
position changes or the completion of window-effects.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358
2020-08-29 12:40:11 +00:00
Olivier Fourdan
5171e35a97 xwayland: Add a setting to disable selected X extensions
The X server, including Xwayland, can be compiled with different X11
extensions enabled at build time.

When an X11 extension is built in the X server, it's usually also
enabled at run time. Users can chose to disable those extensions at run
time using the X server command line option "-extension".

However, in the case of Xwayland, it is spawned automatically by the
Wayland compositor, and the command line options are not configurable
by users.

Add a new setting to disable a selected set of X extension in Xwayland
at startup, without needing to rebuild Xwayland.

Of course, if Xwayland is not built with a given extension support in
the first place (which is the default for the security extension for
example), that option has no effect.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1405
2020-08-29 12:20:26 +02:00
Björn Daase
5ec9bde64f *: Fix spelling mistakes found by codespell
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1410
2020-08-29 09:10:31 +00:00
Robert Mader
1c4a518cd3 wayland/xdg-shell: Move popup role assignment behind checks
If we returned early in one of the checks but already assigned the
surface role, we'd later run into a double-free and crash. Just do
the checks at the beginning.

Also add a missing return statement that was left out in commit
88ff196fe3 and tighten the parent surface check.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1415
2020-08-27 00:10:05 +02:00
Robert Mader
88ff196fe3 wayland/xdg-shell: Handle null-parent in get_popup()
The spec allows `parent_resource` to be `NULL`, requiring the parent
surface to get specified by some other protocol. Send a protocol error
with some meaningful explanation instead of crashing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1408
2020-08-26 21:22:00 +02:00
Robert Mader
034c6ab9db wayland/xdg-shell: Add parent window validation in get_popup()
Like in most similar places we can not assume to get a valid window
when calling `meta_wayland_surface_get_window` as it e.g. might be
unmapped already.

Calling `get_popup` on an unmapped window is a client bug, thus post
a protocol error when this happens.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1174
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1293
2020-08-26 18:34:03 +00:00
Robert Mader
59f0aef438 wayland/seat: Add seat_release interface
Without this calling wl_seat.release would crash Mutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1409
2020-08-26 19:55:09 +02:00
Robert Mader
8cbcd35fdf wayland/subsurface: Add check for parent surface
Just as we do in similar places. This avoids crashes under certain
circumstances.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1411
2020-08-23 22:32:53 +02:00
Christian Rauch
125f0b0351 wayland: prevent resizing of fixed-size window
Clients can set minimum and maximum to identical values to indicate a
fixed-size window. A compositor can ignore these requests and thus a client
has to ensure these limits.
To support clients that do not ensure these size limits by themselves and
to skip unnecessary function calls, we will prevent resizing requests by
the client if a fixed-size has been requested.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1331
2020-08-13 19:54:32 +01:00
Jonas Ådahl
a54a01d1e2 wayland/dma-buf: Advertise support for 64 half point RGBA formats
Just as wl_shm, hook up the Wayland DMA-BUF protocol to the 64 bit half
point pixel formats too. This makes it possible for Wayland EGL clients
to use 64 bit pixel EGL configurations.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Jonas Ådahl
d3f629bfa8 wayland/shm: Advertise support for 64 half point RGBA formats
Now that cogl understands them, hook wl_shm up so they can be used.

This also bumps the wayland-server version dependency to 1.17.90, which
corresponds to the master branch of wayland. The new formats will be
available in 1.18.0.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Jonas Ådahl
8e673d5798 wayland/dma-buf: Advertise support for XRGB2101010 too
https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00