1
0
Fork 0
Commit graph

12155 commits

Author SHA1 Message Date
Jonas Ådahl
efbb8df611 tests/kms/hotplug: Clean up signal handlers in switch-config test
They remained connected, and poked at subsequent tests stack, causing
unexplainable crashes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3233>
2023-09-02 11:07:38 +00:00
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
Pascal Nowack
712c9a1700 screencast: Do not stop remote desktop session when a stream closes
In remote desktop sessions, streams can be created and destroyed
on-the-fly.
If a stream is gone, it is not necessarily an error.
So, don't treat that situation like an erroneous one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2911>
2023-06-20 20:13:47 +00:00
Dor Askayo
56580ea7c9 backends/native: Assume zero rendering time for direct scanout buffers
The previous logic didn't work correctly at least when priority-based
preeption wasn't supported by the DRM driver, such as in the case
of amdgpu. The call to glGetQueryObjecti64v would block on client
work which is already in progress (most likely for the next frame)
and delay notifying the ClutterFrameClock about presentation.

Conveniently, the Wayland transactions mechanism guarantees that all
fences of a dma-buf buffer are signalled before the buffer is
included in a frame, which means that dma-buf buffers are ready for
presentation when being directly scanned-out.

Direct scanout is only supported for dma-buf buffers too, which means
that all buffers going through direct scanout are effectively ready
and require no GPU rendering before presentation.

Assuming zero rendering time for dma-buf buffers going through direct
scanout simplifies the code and removes the need for
glGetQueryObjecti64v, thus avoiding the aforementioned issue where it
could block for longer than expected.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2766
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3080>
2023-06-20 15:32:25 +00:00
Carlos Garnacho
c858ad7f91 wayland: Unset keyboard focus if surface is destroyed
Depending on the ordering of the surface-associated resources
being destroyed, we may fall into the following situation:

 - wl_surface is destroyed
 - destruction notifications for the surface runs
 - The MetaWaylandKeyboard attempts to synchronize the window
   focus
 - The MetaWindow is not destroyed yet, so the focused window
   remains the same, and the MetaWaylandKeyboard keeps the same
   focus MetaWaylandSurface.
 - wl_surface finalizes destruction, MetaWaylandSurface now has
   a NULL resource
 - xdg_toplevel destructor kicks in, it unmanages the window
 - The current focus window is again looked up, forced to look
   a different window
 - The MetaWaylandKeyboard focus now changes, tries to leave the
   old surface, but it has a NULL resource already, and raises
   a protocol error.

If the order is inverted, the window being unmanaged triggers a
focus change into a different window, the MetaWaylandKeyboard
triggers a focus change while the MetaWaylandSurface is still
intact, it succeeds, and the window gets properly destroyed.

In order to make this independent of the order, it makes sense
to make MetaWaylandKeyboard do like the other objects tracking
focus surfaces, and have it care of its own little parcel. The
surface destructor changed to simply unsetting the keyboard focus
to NULL (guaranteeing that the old focus is left while the surface
resource is still up), and leaving potential focus changes to
the xdg_toplevel_destructor->unmanage->update_focus paths.

Doing that alone is basically a revert of commit 228d681b, thus
is still subject to keyboard focus being lost after a popup is
destroyed. Change the approach to trigger the focus sync (and
new focus surface lookup) so it happens from xdg_popup_destructor
specifically to popups and alike xdg_toplevel.

Fixes: 228d681b ("wayland: Trigger full focus sync after keyboard focus surface is destroyed")

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2853
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3077>
2023-06-19 13:13:54 +00:00
Florian Müllner
a95a3a0d30 prefs: Remove titlebar-font preference
It has been unused since decorations moved into the frames client.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3075>
2023-06-15 16:51:20 +00:00
Sebastian Wick
87bd574598 core/window: Change MRU behavior for windows on secondary output
Current behavior pushes a window which receives focus to the start of
the MRU list on every workspace it is on. By focusing a sticky window
the default focus on all other workspaces changes as well. This is fine
for sticky windows explicitly marked as sticky by the user but if a
window is on a secondary output and workspaces are only on the primary
output the behavior is unexpected. Instead we want the window to be the
default focus only on the current workspace but also keep those windows
in a relative MRU order to each other on all workspaces.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2681
Fixes: 058981dc1 ("workspace: Focus the default window only if no window is focused")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2909>
2023-06-15 12:39:58 +02:00
Sebastian Wick
3bbff537d9 Revert "workspace: Focus the default window only if no window is focused"
This reverts commit 058981dc12.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2909>
2023-06-15 12:09:31 +02:00
Dor Askayo
a738132486 profiler: Actually free ThreadInfo when a thread unregisters
The previous commit only freed the list node.

Fixes: a731017ec ("profiler: Free ThreadInfo when a thread unregisters")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3078>
2023-06-14 23:54:41 +03:00
Dor Askayo
edc5d2a933 profiler: Free ThreadInfo when a thread unregisters
This avoids leaking the the ThreadInfo object when a thread unregisters.

Fixes: e16d68372 ("profiler: Add API to register profiler threads")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3076>
2023-06-14 19:48:12 +03:00
Dor Askayo
f49b2a3c7d profiler: Free ThreadInfo list on MetaProfiler finalize
This avoids use-after-free when handle_start() is called following
handle_stop() during the lifetime of the MetaProfiler. This happens
on repeated profiling sessions using Sysprof.

Fixes: e16d68372 ("profiler: Add API to register profiler threads")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3076>
2023-06-14 19:44:48 +03:00
Carlos Garnacho
bc04fcb89d core: Change MetaWaylandTextInput event forwarding to IMs
We need to juggle with some things here to keep key event ordering
and accounting consistent.

The keyboard internal state changes (and maybe modifier event emission)
happening through meta_wayland_seat_update() should ideally happen
from the same key events that reach the client through wl_keyboard.key,
so that wl_keyboard.modifier events are emitted in the right relative
order to other key events.

In order to fix this, we need to decide at an earlier point whether
the event will get processed through IM (and maybe be reinjected),
thus ignored in wait of IM-postprocessed events.

This means we pay less attention to whether events are first-hand
hardware events for some things and go with the event that does
eventually reach to us (hardware or IM).

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5890
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
eaa09be17c wayland: Account for doubly pressed/released keys in MetaWaylandKeyboard
Given the presence of IMs and the different paths in event handling to reach
one of them, we cannot make guesses about whether should stick to the original
hardware-triggered event, or wait/prefer a second hand IM event that might or
might not arrive. We also have no say for other IM foci unrelated to wayland
(e.g. ClutterText) triggering the double event emission.

So go with it and maintain our own internal state for keys, we already kinda
do, but mainly for warning purposes, at the time of updating the
MetaWaylandKeyboard state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
7b26aab08d wayland: Add compositor API to get the text input object
We need to open code a bit the event handling of MetaWaylandTextInput,
in order to avoid out of order events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
7716b62fa2 clutter: Separate ClutterInputFocus event processing and filtering
Currently, we let the same function handle key event filtering as they
are passed to the IM, and the IM events resulting in actions like text
commit or preedit changes.

Split these two aspects into filter/process functions, and port
ClutterText to it. MetaWaylandTextInput still handles everything in
a single place, but that will be split in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
ff4953caa6 wayland: Remove redundant ifdef
It's already surrounded by the same ifdef

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Jonas Ådahl
63767df59a backend: Initialize cursor renderer position too
This means initializing the pointer position in MetaSeatImpl
synchronously too, otherwise it's not guaranteed querying the seat state
will result in the expected position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3071>
2023-06-13 13:22:59 +00:00
Jonas Ådahl
0b0f863428 seat/native/impl: Also init core pointer coordinates
Otherwise clutter_seat_query_state() doesn't give us the expected value,
since it doesn't check the seat pointer coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3071>
2023-06-13 13:22:59 +00:00
Michel Dänzer
4d664fd797 output/kms: Use meta_kms_connector_get_preferred_mode in init_output_modes
I have a monitor which can report two preferred modes: 5120x1440@240
and 3840x1080@60. Since they are enumerated in this order by KMS,
init_output_modes would end up using 3840x1080@60 (and it was impossible
to select any 5120x1440 mode in the GNOME display settings).

Fix this by using meta_kms_connector_get_preferred_mode, which returns
the first KMS mode with DRM_MODE_TYPE_PREFERRED.

v2:
* Use meta_kms_connector_get_preferred_mode. (Jonas Ådahl)

Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3055>
2023-06-12 18:59:06 +00:00
Jonas Ådahl
49e6ce459c backend: Dispatch initial burst of events synchronously on init
This will consist of device-added events, meaning before init finishes,
we can derive some state that depends on the set of input devices
available on startup, such as cursor visibility.

This avoids cursor visibility switching between hidden and visibility
during startup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
27606cf1fb seat/native/impl: Start reading input device events when starting
This opens up for a possibility to handle initial events (devices
discovered on startup) during initialization, meaning we can figure out
a more correct initial state that depends on available input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
af078264fa backend: Init pointer position with clutter_seat_init_pointer_position()
Also fix a function name and remove an unused struct field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
060c4c2dfc clutter/seat: Add API to initialize pointer position
This is different from "warping" as it doesn't necessarily result in a
pointer motion event. This can be helpful during initializing so we can
avoid faked pointer events that would otherwise need to be special cased
to not appear as actual pointer movements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Timotej Šulík
97f0e2e691 monitor: Ensure the preferred mode is always included
If there are two display modes present with the same flags,
and one of them is the preferred mode, it could have been
excluded from the resulting list of display modes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3061>
2023-06-12 15:26:47 +00:00
Jonas Ådahl
bea2fdc12b profiler: Add missing call to stop profiling
Otherwise the profiling backend (cogl-trace.c) doesn't actually stop,
and will complain if we try to start it up again.

Fixes: ab39eaf131 ("cogl/trace: Make global start/stop more explicit")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3068>
2023-06-12 12:20:38 +00:00
Jonas Dreßler
26344fb533 clutter/actor: Don't store a second stage-views list for the stage
The stage already maintains its own list of stage-views via
clutter_stage_peek_stage_views(), it's a bit superfluous to copy that list
around all the time into priv->stage_views of ClutterActor. Let's deal with
that by returning clutter_stage_peek_stage_views() when
clutter_actor_peek_stage_views() gets called for the stage.

In order to make sure ClutterActor::stage-views-changed still gets emitted
correctly for the stage, always emit that signal on the ClutterStage when
the stage views get invalidated. This now depends on the backend only
actually invalidating the views and calling
clutter_stage_clear_stage_views() when things have actually changed, but
that should be the case.

This needs a change in one of the stage-views tests, namely the one which
tests stage-view-changed emission on the stage: Here we now see an emission
of stage-views-changed, but that signal emission actually seems correct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Ådahl
0884747dce window-actor/x11: Fix using shape region for input
There were two issues with using the shape region to derive an input
region.

Firstly, the shape region is against the client rectangle, while the
surface actor needs it to be against the buffer rectangle. Fix this by
offsetting the shape region before passing it along.

Secondly, we can't just intersect the shape and input region, since that
leaves out the window decorations. Fix this by only intersecting the
input region covering the client part, and the shape region, and then
union that with the input region covering the rest.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3045>
2023-06-02 22:41:35 +02:00
Sebastian Keller
6274bb3518 x11: Use input region from frame window for decorated windows
Previously the input region was ignored for decorated windows, which
since the introduction of the frames client meant that the entire shadow
region of the frame window was considered interactive.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2706
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3031>
2023-06-02 20:21:56 +00:00
Bilal Elmoussaoui
9a6ee5d7c7 clutter: Drop unnused cairo specific APIs
The APIs are not used by Mutter and GNOME Shell, so they should be safe to remove

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3040>
2023-06-01 16:10:13 +00:00
Sebastian Keller
2b58efbcbb meta: Remove unused MetaFrameFlags enum
It has been unused since 04fa926e, but could not be removed before
branching due to being in a public header.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3036>
2023-06-01 12:15:20 +00:00
Jonas Ådahl
798a6e450a kms/impl-device/dummy: Add empty disable() implementation
We don't need to do anything, since we have no mode setting devices to
disable in the dummy implementation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2841
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3037>
2023-06-01 11:29:09 +00:00
Jonas Ådahl
b413f45bee profiler: Enable tracing on threads added while running
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
ab39eaf131 cogl/trace: Make global start/stop more explicit
Don't try to handle things by threads enabling/disabling the main trace
context on-demand, just have a clear start/stop API. For the D-Bus API,
it becomes more straight forward, and for the persistent variant too, as
it avoids having to pass garbage input when it's known that arguments
will be discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
33a210d768 x11/events: NULL Check input event when getting name
Fixes a SIGSEGV when trying to get the name of an XIEvent for profile
trace data gathering. We don't use GDK anymore, so we can't rely on any
GDK semantics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
e4b2b141d9 seat/impl: Trace libinput dispatching and event processing
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
1ca76e9b9c context: Start persistent profiling via command line argument
Persistent profiling was started via an env var, but that's rather hard
to discover and remember without grepping; change to use a command line
argument.

The profiler is started early, even during (though late in)
configuration, but configuration should ideally be instant and pointless
to configure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
e16d683721 profiler: Add API to register profiler threads
The registered threads will get tracing turned on when MetaProfiler is
started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
604aeba9b3 events: Trace handling of event
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
340d585f91 compositor: Reparent the backend window unmanaging the display
Under X11 hiding the backend implies also unmapping the stage window, if
we do that after that we've closed the display we may end up in a
BadWindow error because such window seems to be destroyed together with
the compositor output parent (even though we are not notified about), so
to prevent this, reparent the backend window during compositor unmanage,
setting it back as a root window child.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
f013764b57 x11/backend-x11: Close the X11 Display where it's created
We open the clutter backend display inside MetaBackendX11, but we end
up closing it MetaClutterBackendX11, that is not it's direct owner.

So do it where it belongs

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
889cd056e7 x11/x11-errors: Use the default error handler when display is destroyed
An X11 server connection may still be around when we close the display,
and mutter_x_error could be triggered when x11_display has been already
destroyed leading to a crash.

To prevent this use the default X11 error handler.

As per this, also move the ownership of the error traps to x11-errors.

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
6d992e9e45 tests: Perform x11 test in both sync and async modes
The former allows better catching of issues, so do both cases

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Robert Mader
ed1d8bed93 Revert "backend/native: Sending modifiers to clients can be disabled via udev"
This is unused now. For testing purposes,
`MUTTER_DEBUG_SEND_KMS_MODIFIERS=0` can still be used.

This reverts commit efc4fa333c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3030>
2023-05-30 14:25:28 +02:00
Jonas Ådahl
cef1a5d377 wayland/actor-surface: Only set input region of non-X11 window actors
Xwayland nevers sets the input region since that is handled using
`XShapeGetRectangles()` called with `ShapeInput`. Setting it from the
wl_surface would mean setting it to "infinite", effectively undoing what
`ShapeInput` communicated.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2788

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3022>
2023-05-29 13:21:14 +00:00
Jonas Ådahl
e829862249 wayland/actor-surface: Set opaque region even without X11 client support
A `#ifdef` macro wrapped too much making opaque regions no longer being
set if mutter would be compiled without X11 client support.

Fixes: 6e818c8c38 ("build: Allow disabling xwayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3022>
2023-05-29 13:21:14 +00:00
Carlos Garnacho
b5900dd97a backends: Avoid orientation changes around suspend/resume if locked
We currently lock the capability of the MetaOrientationManager to emit
the ::orientation-changed signal, but otherwise keep reading the current
orientation and returning it if we are asked politely through
meta_orientation_manager_get_orientation().

This may bring issues e.g. around suspend/resume, since there may be other
parts of the code trying to get the current orientation without receiving
::orientation-changed signals, this may result in the display orientation
being effectively rotated, then stay locked after that.

In order to fix this, make the MetaOrientationManager return a fixed
orientation while locked, only updated after changes in the lock state.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2600
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3021>
2023-05-27 19:19:09 +00:00
Carlos Garnacho
410c08e1e2 backends/x11: Chain up in nested backend cursor renderer
This is missed, leaving the cursor renderer disconnected from the stage
updates that could trigger further frame callbacks on the cursor, leaving
some clients like Xwayland stuck with cursors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3025>
2023-05-27 10:23:20 +00:00
Marco Trevisan (Treviño)
079745ca9f tests/dbusmock-templates/colord: Remove unused variables
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3016>
2023-05-25 09:21:57 +00:00
Marco Trevisan (Treviño)
7d95a41ec2 tests/dbusmock-templates/colord: Support usernames with dash chars
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3016>
2023-05-25 09:21:57 +00:00
Robert Mader
4a5a31edc6 mutter: Remove stray spaces
To silence code-style-check complains.

Fixes d44f02ba64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3018>
2023-05-24 14:16:41 +02:00
Georges Basile Stavracas Neto
894b4c713f meta/stage: Remove "actors-painted" signal
It is currently unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
Carlos Garnacho
8c0809995a backends: Do not prevent mapping/keep-aspect changes on integrated tablets
We do in fact allow these combinations of configuration since the Settings
Wacom panel revamp. We no longer need to look up Wacom device features,
since this is allowed for all the devices that have these settings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
ee412cc4a3 backends/native: Change handling of display mapping for rel tablet tools
We avoided setting the device matrix applying to the tablet tool (used if the
tablet is in absolute coordinates mode) if the device is configured for relative
motion, but forgot to apply the matrix if changing the device back to absolute
mode, this made the device seemingly forget its attached display until later
configuration changes.

In order to avoid the hassle of looking up the right display again on unrelated
configuration changes, make the matrix be always set on the device, but only
actually used in absolute coordinates mode. This makes the device able to
seamlessly switch between modes and remain mapped to the right display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
558f3156dc backends/native: Fix relative motion filtering for tablet tools
This was somewhat ineffective since it was applied after figuring out
the x/y absolute coordinates. Change the order (filter first, then
figure out abs coords), and use coordinates from the correct device
while at it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
3bea86298d core: Avoid placing hidden windows too early on Wayland
This check only waited for windows without a buffer for wayland
clients. This should happen for all windows on a Wayland backend
here, unlike the other places calling client_window_should_be_mapped()
that expect to get ahead of the window state.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2786
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2999>
2023-05-22 16:12:36 +00:00
Bilal Elmoussaoui
d44f02ba64 mutter: Cleanup gi-docgen annotations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2939>
2023-05-22 15:47:37 +00:00
Carlos Garnacho
4fcfd0350e core: Sync actor frozen state after destroying frame
A window may become undecorated while the frame window is
frozen due to updates. In that case we would both miss a
reply for the frame window, and any other means to trigger
the window actor being thawed.

Check the frozen state after destroying the frame, so that
meta_window_x11_are_updates_frozen() may end up changing
opinion if the frame window was caught in this situation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2639
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2996>
2023-05-22 15:13:30 +00:00
msizanoen1
ae4755cc61 surface-actor: Fix meta_surface_actor_is_obscured_on_stage_view
`meta_surface_actor_is_obscured_on_stage_view` currently fails to
account for non-identity scaling of actor size (e.g. window actor
geometry scale or surface pixel alignment).

Fix this by using the new `meta_region_apply_matrix_transform_expand` to
calculate the unobscured region in stage coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
231729b7f2 window-actor/wayland: Check opacity before subtracting background in cull
This ensures that the background regions don't get marked as obscured if
the window itself is transparent (e.g. in window animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
caca38106f surface-actor: Use clutter_actor_get_paint_opacity
This prevents opaque regions from being subtracted from the unobscured
regions while MetaWindowActor is transparent (e.g. in window close
animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
8b3c1f4b87 cullable: Generalize actor coordinates space translation for regions
This allows MetaCullable to work with actors using arbitrary transforms
which will be needed for implementing surface pixel alignment for
fractional-scale-v1.

This also deletes meta_cullable_is_untransformed as it's no longer
necessary, and we can also stop manually scaling the region objects
while performing opaque region culling in surfaces since it's now
handled transparently by the new `meta_cullable_cull_out_children`
implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ae403f2e94 wayland: Use new highest scale monitor tracking for fractional_scale_v1
This ensures consistency with the surface pixel alignment transforms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
e94b527777 surface-actor/wayland: Implement stable size and position rounding
Implement the stable rounding algorithm as described in the discussions
for the fractional-scale-v1 protocol.

This adds an override of the ClutterActor::apply_transform vfunc for
MetaSurfaceActorWayland that ensures the size and position of the
contents of the surface are rounded according to the stable rounding
algorithm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ed90c78872 window-actor/wayland: Align window content to physical pixel
Always ensure that the MetaSurfaceContainerActorWayland is aligned to physical
pixel boundary in preparation for fractional-scale-v1 protocol support.

This introduces an override of ClutterActor::apply_transform vfunc for
MetaSurfaceContainerActorWayland that always ensures the actor content is aligned
to physical pixel boundary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
e4d7667c43 core/window: Track monitor with the highest scale value
This is used for Wayland fractional scale pixel alignment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
Jonas Ådahl
875922fbe3 tests/test-runner: Log each command before running
With verbose mode test runner will log every command before it executes
it. Hopefully this will help in some cases when tests fail in CI with a
timeout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2893>
2023-05-22 13:21:39 +00:00
Robert Mader
f73fdfb465 drm-buffer-gbm: Bail out early if FBO allocation fails
A failing allocation is non-fatal here, however if it fails later in a
lazy allocation triggered by `cogl_framebuffer_create_timestamp_query()`
we end up crashing. Thus force the allocation early, like we already do
in other places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3004>
2023-05-17 13:37:50 +00:00
Carlos Garnacho
18e06c2484 backends/x11: Use backend-side error traps for input configuration
While it's obviously good to trap possible errors from X calls, we are
mixing the Clutter error trap with the MetaX11Display one for these
calls.

This may result in situations where a X call within a Clutter error
trap fails, but it's actually handled in these sections using the
MetaX11Display error trap. This one will consider the serial out
of the "handled" parts and raise an error.

It is better to stay consistent here, and use the same error traps
than the rest of the X11 backend.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2796
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3002>
2023-05-16 16:02:43 +00:00
Carlos Garnacho
3218626d7e x11: Do not unminimize windows with initial IconicState
This is a revert of commit be5c2ebc, adapted to this day and age.
While this worked around issues in wine/proton, it did contravene
icccm in the interpretation of initially iconic windows.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2043
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3001>
2023-05-16 15:34:25 +00:00
Bilal Elmoussaoui
b9a6891910 display: Drop the indirection when initializating Xwayland
The init function didn't do much other then calling into the xwayland
one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:47:06 +02:00
Bilal Elmoussaoui
15b25568b2 compositor/x11: Drop duplicated methods calls
Those are called in the handler of MetaDisplay::x11-display-opened

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
02a436d607 wayland: Move surface check to MetaWaylandSurface
Allows dropping various HAVE_XWAYLAND ifdef as the function would always
return false if Mutter is built without XWayland

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
a27b9d9707 wayland: Guard XWayland types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
0f88f0931c core/events: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
3e95609073 compositor/dnd: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
761a254e6f core/display: Guard X11 types
This also moves a couple of function calls to
MetaDisplay::x11-display-opened a signal handler

Related https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
aaa3f34cc0 compositor: Guard X11 types
This also moves meta_compositor_x11_redirect_windows to DisplayX11
where it makes more sense as meta_display_x11_redirection_windows

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:23:37 +02:00
Marco Trevisan (Treviño)
184b8e9c8c x11/x11-display: Fix some wrong code style to please CI checker
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:40 +02:00
Marco Trevisan (Treviño)
c9c4b06429 tests/test-client: Use proper style for main arguments
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:39 +02:00
Marco Trevisan (Treviño)
8039b58410 x11/x11-display: Always set the compositor manager selection on init
Set the compositor manager selection during the initialization phase as
we do with the window manager selection

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:37 +02:00
Marco Trevisan (Treviño)
c653f30283 tests/test-client: Ensure that screen has always a compositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
b48351005e tests: Add check for compositor state on XWayland startup
Check that the first X11 window started has a compositor defined.

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472#note_1582262
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
28bd3da21a tests/meson: Make tests depending on test-client to actually depend on it
It allows meson to rebuild the client-related sources when a single test
is running using the client, also ensuring that test-run dependencies
are correctly setup

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
2625edec10 x11/x11-display: Set compositor selection earlier on XWayland
When the X11 display is actually XWayland there's no point to delay the
compositor selection, given that mutter itself is the compositor and
doing this may cause the first X11 client that starts not to receive the
right information (and in some cases misbehave).

Since some toolkits are not handling the compositor selection changes
properly at later times, let's make their life easier by just
initializing the selection as early as the other X11 properties, given
that in this case there's nothing to replace.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:04:59 +02:00
Bilal Elmoussaoui
05dd401b64 tests: Make wayland-x11-interop depends on xwayland feature
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2938>
2023-05-15 11:52:35 +00:00
Jonas Ådahl
99a58be104 build: Set built headers as libmutter_dep sources
This should help avoiding compiling objects depending on built headers
to fail if they happen to be built before the sources are built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3000>
2023-05-15 13:06:40 +02:00
Barnabás Pőcze
f01428bd96 backends/x11: Fix type confusion about object data
Since c390f70edc ("backend: Set up and use ownership chains")
the type of the ClutterInputDevice object's "meta-input-settings-xdevice"
data is `DeviceHandle`, but that commit failed to change the one place
where the object data is queried. As a consequence, that part still
considers it to be an `XDevice`, so everything that uses the return
value of `device_ensure_xdevice()` works with invalid data. Furthermore,
`device_handle_free()` incorrectly uses the `user_data` as the argument
for `XCloseDevice()` leading to a double free.

Fixes: c390f70edc ("backend: Set up and use ownership chains")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2995>
2023-05-14 23:15:55 +00:00
Jonas Ådahl
1a4f03bd79 wayland/surface: NULL check surface resource in handle_output_bound()
Otherwise binding new wl_output's might try to send enter to the
destroyed resource. Fixes the following crash:

     #0 wl_resource_get_client at ../src/wayland-server.c:801
     #1 handle_output_bound at ../src/wayland/meta-wayland-surface.c:1287
     #3 signal_emit_unlocked_R.isra.0 at ../gobject/gsignal.c:3812
     #6 ffi_call_unix64 at ../src/x86/unix64.S:104
     #7 ffi_call_int at ../src/x86/ffi64.c:673
     #8 ffi_call at ../src/x86/ffi64.c:710
     #9 wl_closure_invoke at ../src/connection.c:1025
    #10 wl_client_connection_data at ../src/wayland-server.c:438
    #11 wl_event_loop_dispatch at ../src/event-loop.c:1027
    #12 wayland_event_source_dispatch at ../src/wayland/meta-wayland.c:125
    #15 g_main_context_iterate.isra.0 at ../glib/gmain.c:4276
    #17 meta_context_run_main_loop at ../src/core/meta-context.c:482

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2196527
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2992>
2023-05-09 15:26:32 +00:00
Jonas Ådahl
802c1baec7 compositor-view: Chain up finalize()
The chaining up to the GObject finalize() method was missing, fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2991>
2023-05-09 10:31:38 +00:00
Robert Mader
9884a2c3d2 shaped-texture: Move variable declaration to the top
Just a minor cleanup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2990>
2023-05-07 23:18:33 +02:00
Robert Mader
2dd5196267 egl: Set EGL_IMAGE_PRESERVED_KHR on DMABUF import
Otherwise drivers would be free to alter the buffer content. While no
driver is known to do so, it's probably good to make things explicit.
See also `import_simple_dmabuf()` in Weston.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2990>
2023-05-07 23:16:37 +02:00
Jonas Ådahl
29ec2d2e20 screen-cast/src: Never dequeue pw_buffer's we refuse to record to
The DMA buffer paths vs MemFd paths differ slightly in when content is
recorded. This was in some places done by trying to record but bail if
the dequeued buffer had the wrong type. This is problematic for two
reasons: we'd update the timestamp even if we refused to record, making
the follow-up attempt fail, and we'd dequeue and queue buffers that
didn't get any content, meaning the receiving end would see empty
buffers potentially with only cursor updates.

Fix this by keeping track if a stream is DMA buffer able or not, and
don't attempt to record at all in the places we would previously require
DMA buffers. This avoids both issues: we don't dequeue/queue pw_buffers
that we refuse to record to, and we won't update the recorded timestamp
when we didn't intend to record to begin with.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2783
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2987>
2023-05-04 13:00:07 +00:00
Jonas Ådahl
8a4095308e build: Use / operator instead of format for Wayland protocol paths
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Jonas Ådahl
61b42e5303 build: Use / operator instead of join_paths everywhere
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Jonas Ådahl
dcaca398f1 tests: Set a dummy XDG_CONFIG_HOME variable
This avoids a local ~/.config/monitors.xml messing up tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Andy Holmes
07184e099c docs: Add missing flag documentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2983>
2023-05-04 11:46:09 +00:00
msizanoen1
3f85158b85 surface-actor: Queue rectangles of update region separately
This aims to help reduce the amount of pixels redrawn on the screen in
case the damage rectangle is partially occluded by another surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2965>
2023-05-03 08:53:36 +00:00
adarshgm
7f18cae282 edid: Integrate libdisplay-info for edid parsing
Hides libdisplay-info under a build time default-off flag,
provides provision to parse essential edid parameters with
APIs provided by libdisplay-info. This implementaion increases
readibility, avoids code duplication and decreases complexity
of edid parsing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2642>
2023-05-02 17:37:01 +00:00
Sebastian Keller
d643eb5c6f frames: Disable XDND support on the frame window
All X11 surfaces created by gtk4 claim to support XDND via the XdndAware
property. This was leading some clients, e.g. Qt, to consider the frame
window as drop target instead of the client window.

Avoid this issue by removing the XdndAware property again after gtk has
created the surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2715
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2978>
2023-04-28 12:46:58 +02:00
Carlos Garnacho
18be74edeb core: Fix map transitions for X11 windows on Wayland
We are attempting to show windows that do not yet have a
surface/buffer, this makes GNOME Shell avoid transitions
for these windows.

Since on Wayland X11 windows are also Wayland surfaces,
this check is also valid for these, and is thus made more
generic to also cater for these windows.

Eventually, meta_window_update_visibility() is called
when the surface gets its buffer, so the window can be
neatly animated.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2611
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2975>
2023-04-25 17:34:24 +02:00
Carlos Garnacho
5eb17a362e tests: Avoid CSD window in test
This ATM triggers missed .commit events for the window in question,
to be addressed in Xwayland. Since the test does not seem to specifically
rely on this window being CSD, make it a regular window instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2975>
2023-04-25 17:34:24 +02:00
Carlos Garnacho
57fdd7efd2 frames: Use cairo renderer on GTK frames
Going for the default GL renderer is known to trigger rendering
artifacts using the NVidia proprietary driver. Since we don't have
too many expectatives about frames being flashy (not to the point
of mandating GL), resort to the cairo renderer in the mean time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2976>
2023-04-24 12:07:06 +02:00
Sebastian Wick
cca07612b8 output: Check the EDID for the supported sink Colorimetry
Just like the HDR Metadata property the Colorspace property values only
indicate that the display driver supports signaling certain colorimetry.
It does not indidcate that the sink actually supports processing the
colorimetry. For this we have to look up the colorimetry support in the
EDID.

The default colorimetry is always supported. If we want bt.2020 we might
get either the RGB or YCC variant even if we ask for the RGB variant but
there is nothing we can do about it so let's just pretend it's a driver
issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2919>
2023-04-21 00:00:24 +02:00
Robert Mader
754a1a1ce6 wayland/dma-buf: Enable modifiers by default on non-native backend
If the used EGL backend supports it. In practice this should currently
only affect the nested backend.

Enabling modifiers can help with app development. An example is
`weston-simple-dmabuf-v4l`, which requires the linear modifier to be
available.

Note that Weston behaves similar already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2972>
2023-04-20 15:34:00 +00:00
Sebastian Keller
04fa926eea core: Remove meta_frame_get_flags()
It is private and the last caller was removed in 92feea30.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2971>
2023-04-20 15:49:55 +02:00
Robert Mader
b56ab36704 xdg-shell: Always handle frame callbacks in popup_apply_state()
Just like we do in `toplevel_apply_state()`.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2963>
2023-04-20 12:34:47 +00:00
Daniel van Vugt
dd6be7cf2a backends/x11: Trap errors from XIChangeProperty
And report them as warnings instead of crashing.

https://launchpad.net/bugs/2014986

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2960>
2023-04-18 20:18:01 +00:00
Jonas Ådahl
86b5d9d809 Replace using sscanf() to parse mode strings with new helper
This fixes issues when the locale uses characters other than `.` in
floating point numbers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Jonas Ådahl
2fd9834d94 monitor: Add helper to parse simple mode strings
This will be used to extract the resolution and refresh rate from
strings like "1920x1080@60.0" or "1280x720". This aims to replace the
use of the locale dependent sscanf() function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Jonas Ådahl
550a1dadf1 monitor: Don't use locale dependent mode ID string
The result of printf("%f", number) depends on the locale. To avoid
unpredictable mode IDs, make sure they always are generated the same no
matter the locale.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Michel Dänzer
db24557e40 wayland/xdg-shell: Bail from popup_configure if resource was destroyed
This function gets called when a surface state transaction is applied.
Applying a transaction can get delayed, so the Wayland resource may have
already been destroyed when we get here. In that case we cannot send
events, so there's nothing to do.

v2:
* Drop code comment, expand commit log instead. (Jonas Ådahl)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2737
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2967>
2023-04-18 10:37:18 +00:00
Jonas Ådahl
867494d3df wayland/cursor-surface: Update cursor on dispose
Otherwise we'll have a cursor sprite backed by a surface that no longer
exist. This usually doesn't happen, but can happen in rare situations
related to pointer capability changes Wayland client cursor changes and
hotplugs.

Fixes the following crash:

  #0 meta_wayland_buffer_get_resource() at ../src/wayland/meta-wayland-buffer.c:128
  #1 realize_cursor_sprite_from_wl_buffer_for_gpu() at ../src/backends/native/meta-cursor-renderer-native.c:1649
  #2 realize_cursor_sprite_for_gpu() at ../src/backends/native/meta-cursor-renderer-native.c:1869
  #3 realize_cursor_sprite() at ../src/backends/native/meta-cursor-renderer-native.c:1887
  #4 meta_cursor_renderer_native_update_cursor() at ../src/backends/native/meta-cursor-renderer-native.c:1100
  #5 meta_cursor_renderer_update_cursor() at ../src/backends/meta-cursor-renderer.c:414
  #6 meta_cursor_renderer_force_update() at ../src/backends/meta-cursor-renderer.c:449
  #7 update_cursors() at ../src/backends/meta-backend.c:328
  #8 meta_backend_monitors_changed() at ../src/backends/meta-backend.c:338
  #9 meta_monitor_manager_notify_monitors_changed() at ../src/backends/meta-monitor-manager.c:3590
 #10 meta_monitor_manager_rebuild() at ../src/backends/meta-monitor-manager.c:3678
 #11 meta_monitor_manager_native_apply_monitors_config() at ../src/backends/native/meta-monitor-manager-native.c:343
 #12 meta_monitor_manager_apply_monitors_config() at ../src/backends/meta-monitor-manager.c:706
 #13 meta_monitor_manager_ensure_configured() at ../src/backends/meta-monitor-manager.c:779
 #14 meta_monitor_manager_reconfigure() at ../src/backends/meta-monitor-manager.c:3738
 #15 meta_monitor_manager_reload() at ../src/backends/meta-monitor-manager.c:3745

or the following on gnome-43:

 #0 meta_wayland_surface_get_buffer at ../src/wayland/meta-wayland-surface.c:441
 #1 meta_cursor_sprite_wayland_get_buffer at ../src/wayland/meta-cursor-sprite-wayland.c:83
 #2 realize_cursor_sprite_from_wl_buffer_for_gpu at ../src/backends/native/meta-cursor-renderer-native.c:1612
 #3 realize_cursor_sprite_for_gpu at ../src/backends/native/meta-cursor-renderer-native.c:1836
 #4 realize_cursor_sprite at ../src/backends/native/meta-cursor-renderer-native.c:1854
 #5 meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1087
 #6 meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:413
 #7 meta_cursor_renderer_force_update at ../src/backends/meta-cursor-renderer.c:448
 #8 update_cursors at ../src/backends/meta-backend.c:344
 #9 meta_backend_monitors_changed at ../src/backends/meta-backend.c:354

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2185113
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2968>
2023-04-17 19:53:35 +00:00
Jonas Ådahl
9252131348 cursor-tracker: Don't leak window cursor on exit
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2968>
2023-04-17 19:53:35 +00:00
Robert Mader
a7a7933e03 wayland: Emit frame events in GSource after "empty" updates
Under certain conditions a stage-view update does not trigger a kms
update.

In such cases we still want the next update to run within the same
refresh cycle, as otherwise we'd waste the remaining time in the
current one.
At the same time we currently use the `after-update` signal for Wayland
frame events, which again may result in more "empty" updates -
creating an unthrottled feedback loop. This can trigger excessive
load both in the compositor as well as in clients.

Introduce a new GSource that is dispatched once per refresh cycle at
maximum per stage view and use it to emit frame events. Do so by
computing the time from when on we can be sure that an update resulting
from a client commit would certainly get scheduled to the next refresh
cycle.

Note: this only works on the native backend. Given that chances are
small that we hit the corresponding issue on e.g. the nested backend,
stick to the previous behavior there for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Robert Mader
020d128d15 frame/native: Remember whether the frame carried a kms update
So that information is available in e.g. after_update handlers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Sebastian Keller
dddaf19d07 x11: Always initialize all fields of XEvents sent via XSendEvent
The X server ignores the send_event and serial in incoming XEvents, so
they were not initialized when calling XSendEvent in a few places.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2641
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2964>
2023-04-17 01:52:36 +02:00
Sebastian Keller
6b57ab8975 workspace: Only consider windows that should be showing as focusable
When selecting the default focus window, is_focusable() was not
considering the new conditions for whether a window should be shown or
hidden that were added to meta_window_should_be_showing() in 39942974.
As a result the default focus window could end up a window already
hidden or hidden once meta_window_flush_calc_showing() is called by
meta_window_focus() when focusing the default window. This would cause
meta_window_focus() to fail, which is an issue if it prevents us from
unfocusing a window when it is getting unmanaged.

Fixes: 399429742 ("x11: Integrate frames client into Mutter")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2644
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2962>
2023-04-16 11:48:37 +02:00
Sebastian Keller
a86900091d wayland: Set compositor when creating MetaWaylandDataSourceXWayland
create_and_send_dnd_offer() sets the compositor of the offer to the one
from the MetaWaylandDataSource. This then later gets used in
display_from_offer() when trying to get the context from the compositor.
meta_wayland_data_source_xwayland_new() however was not setting the
compositor, so this was causing crashes when dragging things from X11
windows on Wayland.

Fixes: 2731f0cda ("wayland: Setup and use ownership chains")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2723
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2956>
2023-04-15 16:01:42 +00:00
msizanoen1
1b140e8cb9 wayland/data-device: Clear data source when cancelling drag with ESC
This ensures a consistent code path with other cases where the drag
operation might be cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2953>
2023-04-15 10:11:07 +00:00
msizanoen1
ce0d9ccb37 dnd: Clear Wayland drag source when cancelled from stage grab context
This ensures that applications are notified when a drag gets cancelled
because the user dropped or press ESC while in overview.

This fixes an issue with Chromium on Wayland refusing to acknowledge
wl_pointer::enter events after accidentally dropping a
Chromium-originated object in GNOME Shell overview.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2953>
2023-04-15 10:11:07 +00:00
Carlos Garnacho
2a600ac98e frames: Forward _NET_WM_STATE during frame initialization
Ensure the frame window is created at the right fullscreen state
before showing it and assigning it to the client window.

A peculiarity of this property on frame windows is that it is
typically single-handedly updated from the Mutter side, in synchronization
with client window state. It can only differ during creation, since
GTK still likes to apply its own state.

Also, the only relevant property seems to be _NET_WM_STATE_FULLSCREEN,
since the others are less relevant to the role of the frames client,
and get applied to the MetaWindow as a whole, instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2712
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2961>
2023-04-14 13:55:23 +00:00
Sebastian Keller
6fbe4286ea x11: Fix remaining leaks from switch to XGetAtomName()
After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
94bd5c7319 x11: Use Atoms when constructing a new MetaX11SelectionOutputStream
This was pointlessly being converted between atom and string and back,
which with the switch from gdk_x11_get_xatom_name() to XGetAtomName()
also introduced a leak for every XGetAtomName() call.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
01ae1d32ee x11: Remove unused member variables from MetaX11SelectionInputStream
The private format and type member variables were not being used by any
of the callers, so they can simply be removed. This also fixes a leak of
type which was introduced when switching from gdk_x11_get_xatom_name()
to XGetAtomName().

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
5a4b67dd9e wayland: Don't leak XDnD mime type strings
After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: 014cde646 ("wayland: Do not use GDK functions on XDnD implementation")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Jonas Ådahl
47b6e76578 xdg-shell: Early out of apply if dismissed
We might end up trying to apply a pending state late if it was delayed
by DMA buffers not being ready. Trying to discard the pending state from
the transaction when dismissing is hard, because we might be applying a
chain of transactions that would disqualify subsequent transactions if a
former one dismisses the popup, so lets just drop what the apply would
otherwise do, if we're not going to use it anyway.

This fixes the following crash:

  0) meta_wayland_surface_get_window (surface=0x0)
  1) meta_wayland_xdg_popup_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  2) meta_wayland_surface_role_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  3) meta_wayland_surface_apply_state (surface=0xf5e640, state=0xf662a0)
  4) meta_wayland_transaction_apply (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  5) meta_wayland_transaction_maybe_apply_one (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  6) meta_wayland_transaction_maybe_apply (transaction=0xf56170)
  7) meta_wayland_transaction_dma_buf_dispatch (buffer=0xf448a0, user_data=0xf56200)
  8) meta_wayland_dma_buf_source_dispatch (base=0xf5f140, callback=0x0, user_data=0x0)
  9) g_main_dispatch (context=0x41baa0)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:08 +02:00
Jonas Ådahl
50a37a7fc0 wayland/xdg-shell: Dismiss instead of destroy invalid popup
Destroying is insufficient as it doesn't end any popup pointer grab, if
the dismissed popup was the last. This would later hit an assert as the
popup grab is assumed to always have at least one popup in its chain.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2728
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:03 +02:00
Jonas Ådahl
697b99ee13 wayland/xdg-shell: Ignore reposition if popup was dismissed
If the popup was dismissed (i.e. has no MetaWindow anymore), it'll also
have no parent surface. With no parent surface, we'd try to fetch a
transaction from NULL and crash, but if we don't try if we were
dismissed, we won't reach here anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:03 +02:00
Carlos Garnacho
f744acefee core: Create passive button grab on topmost Window
With the frames client, we do no longer handle events for the
frame window inside Mutter. This means we do not get events
"for free" to handle focus on a just clicked frame window.
This results in a background window not ending up focused if
clicked on its frame.

In order to fix this, make the passive button grab extend to
the frame window if a window has one. This brings back
focus-on-click behavior, while treating windows further as
a unitary surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2727
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Carlos Garnacho
a42bc34e4d core: Pass MetaWindow on passive button grab machinery
In practical effects the passed Window is always window->xwindow,
so pass the MetaWindow and get the better X11 Window deep in the
call stack.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Carlos Garnacho
e30abee5a2 core: Minor refactor
Do not make code live before variable declarations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Georges Basile Stavracas Neto
bc19f55129 screen-cast/monitor-src: Record frames with presentation time
Pass the timestamp of the frame as the target timestamp of the
record. This makes the rudimentary frame throttling mechanism
inside MetaScreenCastStreamSrc work with the timing variability
that dynamic dispatch times introduced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
bc2f1145d8 screen-cast/monitor-src: Record DMA-BUF frames immediately
Instead of always, unconditionally scheduling an idle callback for
frame recording, try to record a DMA-BUF only frame, and only if
that's not possible, schedule the idle callback.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
7f28fa6c79 screen-cast/src: Shuffle a variable around
This GError is only used within the frame recording block, so move
it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
ded7b8dfba screen-cast/src: Clean up DMA-BUF only error paths
When a stream source subclass asks for a DMA-BUF only frame record,
it is legitimate to return FALSE in do_record_frame() - meaning that
a frame was not recorded - but not return an error - meaning nothing
actually failed.

This avoids spamming the journal with warnings on a legitimate case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
16aa2943e2 screen-cast/src: Add frame recording variant with timestamp
Add meta_screen_cast_stream_src_maybe_record_frame_with_timestamp()
which operates on arbitrary timestamps; and make the current function
meta_screen_cast_stream_src_maybe_record_frame() just call into the
new variant, passing g_get_monotonic_time() as the timestamp.

This will be useful later we start using the target timestamp of the
frame for screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:48 +02:00
Georges Basile Stavracas Neto
b47d96b862 backends/stage: Pass ClutterFrame to MetaStageWatchFunc
We'll need to access the timestamp of the frame later on, so pass
it to stage watchers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:19:23 +02:00
Corentin Noël
eeee654031 cursor-tracker: Enhance the documentation and increase annotation coverage
Add the (optional) parameters when they are actually supported and at least add
the minimal documentation on functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2951>
2023-04-07 11:30:40 +02:00
Salman
776e3f329d screen-cast-stream-src: Export damaged video regions
This change will export the damaged regions (when available) out
to the pipewire client. This change is currently specific to
virtual streams only (where I was able to test the change) and
maintains the current behavior for other screencast stream types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Salman
6223742996 screen-cast-stream-src: Minor adjustment
This change makes it easier to add/remove stream params during test/dev.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Salman
43cee4b6b6 stage-impl: Do clipped redraws when drawing offscreen
This change allows clipped redraws for offscreen. The net
effect of this change is to preserve the original redraw clip when
possible (rather than overwriting it with the full view redraw) in
the paint context.

This eventually helps in retrieving the fine grained updated regions of
the frame since last redraw and sending it to the pipewire client
(as shown in a subsquent CL).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Jonas Ådahl
ab36baa9b1 frames/content: Use gtk_widget_compute_point()
The non-graphene-point variant is deprecated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2949>
2023-04-05 16:38:16 +00:00
Florian Müllner
018786dab8 output-xrandr: Don't treat 0 as invalid backlight value
Whether a value is in range depends on the backlight-min/max values,
and I didn't spot anything that excludes 0 as a valid lower limit
outright.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2947>
2023-04-04 19:30:06 +00:00
Florian Müllner
aa1eaa8120 output-xrandr: Consistently return -1 on error
Returning FALSE does not indicate an error, but a valid backlight
value of 0. Consumers expect a negative value to indicate no
backlight support, so return -1 in case of error, just like we
already do for invalid values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2947>
2023-04-04 19:30:05 +00:00
Carlos Garnacho
1e459c8302 x11: Wrap X call with error traps
Lest it fails. Try to recover from that and keep reading
the mimetypes present in the atom list.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6555
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Carlos Garnacho
2e82702084 x11: Pass Atom directly
We convert an atom to string just to convert it to an atom. We
can avoid the roundtrip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Marco Trevisan (Treviño)
20e2adc4fc frames/window-tracker: Select StructureNotifyMask X11 events
The window tracker is filtering XEvents manually as it only requires a
subset of the ones that Gdk listens to in the root window, and this is
nice, but we were restricting the set a bit too much because due to this
we were not notified when an xsettings manager was available, and thus
in case gsd-xsettings was launched after meta-window-tracker (a normal
scenario under X11), no xsetting was actually applied to the decoration
windows.

As per this, the default settings were used for everything and never
updated, until a restart of the window-tracker.

In order to be able to monitor the XSettings changes at startup, we also
need to select the StructureNotifyMask as gtk always do by default.

See also:
  https://gitlab.gnome.org/GNOME/gtk/-/blob/4.11.1/gdk/x11/gdkscreen-x11.c#L947-950

Fixes: #2580
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2948>
2023-04-04 10:50:42 +00:00
Chris Mayo
28a599631d backend: Fix build with -Dremote_desktop=false
../mutter-44.0/src/backends/meta-backend.c: In function ‘meta_backend_real_post_init’:
../mutter-44.0/src/backends/meta-backend.c:560:7: error: ‘MetaBackendPrivate’ {aka ‘struct _MetaBackendPrivate’} has no member named ‘remote_access_controller’
  560 |   priv->remote_access_controller =
      |       ^~

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2655
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2935>
2023-04-03 21:34:54 +00:00
Jonas Ådahl
8ca94f4d3f backends: Use meta_gamma_lut_new_sized() in a few more places
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2944>
2023-03-30 11:21:02 +00:00
Carlos Garnacho
f3f1db5e33 compositor: Drop anchor_window_pos field from MetaWindowDrag
This is now only set and never used. We can remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
7eb0130425 compositor: Use relative anchor coordinates for window drags
The anchor position calculations are somewhat unnecessarily complex
based on root coordinates of pointer and frame positions. This requires
tracking both things, and we don't always get it quite right with the
latter (e.g. window repositions, resizes or overshrinks, leaving the
anchor position visually outside the window).

In order to improve this, capture the window-relative coordinates
when starting the window drag, and ensure the window is always repositioned
in that position, relative to its current size.

This avoids these glitches when unmaximizing a window (e.g. dragged from
the bottom through super+button1 press), or moving windows between monitors
with different scales.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2730
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
179124dc61 compositor: Avoid use of variable during resize
Since we only track changes to window_drag->anchor_window_pos
during move operations through on_grab_window_size_changed(), this
rectangle is in essence the same than window_drag->initial_window_pos
all the time. Just use that and move away from the anchor_window_pos
rectangle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Daniel van Vugt
61801a713a onscreen/native: Avoid freezing the frame clock on failed cursor commits
Since 73fb64cbb6 we have preferred to handle failed updates via callback
but the cursor-only update path was forgotten and so wasn't getting frame
notifications. And so the frame clock would freeze.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2691
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2933>
2023-03-29 10:43:31 +00:00
Jonas Dreßler
7455c293c6 window-actor-x11: Check array bounds before accessing array
scan_visible_region() scans through each value of a uint8_t array and checks
whether that value is 255. Right now it always checks one value too much
though, resulting in a buffer overflow. Fix that by checking the array
bounds before actually accessing the array.

Found by running gnome-shell with address sanitizer and starting
GIMP.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2856>
2023-03-26 11:51:02 +00:00
Simon McVittie
d6af73ba68 tests: Use a more interoperable path to bash
On systems that have undergone the /usr merge, /bin/bash and
/usr/bin/bash can be used interchangeably, but on systems where /bin and
/usr/bin are separate (such as Debian 11 or older), bash was traditionally
in /bin and there is no bash in /usr/bin.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2385
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2900>
2023-03-22 15:16:06 +00:00
Jonas Ådahl
83a6a011d7 backend/nested: Ignore setting pointer constraint
This avoids a crash when pointer constraints are enabled by Wayland
clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2932>
2023-03-22 13:46:21 +00:00
Ivan Molodetskikh
4f47ba26be Export meta_window_has_pointer ()
It is needed in gnome-shell in the screenshot UI to tell which window has a pointer over it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2928>
2023-03-20 20:23:02 +00:00
Florian Müllner
f14dcb023d compositor/window-drag: Fix keyboard resize
Both GRAB_OP_KEYBOARD_MOVING and GRAB_OP_KEYBOARD_RESIZING_* are
defined as GRAB_OP_WINDOW_BASE with FLAG_KEYBOARD set, but the
latter have additional bits set to indicate the direction.

That is, the GRAB_OP_KEYBOARD_MOVING bitmask cannot be used to
differentiate between move- and resize operations. Instead,
check that no direction bits are set.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2684

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2908>
2023-03-20 16:13:32 +00:00
Sebastian Wick
3988f5a47f backends: Fall back to the default and not the unknown color space
The unknown color space's only purpose is to signal that the current KMS
state has a unknown color space set. It is not one of the color spaces
that can be set. We already only try to set a color space if the default
color space is supported so we should use the default color space as a
fallback instead of the unknown color space.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2693
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2915>
2023-03-20 10:00:36 +00:00
Daniel van Vugt
1be2f635e9 kms/impl-device/simple: Avoid destroying a NULL hash table
Which would trigger:
```
g_hash_table_destroy: assertion 'hash_table != NULL' failed
```
on non-KMS systems like with `nvidia-drm.modeset=0`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2904>
2023-03-20 09:20:16 +00:00
Daniel van Vugt
46e1ede687 wayland/buffer: Avoid spamming the log when a buffer is not scanoutable
It's not really an error and we recover seamlessly.

If someone really wants to check if/why direct scanout is failing then
they can still use `env MUTTER_DEBUG=render,kms`.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2702
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2918>
2023-03-20 07:22:03 +00:00
Jonas Ådahl
176418d0e7 kms/device: Avoid leaking some fields
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2926>
2023-03-19 22:32:43 +00:00
Sebastian Keller
7fbef2cb6e kms/impl-device: Fix result listener list leak
queue_result_feedback() takes ownership of the result listeners list via
meta_kms_update_take_result_listeners(), but does not free it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2922>
2023-03-19 22:05:00 +00:00
Jonas Ådahl
08bdee58c9 Revert "core: Avoid setting up frames on fullscreen windows"
This caused feedback loops with old statically compiled SDL
applications. The bug is fixed in upstream SDL, but that doesn't help
when the executables have old SDL's built into them.

This reverts commit beeeea546b.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2678
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2921>
2023-03-18 18:25:39 +00:00
Sebastian Wick
0ed2503140 backends/native: Report correct Gamma support on the KMS properties path
The gamma property blob can be zero to indicate passthrough but Gamma is
still supported in that case.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2686
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2916>
2023-03-18 17:52:27 +00:00
Jonas Ådahl
214a7d393b monitor-manager: Apply switch-config in idle callback
Just as with restoring the previous monitor configuration in case the
user clicked "revert" in GNOME Shell's monitor configuration
confirmation dialog, we need to do switch configs in an idle callback as
well.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2694
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2912>
2023-03-18 16:20:49 +00:00
Carlos Garnacho
5daddf0bc7 core: Retrieve DESKTOP_AUTOSTART_ID early on startup
With the move away from GTK3, and the indirect dependency on GTK4
grown in the GNOME Shell side, we've indirectly gotten a small sneaky
behavioral change: The GTK4 library will, right on dlopen, get
DESKTOP_AUTOSTART_ID for itself and delete it from the environment.

This happens before our own X11 session management code is
initialized, which confuses the hell out of it, into thinking
initialization is actually shutdown, gnome-session does not follow
along with this request, which leaves GNOME Shell into a confused
startup state where it never calls SmcSaveYourselfDone() and grinds
startup to a halt until gnome-session decides to move things forward.

In order to fix this, get the DESKTOP_AUTOSTART_ID before we lend
control to GNOME Shell bits and GTK4 is possibly initialized, and
feed it directly to our X11 session manager bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2906>
2023-03-18 15:40:17 +00:00
Jonas Ådahl
d31b781efb monitor-manager: Restore old config in idle callback when unconfirmed
We might get told to restore the old monitor configuration by the
monitor configuration prompt, in case the user pressed "revert" or
equivalent. This might be in response to a button press, and those
happen during frame clock dispatch. If we would restore an old
configuration during dispatch, it means we would reconfigure the
monitors including their stage views while dispatching, which means we'd
destroy the frame clock while it's dispatching.

Doing that causes problems, as the frame clock isn't expecting to be
destroyed mid-function. Specifically,

We'd enter

  clutter_frame_clock_dispatch (clutter-frame-clock.c:811)
  frame_clock_source_dispatch (clutter-frame-clock.c:839)
  g_main_dispatch (gmain.c:3454)
  g_main_context_dispatch (gmain.c:4172)
  g_main_context_iterate.constprop.0 (gmain.c:4248)
  g_main_loop_run (gmain.c:4448)
  meta_context_run_main_loop (meta-context.c:482)
  main (main.c:663)

which would first call

  _clutter_process_event (clutter-main.c:920)
  _clutter_stage_process_queued_events (clutter-stage.c:757)
  handle_frame_clock_before_frame (clutter-stage-view.c:1150)

which would emit e.g. a button event all the way to a button press
handler, which would e.g. deny the new configuration:

  restore_previous_config (meta-monitor-manager.c:1931)
  confirm_configuration (meta-monitor-manager.c:2866)
  meta_monitor_manager_confirm_configuration (meta-monitor-manager.c:2880)
  meta_plugin_complete_display_change (meta-plugin.c:172)

That would then regenerate the monitor configuration and stage view
layout, which would destroy the old stage view and frame clock.

  meta_stage_native_rebuild_views (meta-stage-native.c:68)
  meta_backend_native_update_screen_size (meta-backend-native.c:457)
  meta_backend_sync_screen_size (meta-backend.c:266)
  meta_backend_monitors_changed (meta-backend.c:337)
  meta_monitor_manager_notify_monitors_changed (meta-monitor-manager.c:3595)
  meta_monitor_manager_rebuild (meta-monitor-manager.c:3683)
  meta_monitor_manager_native_apply_monitors_config (meta-monitor-manager-native.c:343)
  meta_monitor_manager_apply_monitors_config (meta-monitor-manager.c:704)

After returning back to the original clutter_frame_clock_dispatch()
frame, various state in the frame clock will be gone and we'd crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2901>
2023-03-18 13:52:10 +00:00
Jonas Ådahl
dbe8141a67 monitor-manager: Use g_clear_handle() to clean up D-Bus name owning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2901>
2023-03-18 13:52:10 +00:00
Jonas Ådahl
e6a53ef113 monitor-manager: Use guint for handle IDs
To follow convention.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2901>
2023-03-18 13:52:10 +00:00
Florian Müllner
f90749916a prefs: Add get_keybinding_label() method
Commit 7e9d9c7eb9 added new API to replace GTK for accelerator
parsing.

Unfortunately there is another case in gnome-shell, where we have
to get the label from the logical binding name rather than the
modifier+keysym combination.

Add another small method to cover that use case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2899>
2023-03-06 01:57:27 +01:00
Carlos Garnacho
3ac82a58c5 core: Avoid focusing windows on map during grabs
Normally, mutter implicitly allows a window being shown to take
focus. This is normally desired, except it steals input from
GNOME Shell self. Avoid focusing the just shown window in those
situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
608d3019b6 x11: Ignore _NET_ACTIVE_WINDOW client messages while grabbed
When a X11 application is started, typically what happens is:

- A startup notification token is created, with a _TIME%d suffix
- The application being spawned receives it through the environment
- (dbus piping, maybe)
- The application replies the startup notification token, and
  fetches the timestamp from it
- The application makes a _NET_ACTIVE_WINDOW client message request
  with this timestamp
- Mutter handles this client request and activates/focuses the window

Prevent this last step if windows are not interactable (e.g. there is
a compositor grab) and ignore the focus request. This specifically
applies to X11 clients requesting focus themselves, and unlike previous
approaches, doesn't try to prevent focus changes that do come through
interaction with Mutter/GNOME Shell.

This should only break if applications do not observe _NET_ACTIVE_WINDOW
and perform XSetInputFocus on themselves, but in that case the X11
keyboard focus is stolen from our hands already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
92792d6850 Revert "x11/events: Do not update focus XWindow during grabs"
This reverts commit 0e6395d932.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
7de834b915 Revert "x11: Do not move X11 input focus during grabs"
This reverts commit a68b8e9595.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Robert Mader
ce63543a3e tests/wayland: Add missing dependencies
They're needed for `ceilf()`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2895>
2023-03-05 00:23:26 +00:00
Jonas Ådahl
af9a7741f4 frames: Select SubstructureNotifyMask too
This is the mask that lets us receive among other events the rather
important CreateNotify, that tells us about new winows. This has went by
rather unnoticed except for cases where multiple windows show up very
quickly directly after the frames client spawned, because the drag icon
surface cache eventually already did select that particular mask.

Make things more reliably by explicitly setting the mask for the events
we rely on to function.

This fixes flaky stacking tests that map multiple X11 windows in a row.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2894>
2023-03-04 23:45:35 +00:00
Robert Mader
a9c9b89358 tests/wayland: Add test for fractional-scale protocol
For now test that a simple fullscreen client on a FullHD screen selects
the expected values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Robert Mader
18ea492daf tests/build: Order Wayland tests alphabetically
And ensure they all start with "wayland-" for consistency.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Robert Mader
692ea856fb tests/wayland-client-utils: Use interface names instead of static strings
Let's be a good example here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Robert Mader
c64a04678a wayland/surface: Export get_buffer_[width|height] to tests
It will be used in fractional scale tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Robert Mader
305931e2dd wayland: Implement fractional_scale_v1 protocol
Giving clients hints about optimal fractional scaling ratios,
to be used together with the `wp_viewport` protocol.

See
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/1.31/staging/fractional-scale/fractional-scale-v1.xml

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Robert Mader
ef2e9dade8 wayland/surface: Fix can_scanout_untransformed() for transform+viewport
The buffer needs to match the untransformed layout size.

While on it simplify the check from floats to ints where possible - and
improve logging a bit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2394>
2023-03-04 22:13:45 +01:00
Jonas Ådahl
8b42564763 tests/build: Move 'service-channel' test to a 'misc' section
It only has a Wayland test, but might get Wayland unrelated things in
the future, so move it away into a "misc" section.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2892>
2023-03-04 20:56:40 +00:00
Jonas Ådahl
65ef0cb9e8 constraints: Don't apply titlebar constraint on non-drag user-op move
2d8fa26c8e ("core: Pass "frame action" grab operations as an
"unconstrained" grab op") changed the behaviour to treat non-grab
related window moving that has the "user action" flag set to still apply
the "constrain_titlebar_visible" constraint.

The fact that it wasn't applied before was relied upon by some
extensions. While it should arguably exist a better API that for such
extensions to use that have a bit more predictable behavior, until that
is so, restore the old semantics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2891>
2023-03-04 20:31:33 +00:00
Sebastian Wick
950fdc6c04 backends/native: Convert MetaOutputColorspace to DRM Colorspace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2890>
2023-03-04 19:53:30 +00:00
msizanoen1
aad0baf70d shaped-texture: Account for linear sampling when calculating actor damage
Linear sampling can influence the value of surrounding pixels beyond
the scaled framebuffer extents calculated during stage view rendering,
resulting in flickering graphical artifacts due to unaccounted pixel
changes. This is exhibited in xfreerdp and wlfreerdp at 150% display
scaling.

Fix this by ensuring that all pixels that may be affected by linear
scaling is included in the framebuffer redraw clip by padding the actor
redraw clip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2771>
2023-03-04 18:23:34 +00:00
Sebastian Wick
f729a2023e tests: Add tests for HDR Static Metadata encoding/decoding and equality
We have the drm/InfoFrame encoding and our MetaOutputHdrMetadata
encoding. Check that we can correctly convert between each other by
doing a encode/decode and decode/encode roundtrip and then checking for
equality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
af714edafb output: Check the EDID for HDR Static Metadata support
The existence of the KMS property just means that we can send an
InfoFrame but we also have to make sure the sink actually supports the
metadata type 1 and the selected transfer function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
7ecdfaa78d edid: Fix MetaEdidStaticMetadataType bitmask
Support for HDR Static Metadata Type 1 is announced in bit 0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
a8d73e669a backends/native: Wire up color space and HDR metadata
Announce support for color spaces and HDR metadata in OutputKms and
prepare KMS update in OnscreenNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
650d30c7bf backends/native: Process color space and HDR md updates
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
f092b6c78c backends/native: Add color space and HDR metadata updates
Allows to prepare KMS updates to set the color space and HDR Static
Metadata on the output.

For some reason we need ALLOW_MODESET on commits which change the HDR
Static Metadata InfoFrame on AMDGPU. There is no technical reason why
one needs to mode set to send an InfoFrame and the driver should just
manage without ALLOW_MODESET. Until this is resolved in the kernel we
just prepare KMS updates which might mode set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
5984aa8137 backends/native: Let updates require ALLOW_MODESET
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
76e69f2375 backends/native: Read color space and HDR metadata connector state
The HDR Static Metadata InfoFrame contents are described in CTA-861.3
and the kernel maintains a representation of that in `struct
hdr_metadata_infoframe` in `include/uapi/drm/drm_mode.h`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
2e69eafa06 backends/native: Add color space and HDR metadata KMS properties
The Colorspace property informs the display about the colorimetry of the
content. Only variants supported by the sink are exposed in the
property. The strings representing the color spaces are undocumented but
can be found in the `hdmi_colorspaces` list in
`drivers/gpu/drm/drm_connector.c` in the Linux kernel (v 6.2).

The HDR_OUTPUT_METADATA property is a blob with the InfoFrame content.
We have to query support for the different values in the struct from the
EDID/DisplayID ourselfs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
48e759c443 monitor-manager: Make color space and HDR metadata accessible from lg
This adds a new 'experimental-hdr' string property to the MonitorManager
which can be changed from looking glass.

Currently when the string equals 'on', HDR (PQ, Rec2020) will be enabled
on all monitors which support it. In the future support for more
transfer functions and color spaces as well as HDR metadata can be
added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:41 +00:00
Sebastian Wick
fad0efa687 output: Add color space and HDR metadata
The color space and HDR metadata are eventually sent as metadata to the
display. The color space informs the display of the colorimetry of the
frames we produce, the HDR metadata informs the display of the transfer
function and additional mastering display colorimetry and luminance to
guide tone and gamut mapping.

The only color spaces we support right now are the default color space
and Rec bt.2020 which is typically used for HDR content. Other supported
color spaces can be added when needed.

The default color space corresponds to whatever colorimetry the display
has when no further changes are made to the calibration of the display.
The colorimetry is communicated to sources via EDID/DisplayID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:40 +00:00
Sebastian Wick
47fcb52435 backend/native: Make is-privacy-screen-enabled not CONSTRUCT_ONLY
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
2023-03-04 09:30:40 +00:00
Olivier Fourdan
4005fda902 test: Add a test for "activate" hammering
This is what "terminator" (the terminal emulator) does, it basically
calls gdk_window_focus() in a loop thousands of times at startup.

This in turn fills up the Wayland connection between Xwayland and
mutter, and eventually the session dies.

See-also: https://github.com/gnome-terminator/terminator/issues/714
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Olivier Fourdan
3be189192a tests: Update README
"activate" is no longer a no-op on Wayland, it uses xdg-activation.

Update the README accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Olivier Fourdan
32e173c3ce startup-notification: Delay cursor feedback updates
A Wayland client repeatedly requesting activation of its surface using
the xdg-activation protocol would make mutter constantly update the
cursor.

To avoid needlessly updating the cursor back and forth between busy and
default, add a timeout to delay the update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Olivier Fourdan
5e7754f742 x11/display: Delay cursor updates
When a client (either Wayland or X11) is started, the window activation
will update the cursor to the "busy" cursor.

Mutter will then set the X11 cursor on the X11 root window to match that
so that X11 applications which do not explicitly set a cursor inherit
from that default (busy) cursor.

Updating the X11 cursor too often can hammer the X11 connection and
cause a deadlock with Xwayland.

Reload the X11 cursor in a later handler to avoid that issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Jonas Ådahl
4551bc6b86 tests/kms/hotplug: Add tests for connector coming and going
Doesn't test any known issue, but just for the sake of testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2887>
2023-03-03 22:36:30 +00:00
Jonas Ådahl
995f9f9db8 onscreen/native: Hold output and CRTC refs until dispose
We relied on them being valid longer to keep track of used GPUs. If we
don't have the CRTC (or output) we don't have a way to fetch the pointer
to the MetaGpu that drives the associated monitor.

This avoids a crash when trying to fetch said pointer from what would be
the NULL MetaCrtc pointer.

Fixes: 08593ea872 ("onscreen/native: Hold ref to the output and CRTC until detached")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2667
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2887>
2023-03-03 22:36:30 +00:00
Michel Dänzer
3d28e03a29 wayland: Take surface reference for presentation-time feedback
Without this, the feedback->surface pointer could outlive the surface
it pointed to, which could result in use-after-free.

One consequence of this is that if a MetaWaylandPresentationFeedback
object ever lingers on longer than expected, it would keep the
MetaWaylandSurface alive as well.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2585
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2886>
2023-03-03 21:14:07 +00:00
Carlos Garnacho
beeeea546b core: Avoid setting up frames on fullscreen windows
Ensure we preserve the fast zero-copy paths in Xwayland fullscreen
windows, instead of maybe rendering the client surface on top of the
frame surface, and providing the latter to the compositor.

To achieve this, additionally synchronize frame state when
recalculating features (e.g. after fullscreen/unfullscreen), and
account for this new condition when creating or destroying frames.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2797>
2023-03-03 20:33:18 +00:00
Carlos Garnacho
cd6b338ece build: Drop gtk3 build dependency from mutter library/executable
This is no longer directly needed by Mutter, so can be removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
a4f508db57 x11: Drop all bypass_gtk checks
There's no longer a GTK to appease, we can drop these
checks to tiptoe over it the right way.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
1fbbb73343 compositor: Add utility function to convert region to cairo_t path
We were relying on gdk_cairo_region() to convert a cairo_region_t
into a path ready to fill/stroke in a cairo_t. This is a small
and detached helper that we can do ourselves, so put it together
with all other region helper functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
ab9ea61d3d x11: Open a X11 Display directly
Do the few remaining things that GDK is doing for us:
- Open and close the X11 Display
- Set up a GSource on the Display FD to handle events
- Allocate and free the content of XGenericEventCookie,
  to "unroll" the few XInput2 events that Mutter still
  does handle.

And remove the GdkDisplay we've so long relied on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
a5042000c6 x11: Adopt X11 error trap infrastructure from GDK
From reading the comment in the top of the file, not for the first
time. Keep our own error handler and maintain our own list of
failable x11 sequences in MetaX11Display, so we can move away from
GTK's.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
2a182b91fb core: Sync after issuing key/button passive grabs
Try to collect any possible errors in place, instead of maybe
delegating asynchronous errors to maybe another error handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
a7e89453a7 core: Trap errors during passive button/key grabs
These are done on the backend X11 connection, so it is unclear
what is the interplay through the borrowed global XSetErrorHandler()
that triggers issues for us here.

Anyways, better to be explicit, and use error traps the MetaBackendX11
style, in coherence with the rest of the things happening in that
display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
ae2ceeda0b ci,tests: Pass GTK_A11Y=none to tests
Same rationale applies than NO_AT_BRIDGE, but for GTK4 bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Robert Mader
b521747d81 Remove support for window shading
It's been broken for an unknown time and was never supported on Wayland.
Thus let's remove the leftovers.

Helpful command: `rg 'shade(?!r)' --pcre2`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2884>
2023-03-03 19:17:51 +00:00
Robert Mader
92ac922519 window: Fix an if-block indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2884>
2023-03-03 19:17:51 +00:00
Jonas Ådahl
08593ea872 onscreen/native: Hold ref to the output and CRTC until detached
When an onscreen is "attached" it means it has an active CRTC and output
it interacts with, e.g. listens to configuration changes to update gamma
and privacy screen state.

MetaOutput and MetaCrtc are rather short lived objects meaning they are
disposed of and regenerated each time the compositor reloads monitor
resources, and while MetaOutput are indirectly kept alive due to the
MetaMonitor holding on to them during reloading, the same does not apply
to MetaCrtc, so to avoid trying to disconnect our signals from
disappeared outputs and CRTCs when we dispatch, hold our own references
to these objects.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2665
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2885>
2023-03-03 17:32:04 +00:00
Jonas Ådahl
d1785a3917 onscreen/native: Detach onscreens when disposing
On exit, explicitly detach the onscreens during disposal. This means no
functional changes, but allows for doing more cleanup on detach that
doesn't need to be repeated on disposal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2885>
2023-03-03 17:32:04 +00:00
Simon McVittie
ed12df1099 color-device: Don't close lcms profile on error from cd_icc_load_handle
As implemented in colord 1.4.6, cd_icc_load_handle() has three possible
results:

1. success, taking ownership of the profile;
2. failure because cmsGetProfileContextID returns NULL, *not* taking
   ownership of the profile;
3. failure in cd_icc_load(), taking ownership of the profile.

The previous commit ensures that we are not in case 2.

In case 3 where cd_icc_load() fails, ownership was already given to
the colord CdIcc object, so it will be freed when the g_autoptr unrefs
the CdIcc, and we must not free it again: that would be a double-free,
potentially resulting in memory corruption.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2659
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2877>
2023-03-03 12:07:02 +00:00
Simon McVittie
e2be2d271b color-device: Make sure lcms_context is not NULL
lcms interprets a NULL context as using a default, non-thread-safe
context, which is unsuitable for mutter's use. Make sure we're always
using a non-trivial context.

Helps: https://gitlab.gnome.org/GNOME/mutter/-/issues/2659
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2877>
2023-03-03 12:07:02 +00:00
Jonas Ådahl
6c1274b75e tests/monitor/default-scale: Add a couple of more test cases
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
2023-03-03 08:46:02 +00:00
Jonas Ådahl
d03dce4378 monitor: Use fractional scale result to decide the non-fractional scale
We want to avoid using too high scales too easily, which started to
happen 2f1dd049bf ("monitor-manager: Rework default scale factor
selection"). Instead of using the closest non-fractional scale, which
effectively is what we'd do, only round upwards if we're closer than
0.25 (25%).

Since there are some wiggle room for scales to make the logical
resolution on the integer pixel grid, make sure to compensate. This
compensation is done by adding an extra 0.2 to scale difference.

For example the following fractional scales will get these corresponding
integer scales:

    * 1.25 -> 1.0
    * 1.5 -> 1.0
    * 1.75 -> 2.0
    * 2.0 -> 2.0
    * 2.50 -> 2.0

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
2023-03-03 08:46:02 +00:00
Carlos Garnacho
bf8027ef0d tests: Fix default_scale test
It was only testing for the first item in all cases, instead
of going through all of them.

Fixes: a6217c720e ("tests: Add tests for monitor_calculate_mode_scale")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
2023-03-03 08:46:02 +00:00
Jonas Ådahl
b0207f9567 tests/monitor/default-scale: Fix test cases
They weren't running, and didn't pass. Update the values to match what
is the current result.

Fixes: a6217c720e ("tests: Add tests for monitor_calculate_mode_scale")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
2023-03-03 08:46:02 +00:00
Jonas Ådahl
98c9db98e3 tests/monitor/default-scale: Use a large epsilon
To have the test case say e.g. 1.75 while the effective scale is
1.74863386, use an epsilon of 0.2.

Fixes: a6217c720e ("tests: Add tests for monitor_calculate_mode_scale")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
2023-03-03 08:46:02 +00:00
Jonas Ådahl
f3f9200f9a tests: Port headless start test case to VKMS
Instead of testing headless start using the dummy backend, do so with
the real native backend, and use the drm-mock library instead to emulate
monitors being disconnected at startup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2821>
2023-03-02 23:49:15 +00:00
Jonas Ådahl
17623189e8 tests/drm-mock: Add filter mocking
This new filter allows test cases to manipulate what the kernel reports,
e.g. mark connected connectors as disconnected to emulate monitors
connecting and disconnecting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2821>
2023-03-02 23:49:15 +00:00
Jonas Ådahl
671efb9937 tests/drm-mock: Add missing newline in macro
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2821>
2023-03-02 23:49:15 +00:00
Jonas Ådahl
9abce2fca7 gpu/kms: Report that we can have outputs if we have connectors
As part of https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/525
(introduction of transactional KMS API), the logic determining whether a
GPU can have outputs was changed from whether any connectors existed to
whether any connected connectors existed. That effectively meant that we
wouldn't attempt to start at all if there were no monitors connected
while starting up.

This was unintentional, so lets revert back the expected behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2821>
2023-03-02 23:49:15 +00:00
Jonas Ådahl
ffd1e8106c kms/update: Merge connector updates too
This includes privacy screen updates, underscanning etc; this is needed
when merging mode set updates that happen to change these too, which is
rather likely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2881>
2023-03-02 22:09:16 +01:00
Jonas Ådahl
f27ca241f9 renderer/native: Move per frame KMS update to MetaFrameNative
In order to make things more and more asynchronus and to each time we
paint be an isolated event, that can be potentially be applied
individually or together with other updates, make it so that each time
we draw, we use the transient MetaFrameNative (ClutterFrame) instance to
carry a KMS update for us.

For this to work, we also need to restructure how we apply mode sets.
Previously we'd amend the same KMS update each frame during mode set,
then after the last CRTC was composited, we'd apply the update that
contained updates for all CRTC.

Now each CRTC has its own KMS update, and instead we put them in a per
device table, and whenever we finished painting, we'll merge the new
update into any existing one, and then finally once all CRTCs have been
composited, we'll apply an update that contains all the mode sets for all
relevant CRTCs on a device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:40:16 +01:00
Jonas Ådahl
90ae14e792 kms/device: Move result queueing to impl device
This means there will be no entry points to the dispatch machinery that
doesn't report about the results.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
25172c21c9 kms/impl-device: Move fd hold to update when processing
This will let us move the update ownership to the backend, allowing it
to handle it with less restrictions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
6d043e6a8f kms/impl-device: Let process() always take ownership of the update
This allows more freedom how to handle the update in the backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
135ed27d27 clutter/frame: Allow setting a backend release function
The one set by the native backend is empty, but it will be used later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
7b634df379 renderer-view/native: Allocate backend specific ClutterFrame
This will carry an on-demand created MetaKmsUpdate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Dor Askayo
1abd930c56 backends/native: Introduce MetaRendererViewNative
MetaRendererViewNative is a MetaRendererView which contains logic
specific to views of the native backend. It will be used by following
commits.

In the future, per-view logic from MetaRendererNative can be moved to
MetaRendererViewNative where it makes more sense to have it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
2dfbbf0068 tests/kms/render: Add test for scanout failure handling
Make sure we repaint correctly if direct scanout updates fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
fb622974b9 tests: Add static drm-mock library
Add a tiny library that sabotages errors in drmMode*() API calls. This
will be used to artificially trigger arbitrary errors, e.g. cause the
next commit to fail with EBUSY.

The three mocked methods are added as they will be used in a future
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
73fb64cbb6 kms: Always handle KMS update result via callback
Instead of using the "discarded" page flip callback when the
"discarding" happened during actual immediate processing, communicate
the same via the KMS update feedback.

The "discarded" page flip callback is instead used only for when a
posted page flip is discarded. In the atomic backend, this only happens
on shutdown, while in the simple backend, this also happens when a
asynchronous retry sequence eventually is abandoned.

This allows further improvements making KMS handling fully async.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
a2e442ab9d kms/result-listener: Let listeners own a feedback ref
Dispatch results via a helper, and let each result hold a reference to
the feedback. This allows for more asynchronous feedback management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
5dbd9cc1b8 onscreen/native: Process TEST_ONLY updates directly on the device
No point in going via a thin meta_kms_* wrapper.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
b1b9a9aac1 kms/update: Change lock() to seal()
At first it was called seal(), but then updates could be amended after
being posted, given a flag. That flag has been removed, so we can go
back to sealing, since it's once again acts more as a seal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
02b1cfe08f onscreen/native: Handle unexpected scanout failures async
We test direct client buffer scanout using a TEST_ONLY commit on atomic,
and with various conditions in non-atomic, but if we end up failing to
actually commit despite this, handle the fallout asynchronously. What
this means is that we'll reschedule a new frame immediately.

For this to work, the same scanout buffer needs to be avoided for the
same CRTC. This is done by using the newly added signal on the
CoglScanout object to let the MetaWaylandBuffer object mark the current
buffer as non-working for the onsrceen that it failed on. This allows to
re-try buffers on the same onscreen when new ones are attached.

This queues a full damage, since we consumed the qeued redraw rect. The
redraw rect wasn't lost - it was accumulated to make sure the whole
primary plane was redrawed according to the damage region, whenever we
would end up no longer doing direct scanout, but this accumulation only
works when we're not intentionally stopping to scanout. For now, lets
just damage the whole view, it's just an graceful fallback in response
to an unexpected error anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
cc2bbb25ba frame-clock: Don't delay schedule_now() if already scheduled
If we call schedule(), which will schedule an update some time in the
future, and then schedule_now(), we should reschedule the frame clock to
update immediately, and not some time in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
9752ddf2cf onscreen/native: Log kms debug messages when doing test commits
This helps identify the origin of other KMS debug logs logged during
processing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
51ff3fa194 onscreen/native: Don't swap the buffer if page flip failed
If a page flip failed, it means the current active framebuffer didn't
change, meaning we shouldn't swap it in mutter either.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
f6b75eef19 onscreen/native: Warn expecting next buffer on symoblic page flip
If we get a "ready" page flip feedback, it means the page flip was
symbolic, i.e. not real, e.g. as a result of an update that didn't
change the state of the primary plane. Warn if there is a "next fb"
meaning we expected to have a new buffer that we flipped to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
625a9e274a onscreen/native: Don't try to set modes before client buffer scanout
We explicitly don't allow direct client scanout when mode setting,
ensuring modes are set here is unnecessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
dcbe32f39f kms/page-flip-listener: Make object reference counted
The _ref() variant will be added later, when it gets a user, to avoid
a unused compiler warning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
7253ac501d kms: Make KMS feedback struct ref counted
It'll later be sent asynchronously; to prepare for that make it ref
counted with an atomic ref counter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
37db905ff9 kms/update: Support merging updates with mode sets
Will be helpful to allow constructing each initial mode set update per
CRTC, merging them later on-demand.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
9dcb28ffd1 kms/update: Add API to merge two updates
This is intended to be used only for plane assignment, and CRTC like
changes, so that one can e.g. change a cursor plane on a pending update
that changes the primary plane, before it has been committed to KMS.

The kms-updates test overrides the get-state function MetaKmsCrtc. This
is needd to not have the update mechanism not clamp the gamma size to 0,
as vkms reports the gamma length 0. By pretending it's 3, we can test a
simple and small gamma lut is merged correctly when merging updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
3e3611d171 kms/update: Stop tracking update sequence numbers
They were only used for logging, and complicates things when updates can
be merged. Since they aren't really useful, just remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Dreßler
256bdba309 constraints: Remove unnecessary if-check
One of those two must be TRUE because we're already inside exactly this
condition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2873>
2023-03-01 09:48:14 +00:00
Jonas Dreßler
0dd170264d window-wayland: Remove unused API
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2873>
2023-03-01 09:48:14 +00:00
Jonas Dreßler
f68b1ff030 window: Allow can-maximize when size hints are exactly screen sized
This looks like a bug: There's no reason why windows which advertise
min-size hints that are exactly the size of the workarea should not be
allowed to maximize, so change the checks here to allow for that.

The commit message of 7f64d6b9 also makes the point that this was not
intended, as it says "larger than".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2873>
2023-03-01 09:48:14 +00:00
Carlos Garnacho
2279f40e17 frames: Fix code typo
We are picking the wrong fallback frame title string in a
branch.

Fixes: 6df9eab88 ("frames: Handle _NET_WM_VISIBLE_NAME")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2875>
2023-02-28 18:13:23 +01:00
Robert Mader
4409dd24b6 surface-actor/wayland: Ensure screen-casted surfaces have a primary view
Surfaces belonging to a screen-casted window should always be considered
visible even if they are not visible on any stage view - be it because
they are on a different workspace, minimized or occluded.

Doing this in an optimal fashion is highly complex right now -
interdependent with (and somewhat similar to) ClutterClones. Thus treat
stream-casted surfaces similar to those with clones, with the small
difference that even a fully invisible surface still gets a primary view
- the fastest one. This ensures that clients never refresh too slow for a
screen-cast, at the cost of sometimes refreshing too fast.
The later only happens on certain multi-monitor setups and should thus be
acceptable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
2023-02-28 12:03:50 +01:00
Robert Mader
fe17dbc322 wayland/actor-surface: Always schedule stage updates on frame callbacks
There is an increasing number of cases where we want the frame callback
logic to run for a stage-view and the complexity needed to avoid these,
combined with the likelyhood of bugs, arguably does not justify the
benefit any more.

Thus unconditionally schedule updates for all stage-views when frame
callbacks are requested.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
2023-02-28 12:01:17 +01:00
Robert Mader
2d5dd06a50 screen-cast/window: Add API to check if stream-cast is active
Screen-casted windows need to be considered visible in various situations
but existing APIs such as `clutter_actor_is_effectively_on_stage_view()`
don't do so. Add new API that allows checking if a surface belongs to a
screen-casted window for the respective cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
2023-02-28 12:01:17 +01:00
Jonas Ådahl
e18ba5dcc6 backend: Always include D-Bus session watcher header
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2651
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2874>
2023-02-28 09:50:57 +00:00
Carlos Garnacho
5bdc08099e compositor: Fix handling of keyboard-driven window resize
The introduction of the META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED
flag threw off some checks around keyboard-driven resize. This
was partly because there were some == checks that did not account
for that flag maybe being enabled, but also the handling
of META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN into a definite
resize direction was maybe unsetting that flag. Fix both things
at the same time.

Fixes: 2d8fa26c8e ("core: Pass "frame action" grab operations as an "unconstrained" grab op")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2629
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2871>
2023-02-27 18:28:44 +00:00
Carlos Garnacho
022e20e87e frames: Handle WM_NAME
This is the most ancient form of "window titles", not guaranteed
to be UTF-8, take the usual precautions before using this string
and keep it as a last resort.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2872>
2023-02-27 15:38:25 +00:00
Carlos Garnacho
6df9eab880 frames: Handle _NET_WM_VISIBLE_NAME
This is occasionally set by Mutter, in order to hint about remote
X11 clients, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2872>
2023-02-27 15:38:25 +00:00
Carlos Garnacho
6142765262 frames: Minor refactor
Move extraction of UTF8_STRING properties to a helper, as we'll
want to use it for several properties.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2872>
2023-02-27 15:38:25 +00:00
Carlos Garnacho
473f58cb5b frames: Rename function
There's different levels of "title" we'll want to poke, make
this function name a bit more specific.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2872>
2023-02-27 15:38:25 +00:00
Carlos Garnacho
e9fca3eba6 frames: Intern some Atoms in the MetaFrame struct
Start with the ones we handle through PropertyNotify events,
since we want to expand further on those.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2872>
2023-02-27 15:38:25 +00:00
Robert Mader
6b84f5bd00 wayland/pointer: Check for surface resource
Like we do in several other places since
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2869>
2023-02-25 19:18:43 +01:00
Adrian Vovk
a6217c720e tests: Add tests for monitor_calculate_mode_scale
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2653>
2023-02-24 22:42:19 +01:00
Adrian Vovk
2f1dd049bf monitor-manager: Rework default scale factor selection
From the scale factors available to it, Mutter will now try to select
the scale factor that makes the UI's size as close as possible to the
size it would be, w/o scaling, on a display at 135 PPI (for mobile
displays) or at 110 PPI (for stationary displays)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2653>
2023-02-24 21:36:03 +00:00
Carlos Garnacho
53126bf008 x11: Prevent use-after-free if a filter is removed during handling
Keep a pointer to the next element, to protect against filters removing
themselves.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2640
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2868>
2023-02-24 14:11:55 +00:00
Jonas Ådahl
bac7b3f4e6 window: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2867>
2023-02-23 22:26:02 +01:00
Florian Müllner
e74573e165 window: Add raise_and_make_recent() method
After !2489, the active workspace's MRU list is now used to pick
the next focus window instead of the stack order.

This list is currently only updated on focus, which can lead to
surprising behavior when closing a window after activating its
ShellApp in the shell.

That is because raising a window (as part of shell_app_activate())
will only change the stacking order, so when closing the active
app window, the focus will switch to whatever had focus before the
app was activated, not the app's next window.

In order to allow gnome-shell to address this, add a new
raise_and_make_recent() method that also adjust the MRU order.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2540

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2866>
2023-02-23 20:40:58 +00:00
Florian Müllner
79f5059df7 window: Fix compiler warning
Commit b5d873a8ac changed the flag parameter type in the
function definition, but not in the declaration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2865>
2023-02-23 20:33:49 +01:00
Jonas Ådahl
849766652a dbus-session: Make some properties part of the interface
The pointer to the manager, the peer name and the ID are things that are
always metadata related to a session, so make them properties on the
interface instead of duplicating them. The implementations still need to
keep track of them, but their existance is shared.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
2023-02-23 17:52:08 +00:00
Jonas Ådahl
5731268087 Port screen cast and remote desktop to MetaDbusSessionManager
This eliminates some code duplication related to managing D-Bus session
objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
2023-02-23 17:52:08 +00:00
Jonas Ådahl
122fea2dc4 backends: Add generic D-Bus session manager helper class
This class is intended to be used as a base class for D-bus interface
implementations that deal with "session" objects, i.e. a D-Bus object
representing a certain session of some kind, e.g. a screen cast session.

It handles things such as hooking up to the D-Bus client watcher,
generates IDs, handles shutdown procedures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
2023-02-23 17:52:08 +00:00
Jonas Ådahl
10043c7c11 dbus-session: Add get_id() vfunc
It's currently not set by anything, and will only be used by
non-abstract implementations of a future D-Bus interface session
manager. When interface implementations gets ported to this new type,
their MetaDbusSession implementations will set this vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
2023-02-23 17:52:08 +00:00
Jonas Ådahl
7874bea068 dbus-session: Rename client_vanished() to close()
This means the MetaDbusSession interface takes a more active role
instead of being something that more or less sends signals to the
interface implementor. This will allow better control when using
MetaDbusSession to manage these sessions, instead of their non-abstract
variants.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
2023-02-23 17:52:08 +00:00
Sebastian Wick
abdd8c54f3 backends/native: Handle gamma sizes independent of the KMS LUT
Allows for creating LUTs at some fixed size which maintains enough
precision for concatenating or otherwise manipulating the LUT without
having to care about the precision of the hardware.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
4eb581ffc1 backends/native: Read CRTC Gamma state from legacy and property APIs
If the device supports the atomic API the property based API is used to
write gamma updates and the legacy API is used in the non-atomic case.
The current state is read from the legacy API always though which can be
different from the property API. This commit always uses the correct API
to update the state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
e9786452c6 backends/native: Replace MetaKmsCrtcGamma with MetaGammaLut
They are the same type now so there is no reason to keep both of them
around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
8ccbc21d23 backends/native: Use MetaKmsCrtcGamma for the KMS gamma color update
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
0180ffdaa1 backends/native: Introduce MetaKmsCrtcColorUpdate
To store gamma updates. In the future this will grow other CRTC level
color pipeline properties.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
37639295db backends/native: Rename crtc_gamma to crtc_color_updates
We need to update more CRTC color pipeline properties in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
4cf73fcfed backends/native: Remove unused meta_kms_crtc_has_gamma
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
36aada2164 backends/native: Store supported variants for KMS enum/bitmasks
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Sebastian Wick
80dd26428b backends/native: Store min/max value for KMS signed range properties
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2861>
2023-02-23 17:20:36 +00:00
Carlos Garnacho
e0634a4060 x11: Make some unnecessarily public API private again
There's a few functions that GNOME Shell shouldn't ever need,
stop exporting them as public API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
Carlos Garnacho
22c6374374 x11: Drop unused methods
These are not used anywhere in Mutter or GNOME Shell, it seems
we can drop them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
Carlos Garnacho
a799ac8ff0 x11: Add public API to handle X11 events
This API will be used by GNOME Shell to handle X11 events
in the relevant places, as a substitute to gdk_window_add_filter().

It is ATM still a bit ironic, since the Mutter X11 event handler
is itself a GdkFilterFunc, but it may move away from that eventually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
Jonas Ådahl
45bda2d969 renderer/native: Detach old onscreens when rebuilding views
With detach meaning having the onscreen stop listening on configuration
changes on the corresponding backing mode setting objects. We need to do
this as there is a time between rebuilding the views, and that the new
mode sets are called, where the old onscreen is kept alive, but the
stage view is gone. At this point in time, if privacy screen or gamma
configuration changes, e.g. by the night light temperature changing, the
onscreen would attempt to schedule an update on the now gone stage view.

This commit also renames the "keep onscreen alive" to "detached
onscreens" to more clearly communicate that it's detached onscreens from
their corresponding mode setting objects.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2621
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2863>
2023-02-22 15:25:25 +00:00
Jonas Ådahl
9434b01998 renderer/native: Don't leak onscreen in error path
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2863>
2023-02-22 15:25:25 +00:00
Jonas Ådahl
b2579750a7 cogl: Remove legacy OpenGL driver support
This means the two Cogl drivers left are OpenGL >= 3.1 and GLES >= 2.0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2672>
2023-02-21 18:09:28 +00:00
Sebastian Wick
8ab2cbedd7 tests/kvm: Properly capture the test status code
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2862>
2023-02-21 08:54:03 +00:00
Jonas Dreßler
d6062baef3 backends/native/seat-impl: Translate touch coords before storing
For the coordinates of pointers or stylii, we translate the ones we store
using the viewport matrix already. For touch events otoh, we store coords
untranslated and translate them later only for event emission.

Let's be consistent here and store the coordinates of touch events
translated, just like we do for pointer events.

This fixes touch window dragging on rotated monitors. MetaWindowDrag calls
clutter_seat_query_state(), which uses those stored coordinates. So in case
of a touch sequence the coords returned by query_state() would be
untranslated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2859>
2023-02-20 18:00:06 +00:00
Jonas Dreßler
65b93e1d45 window-drag: Check whether window is set when hiding tile preview
In the case where we early-out from meta_window_drag_begin(), the
effective_drag_window might not be set yet. In this case, we might finalize
the object before effective_drag_window is set, leading to a NULL pointer
when accessing window->display in hide_tile_preview().

To avoid that crash, add a check whether the window is set already. If no
window is set, we can just skip hiding the preview anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2858>
2023-02-20 17:16:56 +00:00
msizanoen1
36ae716e4d window/xwayland: Relayout when fullscreen client update emulated RandR mode
This fixes an issue when GLFW tries to change the display resolution
while fullscreen where the application window size doesn't get updated
according to the emulated resolution.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2725>
2023-02-20 16:55:36 +00:00
msizanoen1
899af9d58c window/x11: Make process_property_notify a virtual method
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2725>
2023-02-20 16:55:36 +00:00