33394 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
f823f1052d monitor-dbus-tests: Use autopointer to free errors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4277>
2025-02-17 14:58:06 +00:00
Artur S0
134d0635e2 Update Russian translation 2025-02-17 12:21:52 +00:00
Marco Trevisan (Treviño)
a99def7444 ci: Install zenity in gnomeos sysext
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4280>
2025-02-17 10:30:08 +00:00
Marco Trevisan (Treviño)
73d4bbd1ad tests/build: Require zenity if x11 tests are enabled
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4280>
2025-02-17 10:30:08 +00:00
Marco Trevisan (Treviño)
cfdc63df2d tools/gdctl: Make argcomplete optional
While having automatic completions is a very nice feature of gdctl (I
had suggested to use it too :)), it's not something that distros may
have by default and in particular it's not a package in main in ubuntu.

So, make the code less restrictive on completions, since completions is
not a core functionality of the tool and it can definitely work without
them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4279>
2025-02-15 17:54:20 +01:00
Florian Müllner
33761eb2af clutter/stage: Warn when setting stage key focus to stage
While the `get_key_focus()` method returned the stage itself when
no explicit focus was set, it made sense for the corresponding
setter to accept the stage as synonym for NULL.

But now that the getter always returns the property value, it
makes more sense to expect NULL to unset the key focus.

Keep the current behavior of normalizing the key focus to NULL
in that case to minimize breakage, but print a warning to
use NULL instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4256>
2025-02-14 20:19:45 +01:00
Florian Müllner
897cc303cb tests/shell: Do not set key-focus to stage
Moving the key focus to the stage should be done by unsetting the
focus rather than setting it to the stage itself.

`clutter_stage_set_key_focus()` already "normalizes" the stage to
NULL internally, so this does not change the actual behavior of the
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4256>
2025-02-14 20:19:45 +01:00
Florian Müllner
e49edebf92 clutter/stage: Turn get_key_focus() into a proper getter
The method currently returns the stage itself when the property
is NULL.

This has become particularly problematic as the method is detected
as getter by gobject introspection, and gjs now optimizes property
accesses by calling the getter method instead.

Address this by turning the method into a genuine getter without
falling back to the stage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4256>
2025-02-14 20:19:45 +01:00
Florian Müllner
1d69b1b505 clutter: Prepare for get_key_focus() returning NULL
While the existing `get_key_focus()` methods looks like a getter of the
`key-focus` property and is detected as such by gobject introspection,
it behaves differently in that it returns the stage if no explicit
focus has been set.

This is about to change, so adjust the couple of cases that rely
on the fallback to the stage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4256>
2025-02-14 20:17:58 +01:00
Daniel van Vugt
9a39a0cee9 clutter: Add a CLUTTER_DEBUG_DISABLE_TRIPLE_BUFFERING flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
f06913a2d1 clutter/frame-clock: Optimize latency for platforms missing TIMESTAMP_QUERY
Previously if we had no measurements then `compute_max_render_time_us`
would pessimise its answer to ensure triple buffering could be reached:

  if (frame_clock->state >= CLUTTER_FRAME_CLOCK_STATE_DISPATCHED_ONE)
    ret += refresh_interval_us;

But that also meant entering triple buffering even when not required.

Now we make `compute_max_render_time_us` more honest and return failure
if the answer isn't known (or is disabled). This in turn allows us to
optimize `calculate_next_update_time_us` for this special case, ensuring
triple buffering can be used, but isn't blindly always used. So when
TIMESTAMP_QUERY support is missing we now take the same path as if
presentation timestamps are missing (introduced in 56fc09151d and
improved in 0555a5bbc1), which has the benefit of naturally switching
from double to triple buffering as required without actually having to
measure render times.

This makes a visible difference to the latency when dragging windows in
Xorg, but will also help Wayland sessions on platforms lacking
TIMESTAMP_QUERY such as Raspberry Pi.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
2dbca5ff39 clutter/frame-clock: Record measurements of zero for cursor-only updates
But only if we've ever got actual swap measurements
(COGL_FEATURE_ID_TIMESTAMP_QUERY). If it's supported then we now drop to
double buffering and get optimal latency on a burst of cursor-only
updates.

Closes: https://launchpad.net/bugs/2023363
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
463fc8b92c clutter: Enable triple buffering and adapt the KMS render tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
394bf5ab24 clutter/frame-clock: Add triple buffering support
This replaces the DISPATCHED state with new sub-states that are possible
with triple buffering:

  DISPATCHED_ONE:                     Double buffering
  DISPATCHED_ONE_AND_SCHEDULED:       Scheduled switch to triple buffering
  DISPATCHED_ONE_AND_SCHEDULED_NOW:   Scheduled switch to triple buffering
  DISPATCHED_ONE_AND_SCHEDULED_LATER: Scheduled switch to triple buffering
  DISPATCHED_TWO:                     Triple buffering

Triple buffering is currently disabled until the test cases get updated to
handle it in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
9d2ab85f74 clutter/frame-clock: Merge states DISPATCHING and PENDING_PRESENTED
Chronologically they already overlap in time as presentation may
complete in the middle of the dispatch function, otherwise they are
contiguous in time. And most switch statements treated the two states
the same already so they're easy to merge into a single `DISPATCHED`
state.

Having fewer states now will make life easier when we add more states
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
1c4ee8e062 clutter/frame-clock: Lower the threshold for disabling error diffusion
Error diffusion was introduced in 0555a5bbc15 for Nvidia where last
presentation time is always unknown (zero). Dispatch times would drift
apart always being a fraction of a frame late, and accumulated to cause
periodic frame skips. So error diffusion corrected that precisely and
avoided the skips.

That works great with double buffering but less great with triple
buffering. It's certainly still needed with triple buffering but
correcting for a lateness of many milliseconds isn't a good idea. That's
because a dispatch being that late is not due to main loop jitter but due
to Nvidia's swap buffers blocking when the queue is full. So scheduling
the next frame even earlier using last_dispatch_lateness_us would just
perpetuate the problem of swap buffers blocking for too long.

So now we lower the threshold of when error diffusion gets disabled. It's
still high enough to fix the original smoothness problem it was for, but
now low enough to detect Nvidia's occasionally blocking swaps and backs
off in that case.

Since the average duration of a blocking swap is half a frame interval
and we want to distinguish between that and sub-millisecond jitter, the
logical threshold is halfway again: refresh_interval_us/4.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
6fae16302b doc: Update the frame scheduling diagram to include SCHEDULED_LATER
Although since all SCHEDULED* states basically have the same transitions
it's easier to show them as a single state. The mermaid diagram also won't
render correctly if there is a mix of combined and singular states. We
must use either always combined states or always singular states.

Fixes: 5b214dc2b7 ("clutter/frame-clock: Allow scheduling an update in the future")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
9dec39d92e renderer/native: Discard pending swaps when rebuilding views
It's analogous to discard_pending_page_flips but represents swaps that
might become flips after the next frame notification callbacks, thanks
to triple buffering. Since the views are being rebuilt and their onscreens
are about to be destroyed, turning those swaps into more flips/posts would
just lead to unexpected behaviour (like trying to flip on a half-destroyed
inactive CRTC).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
c681b6977c onscreen/native: Increase secondary GPU dumb_fbs from 2 to 3
So that they don't get overwritten prematurely during triple buffering
causing tearing.

https://launchpad.net/bugs/1999216

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
ffc2a7d3cd onscreen/native: Defer posting if there's already a post in progress
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
5426935adb onscreen/native: Pass frame as a parameter to flip_crtc
Minor style change requested by jadahl. This makes it clear earlier on
in post_next_frame that next_frame has been consumed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
4d4bf1244a onscreen/native: Merge composite and direct scanout posting code paths
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
b6841e2e33 onscreen/native: Insert a 'posted' frame between 'next' and 'presented'
This will allow us to keep track of up to two buffers that have been
swapped but not yet scanning out, for triple buffering.

This commit replaces mutter!1968

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
54b393c2b3 onscreen/native: Split swap_buffers_with_damage into two functions
1. The EGL part: meta_onscreen_native_swap_buffers_with_damage
2. The KMS part: post_next_frame

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
f3688190bf onscreen/native: Deduplicate calls to clutter_frame_set_result
All paths out of `meta_onscreen_native_swap_buffers_with_damage` from
here onward would set the same `CLUTTER_FRAME_RESULT_PENDING_PRESENTED`
(or terminate with `g_assert_not_reached`).

Even failed posts set this result because they will do a
`meta_onscreen_native_notify_frame_complete` in
`page_flip_feedback_discarded`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
0f7183ebef onscreen/native: Invert the early exit from swap_buffers_with_damage
A long overdue tidy-up. Most of the logic doesn't even need to be
indented under the if statement.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
77590d5e65 onscreen/native: Replace an assertion that double buffering is the maximum
Because it soon won't be the maximum. But we do want to verify that the
frame info queue is not empty, to avoid NULL dereferencing and catch logic
errors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
980658ed58 backends/native: Add set/steal_sync_fd functions to MetaFrameNative
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
47f485e94e backends/native: Add set/get_damage functions to MetaFrameNative
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
be7fc75878 renderer/native: Steal the power save flip list before iterating over it
Because a single iteration might also grow the list again.

This is now a partial revert of a5be92e03d3b8f74222c5d53ba1332cdeae69bcc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
fccfaca9fc renderer/native: Avoid requeuing the same onscreen for a power save flip
This is a case that triple buffering will encounter. We don't want it
to queue the same onscreen multiple times because that would represent
multiple flips occurring simultaneously.

It's a linear search but the list length is typically only 1 or 2 so
no need for anything fancier yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Daniel van Vugt
f7b296f2a9 kms: Keep a shutting_down flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
2025-02-14 17:39:09 +00:00
Sebastian Wick
276c4fa6c5 ci: Run mypy on the python tools
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4267>
2025-02-14 16:29:47 +00:00
Sebastian Wick
674ebecd00 gdctl: Fix typing and resulting handling of int|None variables
Introduces two new NamedTuples to deal with dimensions and positions.
The position is special in that x and y can be None. This was previously
wrongly declared to be only int. This commit fixes instances mypy found
where None positions were not handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4267>
2025-02-14 16:29:47 +00:00
Sebastian Wick
e5f6704a81 build: Convert string to int in gen-keyname-table.py
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4267>
2025-02-14 16:29:47 +00:00
Sebastian Wick
1fdebedd94 build: Fix argument type in clutter-keysyms-update.py
It's not a single-element-tuple but something we can iterate and
produces strings.

Also ignore typing for the requests module because we'd have to install
more things for it to be available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4267>
2025-02-14 16:29:47 +00:00
Sabri Ünal
0718ef101c Update Turkish translation 2025-02-14 13:29:46 +00:00
Alessandro Bono
5aabd66481 schemas: Set Super as default for overlay-key
Now with the new parsing mechanism we are able to set `Super` as
default for overlay-key. The parsing of the `Super` string will
fail at the new mechanism will kick in by appending `_L` and `_R`.
The parsing of the new two strings then will succeed and we will
be able to use both Super_L and Super_R to activate the overview.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
907460376f prefs: Introduce new parsing mechanism for special keys
The overlay-key and locate-pointer-key are special keys. They
can be used together with other keys to create a combo or they
can be used as a single key. This means that we are treating a
modifier key as a regular key while still allowing to use it as
part of a combo. This requires a special treatment that we can't
extend to an arbitrary list of keys.

However, we would like to use both Super_L and Super_R to
activate the overview. In order to allow this, introduce a new
parsing mechanism. With the new mechanism, if we fail to parse
the configured string, we will try to parse again by appending
_L first and _R later. If both succeed then we will use their
combos for handling the special key.

With this in place, we can configure Super as overlay-key. The
parsing of Super will fail, but Super_L and Super_R will succeed.
Allowing us to use both.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1277
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
c051c2ff69 prefs: Handle up to two combos for special keys
The second combo is still disabled. This is in preparation for a
subsequent commit that is going to parse the preference in a
different way and might end up with two combos defined.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
b48c7536ab keybindings: Introduce resolve_special_key_combo()
Special keys are going to be represent by up to two combos. This
functions is able to handle them by adding all the keycodes that
these combos resolve to. Special keys don't have modifiers, so there
is no need to devirtualize them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
ea53865962 keybindings: Introduce get_keycodes_for_combos()
This function allows, given an array of combos, to get all the
keycodes associated with them. Right now it is used for just
one combo, but will be used for two combos in order to handle
special keys like the overlay-key and the locate-pointer-key.

As it is now, this function is still useful for aggregate the
GArray creation/destruction in a single place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
5f85d6afb1 keybindings: Don't assume keycodes GArray is empty
See 44269e6a1dadb643af3a748c2bcca04ac1ab72eb. The function
add_keycodes_for_keysym() is going to be called more than
once on purpose and we want the keycodes do be appended to
a non-empty GArray.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
8172ecbf2a keybindings: Add keycodes for keysym to a GArray
We are going to need to call this function more than once to add
all the keycodes to the same GArray. Switch to handle GArrays and
rename the function in order to give a hint that keycodes are going
to be added to the passed GArray.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
b145f659fb keybindings: Rename variable
It contains more than one combo, use the plural form.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
be819d9983 keybindings: Reduce variable scope
We can't remove the variable entirely because g_array_append_val()
is a macro that assumes a variable as parameter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
db81ba4d5b keybindings: Stop tracking special binding combos
We use them in a single place, there is no need to internally keep
track of them. The MetaKeyBindingManager has their resolved key
combo (overlay_resolved_key_combo and locate_pointer_resolved_key_combo)
which is enough. Get the special binding combos from the preference
right away when needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
c60285ff76 keybindings-private: Style fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Alessandro Bono
10d0ed65aa prefs: Invert if statement condition
Mimic what we already do for the locate-pointer. There is
no need for an empty "then" branch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4050>
2025-02-13 22:43:50 +00:00
Carlos Garnacho
b7d533c301 wayland: Honor wl_surface.offset on cursor surfaces
Update the cursor hotspot based on wl_surface.offset requests. This
is the expected way to update the cursor hotspot once the cursor
surface is already visible and has buffers attached.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/7249
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4239>
2025-02-13 21:28:59 +00:00