13394 Commits

Author SHA1 Message Date
Jonas Ådahl
edb91a3cc6 udev: Don't ignore drm devices with mismatching seat when headless
The seat we'll have is not a real seat, so lets not filter out drm
devices when running headlessly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3912
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4281>
2025-02-25 08:21:17 +00:00
Sebastian Wick
d8512767ea color-device: Update the color device on force-hdr debug-control changes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4298>
2025-02-25 03:27:27 +00:00
Sebastian Wick
74f8e83154 wayland/color-management: Enable support for EXT_LINEAR tf
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4291>
2025-02-25 02:40:17 +00:00
Sebastian Wick
8fb2a8a4b8 wayland/color-management: Expose the protocol by default
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4291>
2025-02-25 02:40:17 +00:00
Sebastian Wick
4fe1e41ab3 wayland/color-management: Update to upstream wp_color_management_v1
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4291>
2025-02-25 02:40:17 +00:00
Sebastian Wick
b1ef99bf23 build: Reorder wayland protocol alphabetically
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4291>
2025-02-25 02:40:17 +00:00
Lukáš Tyrychtr
5eaed6e3f3 core: Let the MetaA11yManager handle keyboard events
Plumb the MetaA11yManager into key event handling. This manager
is partly in control of keyboard event propagation, depending on
the screen readers connected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
a817d7c137 core: Add a debug control override to disable the a11y manager ACL
This commit adds another way how to disable the a11y manager ACL in development.
Setting the unsafe mode might not be as straightforward as setting an
environment variable for the session, and you can control it invidually too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
1c34794b13 backends: Add D-Bus access control helper
Track unique DBus senders and allow only thse which own a (at least so far)
pre-defined set of well known DBus names.

Carlos Garnacho: Renamed to a more generic helper, use g_bus_watch_name().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
20c9b8cf0c backends: Add a11y interface methods to subscribe to key event input
This adds a pair of methods to signal an interest in receiving
all key events without grabbing them, e. g. the previously expected behavior
by screen readers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
800981c40c backends: Add method to pass key events to screen readers
Accessibility shortcuts and keyboard grabs need to be consumed,
and key events propagated to screen readers. Add a function that
does it all at once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
45f6bed780 backends/native: Propagate a11y modifiers from MetaA11yManager
Listen to changes in MetaA11yManager configured modifiers, and propagate
these along to the MetaSeatNative. This lets the backend keep track of
configuration changes in a11y modifiers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
1498724774 backends: Add MetaA11yManager method to get configured a11y modifiers
The ::a11y-modifiers-change method allows tracking for changes in the
configured modifiers, add this method to allow backends to get the
modifiers so that they can be passed along the lower layers.

Carlos Garnacho: Turn into a method instead of a signal argument, turn
into an array+length instead of a hashtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
0bcda4ecf4 backends: Implement A11y monitor interface
Implement the org.freedesktop.a11y.KeyboardMonitor interface,
allowing screen readers to interact with Mutter and grab
shortcuts or full keyboard interaction.

Carlos Garnacho: Move setup to ::constructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
f4ce1e8a46 backends: Manage MetaA11yManager in MetaBackend
The MetaBackend will own the MetaA11yManager, being actually
put to use in backend implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
c0c4524452 backends: Add MetaA11yManager
This a11y manager will handle key event emission to screen
readers and other ATs. This initial commit only introduces
the object.

Carlos Garnacho: Make the object take a ::backend property

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
8c52e243c0 backends/native: Plumb a11y modifiers through MetaSeatNative
These modifiers will be set by the backend from the main thread, and
need to be handled specially for them to be usable as both modifier
buttons, and their own regular action.

Carlos Garnacho: pass modifiers as array+lenght instead of hashtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
d867964139 backends/native: Handle a11y modifier presses in MetaSeatImpl
The state handling about whether the a11y modifier is a first press (so
could be consumed for other actions), or results in the modifier action
(e.g. caps lock) is performed in the input thread. This information will
be propagated through the CLUTTER_EVENT_FLAG_A11Y_MODIFIER_FIRST_CLICK
flag in the related key events.

Carlos Garnacho: Drop synchronous wait for configuration changes

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Lukáš Tyrychtr
84fc62a280 data: Introduce the DBus interface description for the a11y manager
This object will for now only provide a way for assistive technologies
to receive keyboard events, however it is expected that it will be used for
the new a11y communication protocol in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Daniel van Vugt
ef43bec374 tests/kms: Ignore real GPUs when only VKMS is wanted
This prevents spurious test failures on machines with a real GPU as
well as VKMS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4274>
2025-02-24 07:47:48 +00:00
Peter Hutterer
aaf6c88226 input-settings/native: Default to sticky drag lock
libinput 1.27 added a new "sticky" mode to the tap-and-drag drag lock -
the previous mode is now called the "timeout" mode.

In sticky mode the drag lock is explicitly terminated with an extra tap,
i.e. a full sequence is:
        tap, down, [:move, up, wait, down:], up, tap
where the middle part can repeat and/or wait as long as required.

In the previous "timeout" mode the drag lock would automatically release
after a timeout - for users with low dexterity this timeout may be too
short.

The sticky mode is also how macos does drag lock.

Related: https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2798
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4292>
2025-02-20 10:48:19 +00:00
Daniel van Vugt
045342eb5a onscreen/native: Prefer gbm_surface_create_with_modifiers even for linear
The Nvidia driver doesn't implement `gbm_surface_create` properly,
which was first mentioned in 9fee3a9ec1. So using `gbm_surface_create`
as a fallback for the linear case was failing with ENOSYS (Function not
implemented).

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

Fixes: 163520c177 ("onscreen/native: Do not use modifiers if surface should be sharable")

See also: https://forums.developer.nvidia.com/t/gbm-surface-create-fails-if-flags-0/279951

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4284>
2025-02-19 19:33:01 +00:00
Mattia Formichetti
db955eccc7 tests/stacking: Account for cascading in always-on-top-map-new-partial
Since we now cascade when center-new-windows is true, we need to update the
always-above window positions to account for where the new windows will end
up being placed.
Assertions are also added for the two test windows' positions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
4d280086fe core/place: Fix and enable centered find_next_cascade
We use place_centered to start the cascade from the center of the
usable work_area; sorting now takes either the top left or top right window
corner as a reference using window_distance_cmp.

Helps: https://gitlab.gnome.org/GNOME/mutter/-/issues/2123
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
c606d1e670 core/place: Introduce window_distance_cmp
This commit introduces a new comparator, window_distance_cmp,
which uses either the top left or top right corner of a given window, based
on LTR, as reference for the squared distance.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
45052aeafd core/place: Normalize comparator functions to work_area coordinates
Both northwest_cmp and northeast_cmp didn't account for the work_area's
relative x and y coordinates which would lead to improper sorting on
multi-monitor setups.
To fix this, we pass the work_area when necessary and use it to offset the
absolute coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
14b90daa5a core/place: Remove unnecessary sqrt in comparator functions
Remove unnecessary sqrt() calls in northwest_cmp and northeast_cmp.
The square root would have been necessary if we needed the actual distance,
but we only care about the relative order, so it isn't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
970ac8ff50 core/place: Simplify meta_window_place
This is a preparatory commit, it refactors away of the
done_check_denied_focus label, simplifying the control flow.

The only functional difference is that now the auto-maximization when
windows don't fit the work_area is always applied.

The next commits will adapt find_next_cascade to properly handle this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
b3fd815bed core/place: Drop unused arguments in find_next_cascade
We drop the x and y arguments from find_next_cascade
since they're unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
61a7b21d08 core/place: Drop unused arguments in find_first_fit
We drop the x and y arguments from find_first_fit since they're unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
Mattia Formichetti
7c5005b9b0 core/place: Reformat place.c
This commit only reformats place.c, starting off uncrustify's output, no
functional change is intended.
It mostly aligns comments, as well as properly space out math,
follow current formatter enforced guidelines and fix alignment on a rogue
bracket.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
2025-02-19 19:20:38 +00:00
José Expósito
5d07e69461 onscreen/native: Allow to force copy mode
Create an environment variable to allow to set the copy mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4251>
2025-02-19 19:10:02 +00:00
José Expósito
8245f9f790 onscreen/native: Allow to force CPU copy on copy mode primary
By default, copy mode primary tries to use the GPU to perform the copy
and, in case of error, it fallbacks to CPU.

Add a flag (unused for the moment) to allow to use the CPU to perform
the copy.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4251>
2025-02-19 19:10:01 +00:00
Sebastian Wick
005b969227 wayland: Implement the cursor_shape_v1 protocol
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3668>
2025-02-19 18:06:45 +00:00
Sebastian Wick
25bb319ec2 debug-control: Add property for toggling the cursor shape protocol
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3668>
2025-02-19 18:06:45 +00:00
Sebastian Wick
92c6452753 cursor: Support css and wayland cursor-shape cursors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3668>
2025-02-19 18:06:45 +00:00
Sebastian Wick
4009bfe006 wayland: Move pointer and tablet tool focus serial check to function
This will be used by the cursor_shape protocol in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3668>
2025-02-19 18:06:45 +00:00
Michel Dänzer
ba4cb3e021 kms: Add debug logging about full resource change triggers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
3fde2f7100 kms/connector: Fix kms_modes_equal
It would return FALSE if any pair of one mode from each list didn't
match, which is always the case if either list has at least two modes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3831
Fixes: a8d11161b6b4 ("kms: Only emit resources-changed signal if we recorded a change")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
6fe8993e35 kms/connector: Return TRUE from edid_equal if both EDID pointers are NULL
Fixes: a8d11161b6b4 ("kms: Only emit resources-changed signal if we recorded a change")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
71603c22fb kms/connector: Refactor edid_equal helper out of _state_changes
No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
313860e2fa kms: Wait for 2 seconds before handling udev hotplug events
More precisely, wait until no further udev hotplug events have arrived
in 2 seconds.

Keep a list of unique UpdateStatesData structs which have received
hotplug events, and call handle_hotplug_event for all of them once the
timeout expires.

This avoids problems due to some monitors generating hotplug events
when power saving is enabled on locking the session, and then
temporarily appearing disconnected.

v2:
* Make meta_test_disconnect_connect wait and run main context dispatch
  before checking the number of logical monitors.
v3:
* Call g_source_unref immediately after g_source_attach, simplifies
  source cleanup. (Sebastian Wick)
* Free hotplug devices list in meta_kms_finalize. (Sebastian Wick)
* Add KMS debug logging in on_udev_hotplug & hotplug_timeout.
* Bump timeout to 2 seconds. With my affected monitor, the second udev
  hotplug event normally arrives almost a second after the first one,
  occasionally more than 1.5 seconds though.
* Use UpdateStatesData with custom compare function for hotplug_devices
  list data, since the GUdevDevice / device path string pointer values
  are always different.
* Don't wait for timeout if meta_is_udev_test_device returns TRUE, to
  hopefully fix VKMS CI tests. Drop meta_test_disconnect_connect changes
  again.
v4:
* Use hash table instead of list for hotplug_events set. (Sebastian Wick)
* Add comment describing the keys & values in the hash table. (Sebastian Wick)
* Add KMS debug logging in handle_hotplug_event as well.
* Dropped Closes:, this might not suffice to fully address
  https://gitlab.gnome.org/GNOME/mutter/-/issues/3831 after all.
v5:
* Simplify hash table annotation comment. (Sebastian Wick)
v6:
* Rename hotplug_timeout local string pointer to hotplug_event.
* Drop g_clear_pointer in favour of g_autofree in on_udev_hotplug.
  (Sebastian Wick)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
7f78b6a9e5 kms: Use encoded strings instead of UpdateStatesData
Handle NULL string pointer in meta_kms_update_states_in_impl.

Drop second parameter of meta_kms_update_states_sync, which wasn't used
by the external test caller anyway. Split out static update_states_sync
function which takes a hotplug event string pointer instead.

Preparation for next commit.

v2:
* Drop UpdteStatesData for encoded hotplug event strings.
v3:
* Put device path at the end of encoded string, allows simplifying
  meta_kms_update_states_in_impl slightly further.
v4: (Sebastian Wick)
* Use g_autofree for hotplug_event string in on_udev_hotplug, fixes
  leak.
* Store pointer to hotplug event device path string in local variable in
  meta_kms_update_states_in_impl.
v5:
* Initialize `path` local variable to `NULL` and test it instead of the
  `hotplug_event` parameter. Avoids (false-positive) compiler warning
  about `path` possibly being used uninitialized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
ec73076e07 monitor-manager/native: Remove _read_current_state specialization
It forced the power save mode to META_POWER_SAVE_ON when reading the
current KMS state.

This was problematic when a hotplug event is emitted while the session
is locked, which can be triggered by monitors polling all their inputs
for a signal: There's no mechanism to restore the previous power save
mode in this case, so the monitors would fail to actually enter power
saving mode but stayed on with a blank screen. This was at least one
cause of the symptoms described in
https://gitlab.freedesktop.org/drm/amd/-/issues/662 .

Moreover, I suspect it hasn't had any effect for the actual reading of
KMS state since 5f6aee341959 ("kms/update: Make power saving an update
wide change"), as changing the power save mode to META_POWER_SAVE_ON no
longer results in any immediate KMS state change, it's now only taken
into account for the next mode set.

It's not clear what the intended effect was in the first place, it was
originally added as part of 65db8efbe8b1 ("MonitorManager: add a KMS
backend") without rationale. It might have been cargo-culted from
somewhere else. It shouldn't be necessary from a KMS API PoV though.

Also adjust the KMS hotplug test to assert that a hotplug event doesn't
implicitly change the power save mode.

v2: (Sebastian Wick)
* Fix shortlog of commit which added
  meta_monitor_manager_native_read_current_state.
v3:
* Adjust KMS hotplug test for the change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Michel Dänzer
a5f1bdff1a kms: Delete unused members of MetaKms
Unused since f27ca241f9a2 ("renderer/native: Move per frame KMS update
to MetaFrameNative") / a6baa77eab89 ("kms: Split out impl/non-impl
separation into MetaThread(Impl)").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4209>
2025-02-19 16:53:58 +00:00
Alessandro Astone
f31539984d tests/cursor: Embed a copy of the Adwaita cursor theme
As a follow-up to 87cc6633a5, embed a partial copy of the Adwaita cursor theme
and point to it with XCURSOR_PATH to make the test completely independent
from the installed cursor themes.

Indeed, adwaita-icon-theme changed ever so slightly in version 48 so the
ref tests started failing when the new version was installed.

This is a copy of adwaita-icon-theme 47, which is what was used to generate
the ref images.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4252>
2025-02-19 09:21:32 +00:00
Michel Dänzer
eeaff29264 tests/kms/render: Disable triple buffering for now
This requires reverting the previous changes intended for adapting to
triple buffering.

Fixes these tests randomly failing, also in CI pipelines of MRs not
directly related to any of this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4290>
2025-02-19 06:54:06 +00:00
Marco Trevisan (Treviño)
169ea4cf81 tests: Use env in bash scripts shebang
Bash can be in both /usr/bin/bash or /bin/bash (or elsewhere!) depending on
the distro, so let's be generic using env to figure it out.

This comes from a packaging lintian error we get:

 E: mutter-16-tests: wrong-path-for-interpreter /usr/bin/bash != /bin/bash
    [usr/share/mutter-16/tests/socket-launch.sh]

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4288>
2025-02-18 18:56:29 +00:00
Michel Dänzer
fac0854a4f cursor-renderer/native: Cast MetaGpu to MetaGpuKms only if it is one
Fixes crash in gnome-shell CSS styling test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4289>
2025-02-18 17:58:20 +00:00
Bilal Elmoussaoui
8223f58b98 frames: Don't set prefer-dark-theme if adwaita is loaded
Avoids the following warning in the logs
mutter-x11-frame[4003]: Using
GtkSettings:gtk-application-prefer-dark-theme with libadwaita is
unsupported. Please use AdwStyleManager:color-scheme instead.

When initializing libadwaita, the AdwStyleManager default instance is
initialized taking care of loading the appropriate stylesheet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4276>
2025-02-18 18:24:44 +01:00