Commit Graph

13502 Commits

Author SHA1 Message Date
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
ef21f2307e cursor-renderer/native: Invalidate state for output color state changes
When the output color state changes, we have to re-create the color
state transform. This is especially noticable when the luminance is
adjusted and the cursor is not affected.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3935
Fixes: a72ee3be0d ("cursor-renderer/native: Transform cursor sprite into output color state")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4315>
2025-03-06 11:42:49 +00:00
192f11646c cursor-renderer/native: Removed unused argument and update name
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4315>
2025-03-06 11:42:49 +00:00
3203fbafad wayland/drm-lease: Send drm_fd to pending clients
Listen to the signal that indicates that the current session is active
and send the drm_fd, connector(s) and done events to the clients that
were waiting for them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3921>
2025-03-04 16:34:44 +00:00
d49a5b37a9 wayland/drm-lease: Move on device bind events to a function
Now that sending a drm_fd can fail, wrap the on device bind events
(drm_fd, connector and done) in their own function.

Refactor, no function changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3921>
2025-03-04 16:34:44 +00:00
eb4b70baed wayland/drm-lease: Put clients in a queue on drm_fd error
When a client binds to the a device, if obtaining a non-privileged fd
fails, instead of returning an error, put the client in a pending
queue.

Delaying the drm_fd is allowed by the protocol definition:

    The compositor will send this event when the wp_drm_lease_device_v1
    global is bound, although there are no guarantees as to how long
    this takes [...]

A future commit will send the drm_fd events to the clients in the list
once Mutter can obtain a valid fd.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3921>
2025-03-04 16:34:44 +00:00
30315f3fca wayland/color-management: Ensure ref lum can't be bigger than max lum
This might be possible if extended target volume is supported but
currently it isn't.

This is a requirement from the wayland color management:

"'reference_lum' may be higher than 'max_lum'. In that case reaching
the reference white output level in image content requires the
'extended_target_volume' feature support."

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4304>
2025-03-04 14:05:41 +01:00
565cff5cb9 clutter/color-state-params: Ignore explicit max_lum on EOTF_PQ
This is a requirement from the wayland color management:

"With transfer_function.st2084_pq the given 'max_lum' value is
ignored, and 'max_lum' is taken as 'min_lum' + 10000 cd/m²."

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4304>
2025-03-04 14:05:41 +01:00
c87bf90471 tests: Vary the gdctl path used for installed tests
So they don't rely on the source tree.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4309>
2025-03-04 01:30:29 +00:00
6bd634e7ad tests: Mock logind’s Inhibit method
This is needed to allow gnome-shell to start up during its unit tests,
as it now calls `Inhibit` to make saving screen time information
race-free.

See
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3643#note_2367420.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4314>
2025-03-03 12:58:55 +00:00
5a7ec6791d wayland: Move window before tiling/maximizing when restoring from session
Ensure the window is placed in coordinates, before maximizing, tiling or
minimizing it. This should make the window maximized/tiled on the right
(or correctmost) monitor given the stored coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4311>
2025-03-01 15:02:21 +01:00
351f2fddff tests: Add more session management tests
Ensure that windows get restored either in maximized and unmaximized
state. And ensure that monitors being removed result in windows
snapping back to reachable positions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4311>
2025-03-01 15:02:21 +01:00
e82cc58614 wayland: Ensure to constrain windows restored through session management
Otherwise, these might end up outside the desktop extents.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4311>
2025-03-01 15:02:21 +01:00
9a1dc0216e core: Add MetaSessionManager::session-instantiated signal
Mostly useful for tests to catch a session being created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4311>
2025-03-01 15:02:21 +01:00
2682ab2863 stage-view: Plumb through target presentation time to ClutterFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
700510b7dc cogl/frame: Keep track of target presentation time for direct scanout
Same as for painting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
687f5552fb onscreen/native: Peek the correct frame for power save page flips
The superseded frame is always the oldest frame so it's the head of
the queue, not the tail. Aside from anything else, the call to
`meta_onscreen_native_notify_frame_complete` that follows *does* use
the head and not the tail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4310>
2025-03-01 04:23:09 +00:00
44e2543172 meta/window-wayland: Update monitor from id for unplaced windows
If a window isn't placed yet, then we can't use its position to determine
the window's main monitor.
To solve this we get the monitor from its id instead, which correctly
uses preferred_logical_monitor whenever possible, as well as still handling
the potential edge case of unplaced windows during monitor configuration
changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2116
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/525
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4297>
2025-02-28 19:19:15 +01:00
eed9858459 core/window: Reformat window.c
This commit uses uncrustify's output with some changes to reformat parts of
window.c.
No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4297>
2025-02-28 14:13:35 +01:00
de2d19e882 gdctl: Support showing and setting output luminance
`gdctl show` now prints "monitor preferences", which currently consists
of only the luminance setting.

`gdctl prefs` is introduced, where one can run e.g. `gdctl prefs
--monitor DP-1 --luminance 80.0` to set the output luminance of the
monitor connected to DP-1 to 80%.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:42 +01:00
be6af00d6b DisplayConfig: Add API to get and set output luminance
This will in turn change the GSetting, where the setting is actually
stored.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:42 +01:00
db2376cb84 settings: Add API to manipulate output luminance
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:42 +01:00
b7a6689941 monitor-manager: Use G_CONNECT_DEFAULT instead of 0
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:42 +01:00
8cae2e7b08 debug-control: Remove output luminance knob
It was replaced with an actual setting and is no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:42 +01:00
7ae038a62d color-device: Get output luminance from MetaSettings
This makes it per output, and not a debug utility.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 13:13:17 +01:00
bdf1ff0360 settings: Add output luminance settings to org.gnome.mutter
This aims to allow configuring the output luminance currently used via
the color state shaders. It will replace the output luminance property
of the debug control API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
5b6519b4d4 monitor: Allow passing const monitor specs to equals()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
7fa41a6f97 monitor: Make spec clone function take a const pointer
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
ad77344809 output: Declare color mode type in backend types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
463eb3993b settings: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
e0b44bdc03 settings: Fix include order
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4271>
2025-02-27 11:35:22 +00:00
df555f4828 tests: Fall back if there's no seat_id for the current session_id
Such as in an ssh login.

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

Fixes: 98b347b204 ("dbusmock/logind: Mock logind and remove KVM special handling")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4299>
2025-02-27 01:15:06 +00:00
a673adebab core/stack: Simplify compare_window_position
compare_window_position calls into meta_window_stack_position_compare
with inverted inputs instead of duplicating the logic.
This comes at the cost of an extra meta_stack_ensure_sorted which should
be culled out.
To ensure this, need_resort is reset before the sorting process starts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4183>
2025-02-26 10:03:18 +00:00
02e3eb8de8 core: Drop meta_stack_windows_cmp and derived functions
Since these will not be used from now on, we can finally clean up
meta_stack_windows_cmp, window_stack_cmp and meta_display_stack_cmp.
Now the only comparison function is meta_window_stack_position_compare.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4183>
2025-02-26 10:03:18 +00:00