1
0
Fork 0
Commit graph

12538 commits

Author SHA1 Message Date
Jonas Ådahl
97af5f8705 wayland/xdg-shell: Update min/max window size also on geometry changes
The internal representation of the min/max width of windows include what
is outside of the window geometry, so when the window geometry changes,
but the min/max size did not in the same commit, we'd be left with an
out of date min/max size, potentially causing windows to shrink when
configured.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3755>
2024-05-21 09:22:09 +00:00
Georges Basile Stavracas Neto
638d3355b4 cogl: Drop CoglSwapChain
CoglSwapChain is currently unused, and doesn't hold any information
nor is used for anything in particular.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3759>
2024-05-20 11:45:31 +00:00
Bilal Elmoussaoui
c13956fb9e Use gboolean consts instead of C bools
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3748>
2024-05-20 11:29:54 +00:00
Sebastian Keller
7a38e12ed0 egl: Don't free source error after propagating it
local_error in meta_egl_query_device_string() is using g_autoptr,
meaning that it was getting freed after g_propagate_error(). This then
would result in error->message becoming invalid, causing crashes when
logging the error message later on.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3757>
2024-05-19 21:43:10 +00:00
Marco Trevisan (Treviño)
6ab36f7297 tests/stacking: Do struts toggling during monitor-changed event
To simulate better what happens in a real shell environment

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

  [window-id]::signal => command

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

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

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

Here it is now.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes: 6bd920b35 ("x11/window: Use correct bounding rect to determine NULL input region")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3451
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3720>
2024-05-15 14:07:36 +00:00
Michel Dänzer
1c7ed16d05 Revert "wayland/surface: Check buffer size also for role-less surfaces"
This reverts commit 98c8c03729.

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

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3471
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3743>
2024-05-15 09:15:07 +00:00
Florian Müllner
da0bd303ad core/anonymous-file: Support 0-sized files
There is nothing to allocate for a 0-sized files, and indeed
posix_fallocate() will error out if the passed len isn't greater
than 0.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3752>
2024-05-15 08:52:50 +00:00
Michel Dänzer
09a6ff6eb7 color-manager: Call update_all_gamma from on_monitors_changed
This ensures that an up-to-date gamma LUT is applied for newly-enabled
monitors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2480
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2546
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3439
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3742>
2024-05-14 12:45:15 +00:00
Michel Dänzer
9ed00280f7 color-manager: Move update_all_gamma helper up
Preparation for next commit, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3742>
2024-05-14 12:45:15 +00:00
Jonas Ådahl
22f67d107d tests: Add test case for keybinding remove race
When a key binding is removed, and a trigger key sequence is dispatched
before the idle callback that resolves and updates the actual binding,
we should handle that gracefully.

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3711>
2024-05-07 09:18:01 +00:00
Jonas Ådahl
57e16cf010 window/wayland: Constrain sporadic client resizes immediately
When a client resizes on its own, make sure the new size is passed
through the window constraints machinery directly, to trigger any
potential window management rule that might apply.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3700>
2024-05-07 08:59:50 +00:00
Bilal Elmoussaoui
fc623c1ed1 build: Enable -Werror=shadow and fix related issues
Mostly renames or removing already defined types

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3378>
2024-05-06 15:54:16 +00:00
Sebastian Wick
e509fc7f00 window: Start in the activate suspend state until mapped
Starting the timeout to move from hidden to suspended before the window
is mapped means we don't have a previous window configufration which we
need to get the new window configuration with the suspended state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
2024-05-03 18:24:27 +00:00
Sebastian Wick
7a9883d5bb window: Move implement_showing for the next commit
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
2024-05-03 18:24:27 +00:00
Jonas Ådahl
52d5758f1b tests/wayland: Add test for mapping clone of obstructed window
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
2024-05-03 18:24:27 +00:00
Jonas Ådahl
b69fc15543 tests/wayland: Run with G_MESSAGES_DEBUG=all
Helpful when debugging tests.

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

Fixes changes part of commit e1e6534eb

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3727>
2024-05-03 12:38:01 +00:00
Marco Trevisan (Treviño)
b422393bbc x11/window: Add type-check guard to meta_window_x11_get_group()
Since this is still public API we want to ensure that we don't cast
it directly without having checked its type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3727>
2024-05-03 12:38:01 +00:00
Marco Trevisan (Treviño)
2a88a3eb96 x11/window: Do not try to compare a wayland active window with X11
If a window sends a configure stacking request, we were comparing the
active window with the event window even though they were different
client types (e.g. wayland and x11).

This was leading to a critical error, so let's handle this by ensuring
that the active window is of the same kind of the event window before
doing x11-specific checks. Behaving as different applications in case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3727>
2024-05-03 12:38:01 +00:00
Daniel van Vugt
f3a52551f1 backends/native: Remove unused meta_kms_device_add_fake_plane_in_impl
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Daniel van Vugt
14e18de90d backends/native: Add fake cursor plane using impl_device's crtcs
Because `meta_kms_impl_device_simple_initable_init` is called in the
middle of `meta_kms_device_new`, the crtcs list for `MetaKmsDevice`
has not been populated yet. And thus the loop to detect missing
cursor planes and create fake ones never iterated. But the crtcs list
does already exist in `MetaKmsImplDevice` so iterate over that instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3264
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Daniel van Vugt
b620dbb188 kms/impl-device: Add function meta_kms_impl_device_has_cursor_plane_for
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3676>
2024-05-02 09:34:46 +00:00
Michel Dänzer
dd32f3b3be wayland/transaction: Check surface pointer validity in _ensure_entry
If a caller passes in NULL or a non-NULL value which doesn't point to
a valid MetaWaylandSurface object, this will hopefully point in the
direction of the cause.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
2024-04-30 17:14:56 +00:00
Michel Dänzer
b67f94ca7e wayland/subsurface: Hold sibling surface reference in placement ops
It was possible for the sibling surface to be already destroyed in
meta_wayland_transaction_add_placement_surfaces, in which case
g_object_ref would return NULL for it, and
meta_wayland_transaction_commit would then crash dereferencing a NULL
surface pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3462
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3725>
2024-04-30 17:14:56 +00:00
Carlos Garnacho
243890a688 wayland: Do not forget immediately of key press serials on key release
Prior to commit 5dfed8a431, the MetaWaylandKeyboard would always remember
the last key press serial, and consider it valid after the key was released,
as long as no other key presses/releases happened in between.

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

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

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

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3372
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3715>
2024-04-25 14:33:28 +00:00
Mart Raudsepp
669d21daa2 x11: Drop obsolete libXrender dependency
It seems only the iconcache used to use it, but this is gone since
commit d16ddc42ce.
Even before that, the Xrender usage was removed in commit 556e7694de,
albeit leaving a redundant include <X11/extensions/Xrender.h> in its
place then, which comes from libXrender.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3716>
2024-04-22 10:16:31 +00:00
Robert Mader
6a81d5f0bb wayland/surface: Fix sending preferred buffer transform
Fix an obvious copy paste error that slipped through the cracks.
Fortunately it doesn't have a visual impact for well behaving clients
but only makes us not hit direct-scanout paths, assuming no other bugs
in the stack.

Fixes: f21762ea6e (wayland: Add support for preferred_buffer_scale/transform)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3717>
2024-04-22 11:39:31 +02:00
Carlos Garnacho
1fdae4f856 wayland: Drop meta_wayland_keyboard_get_focus_client()
All its users did not necessarily depend on a MetaWaylandKeyboard
existing, so were ported to using the MetaWaylandSeat global input
focus. This may now be dropped.

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

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

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

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

Abort the async transfer when we have a new owner.

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

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

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

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

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

This fixes inital suspended state when mapping a window maximized.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
69c7ca02f4 tests/wayland: Replace wl_display_dispatch() with helper
In most cases, we just want to fail the test if dispatching fails, so
add a helper that does that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
4d8f6af487 test/wayland/client-utils: Add 'painted' signal
This is emitted when a client painted and committed new surface content.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
2d18b976c1 tests/wayland/client-utils: Add GObject parent instance field
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
eab06bcf24 window: Move out 'showable' check from should_be_showing_on_workspace()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
33ff998a10 tests/wayland/utils: Add method to synchronize with windows being shown
Can be used to wait for a window to be "shown", meaning it'll be added
to the stack and will be part of the next frame (assuming it's actually
not obscured etc).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Jonas Ådahl
fd6d86d33d window: Add documentation to should_be_showing(_on_workspace)()
It's a bit unclear whether "should be shown" takes ability to actually
immediately show into account. Make this clear in a function doc
comment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
2024-04-19 13:33:42 +00:00
Sebastian Keller
e4763d00e8 x11/window: Update comment and variable name to reflect current behavior
d991961ae changed this code from client rect to buffer rect to account
for the fact that for SSD windows the decorations are now included in
the bounding region, but it kept the variable name as client_area and
the comment was also still referring to the client rect.

Fixes: d991961ae ("x11: Use input region from frame window for decorated windows")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Sebastian Keller
6bd920b355 x11/window: Use correct bounding rect to determine NULL input region
When updating the input region we check whether the input shape reported
by XShape matches the bounding region of a window to determine when it
was not set by the client. We would then use a NULL input region instead
which always matches the full size of the window. The code however was
using the client rect for this comparison, which does not include the
window frame. Since d991961a the frame is considered part of the input
region.

This meant that for SSD windows where the input region would match the
bounding region, we would not detect that and fail to set the input
region to NULL, but instead set it to the reported input shape.

Usually this would not be the case due to the GTK frame window having
shadows and a resize region, but in the presence of an issue that causes
GTK to wrongly detect _GTK_FRAME_EXTENTS as not supported, GTK would not
draw shadows or set an input shape. And due to GTK not updating its
input shape, there would be no further calls to
meta_window_x11_update_input_region() after the initial one.
The input region would therefore remain at the fixed size from the
initial call. This was causing windows to become click-through outside
of the region corresponding to their initial size after being resized.

Fixes: d991961ae ("x11: Use input region from frame window for decorated windows")
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6558
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3404
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Sebastian Keller
2e38ec6ce1 frame: Assume a size of 0 when extent properties are undefined
Previously the function would exit early, never changing the out value
which is usually passed in uninitialized. This would however only happen
in the presence of another issue leading to the properties being
undefined. We can still be a bit more defensive against this though.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/3404
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6558
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
2024-04-19 13:18:39 +00:00
Michel Dänzer
c25f6f2ded wayland/buffer: Pass g_object_unref to g_ptr_array_new_with_free_func
The release_points array holds pointers to MetaWaylandSyncPoint objects.

Fixes leaking references (and ultimately the underlying memory) for the
array elements.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3442
Fixes: e8b890ab53 ("wayland: Implement linux-drm-syncobj-v1")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3710>
2024-04-19 10:32:38 +00:00
Jonas Dreßler
bbb196bdde wayland/touch: Store touch serials more persistently
Right now we store touch serials on their according MetaWaylandTouchInfo
entries. These entries are gone as soon as the touchpoint ended though, and
it's not unlikely that clients will respond to that touch-end event after we
removed the touchpoint.

In this case we currently can't match the client provided serial to any of
our known touch sequences, which causes xdg_popup grabs that get requested
shortly after the touch-end to fail.

Let's be a bit more gentle on clients here and store the latest touch-down
serial on the MetaWaylandTouch, so that it continues to be around after the
touch-end and we can match the serial of the xdg_popup_grab() as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2946>
2024-04-17 11:13:08 +00:00
Daniel van Vugt
d53da38198 onscreen/native: Avoid dereferencing gbm.next_fb when not in MODE_GBM
Such as with MODE_EGL_DEVICE.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3436
Fixes: 40950f99b3 ("drm-buffer-gbm: Do not call ensure_fb_id from...")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3708>
2024-04-17 13:34:22 +08:00
Daniel van Vugt
040800268f onscreen/native: Don't refuse primary GPU copy support based on egl_surface
Because that egl_surface is only used for secondary GPU copying, which
isn't relevant to primary GPU copies.

This is a partial revert of 41bfabad96 which is no longer required since
the previous commits have enabled secondary GPU copy support for nvidia-drm.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2551
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
7e27d297dd renderer/native: Remove cached program ID when EGLContext destroyed
In the rare event that hotplugs destroy and then create a new EGLContext
with the exactly the same ID, this ensures we will forget the old program
which presumably wouldn't work in the new context. It will be recreated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
ccca3709c2 renderer/native-gles3: Fix up function parameter alignment
check-code-style was complaining about this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
2d3a2a52b8 renderer/native-gles3: Add fallback using a shader
The EGL context can only import and blit an EGLImage if the
backing DMA buffer has a format modifier combination that is advertised
as supported and not marked as "external_only".

When the context can't blit the imported image, we can still paint using
it GL_OES_EGL_image_external using the texture target
GL_TEXTURE_EXTERNAL_OES.

However, treat drivers who doesn't support modifiers at all as if they
do support blitting, if the modifier is 'linear', to avoid regressions.

[jadahl: Make shader path a fallback to allow hardware to utilize copy
engines via blitting]

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6221
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2247
Related: https://launchpad.net/bugs/1970291

now only falls back if modifiers are supported, and they mark linear as
export only.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
b065dce194 renderer/native-gles3: Remember to set the glViewport
This is a critical part of any OpenGL program. Mesa allowed us to get
away without it and provided a sane default of the full buffer, but
Nvidia seems to default to an empty/zero viewport so would refuse to
paint any pixels.

In the OpenGL ES 2.0 spec this is ambiguous:

> In the initial state, w and h are set to the width and height,
> respectively, of the window into which the GL is to do its rendering.

because the first "window" used is EGL_NO_SURFACE in
init_secondary_gpu_data_gpu. It has no width or height.

In the OpenGL ES 3.0 spec the ambiguity is somewhat resolved:

> If the default framebuffer is bound but no default framebuffer is
> associated with the GL context (see chapter 4), then w and h are
> initially set to zero.

but not entirely resolved because neither spec says whether
EGL_NO_SURFACE should be treated as zero dimensions (Nvidia) or ignored
and not counted as the first "window" (Mesa).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
af98776224 onscreen/native: Finish primary GPU rendering before copying to secondary
As mentioned in the OES_EGL_image_external spec, there is no implicit
sync between the EGLImage producer and consumer. And in this code path
we don't have meta_drm_buffer_gbm_new_lock_front on the primary GPU to
do it for us either. So synchronization has to be done manually or else
the secondary GPU is likely to get an unfinished image.

This problem has only been observed when the secondary GPU is using the
Nvidia proprietary driver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
5edb22d7d7 renderer/native: Flag when explicit sync between GPUs is required
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
8c6aabb9ca egl: Add function: meta_egl_query_string
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Daniel van Vugt
9fee3a9ec1 onscreen/native: Fall back to gbm_surface_create without flags
The Nvidia driver will return ENOSYS if any flags are used. Bug filed
upstream on the NVIDIA forums.

https://forums.developer.nvidia.com/t/gbm-surface-create-fails-if-flags-0/279951

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
32da2789bf meta/util: Move out debug topics and meta_topic()
The purpose is to not include all of clutter and cogl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
a24b7956da meta/common: Put META_EXPORT in its own header
Want to include it without including all of clutter and cogl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Jonas Ådahl
0b91d22848 common/cogl-drm-formats: Split out format to string helper
It means it can be included in places that assume cogl and everything it
involves shouldn't be included, e.g. meta-renderer-native-gles3.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304>
2024-04-16 21:05:09 +00:00
Sebastian Wick
f91851154e core/window: Do not rely on Monitor Numbering
When the monitors change meta_window_update_for_monitors_changed is
called which is responsible for updating window->monitor. It however can
go through the entire window placement and constraint machinery before
it's able to do so. In this period window->monitor points to the old
MetaMonitor where the monitor number doesn't reflect the index into the
MonitorManager anymore.

Avoid relying on the window->monitor->number and go through the Monitor
directly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3402
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3691>
2024-04-16 20:31:23 +00:00
Sebastian Wick
74a01e3f39 color-device: Use a sRGB profile if the EDID is missing
This makes sure the ColorDevice can initialize successfully even if the
display doesn't have an EDID.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3394
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3673>
2024-04-16 13:45:13 +02:00
Carlos Garnacho
d214583aa2 wayland: Do not bypass MetaWaylandInput changing keyboard focus
In every other device and circumstance, we update the logical focus
(i.e. the surface that would be focused, if no other circumstances
applied) but let the MetaWaylandInput figure out the surface that
should be effectively focused, if at all. This is where we apply the
actual compositor state (e.g. grabs) and result in an effective focus
window.

The only exception to this is `meta_wayland_seat_set_input_focus()`
where the logical focus for keyboards and related devices is set, but
also applied as the effective surface.

We should do the same as everywhere else, and let MetaWaylandInput
focus determine whether the logical focus is also the effective focus.
These replaced set_focus() internal calls will happen through the
default MetaWaylandEventInterface.focus implementation in MetaWaylandSeat.

This resulted in keyboard focus being set on windows in circumstances
it ought not to, like in the overview. Actual key events were never
sent in these circumstances, but changes to modifier state could.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3704>
2024-04-15 20:43:44 +00:00
Carlos Garnacho
3b5f467163 core: Allow fullscreen modals to move out of the center of their parents
If a modal dialog (i.e. with a "revolves around center of parent window" policy)
becomes fullscreen, we cannot neatly honor both the modal dialog going fullscreen
and the window staying around the center of its parent.

In order to make fullscreening work in this situation, allow fullscreen modal
dialogs to "snap out" of the parent. This rule will become again effective after
the window is unfullscreened.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3425
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3695>
2024-04-15 20:24:30 +00:00
Sophie Herold
d36afd32d7 wayland: Always use logical pixels for bounds
This fixes that with scale-monitor-framebuffer disabled, windows were always
configured with bounds using physical instead of logical pixels.

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

Co-authored-by: Jonas Ådahl <jadahl@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3698>
2024-04-15 20:13:50 +00:00
Jonas Ådahl
454a70cce5 edge-resistance: Use current conventions for lists
Use GList *l and for loop for iterating, autopointers and autolists
for memory management, and a function instead of a macro for a
condition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3703>
2024-04-15 16:48:04 +00:00
Robert Mader
1f82365021 window-actor/wayland: Improve scanout candidate check
By ignoring obcured surfaces we can generalize the single-pixel-buffer
background check to work with arbitrary surface trees, as long as the
two top ones are the background and content surfaces.

As a nice side effect of this, clients like Firefox now usually take the
shorter `meta_window_is_fullscreen (window) && n_visible_surface_actors == 1`
route.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3699>
2024-04-15 15:52:26 +00:00
Jonas Ådahl
e5068bfc91 wayland/single-pixel-buffer: Fix reusing buffer
We had missed to actually return the cached texture, so do that.

Also add a test.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3432
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3702>
2024-04-15 17:37:52 +02:00
Michel Dänzer
a834eb5c94 onscreen/native: Don't create timestamp query with secondary GPU work
The timestamp query is currently always created for the primary GPU, so
it doesn't cover any later secondary GPU work.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3070
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3689>
2024-04-10 11:59:30 +02:00
Michel Dänzer
09267d0bdd cogl/onscreen: Add cogl_onscreen_egl_maybe_create_timestamp_query
Move the code out of cogl_onscreen_egl_swap_buffers_with_damage, and
call the new function from callers of the former.

v2:
* Use early return if the cogl context doesn't support timestamp
  queries. (Sebastian Wick)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3689>
2024-04-10 11:17:23 +02:00
Michel Dänzer
40950f99b3 drm-buffer-gbm: Do not call ensure_fb_id from lock_front
When preparing a frame for scanout on a secondary GPU, calling
meta_drm_buffer_gbm_ensure_fb_id for the primary GPU device is
unnecessary and potentially harmful.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3389
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3674>
2024-04-09 08:28:59 +00:00
Barnabás Pőcze
c0ae617b3f tests/mtk/region: Fix MtkRectangle leak
`mtk_rectangle_new()` allocates the object dynamically,
but in the "contains-point" test case the allocated object
was not freed. Fix that by creating the object on the stack.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3679>
2024-04-05 15:10:18 +00:00
Daniel van Vugt
22689d722a compositor/sync-ring: Allow the gpu_fence to be moved
When the compositor inserts two waits in a frame, such as f606a4424a,
the second insertion shouldn't break the ring's state machine as easily
as it does. We can instead merge the two GL waits into one by simply moving
the GL fence to the latest insertion. Each insertion still does its own X11
sync though.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3384
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3685>
2024-04-05 14:18:12 +00:00
Jonas Ådahl
82c0f9c57d cursor-renderer/native: Don't predict the dumb buffer stride
The stride of the dumb buffer isn't necessarily 4 * width even if the
bytes per pixel is 4, so lets not make that assumption.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2267951
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3666>
2024-04-05 14:06:54 +00:00
Bilal Elmoussaoui
ee3221f146 tests/wayland-clients: Avoid using static when not needed
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3687>
2024-04-04 14:51:21 +00:00
Bilal Elmoussaoui
4b26feafac tests/wayland-clients: Pass WaylandDisplay as user_data
Avoids using a static and make sure things are properly freed by
using g_autoptr. Also take the opportunity to add some missing NULL
initialization for auto-pointers variables

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3687>
2024-04-04 14:51:21 +00:00
Carlos Garnacho
bc72428a02 backends/native: Declare variables at beginning of block
In consistence with the code style, and in order to fix build errors
with older clang:

    ../src/backends/native/meta-onscreen-native.c:521:7: error: expected expression
      521 |       graphene_rect_t src_rect;
          |       ^
    ../src/backends/native/meta-onscreen-native.c:529:39: error: use of undeclared identifier 'src_rect'; did you mean 'dst_rect'?
      529 |                                      &src_rect);
          |                                       ^~~~~~~~
          |                                       dst_rect
    ../src/backends/native/meta-onscreen-native.c:522:20: note: 'dst_rect' declared here
      522 |       MtkRectangle dst_rect;
          |                    ^

And warnings with newer clang:

    ../src/backends/native/meta-onscreen-native.c:521:7: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
      521 |       graphene_rect_t src_rect;
          |       ^

This should allow the build for coverity to succeed again.

Fixes: adc776d0d7 ("crtc/kms: Pass on src and dst rects to primary plane assignments")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3686>
2024-04-03 10:37:17 +00:00
Austin Shafer
e8b890ab53 wayland: Implement linux-drm-syncobj-v1
This implements the explicit sync protocol linux-drm-syncobj-v1. This
works by importing a DRM syncobj timeline and importing/exporting fds
to/from the sync points on the timeline corresponding to buffer acquire
and release. We take fds for sync points provided during a surface
commit and use them to delay transaction application, and fetch fds
from Cogl to signal when we are done using a particular buffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3300>
2024-03-28 13:28:08 -04:00
Austin Shafer
7ca01867f7 wayland: Add linux-drm-syncobj v1 to build
This adds the explicit sync wayland protocol to the list of build
dependencies.

This adds a copy of the linux-drm-syncobj protocol that we will use
privately for builds. This avoids the pain of requiring wayland-protocols
1.34 for distros. This commit can be reverted once we want to use
linux-drm-syncobj from the system wayland-protocols.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3300>
2024-03-28 13:27:42 -04:00
Austin Shafer
8e9f01d1ce wayland: Add MetaDrmTimeline
This abstracts away directly dealing with DRM syncobjs. Explicit
sync code can simply create a MetaDrmTimeline and request an fd at
a particular sync point.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3300>
2024-03-28 13:27:42 -04:00
Ray Strode
3f5bf42ab6 wayland/buffer: Don't assert mutter supports all shm formats
On big endian architectures the mapping of drm formats to cogl
formats is significantly trimmed compared to on little endian
architectures.

meta_wayland_init_shm tries a bunch of formats, including some
that just aren't mapped on e.g. s390x.

The code asserts the mapping will exist, however, leading to
crashes when Xwayland starts.

This commit makes failure to find a mapping non-fatal.

Suggested by Jonas Ådahl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3672>
2024-03-27 10:16:47 -04:00
Jocelyn Falempe
a775241efd backend/native: Use drmModeCloseFB for flicker-free login
When logging in from gdm to gnome, the main plane is deactivated, and
leads to the screen going blank before gnome is able to enable it
again.
Using the new CloseFB ioctl, allows to keep the gdm login screen
displayed until gnome-shell replace it.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3659>
2024-03-16 10:45:41 +00:00
Sebastian Wick
a50bc0ff7d onscreen/native: Only set a VRR update if the CRTC supports the property
This also gets rid of the MetaFrameSyncMode enum and instead issues a
VRR update when the requested state differs from the CRTC state.

Fixes: fee33299 ("onscreen/native: Allow requesting frame synchronization")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3646>
2024-03-16 10:28:30 +00:00
Sebastian Wick
51811ec7b3 output: Add a function to check if VRR is enabled for the output
An output with enabled VRR requires that the mode is a VRR mode which
also means that VRR is supported.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3646>
2024-03-16 10:28:30 +00:00
Sebastian Wick
91e3180985 output/kms: Track in OutputInfo if the output is VRR capable
This includes checking the vrr_capable property on the connector as well
as the VRR_ENABLE property on any CRTC the connector might get assigned
to. Also takes into account when a GPU is tagged for broken VRR support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3646>
2024-03-16 10:28:30 +00:00
Sebastian Wick
514a18fe0c kms/crtc: Track if the VRR_ENABLED property is supported
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3646>
2024-03-16 10:28:30 +00:00
Bilal Elmoussaoui
f480de4ecd plugin-manager: Guard MetaPluginClass.xevent_filter
As we are getting close to have a Wayland-only build, guard those usages
so we don't 'regress'.
Once Kiosk figures it use case, we can revert both this commit and the
previous one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3652>
2024-03-16 04:11:38 +01:00
Bilal Elmoussaoui
eb1d1883c2 Revert "plugin-manager: Drop MetaPluginClass.xevent_filter"
This reverts commit 917526ee9d.

As it is currently used by GNOME Kiosk, until upstream figures out
how to replace that code path, let us revert the commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3652>
2024-03-16 04:09:41 +01:00
Balló György
35335e65af window: Queue resize if window is maximized on wayland
When multiple configure requests sent to the wayland client within a sort period, maximized windows may end up in wrong position and cover struts. To avoid this, queue a resize when the resize event sent by the wayland client results a changed size or position to ensure that the final size and position will be always right.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3601>
2024-03-15 20:44:33 +00:00
Robert Mader
d434518303 wayland/surface: Remove some trailing spaces
To make the CI happy.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3662>
2024-03-15 17:09:42 +00:00
Robert Mader
f1a4758ce2 window-actor/wayland: Access single pixel buffer object directly
Using `meta_wayland_single_pixel_buffer_from_buffer()` can fail if
the buffer resource is already gone. Given that we release the buffer
immediately, that is actually expected - but the client this was tested
with did/does not do so.

This made the single pixel black bar optimization fail for
GstWaylandsink, while working for the mpv Wayland backend.

Access the object directly, which is both faster and works as long as
the buffer is alive.

Fixes: ed50cbbfe4 (window-actor/wayland: Update scanout candidate check)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3662>
2024-03-15 17:09:42 +00:00
Jonas Dreßler
f62e30b761 tests/clutter/conform: Add a test for gesture-relationships
Add a few tests for gestures sharing a sequence and how they influence each
other.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2389>
2024-03-15 00:09:09 +01:00
Jonas Dreßler
f61c095ccb tests/clutter/conform: Add some tests for ClutterGesture
This is testing the basic things like whether the state machine works
and that no memory is leaked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2389>
2024-03-15 00:08:56 +01:00
Sebastian Keller
a1381ea6bc cursor-tracker: Move visibility-changed signal emission to the end
The gnome-shell magnifier listens to the `visibility-changed` signal
and calls meta_cursor_tracker_set_pointer_visible(false) when the
cursor became visible.

This leads to a reentrance in meta_cursor_tracker_set_pointer_visible()
and clutter_seat_uninhibit_unfocus() gets called twice, once from the
meta_cursor_tracker_set_pointer_visible(false) by the magnifier and then
the original meta_cursor_tracker_set_pointer_visible(true) continues,
after the first call has set is_showing to false again. This breaks the
inhibitor counting and the ability to use the cursor while using the
magnifier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3661>
2024-03-14 20:00:06 +00:00
Carlos Garnacho
1cfc1aa92b wayland: Check surface before looking up modals
Near window destruction, there might be cases where the surface
actor does no longer have a surface, yet it's still in the stage
and eligible for picking. In that situation looking for modal
dialogs attached to this surface will evidently fail, so avoid
this check on a NULL surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3332
Fixes: 93a9e7f3f ("core: Move code ignoring events on windows with modals to Wayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3660>
2024-03-13 18:39:52 +00:00
Robert Mader
aaae07f9dd onscreen/native: Mark GPU rendering duration as valid if supported
Since commit e30eb78891 `ClutterFrameClock` assumes that a valid CPU time
implies timestamp query support, which is also checked in
`cogl_onscreen_egl_swap_buffers_with_damage()`.

Unconditionally setting the CPU time on direct scanout meant that the
compositing path would be stuck on the last (direct scanout optimized)
result on GL implementations without timestamp query support since.

be0aa2976e (clutter/frame-clock: Avoid rapidly toggling dynamic max render time)

Fix that by explicitly marking the gpu rendering duration as valid when
querying the GPU timestamps is supported and check for it ClutterFrameClock.

Fixes: 56580ea7c9 ("backends/native: Assume zero rendering time for direct scanout buffers")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3655>
2024-03-13 16:37:16 +01:00
Petr Hodina
e2b42cdfd9 monitor: Allow DPI connectors to be built-in displays
Needed for the Pinenote built-in display to be detected by Mutter
https://pine64.org/devices/pinenote/

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3067>
2024-03-13 13:14:01 +00:00
Zander Brown
8002919f7b meta: Update annotations
MetaBackend is part of the public API but MetaGPU is not so gpu-added
can cause confusion, treat it as gpointer.
Also ensure XEvent is properly recognised

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1918>
2024-03-13 12:52:41 +00:00
Zander Brown
6a445d2eef build: Make exported package in gir consistent
Additionally Cogl was missing xlib as an include

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1918>
2024-03-13 12:52:41 +00:00
Sebastian Wick
5690bd3eaa wayland/output: Track protocol state for computing changed properties
This makes sure that xdg-output.logical_size and
xdg-output.logical_position are only sent when they actually changed.

There should be no behavior change in wl_output_transform_from_transform
but it now uses the same technique of tracking the protocol state and
comparing it to the current state to compute which properties have
changed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3622>
2024-03-12 19:21:27 +00:00
Sebastian Keller
f94e32037c background: Call malloc_trim() after loading background image
Some of the new JXL backgrounds from gnome-backgrounds can allocate
several hundred MB during loading, so let's call malloc_trim() after we
are done with loading the image into a pixbuf.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3327
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3653>
2024-03-12 17:27:29 +00:00
Bilal Elmoussaoui
6d03666d2d window/x11: Try harder to find the associated group
Otherwise we would try to create a new group later on which would crash

Fixes #3329

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3656>
2024-03-12 14:30:40 +01:00
Peter Hutterer
2a879be180 core: Whitespace fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3658>
2024-03-12 12:48:20 +10:00
Sebastian Keller
a66b4c3da9 x11/display: Always use meta_display_set_input_focus() for focus change
X11 server side focus changes, such as when a focus change was requested
by mutter for a globally active window, did not go through
meta_display_set_input_focus(), which is responsible for emitting the
`focus-window` signal. Since this signal is what triggers the display
server specific code to handle focus changes, this was leading to a
problem on Wayland where the focus remained on the last active Wayland
window when the focus got changed to a globally active XWayland window.

This commit now changes handling X11 server side focus changes to also
go through the code path that emits the signal while making sure to not
trigger another focus change and keeping the same serials as the
previous code to not interfere with future focus changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3328
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3651>
2024-03-11 10:47:43 +00:00
Yotam Bar-On
aca8be64c1 meta/selection-source-memory: Use memfd instead of GBytes
MetaSelectionSourceMemory currently uses GBytes for its underlying data.
This can cause memory overhead when large items, such as HD images, are
stored in the clipboard. This commit changes the underlying data
structure to a MetaAnonymousFile object, which writes to memfd instead
of heap. When reading, MetaSelectionSourceMemory will create a
Gio.UnixInputStream from the file descriptor generated by
MetaAnonymousFile. We subclass the UnixInputStream as
MetaUnixInputStream, to override the stream's close_fn function so
that it invokes meta_anonymous_file_close_fd when the stream terminates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3551>
2024-03-08 18:34:52 +00:00
Sebastian Wick
5626004aed kms/impl-device/atomic: Set hotspot cap before initing mode setting
We need to set the drm CAP before we read the KMS resources to make sure
we actually get all resoures the CAP makes visible.

Fixes: 27f798b6d ("kms/impl-device/atomic: Implement mouse cursor hotspots")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3341
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3654>
2024-03-08 17:27:10 +00:00
Robert Mader
f21762ea6e wayland: Add support for preferred_buffer_scale/transform
Which got introduced in wl_compositor version 6.

Note that if the surface is visible on multiple monitors with different
transforms, we pick the transform of the monitor which we choose for the
scale as well. This doesn't really matter at the moment, as the
transform is only really relevant for direct-scanout - which we
currently only support for fullscreen clients.

Once we support direct-scanout for partially visible clients we'll
likely want to introduce a more sophisticated algorithm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3580>
2024-03-08 17:01:43 +00:00
Robert Mader
037077bb56 screen-cast-stream-src: Always advertise support for BGRA
Some clients - notably the Gstreamer vapostproc element when using Intel
GPUs - only support BGRA, not BGRx. We already assume that we can
support this format for window screen casts, and even in case of failure
we now have a re-negotiation fallback in place. Thus it's pretty safe to
support it for all screen cast types.

The possible duplication in case of window screen casts doesn't seem to
be a problem for either Pipewire or existing clients like OBS.

Note that the implementation lays the foundation to make it easy to add
more formats in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3617>
2024-03-08 14:31:16 +00:00
Robert Mader
77186c2063 screen-cast-stream-src: Use dynamic buffer allocations
In order to allow arbitrary number of formats, modifiers and other
parameters. This makes the code more robust and easier to adapt.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3617>
2024-03-08 14:31:16 +00:00
Robert Mader
774d0ad0bc screen-cast-stream-src: Remove unnecessary enum choice
If we don't offer different options there's no need to pretend there's a
choice.

Fixes: dc2b2e379b ("screen-cast-stream: Add explicit modifier support")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3617>
2024-03-08 14:31:16 +00:00
Robert Mader
572801c02f screen-cast: Clear GError within loop
In order to silence warnings and/or prevent memory leaks.

Fixes: dc2b2e379b (screen-cast-stream: Add explicit modifier support)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3617>
2024-03-08 14:31:16 +00:00
Peter Hutterer
75186fb40a backends/native: Change a C cast into a GObject type cast
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3647>
2024-03-07 14:34:36 +10:00
Christian Hergert
1513dd4ef7 wayland: Use timerfd for sub-msec poll() precision
Like the change to ClutterFrameClock, this allows poll() timeouts below
1 msec by using a timerfd which will trigger using G_POLL_IN.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3636>
2024-03-06 23:10:13 +00:00
Carlos Garnacho
ab8e145e25 wayland: Filter scroll events based on source
The POINTER_EMULATED flag was a convenience to filter either
side of smooth/discrete events that we should ignore based on
the source.

This distinction was challenged, first by v120 mice that use
Clutter smooth events to deliver semi-discrete changes, second
by commit e0c4b2b241 ("backends/native: Mark the emulated smooth
scroll event as such") which made the smooth events be flagged
as emulated, and the discrete whole-step events marked as
real.

This distinction feels convenient for the time being, since
upper layers might be confused by real smooth scroll events
without finish flags. Adapt to this change at MetaWaylandPointer
so that we drop the POINTER_EMULATED check, and the events are
perhaps filtered based on their source and the preferred
wl_seat version of the client that we are talking to.

This handles the whole grid of combinations:
- wheel sources with wl_seat >=8 result in wl_pointer.axis_value120
  from "emulated" smooth scroll events, with value120 information.
- wheel sources with wl_seat < 8 result in wl_pointer.axis_discrete
  from "real" discrete scroll events.
- finger/continuous sources prefer smooth events. Previously, always
  non-emulated for those.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Carlos Garnacho
39d8e44f5e wayland: Always send wl_pointer.axis after .axis_value120/discrete
The wl_pointer.axis_discrete axis (applicable to wl_seat <= v8) is
meant to be sent together with wl_pointer.axis events in the same
frame. And the wl_pointer.axis_value120 event replaces it in
wl_seat >= v9, but has the same relation with the other information
available in a frame.

This emission should not be conditional to anything, so drop the
various checks leading to maybe sending wl_pointer.axis or not.

This fixes emission of wl_pointer.axis in conjunction with discrete
events, for some combinations of versions and (non)value120 mice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Carlos Garnacho
ddc76d878e wayland: Fix handling of non-v120 discrete events on wl_seat >= v8
Unveiled by commit e0c4b2b241 ("backends/native: Mark the emulated smooth
scroll event as such"). The sudden "lack" of smooth scroll events (Used by
Clutter to forward v120 events) made it evident we silently ignore Clutter
discrete events, as we don't send wl_pointer.axis_value120 for these.

Fix this by assigning a value120 value to discrete scroll events. This
makes wl_pointer.axis_value120 events actually sent on non-v120 mice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Carlos Garnacho
7aebc9e63d clutter: Pass scroll source to discrete events
This piece of information was lost, always returning
"unknown". We can do better on the native backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Jonas Dreßler
58290cca57 window: Stop event propagation for drag and window-menu triggering events
meta_window_handle_ungrabbed_event() triggers the show of the window menu in
gnome-shell via meta_window_show_menu() on hold of Meta + right mouse button
click.

Since meta_display_handle_event() was refactored lately and now forwards a
lot more events to Clutter (including the one triggering the window menu),
gnome-shell now sees this event after the menu has opened, figures that the
source-actor is outside of the menu, and immediately closes the menu again.

This is the correct behavior from the PopupMenuManager on the gnome-shell
side, it is the responsibility of the event handler that opens the menu (aka
meta_window_handle_ungrabbed_event()) to return CLUTTER_EVENT_STOP and stop
event propagation.

So fix this issue by adding a return value to
meta_window_handle_ungrabbed_event() and stopping event propagation in case
the event opened the window menu.

While at it, also return CLUTTER_EVENT_STOP for events triggering window
drags, so we can drop the extra check for that in
meta_display_handle_event().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3623>
2024-03-04 09:59:59 +00:00
Peter Hutterer
6a31664a42 input-capture: Ignore emulated scroll events
For each libinput scroll event we generate two clutter events
(continuous and discrete), one of them marked as emulated. libei
explicitly specifies that emulation of scrolling must be done in the
client (if desired) so drop the emulated one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3637>
2024-03-04 08:46:38 +00:00
Peter Hutterer
e0c4b2b241 backends/native: Mark the emulated smooth scroll event as such
This path is hit for discrete (wheel) scroll events from libinput but
the emulated smooth scroll event isn't marked as such.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3637>
2024-03-04 08:46:38 +00:00
Sebastian Keller
c09fb9c5a1 compositor/drag: Use "default" cursor for moving windows
This is consistent with the DnD related cursor changes that also use the
"default" cursor for moving. The "move" cursor is kept for moving and
resizing windows using the keyboard since we currently have no other way
indicate this state.

See: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7425#note_2023057
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3634>
2024-03-02 23:42:55 +00:00
Barnabás Pőcze
fb890ead96 display: Force window user time update to happen
`meta_window_set_user_time()` will not update the window's
user time if it timestamp in the argument is before the
currently saved timestamp. However, when trying to work around
problematic timestamps, this is exactly what needs to be done.

So force the update to happen by setting the "is user time set?"
flag to false.

Fixes: 8f3da9f68a ("Use meta_window_set_user_time for setting user time consistently")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3027>
2024-03-02 23:19:22 +00:00
Robert Mader
e8b43d3b1b surface-actor: Add NULL check for stage
In some cases Wayland surface actors are not decendents of the stage,
notably subsurfaces without a parent surface. The code changes in the
mentioned commits dropped the previously existing check for that - readd
it.

Fixes: 627ab24721 (surface-actor: Add meta_surface_actor_schedule_update())
Fixes: 7eb99ddef7 (wayland/surface: Schedule updates in the context of the surface actor)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3323
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3633>
2024-03-02 22:37:22 +00:00
Jonas Dreßler
e9866eee0f compositor: Set priv->current_drag before calling meta_window_drag_begin()
priv->current_drag is the property that
meta_compositor_get_current_window_drag() and therefore also
meta_display_is_grabbed() bases its check on. We use
meta_display_is_grabbed() to select which cursor to use (window cursor
vs root cursor) when updating the cursor in MetaCursorTracker.

Since meta_window_drag_begin() sets a new cursor, and therefore triggers the
cursor tracker to update the current visible cursor, we should set
priv->current_drag before the call to meta_window_drag_begin(). This makes
sure the cursor tracker sees that there's a window drag and changes the
cursor right away when the window drag begins (instead of doing so on
subsequent pointer events).

Fixes: 525ed1166c ("wayland/pointer: Unset current surface during window drags")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3630>
2024-03-02 20:24:26 +00:00
Michel Dänzer
0690addcfc wayland/tablet-tool: Check for non-NULL surface resource
A MetaWaylandSurface object can outlive the corresponding wl_surface
object since https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880 .

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3320
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3632>
2024-03-02 19:46:15 +01:00
Dor Askayo
8df0beae08 monitor-manger: Expose the minimum refresh rate of monitors
This exposes the minimum refresh rate of monitors through D-Bus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
a53c02bba5 monitor: Add meta_monitor_get_min_refresh_rate()
This function gets the minimum refresh rate of the monitor's main
output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
cb40a1c510 output: Add meta_output_info_get_min_refresh_rate()
This function gets the minimum refresh rate of an output if it was
found in EDID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
a96d524503 edid: Decode the minimum vertical rate from the display range limits
This is used as the minimum refresh rate in the variable refresh rate
range.

This value is expected to be found in the DisplayPort and eDP EDID of
every monitor that supports variable refresh rate.

It is also found in the HDMI EDID of some monitors that support
variable (FreeSync), but most likely not all of them. The rest require
parsing the AMD vendor extension which libdisplay-info doesn't
support.

No fallback is implemented for cases where libdisplay-info support is
disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
4919a53f84 compositor/native: Enable frame synchronization for surface actors
Find a surface actor that meets the criteria to drive the refresh
rate for the view. If a new surface actor is found, add a
reference to it and request frame synchronization to be enabled
for the relevant MetaRendererViewNative.

Whenever the surface actor schedules a repaint or an update, and
in case frame synchronization is enabled for the
MetaRendererViewNative, schedule the update to occur "now". This
effectively makes the surface actor's frame rate drive the refresh
rate of the monitor.

If the actor is frozen or destroyed, it is no longer expected to
schedule repaints or updates and should stop driving the refresh
rate.

When there is no surface actor to drive the refresh rate, request
frame synchronization to be disabled for the MetaRendererViewNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
7eb99ddef7 wayland/surface: Schedule updates in the context of the surface actor
This makes all stage updates that result from applying the pending
state of a Wayland surface emit an "update-scheduled" signal in the
context of the relevant surface actor.

A common case where an "update-scheduled" signal is needed is
when applying "empty" client commits. In this case a
"repaint-scheduled" signal would not be emitted since the commit
doesn't trigger a repaint. However, it is still important to add
handling for such updates with variable refresh rate when the
releavnt actor is also driving the refresh rate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
627ab24721 surface-actor: Add meta_surface_actor_schedule_update()
This function allows scheduling a stage update in the context of a
surface actor and emit the "update-scheduled" signal. This signal is
similar to "repaint-scheduled", but can be used to be notified of
updates that do not necessarily result in a repaint.

With variable refresh rate, any update potentially affecting the
frame pacing of a surface actor needs to be handled differently
depending on whether that surface actor drives the refresh rate or
not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
1318cd3faf window: Allow checking if a window covers a rect
This is just a small function to improve the readability of the code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
4e5ac0186c surface-actor: Allow checking if a surface actor covers a rect
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
f5e5032eac surface-actor: Add "is-frozen" property
This can be used to receive notification of when a surface actor
becomes frozen or thawed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
fee3329997 onscreen/native: Allow requesting frame synchronization
Frame synchronization is enabled for a view as long as it's
applicable to be enabled. It is considered applicable if it's both
requested for the onscreen and if the onscreen uses a CRTC which is
configured with a variable refresh rate mode.

When frame synchronization is enabled, it enables both the the variable
scheduling mode of ClutterFrameClock and the variable refresh rate
property for the CRTC.

Changes in the frame synchronization mode are applied asynchronously,
before the next frame is drawn.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
732f5afe13 monitor-manager: Add support for refresh rate modes
The refresh rate mode is exposed in the DisplayConfig D-Bus interface
and is made persistent through monitors.xml.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
1721dad5ec monitor: Include the refresh rate mode in the mode spec
Variable refresh rate modes are preferred over their fixed refresh
rate counterparts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
be36c18787 output/kms: Initialize variable refresh rate output modes
Add variable refresh rate output modes for connectors that are VRR
capable when VRR is not disabled for the GPU.

Variable refresh rate output modes are sorted before their fixed
refresh rate counterparts. They are also marked as the preferred mode
for the output between the two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
455ac43e0a kms: Initialize variable refresh rate CRTC modes
When VRR is not disabled for a GPU, create two variants of every
display mode: one with fixed refresh rate and another with variable
refresh rate.

The variable refresh rate modes are not used yet. They will be used
in a following commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
9fcc938075 gpu/kms: Allow checking if VRR should be disabled
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
b2ceb055d6 backends/native: Add support to disable VRR using udev
This can be used to disable VRR in specific drivers and hardware
combinations where it is found to be problematic.

No default rules are added for now to encourage testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
e72baac97d settings: Add experimental feature for variable refresh rate
Require the "variable-refresh-rate" keyword under the
"experimental-features" gsetting to enable the feature for now.

It would no longer be required once the experience with variable
refresh rate is good enough for general use and handles all common
use cases well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
a74fbecbd6 kms/crtc: Calculate CRTC deadline for VRR
Use a sufficiently low refresh rate to calculate the CRTC deadline
when variable refresh rate is enabled. This is done to avoid cursor
updates from driving the monitor refresh rate.

It's not great solution and is sometimes not enough, but it avoids
stutter in the main content as a result of cursor movement in most
cases.

The unfortunate downside of this approach is that cursor movement
would usually only update with the main content and would not be
smooth when the main content updates are not frequent enough.

A better solution may use an approach similar to LFC (Low Framerate
Compensation) to insert cursor-only updates between updates of the
main content, but achieving adequate results with an approach of this
nature requires more research and experimentation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
2a3fc9b830 kms/impl-device: Allow the expected presentation time to be unknown
It is not trivial to accurately estimate the expected presentation
time with variable refresh rate, and not doing so only affects debug
prints.

No change in behavior for now because the expected presentation time
is always calculated. A following commit will introduce a case where
it is not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
4ad282cf26 kms: Allow setting the "VRR_ENABLED" property on a CRTC
Add functions to update and monitor the value of the "VRR_ENABLED"
KMS property.

This requires the addition of functions to process CRTC property
updates in both the atomic and the simple KMS backends. The
implementation is similar to the implemention of processing
connector updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
b7128b1d12 connector/kms: Detect variable refresh rate capability
The "vrr_capable" property indicates whether variable refresh rate is
supported for a connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Jonas Dreßler
525ed1166c wayland/pointer: Unset current surface during window drags
Commit d48129f5ee broke the displaying of our own drag cursor during window
drags, as now the window cursor is always used, even during stage grabs
(window grabs are just a kind of stage grab).

To fix it, while not regressing on the intention of the other commit, unset
the MetaWaylandPointer surface in case a window drag is active (instead of
all kinds of grabs) by checking via meta_display_is_grab().

Fixes: d48129f5ee ("wayland: Fix pointer cursor during Wayland grabs")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3316
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3624>
2024-03-01 16:41:46 +01:00
Carlos Garnacho
8519a31e8f wayland: Make MetaWaylandTabletTool struct private
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
f17300a22e wayland: Refactor tablet tool grab checks
Move the bulk of the implementation inside MetaWaylandTabletTool
files, so MetaWaylandTablet does not need to access at tool struct
fields.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
314ab7c3cb wayland: Remove some unnecessary header includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
bff8269a3e wayland: Make MetaWaylandPointer struct definition private
Move it outside the header and into private code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
f53adae278 wayland: Avoid MetaWaylandPointer struct peeking in touchpad gestures
Use getters for the MetaWaylandPointerClient and MetaWaylandSurface for
the logical focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
bf4d46097b wayland: Add getter for the pointer focus client
Similarly to MetaWaylandKeyboard, there's some subsystems
that want access to this, e.g. touchpad gestures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
03b504fc38 wayland: Refactor pointer grab checks
Move the bulk of the implementation inside MetaWaylandPointer
files, like it happens in other places (e.g. MetaWaylandTabletSeat).
This avoids MetaWaylandPointer struct peeking from outside.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
84d48254d7 wayland: Make MetaWaylandKeyboard struct private
Move it out of the header and into the C code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
fb7cd18ebf wayland: Fetch seat input focus as focus for new pad devices
Use the MetaWaylandSeat focus, and avoid peeking at MetaWaylandKeyboard
internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
017eff6663 wayland: Avoid MetaWaylandKeyboard struct access
Use the MetaWaylandSeat focus, instead of peeking at MetaWaylandKeyboard
internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
81df305645 wayland: Add MetaWaylandSeat input focus getter
This will be useful for MetaWaylandCompositor to get the
current input focus for keyboard and other related devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Sebastian Keller
9e77d45704 Revert "frames: Always initialize _MUTTER_FRAME_EXTENTS to zero"
The _MUTTER_FRAME_EXTENTS need to have the correct size before the
window is shown, otherwise the client window size will effectively have
the headarbar height subtracted when initially syncing the frame/client
geometries.

This reverts commit f10b3eac62.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3628>
2024-03-01 10:54:32 +01:00
Carlos Garnacho
c12991936e wayland: Let the tablet tool handle the handle_event() return value
This was being ignored, and the events propagated always. This may lead
to confusion with Clutter about who handled what, since shockingly the
events may be delivered to clients.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3317
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3625>
2024-02-28 22:46:03 +00:00
Carlos Garnacho
4c4c0b847d wayland: Do not claim tablet tool events as consumed without focus
If the tablet tool has no focus, it should let events go through.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3625>
2024-02-28 22:46:03 +00:00
Sebastian Wick
8234f5bc7e egl: Return success status from meta_egl_query_device_string
QueryDeviceString can successfully return NULL. The convention however
is that when NULL is returned, the error will be set.

This commit makes the returned string an output parameter which allows
us to return the success status and have the error set accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3614>
2024-02-27 13:13:53 +00:00
Sebastian Wick
46619573e0 egl: Make sure GError gets set when we return FALSE
The convention is that when a function returns FALSE or NULL, the error
will be set. In this file we call set_egl_error but it might not set an
error. Code of the form

if (egl_do_thing (..., &error))
 use_error (error);

will crash in those cases.

This commit makes sure we always set the error even if EGL doesn't give
us an error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3614>
2024-02-27 13:13:53 +00:00
Doğukan Korkmaztürk
a816470996 screen-cast-stream: Remove stale comments and an unused variable
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3592>
2024-02-27 12:38:01 +00:00
Marco Trevisan (Treviño)
839158ffd5 build/meta: Add explicit dependency on Gio-2.0 gir
We depend on Gio for many introspection features (GSettings, GFile...)
without this we'd end up not having many symbols being exposed.

And errors such as
  Warning: Meta: meta_display_add_keybinding: argument settings:
    Unresolved type: 'GSettings*'

As per previous commit we now have this dependency implicitly, but still
it's better to make it clearer in case Clutter would drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3620>
2024-02-27 10:35:06 +01:00
Carlos Garnacho
e5483a963e wayland: Pass button/touch press begin coordinates as window drag hint
This will make windows stick to the pointer from the right point
where dragging started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
1b3759d51c x11: Pass NET_WM_MOVERESIZE coordinates as window drag hint
This will make windows stick to the pointer from the right point
where dragging started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
4b1e24fcc4 core: Pass position hint to meta_window_begin_grab_op()
Add an argument to pass the position hint to this public API
call, so that callers can specify such hint. Everyone passes
NULL at the moment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
51e084ee8d compositor: Forward window drag position hint across internals
Allow passing an argument to meta_compositor_drag_window() to pass
the hint. Unused so far.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:20 +01:00
Carlos Garnacho
e4542a6495 compositor: Add MetaWindowDrag API to add a hint on the grab coordinates
This is added as a hint so that the caller can optionally use it, e.g.
in the case that a window drag is driven by the mouse. This will be used
to more accurately follow the drag position, other than starting at the
current pointer position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:18:23 +01:00
Carlos Garnacho
4fa2706b9b wayland: Look up pointer logical focus when enabling constraints
Pointer constraints obey to logical pointer focus changes, and looking
up the current surface in order to maybe enable them is getting ahead
of itself, since the pointer focus might differ from the current surface
due to other factors (e.g. grabs).

Change the code checking whether constraints should be enabled to again
check the pointer logical focus, this will be influenced by the
MetaWaylandEventInterface mechanism, and correctly reflect the logical
state accounting for those factors.

Fixes: 125ba92169 ("wayland: Port pointer constraints to using MetaWaylandEventInterface")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3303
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Carlos Garnacho
1d5676bc9a wayland: Handle event interface changes during focus synchronization
Currently, we don't handle too well the removal of a MetaWaylandEventInterface
during meta_wayland_event_interface_invalidate_all_focus(), since the
MetaWaylandEventInterface may be freed at an intermediate point in that function
while handling the focus change for all input devices.

Turn this invalidate_all_focus() function into a MetaWaylandInput method, and
always ensure to use the currently effective MetaWaylandEventInterface when
resetting the focus for each device.

This fixes the situation through handling reentrancy naturally, a focus
sync (say, triggered by a grab) would reset a device focus (say, pointer), which
would remove an event interface (say, a pointer constraint), which would
invalidate_all_focus() again underneath using the new effective
MetaWaylandEventInterface. When that is done, the initial invalidate_all_focus()
call would re-apply the same focus to the same currently effective
MetaWaylandEventInterface, resulting in a no-op for the remainder of the function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Carlos Garnacho
7fc49f742b wayland: Add getter for the MetaWaylandPointer logical focus
Even though the logical focus is typically business that only the
MetaWaylandEventInterface mechanism minds about, there are some pointer
subsystems that want to look this up, as opposed to the current surface.

Add a getter to make this easier, without struct peeking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Sebastian Wick
b102b6eca7 kms/connector: Remove getters for state tracked by KmsConnectorState
This also removes some g_return_if_fail's because the test suite expects
to be able to create arbitrary KmsUpdates even if they don't make sense
for the real state. We just get lucky that the test suite isn't
constructing updates with color space and hdr changes, yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
420c8cb37f kms/connector: Simplify privacy screen tracking
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
3e14edb00c kms/connector: Track max_bpc in KmsConnectorState
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
e9e613a6c3 kms/connector: Track underscan in KmsConnectorState
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
0dc43c04ee onscreen/native: Move rgb range support to OutputInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
706bee2a58 onscreen/native: Use max bpc support from OutputInfo
The max bpc support is already tracked in the OutputInfo, so let's use
that instead of querying the KMS Connector directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00