1
0
Fork 0
Commit graph

1737 commits

Author SHA1 Message Date
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
Jonas Ådahl
115de303b0 wayland/shm: Add ARGB2101010 formats and friends
In order to get higher color pixel precision when the alpha channel is
less important. Only advertise these formats if it is supported by the
used cogl renderer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Jonas Ådahl
2d6040e2a3 wayland/shm: Advertise support for RGB565
Doesn't hurt to support it, could save memory bandwidth would any client
use it without degrading visual quality.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Jonas Ådahl
5a8e4da2a8 wayland/shm: Send error if client uses unsupported format
Instead of rendering incorrectly (we fell back on some arbitrary
format), just send an error.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Sergio Costas
f894f5cc13 wayland: Add API to launch trusted clients
Allowing code from inside mutter to create a child process and
delegate on it some of its tasks is something very useful. This can
be done easily with the g_subprocess and g_subprocess_launcher classes
already available in GLib and GObject.

Unfortunately, although the child process can be a graphical program,
currently it is not possible for the inner code to identify the
windows created by the child in a secure manner (this is: being able
to ensure that a malicious program won't be able to trick the inner
code into thinking it is a child process launched by it).

Under X11 this is not a problem because any program has full control
over their windows, but under Wayland it is a different story: a
program can't neither force their window to be kept at the top (like a
docker program does) or at the bottom (like a program for desktop icons
does), nor hide it from the list of windows. This means that it is not
possible for a "classic", non-priviledged program, to fulfill these
tasks, and it can be done only from code inside mutter (like a
gnome-shell extension).

This is a non desirable situation, because an extension runs in the
same main loop than the whole desktop itself, which means that a
complex extension can need to do too much work inside the main loop,
and freeze the whole desktop for too much time. Also, it is important
to note that javascript doesn't have access to fork(), or threads,
which means that, at most, all the parallel computing that can do is
those available in the _async calls in GLib/GObject.

Also, having to create an extension for any priviledged graphical
element is an stopper for a lot of programmers who already know
GTK+ but doesn't know Clutter.

This patch wants to offer a solution to this problem, by offering a
new class that allows to launch a trusted child process from inside
mutter, and make it to use an specific UNIX socket to communicate
with the compositor. It also allows to check whether an specific
MetaWindow was created by one of this trusted child processes or not.

This allows to create extensions that launch a child process, and
when that process creates a window, the extension can confirm in a
secure way that the window really belongs to that process
launched by it, so it can give to that window "superpowers" like
being kept at the bottom of the desktop, not being listed in the
list of windows or shown in the Activities panel... Also, in future
versions, it could easily implement protocol extensions that only
could be used by these trusted child processes.

Several examples of the usefulness of this are that, with it, it
is possible to write programs that implements:

- desktop icons
- a dock
- a top or bottom bar
...

all in a secure manner, avoiding insecure programs to do the same.
In fact, even if the same code is launched manually, it won't have
those privileges, only the specific process launched from inside
mutter.

Since this is only needed under Wayland, it won't work under X11.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/741
2020-08-04 08:42:29 +00:00
Olivier Fourdan
17417a82a5 cleanup: remove controversial naming
Replace "whitelist" and "blacklist" with "allow_list" and "deny_list"
which better represent the purpose of those variables.

There is no functional change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1396
2020-08-04 10:04:16 +02:00
Jonas Ådahl
1ecdaa646f wayland: Respond to frame callbacks also if a clone was painted
This will mean that a surface on one monitor, with e.g. a preview on
another, will still get frame callbacks if the preview is painted, but
itself being hidden.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:51 +02:00
Jonas Ådahl
a9a9a0d1c5 clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.

For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.

This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.

Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:51 +02:00
Jonas Ådahl
8cff3b84f7 wayland/compositor: Process frame callbacks on 'after-update'
Instead of going via MetaCompositor to know about when we updated
(confusingly named post-paint), use the new stage signal directly.

Note that this doesn't change the time frame callbacks are dispatched;
it's still not tied to actual painting even though it seemed so before
given the function names.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:51 +02:00
Jonas Ådahl
4c0aa2afca wayland/xdg-shell: Don't use xdg_surface private to get window geometry
We already used the actual API in the same function, move that call a
bit higher up to and use the variable in more places.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1295
2020-06-26 07:47:41 +00:00
Jonas Ådahl
d6af59612c wayland/shell: Apply geometry after subsurface state application
The subsurface state may affect the geometry end result, e.g. when
window decoration enlarging the toplevel window are applied. If we don't
wait with calculating the window geometry, intersecting the set region
with the subsurface tree extents will not include the subsurfaces.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1295
2020-06-26 07:47:40 +00:00
Jonas Ådahl
be59b514ca wayland: Remove a couple of stray newlines
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1295
2020-06-26 07:47:40 +00:00
Carlos Garnacho
79050004b0 wayland: Avoid popup grab focus changes if there's an implicit grab
Event delivery with grabbing popups stay essentially the same within
the grabbing client, we still must honor the implicit grab as long as
there is one.

This is however not the case, the popup_grab_focus() function ignores
the button state. The popup_grab_button() function will already indirectly
re-sync the focus surface after the last button is released, so checking
for button state in popup_grab_focus() is sufficient to make the implicit
grab honored with popup grabs involved.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1270
2020-06-17 13:47:38 +00:00
Jonas Dreßler
7539de2320 clutter/input-device: Make clutter_input_device_get_actor() public
Make the clutter_input_device_get_actor() API public and remove
clutter_input_device_get_pointer_actor() in favour of the new function.

This allows also getting the "pointer" actor for a given touch sequence,
not only for real pointer input devices like mice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Sebastian Keller
51a8193c16 wayland/keyboard: Fix anonymous file leak on repeated keymap changes
keymap_rofile was being overwritten without the old one being free'd on
repeated calls of meta_wayland_keyboard_take_keymap().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1304
2020-06-11 07:23:18 +00:00
Sebastian Keller
99c9f4c1fa wayland/data-device: Don't create and leak unused memory on dnd
"offer" is overwritten with the result of meta_wayland_data_offer_new a
few lines later.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
Sebastian Keller
dd32ff018a wayland: Free selection streams streams after transfer
They were only being closed but never freed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
Jonas Ådahl
55302dbb38 cursor-renderer: Pass backend to constructor
Then use the backend passed instead of the global singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Jonas Ådahl
066bc5986d wayland: Drive frame callbacks from stage updates
Don't tie frame callbacks to actor painting, as it may end up in
situations where we miss sending frame callbacks when we should have. An
example of this is when a surface is partially off screen, and then
reports damage that is fully off screen. When this happen, we are likely
not to repaint anything, thus we won't send any frame callbacks even
though it's "suitable" for rendering again, as the surface is not on a
separate workspace or fully obscured.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:46:57 +02:00
Jonas Ådahl
e8b09df8d2 wayland/compositor: Pass backend when constructing
This is so that it can be retrieved later without going via the global
singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:01 +02:00
Jonas Ådahl
1571f8078a Reshuffle Wayland initailization
Move Wayland support (i.e. the MetaWaylandCompositor object) made to be
part of the backend. This is due to the fact that it is needed by the
backend initialization, e.g. the Wayland EGLDisplay server support.

The backend is changed to be more involved in Wayland and clutter
initialization, so that the parts needed for clutter initialization
happens before clutter itself initialization happens, and the rest
happens after. This simplifies the setup a bit, as clutter and Wayland
init now happens as part of the backend initialization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Dreßler
c65f63b647 wayland/actor-surface: Don't notify geometry-changed on mapped changes
There's no reason to notify the surface that its geometry changed when
the visibility of the actor changes. This is only needed to update the
outputs of the surface, so do that directly instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
79d981aac9 wayland/actor-surface: Factor in mapped clones in mapped check
We started listening to notify::mapped with commit
5eb5f72434 in order to emit
wl_surface.leave events consistently when a surface gets hidden. This
caused a problem with the ClutterClones used in the overview, since
those temporarily map and unmap the windows for painting, spamming
wl_surface.leave and enter events to all surfaces.

We can easily fix that by also treating mapped clones as mapped, which
means the surface should also be on a wl_output when the overview is
shown.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
e68bb27df2 wayland/actor-surface: Don't listen to notify::position signal
We started listening to "notify::position" on surface actors with commit
08e4cb54. This commit was done to fix a regression from commit cf1edff9,
which forgot to handle some cases like the actual WindowActor and not
the SurfaceActor (which is a child of the WindowActor) moving (that was
fixed by listening to MetaWindows "position-changed" signal). Also that
commit introduced meta_wayland_surface_update_outputs_recursively(),
which updates the outputs of all (sub-)surfaces in case any position
changed and made sure subsurfaces also get their outputs updated in case
the parent actor moved.

Connecting to the "notify::position" signal, which the above commit also
did is now superflous though because position changes will queue a
relayout and the actors allocation will change during the next
allocation cycle, notifying the "allocation" property which we also
listen to.

So save some resources and stop listening to that signal.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:52:15 +02:00
Jonas Ådahl
7343b8d817 wayland/dma-buf: Make gbm_bo import function better named
It imports a DMA buffer as a gbm_bo, but only if it can be used to scan
it out, so name it import_scanout_gbm_bo().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
Jonas Ådahl
dbf47b652e wayland/dma-buf: Handle failing to import scanout DMA buffer
A DMA buffer might not be able to scanout, and in that case the import
with GBM_BO_USE_SCANOUT will fail. Handle that by failing to scanout,
effectively falling back to compositing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
Jonas Dreßler
bc0b9f7628 window: Use pid_t for get_client_pid() vfunc
It makes sense to use pid_t when getting the PID since that will work on
all platforms and architectures.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00