2412 Commits

Author SHA1 Message Date
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
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
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
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
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
Carlos Garnacho
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
Michel Dänzer
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
Michel Dänzer
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
Michel Dänzer
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
Sebastian Wick
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
Sebastian Wick
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
Sebastian Wick
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
José Expósito
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
José Expósito
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
José Expósito
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
Joan Torres
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
Carlos Garnacho
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
Carlos Garnacho
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
Mattia Formichetti
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
Keyu Tao
57698c2689 wayland/text-input: Reset focus state when destroying text_input
When closing some wayland apps using text-input-v3, text_input_destructor
could remove resource in focus_resource_list without resetting focus.

This could be an issue if, the focus is on a wayland app not using text-
input-v3 after closing those. Text committing would fail, and the
candidate window would always show on previous entry.

This commit adds check in text_input_destructor, resetting focus if
necessary.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4776
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4164>
2025-02-26 09:44:50 +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
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
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
Carlos Garnacho
b7d533c301 wayland: Honor wl_surface.offset on cursor surfaces
Update the cursor hotspot based on wl_surface.offset requests. This
is the expected way to update the cursor hotspot once the cursor
surface is already visible and has buffers attached.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/7249
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4239>
2025-02-13 21:28:59 +00:00
Dudemanguy
e078147f7d wayland: Support presentation-time version 2
It is simply a matter of checking the version and always sending back
the refresh rate of the display if we have version 2 of the protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4227>
2025-02-11 09:37:32 +00:00
Dudemanguy
271c712146 wayland: Fix refresh interval reporting in presentation-time version 1
Version 1 of the presentation protocol requires that 0 be sent for the
refresh rate for variable refresh rate. Fix this by checking the mode
during the presentation event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4227>
2025-02-11 09:37:32 +00:00
Carlos Garnacho
92cbefd863 wayland: Avoid meta_window_move_resize_internal()
We are using no placing flags, so this is essentially the same
as meta_window_move_resize().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3972>
2025-01-29 12:44:05 +00:00
Carlos Garnacho
fb49a700a1 core: Drop MetaGravity argument from move_resize_internal() call
Obtain the gravity through the newly added MetaWindow method from the
window being moved/resized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3972>
2025-01-29 12:44:05 +00:00
Carlos Garnacho
432e52bad0 core: Drop MetaGravity argument from move_resize_internal() vmethod
The implementations no longer need this argument, so drop it in
favor of meta_window_get_gravity().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3972>
2025-01-29 12:44:05 +00:00
Carlos Garnacho
33c287e271 wayland: Get gravity through MetaWindow getter
Ignore the gravity argument in the move_resize_internal() vmethod,
and use the window getter to get it. It should be functionally
equivalent, and will eventually replace the argument entirely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3972>
2025-01-29 12:44:04 +00:00
Carlos Garnacho
37df41097c wayland: Implement get_gravity() vmethod
Handle here the toplevel drag surface getting nortwest gravity,
and fall back to the default static gravity for everything else.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3972>
2025-01-29 12:44:04 +00:00
Jonas Ådahl
2d43721c09 wayland: Replace meta_warning() with g_warning()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4005>
2025-01-16 00:48:42 +00:00
Jonas Ådahl
6dd7b0c7cd wayland: Don't warn when there is no session manager
This is often the case when running e.g. using `dbus-run-session`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4005>
2025-01-16 00:48:42 +00:00
Jonas Ådahl
98bdaaf87f wayland: Replace meta_verbose() with 'wayland' debug logs
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4005>
2025-01-16 00:48:42 +00:00
Michel Dänzer
82398945ea wayland/buffer: Do not get latest sync_fd if there are no release points
It's pointless busy work in that case.

Fixes: e8b890ab53a6 ("wayland: Implement linux-drm-syncobj-v1")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4208>
2025-01-15 20:50:07 +00:00
Jonas Ådahl
03553daacb wayland/cursor-surface: Update preferred scale monitor
Both when the renderer is set, which happens early shortly after
assigning the role, and when the cursor sprite is prepared at a specific
position, which happens as the cursor moves.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3829
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4205>
2025-01-09 16:34:35 +00:00
Jonas Ådahl
16e2c4785d wayland/surface: Add preferred scale monitor role vfunc
Use this new getter for getting the preferred surface scale.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4205>
2025-01-09 16:34:35 +00:00
Jonas Ådahl
29571397bc wayland/surface: Change a term from highest to preferred scale
It isn't always the highest scale for the surface, so change the
terminology in the common path to reflect this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4205>
2025-01-09 16:34:35 +00:00
Derek Foreman
fd39ca9f20 wayland: Add support for FIFO commits
New protocol that allows a client to require that a previously flagged
content update must be presented before a content update can be applied.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3355>
2025-01-08 10:35:46 -06:00
Derek Foreman
14c70c4f53 wayland/commit-timing: Add support for the commit-timing-v1 protocol
Allow clients to add timestamps to content updates.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3355>
2025-01-06 09:21:15 -06:00
Derek Foreman
a645659440 wayland: Add timed transactions
Allow a transaction to have a timing constraint.

Any transaction with a timing constraint will be deferred at its initial
commit, without testing the target time. The timing constraints are cleared
later in an on_before handler immediately before repaint.

The new frame clock api to schedule later ticks is use to ensure we get an
appropraitely timed tick to clear the constraint.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3355>
2025-01-06 09:21:15 -06:00
Jonas Ådahl
3d45345789 tests/cursor-tests: Also test a couple of fractional scales
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
2024-12-11 16:22:57 +00:00
Robert Mader
e674c7e454 cursor-sprite: Add API for viewports
[jadahl] Rework hotspot calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
2024-12-11 16:22:57 +00:00
Jonas Ådahl
f4201bc3d3 service-channel: Add global shotcuts portal backend client type
The global shortcuts portal backend component lives in
gnome-control-center, and is responsible for preseting the GUI for
managing client provided global shortcuts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4173>
2024-12-10 17:02:24 +00:00