1
0
Fork 0
Commit graph

12482 commits

Author SHA1 Message Date
Corentin Noël
24f2e76576 meta/plugin: Annotate dialog creation virtuals as return full
The two dialog creation virtual functions returned by these functions have to
be unreferenced by the caller (and are actually unreferenced in other places in
the code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3790>
(cherry picked from commit 4134d12789)
2024-06-29 21:12:29 +02:00
Jeffrey Knockel
18c17aaa5a constraints: Allow resize of windows moved above screen
If the titlebar of a window has been moved above the screen by a user
via an unconstrained move, then any constrained user resize following
this move will cause the window to jump below the top of the screen or
cause other glitchy behavior.

This commit removes the constraint that the titlebar of a window must be
below the top of the screen for any resize that is both (1) triggered by
a user and (2) is a resize that affects only the left, right, or bottom
edges of the window.  This allows users to move a window partially above
the screen and then resize the window to be wider or resize the bottom
edge of the window to make it taller or shorter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1206
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3764>
(cherry picked from commit 5ba364a947)
2024-06-28 23:22:22 +02:00
Orko Garai
7f344053f8 Use byte offset for cursor_end/anchor value sent in preedit_string.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3845>
(cherry picked from commit f214eb5134)
2024-06-28 23:22:06 +02:00
Michel Dänzer
8978f74c1e wayland/surface: Can't send scale events with NULL surface->resource
The committed state can't have any children sub-surfaces either, so
just bail.

Fixes: ae403f2e94 ("wayland: Use new highest scale monitor tracking for fractional_scale_v1")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3552

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3849>
(cherry picked from commit 94f3bbd94b)
2024-06-28 21:18:01 +02:00
Sebastian Wick
7e4f6faaaa wayland/surface: Send unmapped signal when the surface goes away
This was the intention anwyway but it didn't work properly because
GObject::dispose removes all signal handlers and we unmap surfaces in
WaylandShellSurface::finalize. Move all the unmanaging and unmapping to
the dispose vfunc where we can still run all the signal handlers.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3501
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3783>
(cherry picked from commit 4eacf97678)
2024-06-28 21:18:01 +02:00
Sebastian Wick
e8cc52044d wayland: Handle unmapping surfaces
Right now the unmapped signal doesn't always fire which means we didn't
see a surface that's being unmapped in these code paths before. In
particular the resource, window and role can be gone. Handle those
cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3783>
(cherry picked from commit 3e7b1d9cbd)
2024-06-28 21:18:01 +02:00
Pascal Nowack
30f73d554f backends/screen-cast-stream-src: Always initially set buffer stride
When mutter creates a dma-buf buffer for screencasting, the buffers
stride will, among other attributes, also be defined.
However, mutter currently only sets the buffer stride, when actually
recording a frame, but not when adding it.
This behaviour disallows screencast consumers (clients) to already
import the respective buffer (i.e. for Vulkan creating a VkImage for the
dma-buf image), as the stride is not yet communicated to the client.

Since the stride won't change after adding the respective buffer,
directly set the buffer stride, when adding the PipeWire buffer. This
allows screencast consumers (clients) to do optimizations in their
encoding paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3827>
(cherry picked from commit 0dd4080509)
2024-06-28 21:18:01 +02:00
Daniel van Vugt
1d7c2c7b61 x11: Add another fallback to legacy X11 cursor names
For X11 apps that don't specify their own.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3403
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
(cherry picked from commit 807c99fca6)
2024-06-28 21:18:01 +02:00
Daniel van Vugt
d2d98a850c backends: Restore support for loading X11 cursor themes missing "default"
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3184
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
(cherry picked from commit d2c6b77059)
2024-06-28 21:18:01 +02:00
Daniel van Vugt
f744efe347 backends: Add meta_cursor_get_legacy_name()
To aid loading of legacy cursor themes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
(cherry picked from commit 4a4ab8c533)
2024-06-28 21:18:01 +02:00
Daniel van Vugt
234013961e backends: Fix parameter alignment check-code-style complains about
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
(cherry picked from commit 13b2803a03)
2024-06-28 21:18:01 +02:00
Daniel van Vugt
c1f03eba73 backends/x11: Avoid defining (and freeing!) nonexistent cursors
Such as "default" for legacy X11 themes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3454
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3718>
(cherry picked from commit 847f015017)
2024-06-28 21:18:01 +02:00
Jonas Ådahl
df93ce4524 tests: Mark some tests as skippable
Wayland tests also get kvm and tty test variants, but running tty tests
on your main session makes them fail. The intention for tty tests is to
skip when not run from a tty, so fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3811>
(cherry picked from commit 6d8c93ba66)
2024-06-28 21:18:01 +02:00
José Expósito
88f5fb3447 backends/eis-client: Release buttons on device remove
Due to a copy and paste error, buttons were not released when the device
was removed.

Found by Coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3809>
(cherry picked from commit 4ae305f19e)
2024-06-28 21:18:01 +02:00
Jonas Ådahl
a193da6d97 kms: Don't use kernel thread when headless
We're not doing anything significant in the KMS thread anyway, so don't
make it a kernel thread, and don't ask to be real time scheduled (which
we wouldn't be anyway, but for clarity).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3805>
(cherry picked from commit 5bca761148)
2024-06-28 21:18:01 +02:00
Jonas Ådahl
80d1b79849 backend/native: Find render node directly via udev
Don't try to find the card, and then the render node from it, just ask
udev to list the render nodes directly. This avoids running into
permission errors when the user cannot open /dev/dri/card* even without
mode setting capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3805>
(cherry picked from commit 6bd2fd6a74)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
e1efc4c64e wayland: Double check surface/window before looking for modals
While it should not be expected that we pick the pointer into a
MetaSurfaceActor that is disembodied of its MetaWaylandSurface/MetaWindow,
the paths where this should be enforced are somewhat scattered.

So account for the situation in picking code, and prefer a NULL surface
over a crash. This operates on the assumption that this inconsistent state
where Mutter didn't know better to pick a correct surface actor will be fixed
by later crossing events resolving the intermediate state, and that no
other input events will be received meanwhile.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3393
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
(cherry picked from commit e731f2a055)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
2f4dc03451 wayland: Make subsurface actors unreactive early during destruction
When unmapping a subsurface, it does lose early its connection to the
parent surface. This is however a deciding factor in determining whether
the surface (role) has a window.

Make the subsurface actor unreactive if its connection to the parent
MetaWindow was severed, since it should not be eligible for picking anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
(cherry picked from commit 66e23b009c)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
523d716e63 compositor: Make surface actors unreactive after losing their surface
These actors are expected to be destroyed along with their surface, this
however happens later in the process, so there is a moment where actors
are eligible for picking, but do not have a surface anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3729>
(cherry picked from commit 17dc9393e0)
2024-06-28 21:18:01 +02:00
Sebastian Keller
feec993dee events: Don't check for stage grabs before sending events to ibus
Prior to the grabs/focus rework in !3420, Wayland grabs were handled
separately from ClutterGrabs. This required explicitly checking for
ClutterGrabs as those were expected to prevent events from reaching
Wayland clients.

Now after !3420, Wayland client grabs also result in ClutterGrabs, which
means that this check causes input events for popups with grabs to not
get sent to ibus anymore. Instead the events are getting sent to the
client directly, which results no ibus support in popups (unless the
client handles that itself by using a different GTK_IM_MODULE).

However due to the changes from !3420 checking for ClutterGrabs is also
no longer necessary and the meta_wayland_text_input_update() focus check
is now sufficient to only forward events to ibus, when the focus is
actually on a Wayland client. So to fix this we can simply remove the
check.

Fixes: 2a584a8f0 ("wayland: Make use of Wayland event grabbing mechanism")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3502
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3787>
(cherry picked from commit a99e139a68)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
6aaa76dfc3 Revert "wayland: Add meta_wayland_seat_get_input_focus_client() call"
This reverts commit 743fb6df30.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
(cherry picked from commit ad60d7123b)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
c2dc92a214 wayland: Fix possibly out of sync clipboard selections
Replace the sync_focus() calls with a set_focus() do-it function taking
a surface. This is in line with the rest of the things that happen at
the default MetaWaylandEventInterface.focus implementation, and will
make these correctly observe the presence of grabs, since
meta_wayland_seat_get_input_focus() will return the would-be focus
in these cases.

This change makes the "focused" client selection truly
in sync with the keyboard focus.

Fixes: 5ca10c31d1 ("wayland: Follow seat's input focus client for clipboard selections")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3490
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
(cherry picked from commit b968796f1f)
2024-06-28 21:18:01 +02:00
Carlos Garnacho
73cab26d0f wayland: Fix possibly out of sync primary selections
Replace the sync_focus() calls with a set_focus() do-it function taking
a surface. This is in line with the rest of the things that happen at
the default MetaWaylandEventInterface.focus implementation, and will
make these correctly observe the presence of grabs, since
meta_wayland_seat_get_input_focus() will return the would-be focus
in these cases.

This change makes the "focused" client selection truly
in sync with the keyboard focus.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3498
Fixes: 9bdb00c459 ("wayland: Follow seat's input focus client for primary selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789>
(cherry picked from commit 9dab806a18)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
2fca52fb91 core/context: Add typecheck guards to the public functions
In the shell side we ended up calling the wrong function [1] and mutter
didn't stop us from doing it, so add some type-check guards to ensure we
don't do similar errors again

[1] https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3355

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3791>
(cherry picked from commit 467746c8a7)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
fb327dfb4d backends/x11/backend-x11-nested: Cleanup the cursor renderer on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit 0fda3ab8a1)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
1a93640aa0 backends/input-settings: Clear the devices list on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit 6a04ea9a59)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
ab86f20c9b backends/backend: Clear egl object if any
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit b630c3baa6)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
95166ea750 backends/color-store: Unify and simplify codepaths for profile ready
Just steal from the hash table all the times, and use autopointers
to cleanup if needed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit de8691c7ff)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
a34b0ce86a backends/color-store: Clarify the color profile ownership fixing the key leak
We were leaking the color profile path keys but also it wasn't clear how
the ownership was passed to the new hash-table, so let's just remove it
from the pending hash table and add it to the new one including the
expected reference.

This is safe because we were still adding a temporary extra ref to the
profile

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit 430e55a535)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
8e652e3562 backends/native/backend-native: Free the device path when stealing the device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit c2cc26b370)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
f76591fd02 backends/native/thread: Unref the callback sources hashtable on finalize
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit ce1dd40f7b)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
63ff9588a4 backends/remote-access-controller: Own and free the session managers
We were leaking the session managers list, but at this point I feel it
looks cleaner to also own it fully

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit f74a46d98d)
2024-06-28 21:18:01 +02:00
Marco Trevisan (Treviño)
e975e2c4c9 backends/backend: Cleanup MetaDnd on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
(cherry picked from commit c33a02dd32)
2024-06-28 21:18:01 +02:00
Philip Withnall
426fcb61be tests: Fix a -Wmaybe-uninitialized warning
Since the `switch` didn’t have a default case, the `cull_front` and
`cull_back` variables could technically be used uninitialised if the
`cull_mode` was unrecognised.

That seems unlikely to happen as presumably other code makes sure the
`cull_mode` is valid, but it doesn’t hurt to add a `default:` case to
squash the compiler warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3770>
(cherry picked from commit 173332e928)
2024-06-28 21:18:01 +02:00
Philip Withnall
5f6cf26721 display: Fix a -Wmaybe-uninitialized warning
Depending on whether the input mapper was found, these variables could
indeed be used uninitialised, so this is a true positive warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3770>
(cherry picked from commit ca1434ff1e)
2024-06-28 21:18:01 +02:00
Jonas Ådahl
2ea002c0df Revert "window/wayland: Use scale for configured rect in configuration"
This caused https://gitlab.gnome.org/GNOME/mutter/-/issues/2616.

This reverts commit 2a62e690a2.
2024-06-27 23:40:09 +02:00
Michel Dänzer
ec5444f541 wayland/actor-surface: Don't sync actor state for frozen actors
This ensures that sub-surfaces remain visible during the fade-out
animation of their window.

Fixes: be4bf8da9c ("wayland/surface: Keep applied sub-surface branch node linked up")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3508
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3840>

(cherry picked from commit fab78d951a)
2024-06-26 13:28:13 +02:00
Michel Dänzer
ce4a22b80f window-actor/wayland: Sync actor state when actor is thawed
This is currently redundant, but will be needed with the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3840>

(cherry picked from commit 03f3c18d27)
2024-06-26 13:27:56 +02:00
Daniel van Vugt
175a4615ad build: Compile schemas locally for use in build tests
So they don't need to be installed system-wide before build testing
can work.

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

(cherry picked from commit b684b5cf05)
2024-06-25 17:32:25 +08:00
Jonas Ådahl
68a7d6dcfc screen-cast/window: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-16 14:26:41 +02:00
Jonas Ådahl
c7819dbfdc screen-cast/monitor: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-16 14:26:41 +02:00
Jonas Ådahl
c0ad6c8a88 screen-cast/area: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-16 14:26:41 +02:00
Jonas Ådahl
edbdda7cbd screen-cast/virtual: Only record cursor updates if anything changed
If we're doing a cursor-only update, only actually do it if anything
changed relative to the stream itself.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3220
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-16 14:26:41 +02:00
Jonas Ådahl
33907073ff screen-cast/src: Allow dropping cursor-frame if nothing changed
Allow a screen cast stream source to say that nothing changed in terms
of cursor metadata, and treat this together with a cursor-only frame as
we not recording anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3803>
2024-06-16 14:26:41 +02:00
Marco Trevisan (Treviño)
24e6843ab7 frame: Handle X11 errors earlier on frame setting
Avoid changing the stack information if we fail earlier than that
2024-05-27 17:21:10 +02:00
Marco Trevisan (Treviño)
1e02c06298 frame: Handle reparent failure avoiding duplicate stack windows instances
In some cases, reparenting a window with its frame may fail; this seems
to happen especially during initialization of a window that may be
unmapped and re-mapped quickly and multiple times.

If this happens, we're never going to receive a remove event on the
stack tracker and so we may end up adding it twice to the list of the
windows to synchronize with the compositor, breaking its assumption that
the stack list is unique, and eventually leading to a crash because we
do not end up removing all the instances of a window on its destruction.

In particular we may end up in this situation:

  Syncing Window 10485927: 0x555558863540 (actual xid is 10485927),
    user time is 10485928 frame is 0x5555588715c0, frame xid 6291591
  Syncing Window 14680081: 0x5555588664b0 (actual xid is 14680081),
    user time is 14680082 frame is 0x555558871d80, frame xid 6291595
  Syncing Window 6291460: 0x55555796dc80 (actual xid is 10485763),
    user time is 10485764 frame is 0x555557a6f630, frame xid 6291460
  Syncing Window 6291465: 0x555557a68af0 (actual xid is 14680067),
    user time is 14680068 frame is 0x555557a73e80, frame xid 6291465
  Syncing Window 6291509: 0x555557f9d830 (actual xid is 8388623),
    user time is 0 frame is 0x555557fac780, frame xid 6291509
  Syncing Window 6291586: 0x5555586e1690 (actual xid is 4194363),
    user time is 0 frame is 0x55555886e550, frame xid 6291586
  Syncing Window 6291591: 0x555558863540 (actual xid is 10485927),
    user time is 10485928 frame is 0x5555588715c0, frame xid 6291591

Where the same meta window 0x555558863540 is added twice because that's
both mapped by the window itself (10485927) and by its frame (6291591).

This happens because for historical reasons the xids hash table managed
by the x11-display maps both the X11 windows, their frames and their
user time windows as the meta-window, and so if we don't filter out them
properly we end up duplicating the entries in the compositor list.

Such duplicates finally end up making mutter to crash in
meta_compositor_sync_stack() because we could end up trying to access
to an invalid window, given its actor has been destroyed but not all the
instances have been removed from the compositor windows list:

  0x00007ffff71059 in meta_compositor_sync_stack (compositor=0x555555b8,
  stack=0x555558701b80) at ../../mutter/src/compositor/compositor.c:773
  773	          if ((old_window->hidden || old_window->unmanaging) &&
  (gdb) print old_window
  $1 = (MetaWindow *) 0x0

So, in order to prevent this, check that XReparentWindow does not fail,
and in case of failure, reset the window state to the one it had before
we failed and more importantly, remove the association between the frame
X11 window and the MetaWindow, since this is not true anymore and so
that at the next stack synchronization there won't be any meta window
associated to that frame XID (unless there aren't further stack changes
impacting on that). Without this we would have instead waited for the
remove event that we predicted, but that could never happen because no
ReparentNotify is emitted in such case.
2024-05-27 17:21:10 +02:00
Marco Trevisan (Treviño)
bd799b6b36 frame: Associate the frame to the window after reparenting
Since we listen the X events in the same thread, and they are delivered
through the main loop, there's not any need to set the frame details on
windows before the reparent operation, because such action could fail.

So move the code order, as preparation for handling the error.
2024-05-27 17:21:10 +02:00
Marco Trevisan (Treviño)
bcc209bf73 frame: Define a free function for MetaFrame and use via autoptr
Use clearer memory management for the MetaFrame making it easier
to destroy it.
2024-05-27 17:21:10 +02:00
Sebastian Keller
5a5a506f57 wayland/pointer-constraints: Don't steal regions for new constraints
meta_pointer_constraint_new() does not take ownership of the passed
regions but instead creates a copy, resulting in a leak in the calling
functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
(cherry picked from commit 650ef9b57f)
2024-05-24 09:34:01 +02:00
Sebastian Keller
e466a1bccc wayland/pointer-constraints: Disconnect focus surface handler early
When meta_wayland_pointer_constraint_remove() is called, it can trigger
a meta_wayland_event_handler_invalidate_focus() via:

meta_wayland_pointer_constraint_destroy()
meta_wayland_pointer_constraint_disable()
meta_wayland_input_detach_event_handler()
meta_wayland_input_invalidate_all_focus()
meta_wayland_event_handler_invalidate_focus()

Which then would result in a "focus-surface-changed" signal which would
call meta_wayland_pointer_constraint_remove() a second time. This
happens after surface_remove_pointer_constraints() has already been
called in the first meta_wayland_pointer_constraint_remove() call,
leading to "data" being NULL.

To prevent this issue disconnect the signal handler before calling
meta_wayland_pointer_constraint_disable() when destroying a constraint.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3476
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
(cherry picked from commit c3e626405f)
2024-05-24 09:34:01 +02:00
Sebastian Keller
eff6e48200 pointer-constraints/native: Fix typo in function name
The vfunc is named "constrain" not "constraint".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
(cherry picked from commit d4907a960c)
2024-05-24 09:34:01 +02:00
Sebastian Keller
e14bd837e1 pointer-constraints/native: Warp locked pointer to correct position
In case of empty regions (e.g. when locking the pointer) the pointer
was only forced to stay within the boundaries of its current pixel
(i.e. culling subpixel position), instead of the position where the
pointer lock did start.

Fixes: 07d24fe50 ("backends/native: Allow infinitely small pointer constraint regions")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
(cherry picked from commit d686865918)
2024-05-24 09:34:01 +02:00
Sebastian Keller
6a2e8e43a7 pointer-constraints/native: Consider origin when checking constraints
Since 07d24fe50 regions are not translated to their on-screen
coordinates anymore, but are relative to the origin stored in the
constraint. This origin however was not considered when checking whether
the pointer was within the constraint region. This meant that the
constraint region would appear to always be placed at 0,0 instead of on
the surface.

Fix this by using the cursor position relative to the origin.

Fixes: 07d24fe50 ("backends/native: Allow infinitely small pointer constraint regions")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3409
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
(cherry picked from commit c0537096c2)
2024-05-24 09:34:01 +02:00
Jonas Dreßler
9db8609623 wayland/popup: Only close popups if press count drops from 1 to 0
We close wayland popups when a button or touch release happens outside
of the grab, except we don't want to close them when that button release is
actually the release of the press that was opening the grab in the first
place.

We never see the press event that opened the grab, so the first event we
see is actually always a release. Make sure to not close the popup on that
event, and instead only close the popup if we see the press count drop from
1 to 0.

This fixes a bug where popup would close right after they open. To
reproduce, click to open a popup, hold pressed and move the cursor over
shell chrome, then release. Or alternatively test with a popup that gets
opened with a long-press gesture (eg. long touch long press on libadwaita
tabs), just doing the touch long-press and then release.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3631>


(cherry picked from commit 79a79b3450)
2024-05-23 22:02:33 +00:00
Sebastian Wick
044ac90378 tests/wayland-unit-tests: Make sure there are two workspaces
because we want to switch between two workspaces. In some configurations
there is only a single workspace at this point so trying to get current
workspace + 1 gets us a NULL pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3730>
(cherry picked from commit 301c154f02)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
ae863e3e26 wayland/xdg-shell: Update min/max window size also on geometry changes
The internal representation of the min/max width of windows include what
is outside of the window geometry, so when the window geometry changes,
but the min/max size did not in the same commit, we'd be left with an
out of date min/max size, potentially causing windows to shrink when
configured.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3755>
(cherry picked from commit 97af5f8705)
2024-05-23 20:24:34 +00:00
Bilal Elmoussaoui
d9a4a5fcb2 Use gboolean consts instead of C bools
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3748>
(cherry picked from commit c13956fb9e)
2024-05-23 20:24:34 +00:00
Sebastian Keller
b34fbc3120 egl: Don't free source error after propagating it
local_error in meta_egl_query_device_string() is using g_autoptr,
meaning that it was getting freed after g_propagate_error(). This then
would result in error->message becoming invalid, causing crashes when
logging the error message later on.

Fixes: 8234f5bc7 ("egl: Return success status from meta_egl_query_device_string")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3758>
(cherry picked from commit 7a38e12ed0)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
dd735cde01 dbusmock/mocks-manager: Don't create a pipe for started templates
Just shovel the data through our own stdin/stdout, which will end up at
the right place (e.g. /dev/null).

This should hopefully solve `mutter-dist` failing due to a D-Bus method
call timeout in CI.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3757>
(cherry picked from commit e2e687c9db)
2024-05-23 20:24:34 +00:00
Sebastian Keller
d8af06fe49 x11/window: Compare input shape to client rect when undecorating
When a window with an input shape on its decoration window becomes
undecorated and meta_window_x11_update_input_region() gets called via
notify::decorated, the buffer_rect of the window has not been updated
yet while the decorated property has. This would lead to us comparing
the input shape of the client window to the buffer_rect which still
includes the decoration window. This would fail to detect the common
case when the client window has no input shape set, leading to the input
region being set to the size of the client window rather than NULL. If
the window is then resized later, the input shape would remain at the
previous size.

This was not a problem before 6bd920b35, because then we were (wrongly)
always comparing to the client_rect.

Fix this by choosing the correct rect for comparison depending on
whether the window is decorated.

Fixes: 6bd920b35 ("x11/window: Use correct bounding rect to determine NULL input region")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3451
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3720>
(cherry picked from commit 1f1538be76)
2024-05-23 20:24:34 +00:00
Florian Müllner
7562231e2f core/anonymous-file: Support 0-sized files
There is nothing to allocate for a 0-sized files, and indeed
posix_fallocate() will error out if the passed len isn't greater
than 0.

Now that anonymous files are used to back the memory selection
source, this fixes unsetting the selection when the screen is
locked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3752>
(cherry picked from commit da0bd303ad)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
133a1b2e64 tests: Add test case for keybinding remove race
When a key binding is removed, and a trigger key sequence is dispatched
before the idle callback that resolves and updates the actual binding,
we should handle that gracefully.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3711>
(cherry picked from commit 22f67d107d)
2024-05-23 20:24:34 +00:00
Keyu Tao
93b16a5368 keybindings: Add refcounting to fix use-after-free for key handlers
Two new fields: ref_count and removed, are added to MetaKeyHandler, and
it would be freed only if the ref count has reached 0. When handler is
removed from key_handlers GHashTable, key_handler_destroy() would mark
removed as TRUE, and do an unref. handler->removed is checked in
get_keybinding, and binding with handler removed would not be used.

Also in MetaKeyBinding, it now has the ownership of the name field, to
avoid it being freed before logging. Create or copy a binding would
do a ref inc for handler, and free one would unref handler.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1870.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3711>
(cherry picked from commit 8c39a25459)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
67a7900cd3 window/wayland: Constrain sporadic client resizes immediately
When a client resizes on its own, make sure the new size is passed
through the window constraints machinery directly, to trigger any
potential window management rule that might apply.

Fix a couple of tests to make use of this behavior by introducing a new
'wait_size' command that waits until a window has been resized to a
expected size.

This replaces the fix introduced in 0e736af301 ("window: Ensure
constraints after a Wayland client resize").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3700>
(cherry picked from commit 57e16cf010)
2024-05-23 20:24:34 +00:00
Sebastian Wick
ba918baa45 window: Start in the activate suspend state until mapped
Starting the timeout to move from hidden to suspended before the window
is mapped means we don't have a previous window configufration which we
need to get the new window configuration with the suspended state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
(cherry picked from commit e509fc7f00)
2024-05-23 20:24:34 +00:00
Sebastian Wick
9a95767865 window: Move implement_showing for the next commit
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
(cherry picked from commit 7a9883d5bb)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
ed637f63c1 tests/wayland: Add test for mapping clone of obstructed window
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
(cherry picked from commit 52d5758f1b)
2024-05-23 20:24:34 +00:00
Jonas Ådahl
2c6993cfb6 tests/wayland: Run with G_MESSAGES_DEBUG=all
Helpful when debugging tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
(cherry picked from commit b69fc15543)
2024-05-23 20:24:34 +00:00
Carlos Garnacho
50174677d2 wayland: Do not forget immediately of key press serials on key release
Prior to commit 5dfed8a431, the MetaWaylandKeyboard would always remember
the last key press serial, and consider it valid after the key was released,
as long as no other key presses/releases happened in between.

That commit improved things so that MetaWaylandKeyboard can track multiple
keys being pressed simultaneously, but also changed so that the serial for
a key press is immediately forgotten after the key press event was received.
This may break in situations like testing or keyboard macros where key
press and release is handled in a quick sucession, so the client reaction
to the key press (e.g. popping up a menu) might arrive too late.

Add a sort of spiritual successor to this handling, and make keyboard
press serials corresponding to the last key up forgotten at the next
key press/release received.

Fixes: 5dfed8a431 ("wayland: Preserve serial for all pressed keys")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3458
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3721>
(cherry picked from commit 243890a688)
2024-05-23 20:24:34 +00:00
Carlos Garnacho
582155a641 wayland: Track current tablet tool focus surface
We did not track the current surface (i.e. the logical focus) too
thoroughly, so there might be chances that a stale surface pointer
here becomes the focus. Track its destruction (like it's done at e.g.
MetaWaylandPointer) and unset the current surface early, in order
to avoid possible invalid memory access.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3372
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3715>
(cherry picked from commit fb8ac5dff7)
2024-05-23 20:24:34 +00:00
Robert Mader
073ed85007 wayland/surface: Fix sending preferred buffer transform
Fix an obvious copy paste error that slipped through the cracks.
Fortunately it doesn't have a visual impact for well behaving clients
but only makes us not hit direct-scanout paths, assuming no other bugs
in the stack.

Fixes: f21762ea6e (wayland: Add support for preferred_buffer_scale/transform)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3717>
(cherry picked from commit 6a81d5f0bb)
2024-05-23 20:24:34 +00:00
Michel Dänzer
2522f3762f kms/impl-device: Inhibit real-time scheduling when querying KMS state
On some setups, the kernel may keep the KMS thread busy for significant
amounts of time while querying KMS state, which could result in mutter
getting killed by the kernel, e.g. after hot-plugging displays.

Issue: https://gitlab.gnome.org/GNOME/mutter/-/issues/3479
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3763>
(cherry picked from commit 8a862b102c)
2024-05-23 19:49:39 +00:00
Michel Dänzer
0864f20753 Revert "wayland/surface: Check buffer size also for role-less surfaces"
This reverts commit 98c8c03729.

Although the spec technically doesn't allow this for role-less surfaces
either, it's difficult for clients to avoid it for surfaces which later
assume a cursor role, and there's consensus to allow it for the time
being:
https://gitlab.freedesktop.org/wayland/wayland/-/issues/194#note_1371674

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3471
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3743>
(cherry picked from commit 1c7ed16d05)
2024-05-23 19:49:39 +00:00
Michel Dänzer
91055faf33 color-manager: Call update_all_gamma from on_monitors_changed
This ensures that an up-to-date gamma LUT is applied for newly-enabled
monitors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2480
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2546
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3439
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3742>
(cherry picked from commit 09a6ff6eb7)
2024-05-23 19:49:39 +00:00
Michel Dänzer
b359be6ffb color-manager: Move update_all_gamma helper up
Preparation for next commit, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3742>
(cherry picked from commit 9ed00280f7)
2024-05-23 19:49:39 +00:00
Michel Dänzer
a95b19ebda wayland/surface: Keep applied sub-surface branch node linked up
Until this surface or its parent is finalized.

This makes sure that any `MetaWaylandSubsurfacePlacementOp` referencing
this surface for sibling will be applied as intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3737>
(cherry picked from commit be4bf8da9c)
2024-05-23 19:49:39 +00:00
Michel Dänzer
3df53268ab Revert "wayland/subsurface: Drop unapplied subsurface state on unmap"
This reverts commit 35d92e0fac.

This turned out to cause trouble, because it can prevent
MetaWaylandSurface::applied_state.subsurface_branch_node from ever
getting linked up for a sub-surface.

It shouldn't be necessary anyway, since permanently_unmap_subsurface /
wl_subcompositor_get_subsurface reset the sub-surface state as defined
by the protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3737>
(cherry picked from commit 5749810ddb)
2024-05-23 19:49:39 +00:00
Michel Dänzer
37d1af515d wayland/subsurface: Hold surface reference in placement ops
Will be necessary with the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3737>
(cherry picked from commit ad22833cc3)
2024-05-23 19:49:39 +00:00
Michel Dänzer
f7b13fd74f wayland/subsurface: Make sure siblings are actually sub-surfaces
Without this check, is_sibling could spuriously return TRUE when neither
surface passed in was actually a sub-surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3737>
(cherry picked from commit ba93fcd30f)
2024-05-23 19:49:39 +00:00
Michel Dänzer
3c3e649a32 wayland/transaction: Check surface pointer validity in _ensure_entry
If a caller passes in NULL or a non-NULL value which doesn't point to
a valid MetaWaylandSurface object, this will hopefully point in the
direction of the cause.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
(cherry picked from commit dd32f3b3be)
2024-05-23 19:49:39 +00:00
Michel Dänzer
519321252a wayland/subsurface: Hold sibling surface reference in placement ops
It was possible for the sibling surface to be already destroyed in
meta_wayland_transaction_add_placement_surfaces, in which case
g_object_ref would return NULL for it, and
meta_wayland_transaction_commit would then crash dereferencing a NULL
surface pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3462
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
(cherry picked from commit b67f94ca7e)
2024-05-23 19:49:39 +00:00
Echo J
003cb6d5ce wayland: Require ANDROID_native_fence_sync for enabling syncobj protocol
Mutter is currently enabling the protocol when the fence can't be
duplicated and it never signals the release of it (which is problematic
in some Mesa drivers like nouveau when used together with the nouveau
Vulkan driver because of the recent explicit sync support merge)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3744>
2024-05-23 19:04:53 +00:00
Marco Trevisan (Treviño)
35836f0f1a x11/window: Add proper type guard to x11-specific public API calls
These functions are specific for X11 windows only so we should check
if the passed window is an X11 one, not just a MetaWindow since we're
casting to the actual type at later point.

Fixes changes part of commit e1e6534eb
2024-05-03 16:09:00 +02:00
Marco Trevisan (Treviño)
f54579ad27 x11/window: Add type-check guard to meta_window_x11_get_group()
Since this is still public API we want to ensure that we don't cast
it directly without having checked its type
2024-05-03 16:09:00 +02:00
Marco Trevisan (Treviño)
a951c097dd x11/window: Do not try to compare a wayland active window with X11
If a window sends a configure stacking request, we were comparing the
active window with the event window even though they were different
client types (e.g. wayland and x11).

This was leading to a critical error, so let's handle this by ensuring
that the active window is of the same kind of the event window before
doing x11-specific checks. Behaving as different applications in case.
2024-05-03 16:09:00 +02:00
Daniel van Vugt
1a87e8e09b backends/native: Remove unused meta_kms_device_add_fake_plane_in_impl
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
(cherry picked from commit f3a52551f1)
2024-05-03 00:27:39 +02:00
Daniel van Vugt
65069940a4 backends/native: Add fake cursor plane using impl_device's crtcs
Because `meta_kms_impl_device_simple_initable_init` is called in the
middle of `meta_kms_device_new`, the crtcs list for `MetaKmsDevice`
has not been populated yet. And thus the loop to detect missing
cursor planes and create fake ones never iterated. But the crtcs list
does already exist in `MetaKmsImplDevice` so iterate over that instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3264
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
(cherry picked from commit 14e18de90d)
2024-05-03 00:27:39 +02:00
Daniel van Vugt
aa93da72d5 kms/impl-device: Add function meta_kms_impl_device_has_cursor_plane_for
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
(cherry picked from commit b620dbb188)
2024-05-03 00:27:39 +02:00
Carlos Garnacho
1fdae4f856 wayland: Drop meta_wayland_keyboard_get_focus_client()
All its users did not necessarily depend on a MetaWaylandKeyboard
existing, so were ported to using the MetaWaylandSeat global input
focus. This may now be dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
9bdb00c459 wayland: Follow seat's input focus client for primary selections
The concept of "input focus" will exist regardless of a MetaWaylandKeyboard
being available or not, use the seat's focus for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
5ca10c31d1 wayland: Follow seat's input focus client for clipboard selections
The concept of "input focus" will exist	regardless of a	MetaWaylandKeyboard
being available	or not,	use the	seat's focus for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Carlos Garnacho
743fb6df30 wayland: Add meta_wayland_seat_get_input_focus_client() call
This call is meant to replace meta_wayland_keyboard_get_focus_client(),
since we will always have a MetaWaylandSeat with an input focus (or not),
but we may or may not have a MetaWaylandKeyboard.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3707>
2024-04-19 14:42:31 +00:00
Sebastian Wick
cad9a65b07 clipboard-manager: Cancel selection transfers
When there is a new owner but there is no matching mime type we clear
the saved mimetype and the saved clipboard but an outstanding async
meta_selection_transfer_async can set the saved clipboard.

Abort the async transfer when we have a new owner.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3678>
2024-04-19 14:31:01 +00:00
Sebastian Wick
ce32d2b77a clipboard-manager: Make sure we always have mimetype
The precondition checks in meta_selection_source_memory_new can return
NULL if the mimetype is NULL but callers expect the error to be set when
NULL is returned.

Let's just make sure we never call it with a NULL mimetype.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3678>
2024-04-19 14:31:01 +00:00
Carlos Garnacho
5dfed8a431 wayland: Preserve serial for all pressed keys
The current code checking keyboard serials for popup/grab
validation is a bit simple, tracking one key press exclusively.
This may break expectations if a client uses a serial
corresponding to a previous key that is still pressed.

Keep track of the serials corresponding to all pressed keys,
and ensure these are reset across focus changes, since the
validity of those serials is already outdated. The code does
still keep track of a single (last) key release serial, since
the validity lifetime is somewhat underdefined with those if
we keep track of multiple keys simultaneously.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3267
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3644>
2024-04-19 13:50:08 +00:00
Jonas Ådahl
73990f011f window: Set the initial suspend state to 'hidden'
Instead of initializing to 'suspended', which will send the `SUSPENDED`
xdg_toplevel state, set it to hidden at first. If the window is placed
on an inactive workspace, it'll eventually enter the 'suspended' state,
but will have had some time in non-suspended state to get map, even if
not visibly.

This fixes inital suspended state when mapping a window maximized.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3229
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
cf176df006 window: Add internal meta_window_should_show() API
This, in contrast to meta_window_should_be_showing() reports whether a
window should be showing despite not being showable. This is useful to
know the intended visibility state that should happen in the immediate
future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
c5caa4afb5 tests/wayland/client-utils: Add optional xdg-shell v6 support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
f23e1218e3 tests/wayland/client/utils: Add way to mark surface as opaque
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
594cdc5b49 tests/wayland/client-utils: Track xdg_toplevel state
This allows tests to check whether a state is set or not at any given
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00