1
0
Fork 0
Commit graph

12518 commits

Author SHA1 Message Date
Bilal Elmoussaoui
e93fe16241 tests: Move color conform tests from clutter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
2024-06-13 14:45:53 +02:00
Bilal Elmoussaoui
dc52ccc75a cleanup: Port from ClutterColor to CoglColor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
2024-06-13 14:45:53 +02:00
Sebastian Wick
8709fc5353 wayland: Bump connection buffer size to 1MB
Let's increase the connection buffer size a bit to avoid killing
clients which stall just for a few ms when they receive high
frequency input updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3693>
2024-06-13 11:58:14 +00:00
Jonas Dreßler
530659c643 tests/clutter/conform: Wait for stage update right after showing stage
Showing the stage always results in an initial update being queued. If the
virtual input events from the test ends up being dispatched after that, the
`wait_for_update()` checks gets out of sync, as the first update ended up
waiting for the initial update, not the one from the input event.

Fix the gesture test by adding another call to `wait_stage_updated()` right
after `clutter_actor_show()`.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3521
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3795>
2024-06-12 18:45:29 +00:00
Bilal Elmoussaoui
74ece2ad92 clutter: Drop various Color constructors
The fields are writable, there is no need to provide a custom constructor.
This shapes the Color API to be similar to GdkRGBA

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3802>
2024-06-12 16:25:18 +00:00
Bilal Elmoussaoui
04842393aa clutter: Drop Color.from_pixel
Goes along with https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3367
Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3802>
2024-06-12 16:25:18 +00:00
Jonas Ådahl
9d11cc679e 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-12 15:11:04 +00:00
Jonas Ådahl
897c535bd8 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-12 15:11:04 +00:00
Jonas Ådahl
dd8a503f3d 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-12 15:11:04 +00:00
Jonas Ådahl
bbd59ab9e6 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-12 15:11:04 +00:00
Jonas Ådahl
91d43bfbe1 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-12 15:11:04 +00:00
Jonas Ådahl
5bca761148 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>
2024-06-12 11:06:54 +00:00
Jonas Ådahl
6bd2fd6a74 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>
2024-06-12 11:06:54 +00:00
Bilal Elmoussaoui
bb29fa68fe cogl: Remove AtlasTexture.new_from_data
Nothing uses it, allows to drop the corresponding test case as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3804>
2024-06-12 00:42:45 +00:00
Bilal Elmoussaoui
6c972546f1 mtk: Add Rectangle.contains_point
By turning a macro that exists in the codebase to a proper
function so that gnome-shell could make use of it as well
instead of using a region for it contains_point api...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3801>
2024-06-11 00:49:28 +02:00
Daniel van Vugt
2f8a598582 kms/impl-device: Add debug logging for deadline dispatch lateness
And also "completion" time to measure when the commit returned.

This is structured so as to measure all timestamps first before logging
anything. That way our results shouldn't be (don't seem to be) affected
by the logging itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Daniel van Vugt
cf87eae00b kms/impl-device: Remember the expected deadline dispatch time
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Daniel van Vugt
052def76e6 Add debug topic "kms-deadline"
Which will allow us to report on deadline timings without influencing
the CPU clock like the busy "kms" topic does.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3265>
2024-06-10 13:55:21 +08:00
Carlos Garnacho
e731f2a055 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>
2024-06-07 17:02:14 +02:00
Carlos Garnacho
66e23b009c 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>
2024-06-07 17:02:13 +02:00
Carlos Garnacho
17dc9393e0 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>
2024-06-07 17:01:26 +02:00
Sebastian Wick
c166b3fc5b wayland/activation: Apply xdg-activation request when window gets mapped
If the window is not mapped yet and we get an activation request, we
will wait for the window to get mapped or destroyed to try to fullfil
the request.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:06:12 +02:00
Sebastian Wick
77b115399c window/x11: Remove unnecessary user_data
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:05:36 +02:00
Sebastian Wick
fdf9c32dac window: Replace map/unmap vfunc with signal
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3728>
2024-06-07 12:04:27 +02:00
Sebastian Keller
a99e139a68 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>
2024-06-05 15:53:40 +00:00
adarshgm
0ca933baec backend/native: Adds support for SIZE_HINTS Cursor Plane Property
Reads exposed size hints for the given cursor plane. Chooses nearest
minimum cursor size out of the hints with respect to the user chosen
cursor size from the UI. Allocates optimized Hardare cursor size,
hence drm buffer

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3165>
2024-06-04 16:39:16 +00:00
Jonas Ådahl
297ae74771 window: Replace 'winsys_id' for monitor matching
Instead use an abstract "logical monitor id" that is generated from the
logical monitor. Instead of using low level numbers from the mode
setting devices, use either data from the EDID, or the connector, if the
EDID is not useful.

This should help with windows remembering monitor positions when the
same monitor reappears but with another mode setting device ID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3753>
2024-06-04 16:09:50 +00:00
Carlos Garnacho
ad60d7123b 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>
2024-06-03 09:51:30 +00:00
Carlos Garnacho
b968796f1f 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>
2024-06-03 09:51:30 +00:00
Carlos Garnacho
9dab806a18 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>
2024-06-03 09:51:30 +00:00
Georges Basile Stavracas Neto
1d0dc6d6d8 src/backends: Add MetaSubpixelOrder
An exact copy of CoglSubpixelOrder, without the Cogl dependency.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3792>
2024-06-03 08:31:58 +00:00
Marco Trevisan (Treviño)
467746c8a7 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>
2024-05-31 14:51:13 +00:00
Marco Trevisan (Treviño)
0fda3ab8a1 backends/x11/backend-x11-nested: Cleanup the cursor renderer on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
6a04ea9a59 backends/input-settings: Clear the devices list on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
b630c3baa6 backends/backend: Clear egl object if any
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
de8691c7ff 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>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
430e55a535 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>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
c2cc26b370 backends/native/backend-native: Free the device path when stealing the device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
ce1dd40f7b backends/native/thread: Unref the callback sources hashtable on finalize
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
f74a46d98d 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>
2024-05-31 11:01:00 +00:00
Marco Trevisan (Treviño)
c33a02dd32 backends/backend: Cleanup MetaDnd on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3788>
2024-05-31 11:01:00 +00:00
Carlos Garnacho
b35129db61 wayland: Check focus surface to set a pointer cursor
The cursor was following the "current" surface (i.e. the logical
focus, unaffected by e.g. grabs), so MetaWaylandPointer was always
providing window cursors, just so the MetaCursorRenderer would maybe
discard them and show the compositor cursor instead. E.g. in the
presence of grabs.

This clear barrier between grabs being compositor business deserving
a compositor cursor, and non-grabs being client business turned a bit
blurrier in grabs-pt5 where "client" things like popups and DnD would
also involve grabs. The fixes in that regard in the branch went on
the lenient side, introducing situations where grabs do exist but we
are preferring client-side cursors anyways.

Fix this by making MetaWaylandPointer aware of grabs at the time of
updating the client-side cursor, by following the "focus" surface
(i.e. the effective focus, affected by grabs outside of MetaWaylandInput).
The focus surface and cursor will be updated on focus changes, also
induced by grab changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3460
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3736>
2024-05-30 19:18:49 +00:00
dcz
11a4d56185 keybindings: Send trigger when a key accelerator is deactivated
This is neccessary to support the GlobalShortcuts portal which demands Deactivate events.

https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/47

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3680>
2024-05-28 09:27:39 +00:00
Marco Trevisan (Treviño)
b0df2d0f7d frame: Handle X11 errors earlier on frame setting
Avoid changing the stack information if we fail earlier than that

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
e1dbf102dc 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
2065214b71 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
4eb76b565f frame: Define a free function for MetaFrame and use via autoptr
Use clearer memory management for the MetaFrame making it easier
to destroy it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
5b1c0c2123 stack-tracker: Improve documentation why we need to filter x11 windows
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
c202662ca3 stack-tracker: Improve logging when an operation is ignored
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
0653b829c1 stack-tracker: Avoid multiple casts to Window type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3732>
2024-05-27 16:23:20 +00:00
Marco Trevisan (Treviño)
e3d3b257ae window-private: Actually remove frame instance
As per GNOME/mutter!3254 MetaFrame is part of MetaWindowX11Private, but
MetaWindow has still the frame field.

Drop it since it's unused now and can lead to confusion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3784>
2024-05-27 17:11:55 +02:00
Bilal Elmoussaoui
0f19c6f5b6 window: Stop caching frame_bounds
That was only there to force updating MetaFrame's bounds
but that is something that is already updated in
MetaWindowX11.move_resize_internal. So just drop all of that

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
d1b04ffb55 window: Move frame_bounds to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
bcb069f454 window: Move frame field to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
503c70e284 window: Replace get_titlebar usages
Uses the hardcoded value that was used for wayland
clients for x11 ones as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
70f8cc433e window: Move get_session_geometry to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
751ef5abd2 window/x11: Add a is_ssd helper
Would be useful for moving frame field to WindowX11 in the upcoming commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
fff528cbf1 window: Remove shove titlebar onscreen functions
Mutter side of
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3332

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
acbb14f34b window: Move has_custom_frame_extents to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Bilal Elmoussaoui
b4b896d4db core: Move frame related types to x11
Also rename the files to meta-x11-frame* for consistency

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
2024-05-27 12:50:26 +00:00
Philip Withnall
173332e928 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>
2024-05-26 09:19:17 +00:00
Philip Withnall
ca1434ff1e 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>
2024-05-26 09:19:17 +00:00
Bilal Elmoussaoui
7f213c2a2f x11: Use the embedded xcursor functions where possible
Makes those functions that are intended to be used in wayland-only
builds to be tested in x11 code paths as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3607>
2024-05-24 13:02:42 +00:00
Bilal Elmoussaoui
0a46ca67ec core: Include a small subset of xcursor in-tree
For a Wayland only build, we would like to avoid linking against
libXcursor which on it turn, links back to some of the X11 deps.
In order to achieve that, we include a small subset of xcursor.

In case Mutter is built with X11 or with both Wayland & X11, we link
against libXcursor and don't make use of the in-tree implementation.

This patch mimics what GTK 4 do by shipping an in-tree copy of xcursor.
Especially that libwayland-cursor does not provide an alternative to
xcursor itself.

Helps #2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3607>
2024-05-24 13:02:42 +00:00
Sebastian Keller
650ef9b57f 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>
2024-05-23 22:34:19 +00:00
Sebastian Keller
c3e626405f 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>
2024-05-23 22:34:19 +00:00
Sebastian Keller
d4907a960c 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>
2024-05-23 22:34:19 +00:00
Sebastian Keller
d686865918 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>
2024-05-23 22:34:19 +00:00
Sebastian Keller
c0537096c2 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>
2024-05-23 22:34:19 +00:00
Jonas Dreßler
79a79b3450 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>
2024-05-23 20:24:13 +00:00
Jonas Ådahl
6b3a289ab5 wayland/drm-syncobj: Check for sync-fd cogl feature
The syncobj implementation uses cogl_context_get_latest_sync_fd(), so
check that that function will actually work.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3475
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3771>
2024-05-23 16:42:21 +00:00
Carlos Garnacho
69e791cda1 wayland: Implement the XDG dialog protocol
This protocol takes over some of our homegrown GTK Shell
protocol, allowing to specify hints on surfaces such as
dialog modality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3557>
2024-05-22 10:42:20 +00:00
Michel Dänzer
8a862b102c 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>
2024-05-22 08:49:29 +00:00
Michel Dänzer
be4bf8da9c 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>
2024-05-21 16:23:59 +00:00
Michel Dänzer
5749810ddb 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>
2024-05-21 16:23:59 +00:00
Michel Dänzer
ad22833cc3 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>
2024-05-21 16:23:59 +00:00
Michel Dänzer
ba93fcd30f 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>
2024-05-21 16:23:59 +00:00
Sebastian Wick
08c9a775e7 tests: Make sure XDG_CURRENT_DESKTOP is unset
GSettings overrides can be active and set the default value depending on
the XDG_CURRENT_DESKTOP environement variable. For the tests we run, we
rely on the default settings by using the GSettings memory backend but
we also need to make sure not overrides are in place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3730>
2024-05-21 12:16:06 +00:00
Sebastian Wick
301c154f02 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>
2024-05-21 12:16:06 +00:00
Bilal Elmoussaoui
b8c5ea4e1f x11: Remove MUTTER_DISPLAY env variable
It is X11 specific and I don't see why it should be used instead of setting
DISPLAY. Nothing seems to set it either in gdm/gnome-session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3762>
2024-05-21 09:38:35 +00:00
Jonas Ådahl
97af5f8705 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>
2024-05-21 09:22:09 +00:00
Georges Basile Stavracas Neto
638d3355b4 cogl: Drop CoglSwapChain
CoglSwapChain is currently unused, and doesn't hold any information
nor is used for anything in particular.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3759>
2024-05-20 11:45:31 +00:00
Bilal Elmoussaoui
c13956fb9e Use gboolean consts instead of C bools
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3748>
2024-05-20 11:29:54 +00:00
Sebastian Keller
7a38e12ed0 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>
2024-05-20 10:43:40 +00:00
Jonas Ådahl
e2e687c9db 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>
2024-05-19 21:43:10 +00:00
Marco Trevisan (Treviño)
6ab36f7297 tests/stacking: Do struts toggling during monitor-changed event
To simulate better what happens in a real shell environment

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
4eed39ed12 test-runner: Add ability to perform actions on signals callbacks
An action can be performed both on a signal emitted by a window or by
a well-known signal name, so that one can do:

  [window-id]::signal => command

 And so these would work:
  w/1::position-changed => resize w/2 20 30
  ::monitors-changed => move w/1 30 40

We only support "monitors-changed" global signal name or connecting to
window signals for now, but this can be easily expanded adding support
for more global signal values or parsing other kinds of object instances

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
9374fad2b4 tests/stacking: Add test for strut changes together with monitors changes
We have an issue causing windows to be hidden below struts when monitor
changes events happen. While this was easily reproducible in gnome-shell
we had not a mutter stacking test checking it.

Here it is now.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1627
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
fcdfc4c86f test-runner: Add command to reload monitors
This trigger monitors-changed event which leads to lots reconfiguration
changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
c544b38dbb tests/stacking: Add test to verify that setting and adding struts works
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
3686b1cf6f test-runner: Support parsing monitor-relative window positions
Can do: assert_position w/1 MONITOR_WIDTH/2 MONITOR_HEIGHT*0.75

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
8246071c1c test-runner: Add ability to remove struts by side
Removes only struts that are in a certain side

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
0bc873419d test-runner: Add support for add_strut command
It allows to add struts to the ones we already have, as per this we can
re-implement `set_strut` as `clear_strut` + `add_strut`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
ea7357f48a test-runner: Add ability to set strut with monitor-relative sizes
Allows to use:
  set_strut 0 0 MONITOR_WIDTH*0.5 MONITOR_HEIGHT/4 top [default]

We use the currently focused window as the reference monitor if any or
the primary one if no monitor is explicitly provided.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
e250bd1ebb workspace: Add a private getter for builtin struts
It can be used to change current struts without having to
track them at test level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
44c6d02964 workspace: Clean structs using clear GSList utility function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
e005d035c0 boxes: Define cleanup function for MetaStrut and use auto-pointers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Marco Trevisan (Treviño)
8dc6115277 test-runner: Add ability to perform basic divisions and multiplications
We may need to compare monitor size to fractions and while it can be
done using inverse divisions, they were not supported as we didn't parse
floating point values.

So, just add support for both multiplications and divisions, so that we
can easily do stuff like `MONITOR_HEIGHT*3/4`.

Additions would be easy to support too if we don't care about operator
priorities, but that's out of scope for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Jonas Ådahl
5e6aee6367 tests/runner: Make 'wait_reconfigure' actually wait for a reconfigure
We just made an half assed attempt to wait, but e.g. when clients were
waiting for a frame event, the attempt was not enough, as the clients
would not ack any configure until the time they were scheduled to paint
again.

Fix this by actually tracking newly pending configurations, and waiting
for them to return.

On X11, still be lazy and hope for the best, as there is no similar
configuration tracking there.

Some tests were updated to use just 'wait' when there was no actual need
for any extra waiting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
2024-05-17 15:33:52 +00:00
Sebastian Keller
1f1538be76 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>
2024-05-15 14:07:36 +00:00