1
0
Fork 0
Commit graph

11854 commits

Author SHA1 Message Date
Jonas Ådahl
96d4ae5ac8 monitor-manager: Add 'reason' argument to 'power-save-changed' signal
We can change power save mode for two reasons: gsd-power told us to, or
we saw a hotplug event. Sometimes it's useful to be able to make the
distinction to why a power save mode changed, so add a reason to the
signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3233>
2023-09-02 11:07:38 +00:00
Daniel van Vugt
444e241ab4 kms/impl-device: Don't skip set_needs_flush during a page flip
If the deadline timer is disabled (like on nvidia-drm or when
`MUTTER_DEBUG_KMS_THREAD_TYPE=user`), then we need to call
`meta_kms_device_set_needs_flush` on every cursor movement. But some were
getting skipped if they coincided with page flips, which resulted in some
cursor movements failing to schedule the frame clock. This resulted in
unnecessary levels of frame skips when using lower frequency input devices
which are less likely to provide another event within the same frame period.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3002
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3210>
2023-09-02 10:30:58 +00:00
Carlos Garnacho
7224bb8a8d backends: Drop X11 ClutterBackend error traps
Replace these with Mtk error traps altogether, and avoid stacking
one API over the other here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
99bcd20f0a backends/x11: Add pair of error trap init/deinit calls
Add a pair of calls to ensure the error trap infrastructure
survives for the MetaBackend. This will help on later commits that
largely operate on the MetaBackendX11 Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
ef366c5fcb mtk: Make error traps multi-display
Keep a per-display list of error traps, so we don't mix them
together, and possibly deem unintended error traps outdated.

This means init/deinit calls are now stackable, and need to
happen evenly. In order to honor this, move the MetaX11Display
error trap destrution to finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
6f46edd93b x11: Replace Mutter X11 errors with Mtk ones
Use Mtk X11 errors in favor of our own implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Jonas Ådahl
88fef1d021 wayland/idle-inhibit: Handle immediate inhibitor destruction
If the inhibitor object was destroyed immediately, the proxy
construction completing would try to update the inhibitation state, but
this didn't work since it was already freed. Fix this by adding an
'initializing' state that keeps track of this.

Fixes: a3c62bf8aa ("wayland/idle-inhibit: Add state tracking to fix races")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2998
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Jonas Ådahl
10d8c5fa82 tests/dbus-runner: Add mocked screensaver service
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Jonas Ådahl
4a600e1031 test/wayland: Don't double-free GThreads
g_thread_join() frees the thread object, so don't use g_autoptr
(Gthread) when they will all be joined.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Joan Torres
adf12504c0 backends/native: Set headless mode when no seat_id
This forces not using the seat_proxy. But still allows the use of
session_proxy.

On tests, headless mode is explicitly set and it might not be available a
systemd session. To avoid test failing on this situation skip using
meta_launcher wich uses session_proxy and seat_proxy.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3093>
2023-09-01 17:05:16 +00:00
Jonas Ådahl
f0bb540797 remote-desktop/session: Add regions for all monitors if input-only
If we're a input-only remote desktop session, create libei regions on an
absolute pointer device corresponding to all logical monitors. This
allows absolute pointer motions without screen casting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:45:33 +02:00
Jonas Ådahl
b23225cea8 eis: Don't treat EIS errors as fatal
g_error() is fatal, but EIS errors are not necessarily that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
69fad154b9 eis: Use either standalone or shared devices for absolute input
Sometimes it makes no sense to have a shared pointer device, for example
when they have no set region occupying the global stage coordinate
space. This applies to for example window screen cast based pointer
device regions - they are always local to the window, and have no
position.

We do need shared absolute devices in some cases though, primarily
multi-head remote desktop, where it must be possible to keep a button
reliably pressed when crossing monitors that have their own
corresponding regions.

To handle this, outsource all this policy to the one who drives the
emulated input devices. Remote desktop sessions where the screen casts
correspond to specific monitors (physical or virtual), we need to make
sure they map to the stage coordinate space, while for window screencast
or area screencasts, we create standalone absolute pointer devices with
a single region each.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
d4559a9ca4 screen-cast: Implement MetaEisViewport in all stream types
This will be used to describe a eis_region in a eis_device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
7faac2aef4 remote-desktop/session: Add API to acquire new mapping ID
They are guaranteed to be unique per session, and never reused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
b3ba8aedcb eis: Tear down in dispose
This means clients can disconnect signals without warnings being logged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
27b790d8c1 screen-cast: Pass remote desktop session on construction
We already have the remote desktop session ID, and we'll soon need the
actual remote desktop session in the screen cast session, so pass it on
construction.

The old screen cast type is set implicitly instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
f5e063ab57 eis: Fix header include style
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
271fb86b15 eis: Add "viewport" interface
A MetaEisViewport represents an absolute region backend by e.g. a
pointer device. There are two kinds: a standalone viewport, which
corresponds to a viewport that has no neighbours, and a non-standalone,
which represents a region of a global coordinate space.

The reason for having non-standalone viewports is to allow to mirror the
logical monitor layout of a desktop, while the standalone are meant to
represent things that are not part of the logical monitor layout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
12c7c1bffb eis/client: Add user_data to add-device helper
This will allow passing extra context to the configure function.
Currently all NULL, but preparing for the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
63acc732ad eis: Add some spacing in API declarations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
2eda81aadf remote-desktop/session: Limit device type access when using libei
The portal could limit access to certain device types, but this was not
forwarded to the EIS context. Add a way to do this, and make use of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
72cc627546 eis/client: Fix minor coding style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
e2a9e6c36b eis/client: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
0160f3c0a0 remote-desktop/session: Take over EIS context
This means there will be an EIS context per session, which will enable
per session devices and region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
ce61c8dc61 eis: Don't expose global socket
How EIS will be used depends on its context, meaning we'll have multiple
EIS contexts that expose different things. To prepare for this remove
the global socket since that won't work with multiple contexts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
7e8bc5850e eis: Remove meta_ prefix from variables
This is more or less never used elsewhere, so don't start here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Bilal Elmoussaoui
da380f2732 boxes: Drop the MetaRectangle typedef
As gjs actually doesn't support typedef/aliases and there is now
a workaround from gnome-shell instead as part of
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2930

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3231>
2023-09-01 09:42:48 +00:00
Daniel van Vugt
98738535dc thread: Remove unused variable when HAVE_PROFILER is not defined
This fixes a compiler warning:
```
meta-thread.c:297:16: warning: unused variable ‘context’ [-Wunused-variable]
  297 |   MetaContext *context = meta_backend_get_context (priv->backend);
      |                ^~~~~~~
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3223>
2023-08-31 22:18:11 +00:00
Daniel van Vugt
fdbd38121b x11/events: Don't define an unused function when tracing is disabled
This fixes a compiler warning:
```
src/x11/events.c:523:1: warning: ‘get_event_name’ defined but not used [-Wunused-function]
  523 | get_event_name (MetaX11Display *x11_display,
      | ^~~~~~~~~~~~~~
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3223>
2023-08-31 22:18:11 +00:00
Carlos Garnacho
aed9f7eb9d backends: Make base MetaCursorRenderer implementation want an overlay
This used to be the behavior, until commit 5d35138df0 changed the meaning
of the return value of MetaCursorRendererClass::update_cursor(). This
made the user of pure-overlay cursors (singular, MetaWaylandTabletTool)
miss their overlays.

Change the return value, so that it matches the desired behavior of
a backend-less overlay-only cursor renderer.

Fixes: 5d35138df0 ("cursor-renderer: Make 'handled_by_backend' state 'needs_overlay'")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3218>
2023-08-31 21:46:35 +00:00
Carlos Garnacho
d24be90941 backends/native: Fix accounting of cursor overlay inhibition
We react on changes to has_hw_cursor, but always try to inhibit if
there is no cursor sprite. While this looks like a reasonable optimization
with the typical situation of one cursor renderer, it may fall into
inhibiting twice without knowing to unwind, e.g.:

1. has_hw_cursor: TRUE, cursor_sprite: !=NULL -> inhibit
2. has_hw_cursor: FALSE, cursor_sprite: NULL -> inhibit
3. has_hw_cursor: TRUE, cursor_sprite: !=NULL -> uninhibit, but once

And this may also result in the CLUTTER_PAINT_FLAG_NO_CURSORS flag
staying on for Tablet cursors, that (so far) always use overlay paths.
This results in invisible tablet cursors after using the mouse at
least once.

Fixes: e52641c4b6 ("cursor-renderer/native: Replace HW cursor with KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3218>
2023-08-31 21:46:35 +00:00
Carlos Garnacho
630f13db78 x11: Handle ConfigureRequest events in frames
Under strange timings, the GTK frames client may implicitly queue
relayouts that end up disagreeing with the latest frame size as
given by Mutter, this results in GTK calling XResizeWindow, and
Mutter plain out ignoring the resulting XConfigureRequestEvent
received.

This however makes GTK think there's pending resize operations,
so at the next resize it will freeze the window, until enough
resizes happened to thaw it again. This is seen as temporary
loss of frame-sync ness (e.g. frozen frame, and other weird
behavior).

In order to make GTK happy and balanced, reply to this
XConfigureRequest, even if just to ignore it in a more polite
way (we simply re-apply the size Mutter thinks the frame should
have, not GTK), this results in the right amount of
ConfigureNotify received on the frames client side, and the
surface to be thawed more timely, while enforcing the size as
managed by Mutter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2837
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3189>
2023-08-31 20:53:04 +00:00
Daniel van Vugt
025e5d5327 Remove unused *.pc.in
It seems *.pc are instead now entirely generated from meson.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3226>
2023-08-31 09:47:50 +00:00
Bilal Elmoussaoui
788caf76aa boxes: Add an alias for MetaRectangle
This is meant for compatibility purposes with the shell extensions
avoiding to break a bunch of them in the last minute and we would
drop it in the GNOME 46 release.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
640cbf339f tests: Move Mtk specific tests from boxes
More of the boxes tests would be moved once we have a new region type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
1abef24154 mtk: Move Rectangle.from_graphene_rect from Meta
And drop the clutter helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
a93471eb90 mtk: Move Rectangle.to_graphene_rect from Meta
Also drops the clutter equivalent

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
3d693e8309 mutter: Completely replace MetaRectangle with MtkRectangle
There are still various helpers that might be worth to move to mtk as
well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
aec8e50df8 mtk: Move Rectangle.[contains|could_fit]_rect from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
eafe07de31 mtk: Move Rectangle.overlap_* from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
db77759938 mtk: Move Rectangle.area from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
af7c7befd8 mtk: Move Rectangle constructors from Meta
Also rename the rect constructor from mtk_rect to mtk_rectangle_new so
it is detected as a proper constructor instead of a random function by
g-ir-scanner

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
565acaed9c mtk: Move Rectangle.intersect from Meta
Also replaces it usage everywhere & remove the Clutter helper. Note the
tests were not moved yet to mtk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
6f66dd9944 mtk: Move Rectangle.union from Meta
Similar to Rectangle.equal. The clutter helper was not used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
9b2cba4e86 mtk: Move Rectangle.equal from Meta
Moves equal the equal function and removes the clutter equivalent. The
tests were not moved until all the remaining helper functions are moved.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
918ae0f4d4 mutter: Replace cairo_rectangle_int_t with MtkRectangle
Note: the various helpers in boxes.c were not ported yet, see the next
commit. This was intentionally done to simplify the porting process

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
765a918a62 build: Add a Meta Toolkit private library
Currently, Meta/Cogl/Clutter makes use of cairo_rectangle_int_t despite
the existance of MetaRectangle.

In order to make MetaRectangle usable in Cogl/Clutter as well, Mtk would
provide such base types that are shared across the various private
libraries

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Sandro Bonazzola
ff4d87727b Update license access method
Dropped obsolete Free Software Foundation address pointing
to the FSF website instead as suggested by
https://www.gnu.org/licenses/gpl-howto.html
keeping intact the important part of the historical notice
as requested by the license.

Resolving rpmlint reported issue E: incorrect-fsf-address.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3155>
2023-08-30 08:48:23 +02:00
Bilal Elmoussaoui
b004d1c577 cleanup: Drop empty vfuncs overrides
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3209>
2023-08-29 23:38:32 +00:00
Carlos Garnacho
7d8d7c89d4 backends: Check that buffer age is available when checking damage history
This used to be the case before the refactor at commit 43cee4b6b6,
use_clipped_redraw would be unset before the larger check if has_buffer_age
was set, but clutter_damage_history_is_age_valid() was FALSE. This got
replaced by a check just on the latter, which will also be FALSE if
has_buffer_age is not present.

We have other means to achieve clipped redraws, so this slight change
culled all of them.

Fixes: 43cee4b6b6 ("stage-impl: Do clipped redraws when drawing offscreen")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2771
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3221>
2023-08-29 11:27:35 +02:00
Jonas Ådahl
a3c62bf8aa wayland/idle-inhibit: Add state tracking to fix races
This changes how state is tracked by introducing an explicit state. We
need this since we use asynchronous calls to the out of process
component that handles actual inhibitation, including idleness.

This means if inhibitations changes rapidly, we might end up with an
incorrect state if we e.g. try to uninhibit while we're currently trying
to inhibit.

This is done by adding a state variable that accounts for the pending
state, as well as the active state, with a function that looks at the
current conditions to derive what state we should be in, and what state
we are in, to decide what the next action should be.

For example, if we're trying to inhibit, but now wants to uninhibit,
we'll wait for the inhibit call to complete, recheck what we want, which
would result in an async uninhibit call being made.

Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 19:16:04 +02:00
Jonas Ådahl
34b60757c2 wayland/surface: Add signal for when the actor changes
This can happen on a xdg-toplevel that is remapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:25:08 +02:00
Jonas Ådahl
170ba63dbf wayland/idle-inhibit: Change to use GObject signals
Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:25:03 +02:00
Jonas Ådahl
45abae7ebb wayland/idle-inhibit: Remove confusing comment
Something about the surface being destroyed and visibility checked,
which isn't what is going on.

Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:24:59 +02:00
Charbel Assaad
388b534062 wayland: Implement idle inhibit protocol
This is based on the original work done by:
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/111

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/20
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3145>
2023-08-26 20:19:22 +02:00
Sebastian Keller
8db400660a backends/x11: Drop warning about libinput property item count
libinput 1.3 introduced a custom acceleration profile extending the
related properties from 2 to 3 items, which now triggering this warning.
This does not have a functional impact since GNOME currently does not
make use of the new profile. Also increasing the libinput version
dependency which would be needed to change the expected item count is
not possible in a stable release either. So just drop this warning to
be compatible with newer versions of libinput.

See: https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/-/merge_requests/39#note_1656566
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2987
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3215>
2023-08-26 12:15:47 +02:00
Jonas Ådahl
e683264051 tests: Add metatests for cloned windows and suspend state
Tests https://gitlab.gnome.org/GNOME/mutter/-/issues/2984.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
87b7b073d3 window-actor: Don't update suspend state if no window
If the window is gone, don't try to update it. This might happen on
unmap animations with active clones.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2984
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
cb6290832e tests/test-runner: Add utilities for testing cloned windows
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
9df38c2126 tests/test-runner: Fix include order
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
baa0f62ced tests/shell: Restore minimized actor state in idle callback
This fixes the following
1. Minimize window; minimize animation starts
2. Do something that immediately destroys the animated actor (e.g. terminate)
3. This triggered the timeline of the animation to emit a "stopped"
   signal while all transitions of the actor were destroyed

Previously we'd implicitly animate the scale again (set_scale(..)) which
created a new transition The hash table iterator didn't like this and
abort():ed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
1e25cb746a window: Don't update suspend state after unmanaging
The actor will try to update the suspend state when it goes away, which
can in the case of unmap animations be after the window was unmanaged.
In this case, don't try to update any suspend state.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2984
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 15:48:19 +02:00
Jonas Ådahl
b743cc3528 tests/test-runner: Add 'sleep suspend_timeout' command
It's a tweak to the 'sleep' command to allow well known sleep lengths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 15:47:05 +02:00
Jonas Ådahl
5071a6df87 wayland/xdg-shell: Set the suspended state to suspended windows
This will allow clients to e.g. enter power saving mode when they are
e.g. on another workspace, minimized or fully obstructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
3af02e1b57 wayland/xdg-shell: Implement support for xdg_toplevel.wm_capabilities
Nothing dynamic yet, we don't have API for this, but we need it to
implement the next version. Sending "all" should be equivalent to v4
anyhow, so this is harmless.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
9a2c8b2592 window: Add suspend state
The 'suspend state' is meant to track whether a window is likely to be
visible any time soon. The hueristics for this are as follows:

 * If a window is hidden, it will enter the 'hidden' state.
 * If a window is visible, and unobscured, it will enter the 'active'
   state.
 * If a window is visible, but obscured by another window, it will enter
   the 'hidden' state.
 * If there is a mapped clone of a window, it will enter the 'active'
   state.
 * If the window has been in the 'hidden' state for 3 seconds, it will
   enter the 'suspended' state.

This will eventually be communicated to Wayland clients so that they can
change their behaviour to e.g. save power.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
2d7a062913 window-actor: Be more consistent declaring the property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:57 +00:00
Niels De Graef
069fe8e915 src: Chain up to finalize()
We forgot to chain up to the parent class' `finalize()` vfunc in both
`MetaEis` and `MetaEisClient`. Plugs 2 (probably tiny) memory leaks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3203>
2023-08-22 21:57:07 +02:00
Daniel van Vugt
c4d7265656 kms/cursor-manager: Transform cursor movement from view space to CRTC
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2955,
        https://gitlab.gnome.org/GNOME/mutter/-/issues/2957

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Daniel van Vugt
ca27dbabd9 backends/native: Pass cursor transform from renderer to cursor manager
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Daniel van Vugt
5a05b1a901 monitor-transform: Invert the behaviour of transform_point
Previously it transformed a physical CRTC coordinate to a logical desktop
coordinate. But current and future users of the function all require
conversion from logical coordinates to physical coordinates. We would have
had to always invert the transform parameter which is a waste of time when
we can instead just invert the function behaviour.

We also simplify the parameters to show both the point coordinate and the
area dimensions are potentially transformed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Sebastian Keller
133931e3a3 core: Don't unmap XWayland windows without buffers on visibility update
18be74ed was changing meta_window_should_be_showing_on_workspace() to
only show XWayland windows when they have buffers to prevent starting
transitions with a seemingly black window.

This however did not just delay the transition, but when called in
meta_window_update_visibility() could result in the X11 window getting
unmapped again if the call happens before there is a buffer. Then,
depending on the client, the window would either remain hidden or if the
client tries to map the window again, this would repeat the process,
triggering the closing transition every time.

This commit instead just hides the XWayland window from the compositor
but keeps the corresponding X11 window mapped while it does not have a
buffer yet.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2611
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2965
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2820
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2867
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3194>
2023-08-21 18:32:41 +00:00
Carlos Garnacho
5d72be4016 backends/native: Regain time precision in a11y generated events
Get times in microseconds, instead of converting from milliseconds.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Georges Basile Stavracas Neto
d4c923edf9 screen-cast/window-src: Report alpha-enabled pixel format
This allows windows screencasts with proper shadows, instead of
a black border around the window!

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2099
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:42:04 -03:00
Georges Basile Stavracas Neto
215b91a2e6 screen-cast/src: Consider preferred format for stream
When creating a new stream, check if the preferred format is
different from the default (COGL_PIXEL_FORMAT_BGRX_8888). If
it is, then also include it in the list of potential formats
for the stream.

COGL_PIXEL_FORMAT_BGRX_8888 is still passed around as it's
both the default, and the fallback for when things go wrong.

When creating buffers, use the negotiated SPA format instead
of a hardcoded value. We leave it to PipeWire to figure out
what's the best format, since clients may not support the
preferred format of the stream.

Due to how chaotic things got, this commit also cleans up
the create_pipewire_stream() to use an auxiliary array of
SPA formats, which is then iterated on in order to generate
the format pods.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:42:04 -03:00
Georges Basile Stavracas Neto
b6bf6572a1 screen-cast/src: Add get_preferred_format vfunc
This allows subclasses to hint which pixel format they would
prefer to be used. It may or may not be respected, depending
on the available hardware capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
e24be82c12 backends/screen-cast: Pass pixel format to DMA-BUF constructor
Following the previous commit, do the same function parameter
treatment to meta_screen_cast_create_dma_buf_handle().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
b391ded7bf renderer/native: Try to convert and use Cogl format
Convert the CoglPixelFormat format to a DRM format, and try
and use it to create a GBM buffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
b814aff600 common/drm-formats: Add function to map Cogl → DRM
It's basically the reverse mapping. It does not deal with
multiplanar formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
fdc3f3fec3 cogl/renderer: Pass pixel format to DMA-BUF constructor
In future commits, we will want to create DMA-BUFs with pixel
formats other than COGL_PIXEL_FORMAT_BGRX_8888. In preparation
for that, let's start passing a new pixel format parameter to
this function, and the corresponding winsys vfunc.

All callers of this function pass COGL_PIXEL_FORMAT_BGRX_8888
for now. Next commits will change that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
14ed29e7b2 renderer/native: Trivial variable rename
Rename 'format' to 'drm_format' to not clash with following
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Sebastian Keller
73bc074917 core: Destroy the correct opaque region when destroying a frame
Freeing the window opaque region rather than the frame one when was
leaking the frame opaque region and wrongly setting the window opaque
region to NULL.

Fixes: 82b2b7688 ("core: Add infrastructure to keep window frames' opaque regions")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-17 00:00:55 +02:00
Sebastian Keller
f57c239a26 kms/cursor-manager: Free struct in meta_kms_cursor_manager_impl_free()
The free function was not actually freeing anything, which was causing a
small leak.

Fixes: 6d873036e ("Add KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-17 00:00:39 +02:00
Sebastian Keller
5fdb6a847f kms/update: Free struct in meta_kms_crtc_color_updates_free()
The free function was only freeing the structs its members were pointing
to, but not the struct itself, causing a small leak.

Fixes: 0180ffdaa ("backends/native: Introduce MetaKmsCrtcColorUpdate")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Sebastian Keller
193a21c601 surface-actor-wayland: Fix leak in apply_transform()
Using g_object_get() to get the allocation creates a copy that needs to
be freed by the caller.

Fixes: e94b52777 ("surface-actor/wayland: Implement stable size and position rounding")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Sebastian Keller
03ba3a825e context: Fix a small leak in meta_context_main_get_x11_display_policy()
The caller of sd_pid_get_user_unit() is supposed to free the unit name
string.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Carlos Garnacho
90a00dae99 compositor: Handle grab state through ClutterStage::is-grabbed handler
This is something the compositor could now track by itself, instead of
being pushed through events. It also makes more sense to do this directly
when the grabbing conditions change, as opposed to the next event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
0b9f5ae75b tests: Add test case for restoring focus after overview
This is a test case for
https://gitlab.gnome.org/GNOME/mutter/-/issues/2690.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
05eeb684d1 window: Postpone focusing until grab ended if uninteractable
When GNOME Shell is in the overview, we don't want windows to steal
focus left and right, but once we leave the overview, we do want
whatever was mapped with "take_focus" to get focus. Do that, but after
the last grab was dismissed.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2690
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
587c31b611 tests/test-runner: Add toggle_overview command
This will emit the `overlay-key` key which will be handled by the test
shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
8268ec2ee8 tests/test-shell: Emulate overview grabs
This mimics what gnome-shell does when the overview is shown. This means
having a grab active, and setting the keyboard focus to the stage
itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
524c9aa458 tests: Introduce and use a custom test shell
Except for the tests that launches `mutter`, use a custom shell
implementation. It's roughly a copy of default.c with some cleanups on
top. A custom shell allows for a bit more freedom when doing testy
things.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
92051d59a6 constraint: Use WxH format for size in debug logs
Whether W,H or +W,H means "size" or "position" is rather unclear; fix
that by formating size as WxH instead of +W,H.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3124>
2023-08-12 21:11:15 +00:00
Bilal Elmoussaoui
cd27cb5c85 cleanup: Fix various typos
Using the typos cli app

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3169>
2023-08-12 20:13:37 +00:00
Michel Dänzer
04f18ae726 backend/x11: Free barriers in meta_backend_x11_dispose
Should fix a memory leak.

Fixes: 0debb24e12 ("barriers: Make barriers fully part of the
backend").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
b081e51a21 Remove unused meta_x11_display_increment_event_serial
Unused since dfcefd3315 ("Remove meta_core_increment_event_serial").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
1a5fb51396 Remove unused meta_window_x11_has_active_sync_alarms
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
75a7870259 Remove unused meta_wayland_tablet_pad_group_lookup_resource
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
76c5eb0060 Remove unused meta_wayland_pointer_constraint_get_seat
Unused since 8a8d47725c ("backends: Delegate pointer confinements to
an impl object").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
09feed5d21 Remove unused meta_wayland_data_device_is_dnd_surface
Unused since 6ec7fa2cbd ("wayland: Use surface role when special
casing surface commits").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
16e8bb34de Remove unused meta_stack_get_bottom
Unused since 1b3a58c951 ("...").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
830f8fcf06 Remove unused meta_seat_x11_lookup_device_id
Unused since d72bacb3cd ("backends/x11: Drop handling of
XI_DeviceChange").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
58326c85a4 Remove unused meta_seat_impl_get_devices_in_impl
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
43716457d1 Remove unused meta_renderer_x11_nested_ensure_legacy_view
Unused since fc8a4afc45 ("Remove meta_is_stage_views_enabled()").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
3b847f28ad Remove unused meta_region_scale_double
Unused since 8b3c1f4b87 ("cullable: Generalize actor coordinates space
translation for regions").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
65add94bfd Remove unused meta_rectangle_edge_to_string
Unused since 52bc675fcb ("introspection: remove --allow-unprefixed")
(if ever used at all).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
15df7c62a3 Remove unused meta_power_save_to_dpms_state
Unused since 5f6aee3419 ("kms/update: Make power saving an update wide
change").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
c3afdefd15 Remove unused meta_output_is_laptop
Unused since cbb2a286f2 ("monitor-manager: Don't use wacky physical
dimensions in display name").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
d3ec28848b Remove unused meta_monitor_get_crtc_mode_for_output
Unused since e52641c4b6 ("cursor-renderer/native: Replace HW cursor
with KMS cursor manager").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
7f9b71cd42 Remove unused meta_kms_update_drop_plane_assignment
Unused since 02b1cfe08f ("onscreen/native: Handle unexpected scanout
failures async").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
f4b8704ae9 Remove unused meta_keymap_x11_get_key_group
Unused since 09b956997c ("backends/x11: Drop platform-specific event
data").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
fbe904471c Remove unused meta_get_renderer_native_parent_vtable
Unused since fe72876b20 ("cogl/onscreen: Make swap_buffer/region
CoglOnscreen class vfuncs").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
a9b42c5c10 Remove unused meta_frame_native_set_kms_update
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
a828eab13c Remove unused meta_crtc_kms_is_gamma_invalid
Unused since 24bdafa220 ("onscreen/native: Track GAMMA_LUT
invalidations here").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
3bf3b14e3f Remove unused meta_crtc_kms_get/set_cursor_renderer_private
Unused since e52641c4b6 ("cursor-renderer/native: Replace HW cursor
with KMS cursor manager").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
bdad097af1 Remove unused *_menu_for_rect functions
Unused since 84785951fd ("x11: Remove MetaX11WindowControl").

v2:
* Leave struct _MetaPluginClass::show_window_menu_for_rect, still used
  by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
63a7313a1b compositor: Fold meta_compositor_do_manage into meta_compositor_manage
meta_compositor_manage hasn't been public API since 4b3cab2cca
("compositor: Don't make internal API public").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
bf53623128 Remove unused meta_clutter_x11_get_root_window declaration
The corresponding definition was removed in e4e0eaac9d
("clutter/backend/x11: Stop keeping track of the screen and root window").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
b0c6864b28 Remove unused meta_stack_get/set_positions
Unused since 9e51d98f4a ("Remove tabpopup and friends").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Bilal Elmoussaoui
f2f9e63568 build/gi: Set header & pkgconfig names
So that the docs generated by gi-docgen contains them

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3087>
2023-08-12 19:34:20 +00:00
msizanoen
6b79a0bae1 cullable: Split unobscured and redraw clip region culling
This splits culling into two different phases to move unobscured region
culling to pre-paint to fix #2680. This is needed as direct scanout
skips the paint phase altogether, but the pre-paint phase always runs as
it's used for selecting the direct scanout surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3127>
2023-08-12 10:27:45 +00:00
Carlos Garnacho
1d6d8d45d0 clutter: Update ClutterActorClass event vmethods to use ClutterEvent
With the ClutterEvent subtype structs sealed, this remains the only useful
struct type that is now usable on the Javascript side. Make all
ClutterActorClass event vmethods use ClutterEvent, and update all users
to this change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3163>
2023-08-09 11:53:18 +00:00
Carlos Garnacho
f168866369 backends/native: Fix handling order of key event
First create the event with the current xkb modifier mask, then
update the xkb_state and the modifier mask. This is how it happened
before commit 2e8d839708, and how it should stay.

Fixes: 2e8d839708 ("backends/native: Port to new event constructors")

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2951
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3162>
2023-08-09 11:36:42 +00:00
Carlos Garnacho
dc527ed510 backends/native: Close the input thread in all situations on dispose
In test situations we sometimes do not create a libinput context, so
our check on dispose to see if we need closing the input thread is off
if META_SEAT_NATIVE_FLAG_NO_LIBINPUT was provided.

Check the input thread existing instead, since that is the thing we
want to undo here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
ba4795a5f9 tests: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
60aa098e94 backends/x11: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
dbbfd03436 backends/native: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
8f3e503c04 backends: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
64490c3489 wayland: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
71fb87a9f2 compositor: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
17191d5a6c core: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:11 +02:00
Carlos Garnacho
9dd2edac18 clutter: Add private call to describe an event
Move the string construction bits in the event logging happening in
MetaSeatImpl to a clutter_event_describe() call, so that it has more
freedom in fiddling with ClutterEvent internals, and may be potentially
reused in other places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
97213041e8 clutter: Add getters/arguments for missed ClutterEvent fields
Add methods, and change the API of some rarely used methods, in order
to make all event info currently held/necessary accessible through
ClutterEvent getters, instead of direct field access.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
562c5532c4 backends/native: Rewrite event for sticky keys
Avoid modifying the event in place, and use a full copy with changed
modifiers, for sticky keys purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
2c86bff0cc backends/x11: Drop clutter_event_set_state_full() helpers
Since the full decomposed modifier state is unused, and only the
effective modifier mask matters to users, the new constructors take
just this effective modifier mask. This	means this helper went
unused in the port to the new constructors, so can be now dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
a837b105d0 backends/native: Drop clutter_event_set_state_full() helpers
Since the full decomposed modifier state is unused, and only the
effective modifier mask matters to users, the new constructors take
just this effective modifier mask. This means this helper went
unused in the port to the new constructors, so can be now dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
2e8d839708 backends/native: Port to new event constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
1f9e787b83 backends/x11: Use new constructor for emulated pointer events
Use the new constructor to generate a synthesized motion event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
75e8bab1c1 backends/x11: Use new event constructors
Use the new event constructors to create input events, instead
of creating them through clutter_event_new (CLUTTER_NOTHING) and
struct field fiddling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
85b13ebd18 core: Pass ClutterStage explicitly to MetaGestureTracker
Pass a ClutterStage argument explicitly, instead of fetching it
from the event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
77510ca72d wayland: Avoid getting the ClutterStage through ClutterEvents
Fetch the ClutterStage through other means, as that field will go
away from events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
af9d406610 tests: Avoid getting the stage through ClutterEvents
Obtain the stage through other means, as this information will
eventually move away from events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
6fd7f95ed3 tests: Port faked events to new constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
c5fc9481c5 backends/x11: Drop return value from main XEvent handler
This return value is unchecked, and may be removed. While at it
rename the function to meta_backend_x11_handle_event().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:00:35 +02:00
Carlos Garnacho
ca3256ee97 backends/x11: Rename function to reset X11 cached current monitor info
This is done from the backend X11 connection, but needs directing at times
from the frontend X11 connection. Commit 5a8509f895 added a XEvent
argument presumably for possible future expansions that did never come.

Since this function is nothing about events, drop the XEvent argument and
make the name a little bit more ad-hoc (according to what it does, at
least).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:00:11 +02:00
Carlos Garnacho
d5938958c0 clutter: Drop ClutterBackend translate_event vmethod
Despite the attempt to make this a generic interface, this was
pretty much used only by the X11 backend, and now it ported away
from it.

This now stands unused and may be removed, in favor of backends
each creating and injecting events as they please.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
b3d6ae34ee backends/x11: Handle MetaSeatX11 event translation in main event handler
This is about the only reason now to go through the ClutterBackend
translate_event vmethod. We can do that directly, and stop requiring the
generic vmethod that is actually just used for X11 events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
990a50539e backends/x11: Handle stage events from the main XEvent handler
This does not do any event translation, so does not need to be
handled through the translate_event() ClutterBackend vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
830a5c0caa backends/x11: Drop unused event time accounting in MetaClutterBackendX11
This has been unused for some time, by the looks of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
a5519fe544 backends/x11: Drop MetaClutterBackendX11 event filters
These are now unused, and may be removed. Event handling in
the backend Display should happen directly from the XEvent
handler from now on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
def478edc8 backends/x11: Handle a11y changing XKB events together with other XKB events
There's no need for an XEvent filter, since this is already code close enough
to MetaBackendX11 XEvent handling and always required anyways. Make the a11y
configuration checks happen directly from MetaBackendX11 event handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:41 +02:00
Carlos Garnacho
0dfb5d1c31 backends/x11: Call cogl xlib event handler directly when handling XEvents
We are pretty much guaranteed that the first event will be handled after
the cogl renderer has been set up. We can avoid the loop through
ClutterBackend vmethods and X11 event filters, and call this directly
from the code that is already close to the MetaClutterBackendX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
a08eea7f10 backends: Do not use clutter_event_[set|is]_pointer_emulated()
Add a new ClutterEventFlag to propagate this information, affecting
a few selected events on each backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
9e96b523ea wayland: Change MetaWaylandDragDest::motion vmethod signature
Stop taking a ClutterEvent and pass the essentials here (x/y/evtime),
we don't have a ClutterEvent handy in all places that we call this
API, and it feels awkward to create one just for calling this vmethod.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
2e3d55c948 clutter: Change clutter_do_event() name/signature
It is a bit backwards that events contain information about
the stage they are being handled by. It makes more sense to
specify in the ClutterEvent handling entrypoint the stage
that will handle the event.

As a first step, add this ClutterStage argument, even though
the information is still carried through the event in order to
keep satisfying calls to the getter function.

This entrypoint has been also renamed to clutter_stage_handle_event(),
so that its ownership/namespace is clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
72c433ef02 compositor: Stop forwarding MapNotify events back through the backend
Nowadays, all our MapNotify event handling happens already prior to
the MetaCompositorX11 handling of XEvents. It does not make sense to
channel these events again through the backend, at best all it could
lead to is double handling of the same events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Bilal Elmoussaoui
a955f0e47c cleanup: Make include macro usages consistent
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Olivier Fourdan
d291d4a733 settings: Set xwayland_allow_byte_swapped_clients at startup
The value for the key "xwayland-allow-byte-swapped-clients" was being
updated on change, but never actually set at startup.

As a result, Xwayland was spawned with byteswap clients disabled, even
if the key was set to TRUE.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2938
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Olivier Fourdan
b9b26cba03 settings: Use appropriate type for xwayland-allow-byte-swapped-clients
The key "xwayland-allow-byte-swapped-clients" is of type boolean, it's
not a flag.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Olivier Fourdan
e35eafebba settings: Remove stray new line
Cosmetic only, no functional change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Jonas Ådahl
8a20d20fe9 kms/cursor-manager: Set hotspot
This is important when running via virtual machines.

Fixes: 6d873036e0 ("Add KMS cursor manager")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2916
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Jonas Ådahl
6ea816184d cursor-renderer/native: Scale hotspot correctly
This got lost during the switch to the KMS cursor manager.

Fixes: e52641c4b6 ("cursor-renderer/native: Replace HW cursor with KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Jonas Ådahl
730efb17d7 cursor-renderer/native: Change comma to semi colon
It was a typo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Bilal Elmoussaoui
68b4cc661d clutter: Remove deprecated & unnused enums
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
185058456f clutter: Remove deprecated BoxLayout pack-start property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
8d038789f6 clutter: Remove deprecated macros usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Carlos Garnacho
cd39ba8baf core: Get per-direction pad feature labels for rings/strips
Let the caller specify the directions, so that the pad OSD UI may
assign distinct labels to each direction, instead of showing an
unified one on both directions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e3660ae5f core: Drop META_PAD_DIRECTION_NONE
Avoid this strange value, and stick with the ones suitable
for rings/strips.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e6f7a9463 core: Drop META_PAD_FEATURE_BUTTON value
This is now handled externally through separate API calls.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
2da9b67673 core: Separate pad button labels in high-level MetaDisplay API
These "features" are somewhat less featured, it's becoming too ugly
to handle all of them with a single API call. The clear outlier are
buttons, so move them to a separate function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
b6a6e9f187 core: Separate MetaPadActionMapper pad button labeling
This will be handled separately in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
85ac3a2d1a wayland: Separate pad button labeling from other pad features
This will be fully split in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
233e612ef8 core: Rename MetaPadActionType to MetaPadFeatureType
We want to separate pad buttons from strips and rings for
purposes of labeling. Start by renaming the enum "features"
to use a less englobing word.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Jonas Ådahl
112cca75e2 kms/impl-device: Remove deadline timer arming from queue_update()
queue_update() in a previous iteration was called in two situations:

 * A page flip was already pending, meaning if we would commit an
   update, it'd fail with EBUSY.
 * A update was marked as "always-defer" meaning it should only be
   processed from the deadline callback (would there be one). These were
   used for cursor-only updates.

In the latter, we had to arm the deadline timer when queuing a new
update, if it wasn't armed already, while in the former, we would
currently idle, waiting for the page flip callback. At that callback
would the deadline timer be re-armed again.

Since we're only handling the former now, we'll never need to arm the
timer again, so remove code doing so. The code removed were never
actually executed anymore, after the "always-defer" flag on updates was
removed.

Fixes: 27ed069766 ("kms/impl-device: Add deadline based KMS commit scheduling")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2940
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3150>
2023-08-07 15:59:18 +00:00
Daniel van Vugt
bafea13e95 kms/impl-device: Handle empty updates properly
This fixes freezes on cursor movement when:

1. meta_onscreen_native_finish_frame would create an empty update.
2. maybe_update_cursor_plane would leave it empty (!cursor_invalidated).
3. do_process would fail to recognise a non-null empty update as an error.
4. meta_kms_impl_device_handle_update would fail to send feedback on errors
   from do_process, because do_process is meant to do it.
5. Page flip listeners would wait forever for feedback that never comes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2923,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2924,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2926,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2933

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3138>
2023-08-07 16:51:43 +08:00
Daniel van Vugt
b516b009fa kms/impl-device: Treat handling update as flushing
Primary plane updates were forgetting to do this in OnscreenNative, but
rather than do it for each post there we should simply do it for each
post.

This fixes cursor stutter in the fallback path (not using deadline timers)
where needs_flush_crtcs would remain populated but CRTC_NEEDS_FLUSH would
never be emitted, because handle_flush hadn't been called for the last
post.

This is safe as the current use of scheduled flushing is only for cursor
updates, and since cursor updates happen on the same thread as processing,
and due to the fact that we always use the most up to date cursor position
when flushing, we never risk leaving an old cursor state unflushed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3138>
2023-08-07 16:50:36 +08:00
Daniel van Vugt
7493ed39ce kms/impl-device: Avoid retrying a failing deadline timer
So as to not fill the log with:
Failed to determine deadline: drmWaitVBlank failed: Operation not permitted

This currently happens on nvidia-drm but hopefully Nvidia will fix that
in future.

Relates to: https://gitlab.gnome.org/GNOME/mutter/-/issues/2923,
            https://gitlab.gnome.org/GNOME/mutter/-/issues/2924

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3138>
2023-08-07 16:30:32 +08:00
Daniel van Vugt
5a33e98431 kms/update: Remove unused is_flushing function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3148>
2023-08-04 09:37:33 +00:00
Daniel van Vugt
6c97bd79d7 kms/cursor-manager: Fix backwards FB_UNCHANGED flag
It was causing the simple/legacy backend to never upload cursor buffers.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2927,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2931

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3144>
2023-08-02 16:15:11 +08:00
Michel Dänzer
679457373a tests/kvm: Use git fetch --depth=1
Otherwise it fetches the full history of the target tag, which is a lot
of data for the Linux kernel.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3141>
2023-07-30 16:29:33 +00:00
Robert Mader
7f19739e6b native/cogl-utils: Add YUV formats
As well as required subformats. This makes the YUV formats available in
zwp_linux_dmabuf_v1.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Niels De Graef
239912cc1f wayland/dma-buf: Add support for YUV formats
Implement importing of multi-plane formats. For now, only support
importing planes individually using "sub-formats". This is the most
commonly driver-supported approach in the moment, used by other
Wayland compositors as well.

In the future we will additionally want to support importing the formats
directly and let the drivers handle conversion internally.

Co-Authored-By: Robert Mader <robert.mader@collabora.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Robert Mader
b15e14e027 native/cogl-utils: Add MetaMultiTextureFormat section
So they can be derived from the DRM format as well.

While updating the users, ensure we don't announce support for
DRM formats in zwp_linux_dmabuf_v1 if the MetaMultiTextureFormat is
INVALID. This will be used for YUV subformats in following commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Niels De Graef
3dd9f15eba shaped-texture: Start using MetaMultiTexture
To be able to later support more complex YUV formats, we need to make
sure that MetaShapedTexture (the one who will actually render the
texture) can use the MetaMultiTexture class.

Co-Authored-By: Robert Mader <robert.mader@collabora.com>
Co-Authored-By: Daniel van Vugt <daniel.van.vugt@canonical.com>
Co-Authored-By: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Niels De Graef
5181a826d1 compositor: Add MetaMultiTexture class
In future commits, we want to be able to handle more complex textures,
such as video frames which are encoded in a YUV-pixel format and have
multiple planes (which each map to a separate texture).

To accomplish this, we introduce a new object `MetaMultiTexture`: this
object can deal with more complex formats by handling multiple
`CoglTexture`s.

It supports shaders for pixel format conversion from YUV to RGBA, as
well as blending. While custom bleding is currently only required for
YUV formats, we also implement it for RGB ones. This allows us to
simplify code in other places and will be needed in the future once
we want to support blending between different color spaces.

Co-Authored-By: Robert Mader <robert.mader@collabora.com>
Co-Authored-By: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Jonas Ådahl
358c10de14 kms/cursor-manager: Only update cursor plane relevant device on mode set
When we see a mode set, the cursor manager will update all the cursor
planes so they are set correctly as part of the mode set. KMS updates
are always per-device, and what was wrong was that it didn't filter out
CRTCs on devices that wasn't part of the mode set.

Reported-by: Michel Dänzer <mdaenzer@redhat.com>
Tested-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3130>
2023-07-23 10:16:19 +00:00
Sebastian Keller
7faf4a308e constraints: Delay initial maximization until after reparenting is done
For SSD windows the decoration window from the frames client might have
a different maximization state than the client window and would end up
restoring it once shown. Avoid this issue by waiting until all
reparenting is done before applying the initial maximization (and
minimization).

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2579
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3035>
2023-07-21 11:38:17 +00:00
Daniel van Vugt
626498348b stage-impl: Blit damage regions of all ages when using a shadow FB
Original idea by Gert van de Kraats, modified to avoid having an
unused intermediate swap_region.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2602
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3117>
2023-07-21 10:43:18 +00:00
Jonas Ådahl
e96475bb8d build: Use correct variable for gathering built headers
We added things unused variable, which is a bit useless.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3131>
2023-07-21 07:59:54 +00:00
Daniel van Vugt
f5ff0f732a onscreen/native: Forget the view pointer when it is detached
Otherwise it would linger after a hotplug event, pointing to the old
(destroyed) view. And it's much easier to debug a NULL pointer than
a pointer to freed memory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3118>
2023-07-20 23:28:49 +00:00
Michel Dänzer
e95499038d frames: Fix XGetWMNormalHints return value check
It returns non-0 if there are any hints in the WM_NORMAL_HINTS
property, 0 if there are none.

Fixes the mouse cursor changing to the resize shape over the decorations
of non-resizable windows.

Fixes: c7b3d8c607 ("frames: Push error traps around various X11 calls")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3096>
2023-07-20 10:19:22 +00:00
Daniel van Vugt
db0870b114 cursor-renderer/native: Removed unused HW_CURSOR_BUFFER_COUNT
It stopped being used in e52641c4b6.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3129>
2023-07-20 15:08:49 +08:00
Gergo Koteles
7b04e8be15 wayland: Find touch grab sequence in subsurfaces also
With libdecor, window moving/resizing only works with
the pointer, not with touch.
The meta_wayland_pointer_can_grab_surface checks for subsurfaces,
but the meta_wayland_touch_find_grab_sequence does not.

Add a similar subsurface check to
meta_wayland_touch_find_grab_sequence.

Closes: GNOME/mutter#2872
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3125>
2023-07-19 13:07:51 +00:00
Bilal Elmoussaoui
b852bbba47 cleanup: Stop translating nick/blurb for pspecs
As those strings are intended to be used by some UI but nothing uses
that in reality except GStreamer.
So drop them similar to what GTK did at
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4717

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3101>
2023-07-19 11:33:59 +00:00
Robert Mader
efe884a97f wayland: Remove DRM_FORMAT_MOD_INVALID defines
In both cases we already unconditionally import drm_fourcc.h and all
distros shipping recent Mutter should by now have versions of that file
containing MOD_INVALID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Robert Mader
96778aa8b1 wayland/dma-buf: Make use of meta-cogl-drm-formats
Removing duplication, making it easier to add new formats and ensuring
that the native backend and Wayland clients can use the same formats.

Also improve related build files so the Wayland backend can be build
without the native backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Robert Mader
192d6686cf backend/cogl-utils: Move, rename to cogl-drm-formats and clean up
1. Move into the new 'common' folder and build for Wayland as well
   so we will be able to share the code in follow-up commits.

2. Rename to cogl-drm-formats to make it more obvious that the format
   map is more than an utility these days.

3. Drop the unused CoglTextureComponents part (see also previous
   commit).

4. Move the map to the header, simplifying some future use-cases.

5. Sync formats with MetaWaylandBuffer and MetaWaylandDmaBufBuffer and
   also use newly introduced opaque formats where appropriate.
   This avoids duplicated code, ensures that new drm-formats added to
   the dmabuf protocol have an adequate representation in Cogl from which
   information like alpha support can be easily derived and finally
   ensures we don't crash if the mappings got out of sync.

6. Remove some likely untested formats. In case some of these are
   actually needed on certain hardware, we can test whether we got
   the correct mapping by also adding support for the corresponding
   wl_shm_format in MetaWaylandBuffer by extending the gradient test in
   https://gitlab.freedesktop.org/jadahl/wayland-test-clients

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Robert Mader
ae88e13c5a wayland/buffer: Clean up format map
Use the newly introduced opaque formats where appropriate, allowing us
to drop the custom components handling.

Also use pre-mult alpha. This may slightly improve upload times
and should generally be more correct.

Tested with `weston-simple-shm`, ensuring the alpha channel still gets
ignored for opaque formats, and `gradient-test` from
https://gitlab.freedesktop.org/jadahl/wayland-test-clients

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Sebastian Wick
ae5512bc05 cogl/tests: Do not blend for texture format paint tests
The default cogl blend string is
`RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))` which is alpha
blending with premult fragment results. We do not clear the src
framebuffer and even if we did set alpha to 1 in the src fb, the
resulting alpha would be 1 and we want to check the alpha of the
fragment color.

Just turn off any kind of blending instead and write out the fragment
color to the fb.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Sebastian Wick
d79e4c182e cogl/tests: Fix float->int, int->float conversions
To obtain a float between 0 and 1 we have to devide the integer by the
highest possible value instead of the number of values.

Fixes off by one errors in the tests on some hardware/driver
combinations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Robert Mader
4097cbbb53 cogl: Extend tests and fix RGB2101010 opaque formats
Notably fix several cases where bitmap packing was broken, resulting in
visual corruption with the GLES2 backend. These were reproducible with
the gradient-test from
https://gitlab.freedesktop.org/jadahl/wayland-test-clients

Also extend testing similar to the RGB8888 formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Robert Mader
f04209dcbf cogl: Add RGB8888 opaque format variants
So we can properly handle matching DRM and WL_SHM formats in a unified
manner.

Add extensive testing between these and existing pre-multiplied alpha
formats, i.e. all formats we support on Wayland.

Note that unfortunately for some format combinations  the value in the
alpha channel is not cleared as expected, likely because of fast-paths
in Cogl. If both source and destination format is opaque, it always
works, however. This thereby includes all cases where they are the same.

Co-Authored-By: Jonas Ådahl <jadahl@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:55 +00:00
Jonas Ådahl
6841153ad7 tests/kms-device: Add test for scheduled no-ops
We can schedule an update from the cursor manager, but that doesn't mean
there will be an actual plane assignment changed at the time of the
update processing, since for example we might have "touched" a CRTC, but
already left it before the processing started, meaning we have nothing
to change after all.

Add a test case that checks that this works properly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
c96e835d56 thread/impl: Set the task source priority to rather high
Tasks should have high, but not highest priority. Roughly the aim is

  page flip feedback > composited updates > cursor updates

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
e52641c4b6 cursor-renderer/native: Replace HW cursor with KMS cursor manager
This removes the old hardware cursor management code and outsources it
to MetaKmsCursorManager. What the native cursor renderer still does,
however, is the preprocessing i.e. rotating/scaling cursor that wouldn't
otherwise be fit for a cursor plane.

The cursor DRM buffers are instead of being per cursor sprite now per
CRTC, meaning we don't need to stop doing hardware cursors if part of
the cursor is on an output that doesn't support it. This is why the
whole scale/transform code changed from being per GPU to per CRTC.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
ade2aa71ed tests/kvm: Bump timeout to 60 s
It can be quite slow to set up the test environment inside the VM, as
well as outside, leaving very little time for the test itself. While
it'd be nice to not run the mock env etc outside the VM, let's just bump
the timeout for now, to avoid unnecessary timeout failures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
7a821345db tests/kms/device: Test cursor updates just before turning off CRTC
If we turn of a CRTC, we might have invalidated the cursor manager for
the same CRTC, but that should not mean a cursor plane is assigned when
turning off the CRTC.

Add a test case for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
6d873036e0 Add KMS cursor manager
This new manager object intends to take over management of the cursor
plane from the native cursor renderer. It's API is intended to be used
from the main thread, except for the _in_input() function, but mainly
operates in the KMS context, i.e. the KMS thread.

It makes use of an "update filter" that is called before each
MetaKmsUpdate is turned into a atomic KMS commit or a set of legacy
drmMode*() API calls. When the cursor position has been invalidated,
it'll assign the cursor plane in the filter callback, using an as up to
date as possible pointer position as the source for the cursor plane
position.

Cursor updates from the input thread schedules updates for the affected
CRTCs which will cause the filter to be run, potentially for cursor-only
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
5a798989c4 seat/native: Add run impl task helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-18 23:51:34 +02:00
Jonas Ådahl
ef64279035 seat/impl: Add signal for pointer motions
This signal is emitted directly in the input thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
f4b76727db stage-view: Add API to inhibit cursor overlay painting
This adds some plumbing to get the "default" paint flags for regular
stage painting, where one either wants to paint the overlay, or not.

If inhibited, the 'no-cursors' paint flag is used, otherwise the 'none'
flag. This will be used to allow having a per stage view hw cursor
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
5d35138df0 cursor-renderer: Make 'handled_by_backend' state 'needs_overlay'
This will, conceptually, and eventually, allow a backend to both want an
overlay, while still handling it by default.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
3b2f95cb1f kms/update: Add destroy-notify to result listener user data
No thread guarantees, users need to handle it themselves.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
27ed069766 kms/impl-device: Add deadline based KMS commit scheduling
This makes it possible to post KMS updates that will always defer until
just before the scanout deadline. This is useful to allow queuing cursor
updates where we don't want to post them to KMS immediately, but rather
wait until as late as possible to get lower latency.

We cannot delay primary plane compositions however, and this is due to
how the kernel may prioritize GPU work - not until a pipeline gets
attached to a atomic commit will it in some drivers get bumped to high
priority. This means we still need to post any update that depends on
OpenGL pipelines as soon as possible.

To avoid working on compositing, then getting stomped on the feet by the
deadline scheduler, the deadline timer is disarmed whenever there is a
frame currently being painted. This will still allow new cursor updates
to arrive during composition, but will delay the actual KMS commit until
the primary plane update has been posted.

Still, even for cursor-only we still need higher than default timing
capabilities, thus the deadline scheduler depends on the KMS thread
getting real-time scheduling priority. When the thread isn't realtime
scheduled, the KMS thread instead asks the main thread to "flush" the
commit as part of the regular frame update. A flushing update means one
that isn't set to always defer and has a latching CRTC.

The verbose KMS debug logging makes the processing take too long, making
us more likely to miss the deadline. Avoid this by increasing the
evasion length when debug logging is enabled. Not the best, but better
than changing the behavior completely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
48501236ec kms: Move error codes to main header
Some will be used outside of meta-kms*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
ee87654224 kms/update: Add helper to checking if an update passed
Instead of comparing values, just add a `did_pass()` helper.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
5bed90114d kms/update: Treat NULL main context as default for page flips too
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
40caa6d87c kms/update: Use callback helper to free page flip listener data
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
6059d8f42d kms/page-flip: Make destroy notify function optional
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
587da92b0a kms: Mark mode set updates as such
This is currently unused, but will be later used to distinguish betwen
per frame/CRTC updates and device wide ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
a7954f4a75 onscreen/native: Move out timeval to timestamp helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
17a78303d0 kms: Make result listener take a vtable too
As with the page flip listener, prepare to make result listeners more
capable by allowing more vfuncs for the same listener instance in the
future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
f97f0f2781 thread: Document the behavior of meta_thread_post_impl_task()
Specifically in what contexts things are invoked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
6ed75c6253 thread: Allow passing a NULL callback vfunc
This is useful when one just wants to free something, which can be done
using the passed destroy notify function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
0d5d1745ce thread: Push the thread-default main context
Makes g_main_context_get_thread_default() do the right thing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
59ba952661 thread: Always add impl thread context as callback source
This is helpful when we add callbacks that should be dispatched in the
KMS impl thread.

This invalidates an assumption about callbacks not being in the impl
context, so some asserts for that are also removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
84ff167328 thread: Add private API to flush callbacks for main context
This will be used to flush out certain callbacks when switching thread
type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
2617bd8e72 thread/impl: Add 'reset' signal
This signal is emitted before terminating the thread, but also when
resetting the thread type. This is to allow thread implementations to
make sure they have no stale pending callbacks to any old main contexts.

This commit "terminates" the impl thread even if there is no actual
thread; this is to trigger the "reset" signal, also when switching from
a user thread to a kernel thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
bedec579b8 tests/kms/updates: Use async update API
We ignored the feedback and entered a temporary main loop, so no need to
do things sync.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
15a91e9fd4 kms/update: Stop sealing updates
This isn't very useful anymore, since posting an update takes ownership
of it. Not sealing it also means e.g. more listeners can be added after
posting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
54d9fab161 kms: Ask to be real time scheduled
This will allow more time sensitive scheduling strategies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
6da3e9eb69 thread/impl: Add API to tell whether its realtime scheduled
Will be used by thread impl's to decide whether they can rely on real
time scheduling or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
e92e4fe64d thread: Register with profiler
This means we can add COGL_TRACE*() instrumentation that is grouped
correctly in sysprof. If kernel threading is enabled, they will end up
in a "Compositor (KMS thread)" group (ignoring translations).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
bd2fa92c29 thread: Support making threads real time scheduled
Real time scheduling is needed for better control of when we commit
updates to the kernel, so add a property to MetaThread that, if the
thread implementation uses a kernel thread and not a user thread, RTKit
is asked to make the thread real time scheduled using the maximum
priority allowed.

Currently RTKit doesn't support the GetAll() D-Bus properties method, so
some fall back code is added, as GDBusProxy depends on GetAll() working
to make the cached properties up to date. Once
https://github.com/heftig/rtkit/pull/30 lands and becomes widely
available in distributions, the work around can be dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
276ebbf5ee kms: Use a kernel thread by default
Also add an API to inhibit the kernel thread from being used, and make
MetaRenderDeviceEglStream inhibit the kernel thread from being used if
it's active.

The reason for this is that the MetaRenderDeviceEGlStream is used when
using EGLStreams instead of KMS for page flipping. This means the actual
page flipping happens as a side effect of using EGL/OpenGL, which can't
easily be done off thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
788ad43e17 thread: Allow switching thread type
This will be necessary in order to default to 'kernel' and then switch
to 'user' if the thread instance can no longer be properly multi
threaded.

To avoid having the same thread impl creating and destroying
GMainContext's, this also means always creating a GMainContext for the
thread-impl. When running in user-thread mode, the GMainContext is
wrapped in a wrapper source and dispatched as part of the real main
thread GMainContext, and when in kernel-thread mode, it runs
independently in the dedicated thread.

This has the consequence that the wrapper source will always have the
priority of the highest impl context GSource, but only after it has
dispatched once. Would we need it earlier than that, we either need a
way to introspect existing sources in a GMainContext and their
priorities, or manually track known sources in MetaThreadImpl.

The wrapper source will never be below 0, as that'd mean it could reach
INT_MAX priority if it had no more sources attached to it, meaning it'd
never be dispatched again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Jonas Ådahl
33b33aa370 onscreen/native: Post updates asynchronously
Results are handled in callbacks anyway, there is no need to wait for
the KMS thread to finish.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
718c78a365 kms: Add API to pass updates asynchronously
While doing this, rename the old synchronous functions to more clearly
communicate that they expect to actually process the update during the
call, not just post it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
e4a8fc93a1 thread: Add destroy notify function for post user data
The destroy notify function can be called on any thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
7c9d4b8c7c kms/result-listener: Allow setting a custom main context
While the default when passing NULL will be the main context of the main
thread, make it possible to specify another main context, so that
result handlers can be invoked on the right thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
1e0367bf08 tests/kms/update: Move out some repetitive code into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
1350b5e260 thread: Make it possible to run sync tasks from any thread
When a task is posted from a non-main thread, a user thread still needs
to go via the queue and be signalled using the condition, just as if it
was a kernel thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
d77b5935cd kms/update: Allow page flip callback listeners on any thread
This hooks into the MetaThread GMainContext callback machinery just
added; and allows receiving page flip callbacks on any thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
f83c30bae5 thread: Support queuing callbacks on any thread
Callbacks could be queued to be invoked either on the impl side or the
main thread side of the thread; change this to take a GMainContext,
which effectively means a callback can be queued to be invoked on any
thread that has a GMainLoop running on its own GMainContext.

Flushing is made to handle flushing callbacks synchronously on all
threads. This works by keeping a hash table of queued callbacks per
thread (GMainContext); when flushing (from the main thread), callbacks
on the main thread context is flushed, followed by synchronization with
all the other threads.

meta_thread_flush_callbacks() is changed to no longer return the number
of dispatched callbacks; it becomes much harder when there are N queues
spread across multiple threads. Since it wasn't used for anything, just
drop the counting, making life slightly easier.

Feedback to thread tasks are however always queued on the callers
thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 17:23:31 +02:00
Jonas Ådahl
ae48019cce tests/kms: Run tests with kernel/user thread too
This means each test is run 4 times:

 * with atomic mode setting using a kernel thread,
 * with atomic mode setting using a user thread,
 * with legacy mode setting using a kernel thread, and
 * with legacy mode setting using a user thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
f1356ce5d3 kms: Add debug env var to configure thread implementation type
Set MUTTER_DEBUG_KMS_THREAD_TYPE to either 'kernel' or 'user', and the
MetaThread backend will be either a kernel thread or a user thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
8b612a6150 thread: Introduce kernel thread support
This commit makes it possible to create a MetaThread where the
MetaThreadImpl side runs in a real thread, instead of a artificially
separated impl context.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
4c317eae07 thread: Make callback handling thread safe
This is in preparation for introducing kernel threads, where proper
synchronization becomes necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
915bceb5a0 thread: Add name to threads
So far this is used to assign names to relevant sources, but will used
to name the kernel threads, when they are introduced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
251722ec4e thread: Flush tasks and callbacks on finalize
This will make sure no tasks or callbacks are unexpectedly dropped,
potentially leaking or leaving things in an unexpected state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
261624538c tests/thread: Quit main loop in idle callback if in impl thread
This isn't a problem for user space threads, as there are no race
conditions, but when kernel thread support is introduced, we must make
sure that e.g. the main loop is actually running before quitting it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
50b0d8cb18 tests/thread: Test mixing async and sync task
The expected behaivor is that the sync task will "flush" the async
tasks, i.e. to maintain task order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
069bee0ce8 tests/thread: Test multiple queued tasks
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
aa723e7207 thread: Add support for posting async task
This uses the queue that was introduced when migrating impl task
management from MetaThread to MetaThreadImpl, with the exception that
it's now fully used as an actual queue. It now has a GSource that sits
on the right GMainContext that is dispatched whenever there are tasks to
execute.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
fda883e859 thread: Move context and task management to impl side
It's the impl side that wants to add impl side idle sources, or fd
sources, etc, so make it part of MetaThreadImpl.

This changes things to be GAsyncQueue based. While things are still
technically single threaded, the GAsyncQueue type is used as later we'll
introduce queuing tasks asynchronously, then eventually queuing across
thread barriers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
229904cb4b kms: Use MetaThread source helpers directly
No need to have thin meta_kms_* wrappers, just use the meta_thread_*
functions directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:36 +02:00
Jonas Ådahl
2e025eea0e tests: Add MetaThread tests
Tests posting sync tasks, posting callbacks, adding impl side fd
sources, callback flushing, impl side idle callbacks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:51:35 +02:00
Jonas Ådahl
7277592255 thread: Initialize using GInitable
To later add error handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:45:00 +02:00
Jonas Ådahl
a6baa77eab kms: Split out impl/non-impl separation into MetaThread(Impl)
It currently does exactly what MetaKms and MetaKmsImpl did regarding the
context separation, which is to isolate what may eventually run on a KMS
thread into a separate unit. It works somewhat like a "user thread",
i.e. not a real thread, but will eventually learn how to spawn a
"kernel thread", but provide the same API from the outside.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:45:00 +02:00
Jonas Ådahl
7fea24d585 cursor-renderer: Realize texture before using it for its size
If we don't, well return an empty size, despite it in practice
shouldn't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 12:45:00 +02:00
Olivier Fourdan
6d0b682d98 remote-desktop/eis: Add support for ConnectToEIS.
Remote desktop version 2 added a new method ConnectToEIS .

ConnectToEIS allows clients to requests a file descriptor from the
compositor which can then be used directly from libei.

Once established, the communication between compositor and application
is direct, without the need to go through the portal process(es).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Olivier Fourdan
812eeddfde backends/eis: Add a new API to get the fd from MetaEIS
This is preparation work for supporting ConnectToEIS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Peter Hutterer
a6d406d7bf backends/eis: Hook eis into the debug system
To be enabled with MUTTER_DEBUG=eis

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Peter Hutterer
a20aa28af0 backends/eis: Add EIS client support
This adds support for EIS clients in the form of MetaEis and
MetaEisClient.

The purpose is to allow clients to connect and send emulated input events
using EIS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
2059273f57 tests/input-capture: Add test for ATK input capture
Cally should not see the events when they are captured.

[ofourdan] Wait for paint before checking button count.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
1513eccc03 tests/input-capture: Test that a11y isn't triggered when capturing
Accessibility should be handled on the receiving end, if needed. Make
sure this is the case by listening on some signals, verifying they are
only triggered if we're not capturing input.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
2fb3bdf774 input-capture: Hook up capturing of events to active session
This adds the actual input capturing rerouting that takes events and
first hands them to the input capture session, would it be active.
Events are right now not actually processed in any way, but will
eventually be passed to a libei client using libeis.

A key binding for allowing cancelling the capture session is added
(defaults to <Super><Shift>Escape) to avoid getting stuck in case the client
doesn't even terminate the session.

The added test case makes sure that the pointer moves again after
pressing the keybinding.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
38d1666049 clutter/event: Set the constrained relative motion too
When a relative pointer motion gets constrained (e.g. a monitor edge or
barrier), save the constrained relative motion delta too.

This will later be used to send the remaining motion delta to input
capture clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a170f2a82b seat/impl: Move out the GSource implementation to a helper object
This will help adding similar sources that work practically the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
3bd401f33a backend: Add input capture getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
f9b18d90c6 keybindings: Make event handlers take a const ClutterEvent
This avoids discarding the const qualifier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a2bdce2c8e clutter/seat: Add seat name
This is similar to the existing seat-id that is part of MetaSeatNative,
but meant to be passed to created input capture seats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
e917b7de43 clutter/stage: Add input-only grabs
An input only grab is a ClutterGrab on the stage that doesn't have an
explicit actor associated with it. This is useful for cases where event
should be captured as if focus was stolen to some mysterious place that
doesn't have anything in the scene graph that represents it.

Internally, it's implemented using a 0x0 sized actor attached directly
to the stage, and a clutter action that consumes the events. An
input-only grab takes a handler, user data and a destroy function for
the user data. These are handed to the ClutterAction, which handles the
actual event handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a79f35612b tests/clutter/grab: Use clutter_event_get_name()
This changes the debug output slightly, but that's fine.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
2a8c11d69b input-capture: Add D-Bus method to clear barriers
This will be needed by the portal backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
1d1983edb5 input-capture: Hook up barrier adding
Adding a barrier and later enabling the input capture session will
create MetaBarrier instances for each added input capture barrier.

The barriers are created as "sticky" which means that when a pointer
hits the barrier, it'll stick to the point of entry, until it's
released.

The input capture session is also turned into a state machine with
explicit state, to more easily track things.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a8f461a4eb barrier: Allow releasing without any event in the native implementation
This allows for a sticky barrier to hold the pointer until it is
released, but the owner of the barrier doesn't need a barrier event to
release it. It will be used to implement input capturing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
221ac2af76 barrier: Add ways to make barriers sticky
A sticky barrier means that a pointer in motion intersecting a barrier
doesn't move once having hit it. The intention with this is to allow an
input capture clients to continue a motion once a barrier is hit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a8b013b006 Add beginning of input capture API
This API aims to provide a way for users to capture input devices under
certain conditions, for example when a pointer crosses a specified
barrier.

So far only part of the API is implemented, specifially the session
management as well as zone advertisement, where a zone refers to a
region in the compositor which edges will eventually be made available
for barrier placement.

So far the remote access handle is created while the session is enable,
despite the input capturing isn't actually active yet. This will change
in the future once it can actually become active.

v2: Remove absolute/relative pointer, keep only pointer (ofourdan)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Carlos Garnacho
281d896f6a compositor: Do not repick after effects finish
This was a temporary fix until there was a better crossing event
delivery mechanism that accounted for actor changes beneath the pointer.
We nowadays have that, and don't seem to need this extra kick to get
crossing events triggered (and cursor changes, etc) when windows appear
or disappear under the pointer.

This commit is effectively a revert of commit
a64dba4d7a.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6808
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3104>
2023-07-06 11:31:32 +00:00
Brendan William
23b98db004 core: Never automatically switch focus in strict focus mode
With window_is_terminal gone, "strict" and "smart" focus mode have no
behavioural difference. Let's broaden the scope of strict focus mode,
such that windows never automatically focus unless they are an ancestor
to the transient.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3063>
2023-06-30 22:40:20 -07:00
Brendan William
3bd36d506b core: Remove window_is_terminal and friends
As noted in the comments of window_is_terminal, this is a hack. This
code has not been touched for the better part of a decade. App res_class
tends to differ between Wayland and X11, so it is likely that none of
these apps have been recognised as terminals under Wayland ever. Also,
there are reports that strict focus mode also does not work under X11,
likely due to changes in these terminal apps over the years resulting
in different res_class than those manually specified in here. Let's remove
this hack and change strict focus mode accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3063>
2023-06-30 22:40:16 -07:00
Daniel van Vugt
150b110726 backends/x11: Make zero comparisons earlier and easier to reason about
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3062>
2023-06-30 17:28:12 +08:00
Dor Askayo
b3d0d84823 tests: Add missing dependencies
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3091>
2023-06-29 20:07:56 +00:00
msizanoen
842f73ac4c window-actor: Fix screencast with fractionally scaled surfaces
Instead of using `clutter_actor_get_resource_scale()`, we now deduce the
intended buffer scale from the window by dividing the unscaled size by
the final actor size. This is more correct as while the return value of
`clutter_actor_get_resource_scale()` depends only on the monitor where
the surface resides, the actual scale of the surface is determined
solely by the application itself. `get_resource_scale` will differ from
the actual buffer scale if the application only supports 100% scaling
(Xwayland), or is performing scaling with wp_viewporter (clients using
fractional_scale_v1).

This also fixes a mismatch between the calculated buffer sizes between
`meta_window_actor_get_buffer_bounds` and
`meta_window_actor_blit_to_framebuffer` which causes broken
screencasting for Chromium 114 and later when using the native Ozone
Wayland backend.

Additionally, this commit also changes
`meta_window_actor_blit_to_framebuffer` from using a simple translation
to using an inverted matrix transformation of the transformation matrix
between the parent of the window actor and the surface actor to ensure
maximum sharpness for fractionally scaled windows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
msizanoen
742d026479 shaped-texture: Introduce get_unscaled_{width,height}
This allows other code to obtain the size of the surface after all
transformations except for scaling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
Daniel van Vugt
1dbf37239f meta: Don't #include <wayland-*> in public headers
It's not required to define `struct wl_display` and having it in a public
header is breaking the g-ir-scanner because Wayland headers use the
non-standard keyword `__typeof__`.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2875
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3098>
2023-06-28 08:47:42 +00:00
Barnabás Pőcze
ab4c415d6e color-manager: Apply temperature after gsd.Color proxy has been created
Previously, restarting mutter in an X11 session resulted in
the previously set color temperature not being applied.
Fix that by applying the color temperature right after
the org.gnome.SettingsDaemon.Color proxy has been created.

Furthermore, only call `update_all_gamma()` from `on_gsd_color_ready()`
when the temperature has actually changed. Otherwise there is no need
since the current temperature has already been (or will soon be) applied
to all ready color devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3008>
2023-06-28 07:51:01 +00:00
Jonas Ådahl
4aeb051e9b tests: Mark some test cases as skippable
This means the mutter/tty suite won't fail when the tests can't
TakeControl, i.e. run in the already active session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Jonas Ådahl
eb9ef1da8d screen-cast/src: Queue follow up frame if no buffers
If we tried to record but did so before the buffers had the chance to be
added, schedule another follow up frame once the buffers start rolling
in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Jonas Ådahl
c724fcae2e tests/screen-cast-client: Don't process stream on tear down
We'd get a re-entry like scenario when destroying the PipeWire stream
object, where PipeWire would call the stream process vfunc. When this
happened, we had already destroyed the stream, so don't try to dequeue
or anything, just do an early exit. Fixes the following crash in the
test case client:

  #0 pw_stream_dequeue_buffer() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #1 on_stream_process() at ../src/tests/screen-cast-client.c:348
  #2 do_call_process() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #3 flush_items() in /usr/lib64/spa-0.2/support/libspa-support.so
  #4 loop_invoke() in /usr/lib64/spa-0.2/support/libspa-support.so
  #5 impl_send_command.lto_priv.0() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #6 suspend_node.lto_priv.0() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #7 pw_impl_node_set_state() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #8 client_node_removed() in /usr/lib64/pipewire-0.3/libpipewire-module-client-node.so
  #9 pw_proxy_destroy() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #10 pw_stream_disconnect() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #11 pw_stream_destroy() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #12 stream_free() at ../src/tests/screen-cast-client.c:530
 #13 main() at ../src/tests/screen-cast-client.c:803
 #14 __libc_start_call_main() at ../sysdeps/nptl/libc_start_call_main.h:58
 #15 __libc_start_main() at ../csu/libc-start.c:360
 #16 _start() in /home/jonas/Dev/gnome/mutter/build/src/tests/mutter-screen-cast-client

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Corentin Noël
6b9efc3b0c wayland: Make the MetaWaylandCompositor type public
Allows mutter implementation to have access to the underlying wl_display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3092>
2023-06-27 16:17:16 +00:00
Carlos Garnacho
60ef069aa8 backends/native: Log event modifiers in input event debug output
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3094>
2023-06-26 16:41:50 +02:00
Carlos Garnacho
4b3a38a589 meta: Add docs description to META_DEBUG_INPUT_EVENTS MetaDebugTopic value
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3094>
2023-06-26 16:28:51 +02:00
Jonas Ådahl
ee6f1f9246 seat/impl: Add 'input-events' debug topic
This will log all input events we forward from libinput.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3052>
2023-06-26 12:36:04 +00:00
Jonas Ådahl
d67d22f948 backend: Init settings before initable_init
This means the settings instance is there before the backend backend's
initable_init() function gets called.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3085>
2023-06-23 11:52:08 +00:00
Shmuel Melamud
993c42e11f compositor: Mirror window placement in RTL environment
If RTL environment (such as Hebrew or Arabic) is detected, the usual new
window placement algorithm is mirrored. New windows appear near the
right side of the screen and cascading is built from the top-right
corner of the screen.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1873
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3009>
2023-06-22 13:59:24 +00:00
Sebastian Wick
985d0dc3ab tests/stage-view-tests: Unref clutter timelines
If the timelines don't get destroyed they keep references to frame
clocks. Later tests check for the destruction of those frame clocks and
then can fail if the frame clock is implemented slightly differenty.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3084>
2023-06-20 23:19:28 +00:00