33610 Commits

Author SHA1 Message Date
Jonas Ådahl
29e1e91dc3 tests: Add drm lease test for non non-desktop hotplugs
This tests that https://gitlab.gnome.org/GNOME/mutter/-/issues/3943
doesn't reproduce by triggering hotplugs in a certain way.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4378>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
70aed7ca75 drm-lease: Connect MetaUdev::hotplug handler after other handles
When we receive a hotplug signal emission, we update the state of leased
and leasable resources. Some of this state depends on the current state
of any potential associated monitor (MetaOutput & MetaMonitor). In order
to have an up to date association of MetaOutput's and MetaMonitor's, we
must only update our own state after MetaMonitorManager has had a chance
to. To achieve this, make sure the MetaUdev::hotplug signal handler is
dispatched after MetaMonitorManager's handler by using
g_signal_connect_after().

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3943
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4378>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
f1e3f76d13 drm-lease: Avoid copying list of connectors
The copied list will be freed, and the copy will be returned, meaning we
can just return the original list directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4378>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
ce698b9a87 wayland: Take over cursor feedback during DnD
The original strategy to let the drag source client be in
charge of pointer cursor feedback during DnD has gotten
way too complex, with tablets and tools, toplevel drags,
and now the cursor shape protocol.

Instead, let the compositor be in charge of pointer cursor
feedback during DnD operation, it will know right away the
cursor renderer to update, and the appropriate feedback
through the current DnD action.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4368>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
73cab206d7 wayland: Add MetaWaylandDataSource::action-changed signal
So code can hook into action changes, either through client negotiation
or induced by the user through keyboard modifiers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4368>
2025-04-28 15:44:02 +00:00
Michel Dänzer
c77d89a9f1 kms/cursor-manager: Get current cursor position later
Specifically, only after checking crtc_state_impl->cursor_invalidated.
If that's false, we bail anyway, so no point getting the current cursor
position, which can get blocked by another thread holding the
seat_impl->state_lock in writer mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4377>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
d7c164e1d7 onscreen/native: Also promote posted frame in ready callback
When the legacy KMS implementation running without a KMS thread receives
a cursor only frame, it doesn't do an actual page flip, but just posts a
"ready" callback without any timing information. In this case we failed
to discard the posted frame, meaning theh onscreen KMS throttling was
still thinking it was supposed to wait for the posted frame to be
presented.

Fixes: df7ac5b0a3 ("onscreen/native: Account for all posted frames")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/4021
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4375>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
99330c53eb onscreen/native: Rename "swap_drm_fb()" function
What it does now is handling the promotion of a "posted" frame to
"presented", or promoting it to the trash bin, if it was not carrying an
actual primary plane buffer. Promoting to presented effectively still
means "swapping the frm fb" though. Make the name reflect this.

Fixes: df7ac5b0a3 ("onscreen/native: Account for all posted frames")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4375>
2025-04-28 15:44:02 +00:00
Michel Dänzer
ca7d7fc53f wayland: Don't take & drop sprite reference in _update_cursor_surface
It's now pointless busy-work, since these functions never own the sprite
object anymore.

Suggested by Sebastian Wick.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4371>
2025-04-28 15:44:02 +00:00
Michel Dänzer
d6f3f4f089 wayland: Cache sprite for current tablet tool cursor shape
meta_wayland_tablet_tool_update_cursor_surface was always creating a new
sprite for the cursor shape, which may result in allocating HW buffers
and uploading the shape to them.

Since meta_wayland_tablet_tool_update_cursor_surface gets called every
time the tablet tool moves, we don't want to repeat that work if the
cursor shape hasn't changed. We cache the sprite in the
MetaWaylandTabletTool struct for reuse next time, and clear the cached
sprite when the cursor shape changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4371>
2025-04-28 15:44:02 +00:00
Michel Dänzer
9f594f63aa wayland: Bail early if tablet tool cursor shape doesn't change
No need to call meta_wayland_tablet_tool_update_cursor_surface in that
case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4371>
2025-04-28 15:44:02 +00:00
Michel Dänzer
830836f72c wayland: Cache sprite for current cursor shape
meta_wayland_pointer_update_cursor_surface was always creating a new
sprite for the cursor shape, which eventually results in allocating HW
buffers and uploading the shape to them.

Since meta_wayland_pointer_update_cursor_surface gets called every time
the pointer moves, we don't want to repeat that work if the cursor shape
hasn't changed. We cache the sprite in the MetaWaylandPointer struct for
reuse next time, and clear the cached sprite when the cursor shape
changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3993
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3996
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4371>
2025-04-28 15:44:02 +00:00
Sebastian Wick
671fa0dffe cursor-sprite/xcursor: Add a cache for the XCursor images
The cache lives on the MetaCursorTracker and thus is shared between all
CursorSpriteXcursors and avoids constantly having to hit the disk when
the cursor shape changes.

We still do a lot of work to get the sprite from the theme into a KMS
plane or drawn into the onscreen, but avoiding disk IO is a first, good
step.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4359>
2025-04-28 15:44:02 +00:00
Sebastian Wick
f787480fda backends/cursor: Propagate cursor theme and size pref changes
This means the cursor will immediately respond to preference changes and
make the right cursor visible.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4359>
2025-04-28 15:44:02 +00:00
Daniel van Vugt
facc5e9563 cursor-renderer/native: Handle when kms_cursor_manager is NULL
This happens during shutdown if the cursor is over some clients.
It seems `kms` has lost its cursor manager because the
`prepare-shutdown` signal is emitted to the backend before clients
are closed. While we could just reverse that and close the clients
first, it's not strictly just a "clients" problem. So keeping
the existing shutdown order and just handling when it is NULL seems
like a more universal solution.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2993
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4370>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
9ce93bbdc4 tests: Add a11y mouse keys test
This test tests two things:

 1. That launching mutter with a connected keyboard (created via uinput
    before initializing mutter) works properly[1]
 2. That pressing the keypad actually moves the mouse

[1] https://gitlab.gnome.org/GNOME/mutter/-/issues/3708

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4374>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
c3076b8dd4 tests/utils: Add helper to wait for stage update
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4374>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
e3660af967 tests: Add uinput based virtual input device factory method
It's included dynamically, to not introduce a new hard dependency
(libevdev).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4374>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
57ec7e403c dbus-templates/logind: Open fds as nonblocking
This is what logind does, and what libinput relies on to function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4374>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
136c0037cc seat-impl: Split initialization in two steps
First instantiate the object, and set the instance pointer in
MetaSeatNative, then initialize it. This is needed due to initializing
libinput may create virtual input devices used for accessibility
features, such as mouse keys, and for this it needs to fetch the
MetaSeatImpl from MetaSeatNative.

Fixes: 5fc60eac ("seat-impl: Keep track of virtual input devices too")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3708
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4374>
2025-04-28 15:44:02 +00:00
Michel Dänzer
d8a12d1667 wayland: Handle NULL backend in handle_release_points
This can happen during shutdown.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3862
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4372>
2025-04-28 15:44:02 +00:00
Michel Dänzer
6f9862ec65 wayland: Refactor handle_release_points helper out of _dec_use_count
Preparation for next commit, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4372>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
255e7e7fad compositor: Ensure to freeze DnD surface actor during failed animation
Otherwise, the client may push a NULL buffer early on, and make the feedback
animation ineffective.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4369>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
37594cf964 clutter/frame-clock: Don't accidentally reschedule-now
The state should go from 'dispatched-one-and-scheduled-later' to
'scheduled-later', not 'scheduled-now' when being notified about a frame
being ready - otherwise we'll dispatch without proper pacing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
51bc12f7ec Revert "kms/impl-device: Always catch pending KMS update in _schedule_process"
Revert this due to the KMS thread not being supposed to handle
multiple updates per cycle.

This reverts commit d6005b539ca42905dfaf1c3854540a559332b78e.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3977
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
a68a06cfc3 onscreen/native: Account for all posted frames
The KMS thread handles updates posted asynchronously, but it expects to
only handle one such frame in flight from the compositor at a time. That
means that the triple buffering state tracking in MetaOncreen, that
keeps track of posted frames and when they become presented, must also
account for posted frames that doesn't contain an actual primary plane
pixel buffer.

This was not the case, causing MetaOnscreenNative to post multiple
frames to the KMS thread, which wasn't handled gracefully in certain
situations.

Before the KMS thread grows real support for it's own queue of separate
updates, make sure we keep the contract to the KMS thread in
MetaOnscreenNative, and only submit at most one KMS update for each CRTC
each cycle, even when there are no actual primary plane changes.

v2: Properly handle frame tracking when when KMS update empty

v3: In the page flip callback, only set the presented frame to frames
that has buffers. This is needed on older kernels which doesn't have
drmModeCloseFB() which would otherwise disable the CRTC when presented
frame with an actual buffer would be replaced with an "empty" frame,
causing the frame with the buffer to be released, with the buffer along
with it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
48cb47425b onscreen/native: Include connector in some debug logs
This makes it easier to reason about what monitor is handled when
debugging multi monitor issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
0e7ef4f6f8 clutter/frame-clock: Add more debug logging
Log when dispatching, dispatch callbacks (ready / presented), and all
state changes. This greatly improves debugability of the frame clock
state machine.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
3b732a14c8 clutter/frame-clock: Set frame clock state via helper
This will allow us to log frame clock state changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
e5ff0dbc81 monitor-manager: Don't apply configurations with unsupported color modes
The set of supported color modes of a monitor might change for the same
monitor, for example by the monitor providing different EDID blobs
depending on configuration done on the monitor itself.

When we have a color mode configured that is not actually supported by
the monitor at the moment, amend the configuration and fall back on the
default color mode.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3911
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4364>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
cb5d43b39a monitor-manager: Split out helper to check monitor availability
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4364>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
ab8272c583 monitor: Add helper to check whether a color mode is supported
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4364>
2025-04-28 15:44:02 +00:00
Jonas Ådahl
6113b2824f monitor-config-utils: Add monitors config copy function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4364>
2025-04-28 15:44:02 +00:00
Michel Dänzer
62d10da4cb wayland: Bail early if cursor shape doesn't change
No need to call meta_wayland_pointer_update_cursor_surface in that case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4361>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
5141ad2acb wayland: Fix thinko in cursor_shape_manager.get_tablet_tool_v2
Look up the MetaWaylandTabletTool from the correct wl_resource.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/4004
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4367>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
d2fdb99838 wayland: Fix thinko in shape protocol implementation with tablet tools
MetaWaylandTabletTool is not a GObject thus we cannot use weak pointers
on them. The good news is that MetaWaylandTabletTool structs are perennial
and we do not need to do that.

Remove this unnecessary weak pointer handling, which can only cause
runtime warnings or crashes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4367>
2025-04-28 15:44:02 +00:00
Sebastian Wick
8b20a75df9 kms/device: Add SUPPORTS_COLOR_MODES flag and use it to guard HDR/color
Technically the impl device simple now also supports HDR, but there are
too many things that can go wrong, such as the colorspace prop getting
set, but not the HDR transfer function. For now, we will say that the
simple device impl does not have usable HDR support.

This gets picked up by the MetaOutputKms and propagtes the state to
everywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4357>
2025-04-28 15:44:02 +00:00
Sebastian Wick
9288845959 kms/impl-device/simple: Add support for missing KMS properties
While we do not intend to support HDR on the simple device impl, being
able to get to the default color mode requires support for those
properties. Otherwise, if the monitor is already in HDR mode when mutter
starts, we would be stuck there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4357>
2025-04-28 15:44:02 +00:00
Sebastian Wick
39e022984e kms/impl-device/simple: Add support for KMS blobs
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4357>
2025-04-28 15:44:02 +00:00
Sebastian Wick
c6f167b1a1 wayland: Allow changing from a cursor shape to a NULL surface
Changing to a cursor shape would set the cursor surface to NULL, so
trying to disable the cursor by setting the cursor surface to NULL was
detected as no-change. This commit fixes the check by taking into
account if the cursor shape is currently set.

Also adds a ref-test for it.

Fixes: 005b969227 ("wayland: Implement the cursor_shape_v1 protocol")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3997
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4358>
2025-04-28 15:44:02 +00:00
Jan Alexander Steffens (heftig)
b08cf5c135 cursor: Move sprite preparation into sprite classes
Make the prepare function a vfunc of MetaCursorSprite, moving the root
cursor prepare function into MetaCursorSpriteXcursor. This should solve
two issues:

- The root cursor prepare function was changed in f77d8e2a12a07ef6abe9
  to solve an issue with fractional scales. The tool cursor prepare
  function was missing this fix.
- The cursors created via the shape protocol had no prepare function at
  all, so were not getting scaled.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3975
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4345>
2025-04-28 15:44:02 +00:00
Carlos Garnacho
bac6e440ae tests: Disconnect dangling signal handlers
These shouldn't survive across tests, but do.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3972
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4353>
2025-04-28 15:44:02 +00:00
Orko Garai
578d3a62ca Fix mutter crash from should_constraint_be_enabled()
In `should_constraint_be_enabled()` calling
`meta_wayland_surface_get_window()` could return a null window when the
toplevel is reset after locking pointer.

The null check was only done inside `HAVE_XWAYLAND` ifdef, and so if
mutter is built without xwayland it could lead to a crash.

Fixes: 6e818c8c38 ("build: Allow disabling xwayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4351>
2025-04-28 15:44:02 +00:00
Florian Müllner
095e1e50da test-client: Ignore GdkX11 deprecations
The entire X11 backend was deprecated, to indicate its planned
removal in GTK5.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4352>
2025-04-28 15:44:02 +00:00
Florian Müllner
48e35f5500 frames: Ignore GdkX11 deprecations
The entire X11 backend was deprecated, to indicate its planned
removal in GTK5.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4352>
2025-04-28 15:44:02 +00:00
Florian Müllner
cb4d8e9aa7 Revert "ci: Disable container building temporarily"
gitlab.freedesktop.org is back, so we can re-enable the
jobs that depend on it.

This reverts commit ad88a6e715bf751488d796d717aa83cafff01d65.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4343>
2025-04-28 15:44:02 +00:00
Florian Müllner
46669d64cb Revert "ci: Disable sysext temporarily"
gitlab.freedesktop.org is back, so we can re-enable the
jobs that depend on it.

This reverts commit 46b4519361f02ac86e50647e2cc1a7d13f99e8d9.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4343>
2025-04-28 15:44:02 +00:00
Daniel van Vugt
aa1f2aac98 tests: Raise the timeout on monitor-unit from 1 minute to 5 minutes
The test is huge and on a very fast machine it takes 10 seconds. So in
Debian and Ubuntu builds we're finding a lot of machines/architectures
where it regularly requires more than a minute to complete.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4340>
2025-04-28 15:44:02 +00:00
Michel Dänzer
6ee87401d4 Revert "onscreen/native: Account for all posted frames"
This reverts commit 9fc5fdc953f96cd91ad54fce6c50964e7ce57815.

It caused freezes for some users.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3974
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4338>
2025-04-28 15:44:02 +00:00
Michel Dänzer
6297a19fa4 kms/impl-device: Always catch pending KMS update in _schedule_process
Not only if the deadline timer is enabled. With the next commit, it'll
be semi-expected to happen even if the deadline timer is disabled.

Still leave the warning though, as a reminder that we'd rather prevent
this outside of the KMS thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4338>
2025-04-28 15:44:02 +00:00