Commit Graph

13485 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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 f77d8e2a12
  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
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
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
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
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
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
6ee87401d4 Revert "onscreen/native: Account for all posted frames"
This reverts commit 9fc5fdc953.

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
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
557ed0bbba Revert GNOME change to force X authentication
See: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2633

It's a headache for us and it doesn't seem to be necessary because we
don't share network namespace between citadel and (nspawn) realms.
2025-04-07 13:30:15 +00:00
99ce63a396 Notify n-workspaces on context switch 2025-04-07 13:30:15 +00:00
7e77910cab Remove mapping of workspace contexts to pid namespaces.
This is handled in gnome shell now.
2025-04-07 13:30:09 +00:00
b7d6d4dfad Citadel changes to Mutter 2025-04-07 13:26:46 +00:00
80e66878e8 kms/impl-device: Don't disable deadline timer due to invalid mode
If crtc->current_state.is_drm_mode_valid happens to be FALSE,
meta_kms_crtc_determine_deadline returns G_IO_ERROR_NOT_FOUND. This
previously resulted in silently and permanently disabling the deadline
timer, which is surprising and undesirable.

Bail early from ensure_deadline_timer_armed in this case instead. In
turn, G_IO_ERROR_NOT_FOUND from meta_kms_crtc_determine_deadline no
longer needs to be treated specially.

Fixes: 7493ed39ce ("kms/impl-device: Avoid retrying a failing deadline timer")

v2:
* Stop treating G_IO_ERROR_NOT_FOUND specially. (Sebastian Wick)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4321>
2025-03-16 13:27:01 +00:00
d5bcce3859 kms/impl-device: Process pending update from _schedule_process
If ensure_deadline_timer_armed fails and crtc_frame->pending_update is
non-NULL, we need to process the pending update, or it may fall through
the cracks, and this stage view may freeze.

v2:
* Don't return immediately after calling
  meta_kms_impl_device_do_process_update. (Sebastian Wick)
v3:
* Call meta_kms_impl_device_do_process_update only if
  is_using_deadline_timer returned true, and log a warning if
  crtc_frame->pending_update is non-NULL otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4321>
2025-03-16 13:27:01 +00:00
46dfb4c4d0 kms/impl-device: Refactor meta_kms_impl_device_do_process_update helper
Preparation for next commit, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4321>
2025-03-16 13:27:01 +00:00
9fc5fdc953 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: [Michel Dänzer]
* Drop Closes due to
  https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4334#note_2378962.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4321>
2025-03-16 13:27:01 +00:00
efbd61ae89 wayland: Bump gtk-shell version to 6
No actual changes. We will use this version to hint GTK about
the availability of non broken wl_surface.offset support for
pointer cursors.

GTK can use this version to avoid cursor breakage when running
on older Mutter versions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4327>
2025-03-13 19:47:29 +00:00
1837c1b299 wayland: Discard stale presentation feedbacks in _present_feedbacks
Any feedbacks for the same stage view but older frames than the one
being presented are discarded.

Since we now use per-frame lists of feedbacks, there can no longer be
any stale feedbacks where we previously discarded them, so remove that
dead code.

v2:
* Use ClutterFrameInfo::frame_count.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 16:27:52 +01:00
903f6281f9 wayland: Use per-view & per-frame list of pending presentation feedbacks
Instead of a single hash table with a list of feedbacks per stage view,
there's a nested hash table per stage view with a list of feedbacks per
view frame counter.

This ensures that presentation feedbacks don't get mixed up between
different frames.

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

v2:
* Use ClutterFrame(Info)::frame_count. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 16:18:33 +01:00
34b203ed99 wayland: Use output & frame counter instead of needs_sequence_update
More robust vs multiple frames in flight.

v2:
* Use ClutterFrameInfo::frame_count.
v3:
* Rename to last_view_frame_counter. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 16:15:23 +01:00
84135e51b0 clutter: Add ClutterFrameInfo::view_frame_counter
And plumb it through from ClutterFrame::frame_count.

Preparation for later changes, no functional change intended.

v2:
* Rename to view_frame_counter. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 15:43:29 +01:00
7bcbd253c2 clutter: Rename ClutterFrameInfo::frame_counter to global_frame_counter
To stress that it's the global frame counter.

Preparation for later changes, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 15:43:28 +01:00
1d2d62662e Add support for Kana and Compose USB HID LEDs
These were added in libinput 1.26 and xkbcommon 1.8.0

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4002>
2025-03-13 11:56:36 +01:00
0f0659e0e8 tests: Add overlay cursor test
This test checks a particular issue, where a pointer moved in a way
resulting in the cursor position not changing, then moving again,
changing the cursor position, not damaging the area of the original
position, causing the cursor to get "stuck" until damaged due to some
other reason.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4331>
2025-03-13 07:24:45 +00:00
22033acd68 tests/ref-test: Add API to capture without full damage
This can be useful to capture the screen content with broken damage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4331>
2025-03-13 07:24:45 +00:00
1dcece298e stage: Track overlay damage per view
The previously painted rectangle of an overlay is not a global state,
but depends on what view it was painted on. There was also an issue
where an overlay being updated but not changing position, e.g. due to a
0,0 pointer movement or an absolute pointer movement with the position
not changing, not properly triggering damage of the old position when it
eventually actually moved.

Fix this by tracking damage per view, while also fixing the state
tracking to handle unchanged positions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4331>
2025-03-13 07:24:45 +00:00
dcd89a62e1 backends: Update stage views and stage dimension from MetaStage
This reduces the amount of code duplication between the native and
nested backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4331>
2025-03-13 07:24:45 +00:00
cbdc3ae9f5 wayland/cursor-shape: Enable the protocol by default
We now have tests, a GTK implementation that was tested on it and the
protocol version 2 changes are upstream. Time to enable it by default.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:02 +00:00
0c9a31459a tests/wayland-unit-tests: Add cursor shape tests
Tests error conditions, selecting a cursor shape, switching back to a
surface based cursor, and that the shape persists when the cursor shape
device is destoryed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:02 +00:00
b18565cee6 tests/wayland-test-client-utils: Allow to bind to cursor shape
Also allow specifying to version so we can test version specific things.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
0e4f4147a2 wayland/cursor-shape: Use an actual map for looking up MetaCursor shapes
The thing before pretended to be a map but wasn't, so it required
iterating over it and checking the fields to find the requested one. The
code didn't do that and index into it anyway and because the shapes
start at a value of 1, everything was off.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
8074cc5fbd wayland: Update cursor-shape protocol to upsteam version 2
The protocol changes for version 2 made it upstream but are not in a
release, yet. As soon as we have a release, we should replace this copy
with the wayland-protocols variant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
b126b01490 tests/ref-test: Inhibit hardware cursors for ref tests
We run some ref-tests in the tty and kms test harnesses which does
support cursor planes. If we get "unlucky", the cursor could end up on
one of them and won't show up in the captured output.

Inhibit the hardware cursor when capturing the output for a ref-test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
4a0b672146 tests: Always use the bundled cursor theme
To not depend on the system cursor theme for tests, always use
our own, even if the cursor theme appearance makes no difference.
We also need to add all of Adwaita's cursors in tree, to avoid any test
arbitrarily triggering missing cursor warnings or errors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
20d5311697 tests/surface-scale: Use the default cursor instead of legacy left_ptr
We will start using only the cursors we ship with the tests, which is a
snapshot of Adwaita cursors. left_ptr is not one of the supported ones,
so we use default instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
2770eef638 tests: Unify G_TEST_SRCDIR/G_TEST_BUILDDIR locations
Cogl and Clutter use the "current source dir" whereas the tests in
src/tests use the non-test source directory. The installed tests already
only use a single directory.

This commit changes everything to be src/test in the source and build
directory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
5c9444d03b cursor-renderer/native: Log instead of warn when cursor size mismatch
KMS can support only very specific cursor sizes and having a cursor that
doesn't match that size isn't something going wrong. Instead of
generating a warning, just log it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
db488ccab0 stage: Maybe schedule updates for the remaining stage views
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
1e28542270 cursor-renderer/native: Use the existing inhibit logic without hw cursor
By setting cursor_stage_view->is_hw_cursor_valid and has_hw_cursor and
then skipping to the code below, we can reuse all the logic for when we
need to inhibit/uninhibit and update the sprite.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4307>
2025-03-11 09:55:01 +00:00
d32f63acc5 drm-timeline: Always call g_set_error when failing _get_eventfd
Fixes crashing in the caller due to dereferencing a NULL GError pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3961
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4326>
2025-03-11 09:26:31 +00:00
d9efa3f52e kms/crtc: Revert DEADLINE_EVASION_CONSTANT_US to 800
This was the value before
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3934.

Now that the deadline timer is used for all KMS updates (since
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3964), the lower
value turned out too aggressive under some circumstances, resulting in
frequent frame skips.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3867
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4325>
2025-03-11 07:37:45 +00:00
892fd772fa renderer/native: Set needs_config for EGLDevice
Just like we do for EGL on X11.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3958
Fixes: 18085b0e40 ("cogl/egl: Choose config only if needed")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4324>
2025-03-11 01:48:18 +00:00
141c6c29ca backends/native: Generalize keyboard LED management
Use an enum and an array to enumerate the keyboard LEDs and
map xkb_led_index_t to libinput_led. There are future additions
coming and this will be extensible without becoming too spaghetti.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4301>
2025-03-07 13:26:27 +00:00