8535 Commits

Author SHA1 Message Date
Michel Dänzer
84135e51b0 clutter: Add ClutterFrameInfo::view_frame_counter
And plumb it through from ClutterFrame::frame_count.

Preparation for later changes, no functional change intended.

v2:
* Rename to view_frame_counter. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 15:43:29 +01:00
Michel Dänzer
7bcbd253c2 clutter: Rename ClutterFrameInfo::frame_counter to global_frame_counter
To stress that it's the global frame counter.

Preparation for later changes, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4306>
2025-03-13 15:43:28 +01:00
Sebastian Wick
603742d98c clutter/stage-view: Notify about color state changes
The cursor renderer will rely on the stage view telling it when its
output color state has changed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4315>
2025-03-06 11:42:49 +00:00
Daniel van Vugt
2d70451bf3 clutter/frame-clock: Verify and change state earlier in dispatch
So that if somehow it does return early then we're not left with an
allocated `clutter_frame_clock_new_frame` that is never dispatched
(which then leads to the pool being exhausted a frame or two later).

It's not yet clear how it comes to this where the source is dispatched
and the state unscheduled, but at least the more detailed logging here
will help us to identify which state it came from.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3945
Fixes: 394bf5ab24 ("clutter/frame-clock: Add triple buffering support")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4316>
2025-03-05 01:56:52 +00:00
Joan Torres
565cff5cb9 clutter/color-state-params: Ignore explicit max_lum on EOTF_PQ
This is a requirement from the wayland color management:

"With transfer_function.st2084_pq the given 'max_lum' value is
ignored, and 'max_lum' is taken as 'min_lum' + 10000 cd/m²."

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4304>
2025-03-04 14:05:41 +01:00
Joan Torres
62df470837 clutter/color-state-params: Handle on gamma EOTFs negative vals
This is a requirement from the wayland color management:

"Negative values are handled by mirroring the positive half of
the curve through the origin."

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4304>
2025-03-04 14:05:41 +01:00
Robert Mader
6c05ec7ded Revert "clutter: Drop CLUTTER_DRIVER env variable"
This reverts commit 7d376dfddc386ae01da8c4dafbb4fc6080642253.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4312>
2025-03-02 10:06:46 +00:00
Michel Dänzer
99606f840c clutter/frame-clock: Use update time estimate in want_triple_buffering
We don't want triple buffering when the estimated maximum update time is
known and no larger than a refresh interval. In that case, regular frame
clock dispatch is scheduled after the previous frame is presented, so no
third buffer is necessary.

Allowing triple buffering anyway was problematic when frames are skipped
for reasons other than the frame update taking too long (e.g.
https://gitlab.gnome.org/GNOME/mutter/-/issues/3884):

1. First frame dispatches, targets display refresh cycle (DRC) n, but
   skips
2. Second frame dispatches, targets DRC n+1
3. First frame is presented at DRC n+1
4. Second frame is presented at DRC n+2

Without triple buffering:

2. First frame is presented at DRC n+1
3. Second frame dispatches, targets DRC n+2
4. Second frame is presented at DRC n+2

The second frame is presented at DRC n+2 in both cases, but with triple
buffering it targeted n+1, i.e. its contents might not be consistent
with when it's presented.

It gets worse with triple buffering if the second frame also skips:

4. Second frame skips, is presented at DRC n+3

That's a discrepancy of 2 refresh cycles between the target and
effective presentation time, which might be noticeable as more severe
stutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
4727d5a00f clutter/frame-clock: Fix max_update_time_estimate clamping
When triple buffering isn't allowed, it needs to be clamped to a single
refresh interval instead of two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
826b856945 clutter/frame-clock: Rename max_render_time → max_update_time_estimate
Better describes what it's about.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
e105533730 clutter/frame-clock: Log by how much a missed frame was off the target
v2:
* Tweak coding style to address check-c-code-style CI job failure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
a5d2eeaa9f clutter/frame-clock: Fix n_missed_frames counting
frame_clock->n_missed_frames was accidentally reset every frame, instead
of only after logging its value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
0470dacb41 clutter/frame-clock: Use ClutterFrameInfo::target_presentation_time
With triple buffering, frame_clock->next_presentation_time_us
corresponds to a different frame in
clutter_frame_clock_notify_presented.

Also remove superfluous has_next_presentation_time field, any
target_presentation_time value > 0 is valid.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
2682ab2863 stage-view: Plumb through target presentation time to ClutterFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
dbd82f47a5 clutter/frame-clock: Log updates to max update duration estimate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
7cc3dede2f clutter/frame-clock: Refactor get_max_update_duration_us helper
Preparation for later changes, no functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Michel Dänzer
ca47a5e83c clutter/frame-clock: Use FRAME_CLOCK topic for dispatch jitter logging
Seems to fit better there than with FRAME_TIMINGS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4282>
2025-03-01 13:33:09 +00:00
Joan Torres
9022b39a50 clutter/color-state: Add do_transform method
This is a CPU-based transformation method that performs the
same transformation implemented on GPU shaders.

The transformation gets an array of pixels in RGB float format and
returns an array of pixels transformed.

This will be used in the next commit to compare the results
between CPU and GPU, validating the shader implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4230>
2025-02-25 18:28:49 +00:00
Joan Torres
ca977ce2bb clutter/color-state-params: Avoid implicit cast from int to float
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4230>
2025-02-25 18:28:49 +00:00
Joan Torres
593eb66b36 clutter/color-state-params: Fix bt709 snippet
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4230>
2025-02-25 18:28:49 +00:00
Sebastian Wick
4fe1e41ab3 wayland/color-management: Update to upstream wp_color_management_v1
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4291>
2025-02-25 02:40:17 +00:00
Lukáš Tyrychtr
d3a0bbdf52 clutter: Add ClutterEventFlag to notify a11y modifier click
Use a Clutter event flag to communicate the the fact that the event
is an a11y modifier first click. The accessibility modifiers will
require special handling in the input and main threads.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
2025-02-25 02:14:46 +00:00
Florian Müllner
c41077a7a9 clutter/actor: Don't create animation info when removing transitions
_clutter_actor_get_animation_info() creates a new info when the actor
currently doesn't have one. That's unnecessary and wasteful in case
where we only need to check for transitions to remove, so switch to
_clutter_actor_get_animation_info_or_default() that falls back to
an empty static info.

Fixes: c250f602bd ("clutter/actor: Remove transitions when removing an effect")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4260>
2025-02-19 17:14:35 +00: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
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
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
Corentin Noël
2da7805f58 meson: Use library instead of shared_library
Allow to theoretically build mutter statically.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4244>
2025-02-11 09:55:07 +00:00
Bilal Elmoussaoui
581607f5f1 clutter: Update keyname table header
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4198>
2025-02-04 13:50:50 +01:00
Bilal Elmoussaoui
ce6a321da2 clutter: Ignore duplicated Break keysum
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4198>
2025-02-04 13:50:50 +01:00
Bilal Elmoussaoui
89d85a809b clutter: Update keysyms header
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4198>
2025-02-04 13:50:50 +01:00
Alberto Ruiz
c9612723f9 build: Remove all perl scripts from the build
replaced gen-keyname-table.pl and clutter-keysyms-update.pl with a
python implementation to remove the need for perl in the build stage

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4198>
2025-02-04 13:50:50 +01:00
Philip Withnall
c250f602bd clutter/actor: Remove transitions when removing an effect
If there are any in-progress transitions on any properties of the
effect, these will cause a crash next time they tick and update, as they
will try to access a `@effects.${effect_name}.${property_name}` property
on the `ClutterActor` which no longer resolves to an effect. In some
cases this will be because `priv->effects` itself is now `NULL` on the
`ClutterActor`.

This can be triggered by rapidly toggling screen time limits on and off
in gnome-shell with a low screen time limit which has already been
reached for the day. It will alternately add a desaturation effect and
fade-in transition, then remove the effect, then the transition will
update and crash.

Avoid this by removing relevant transitions when removing an effect.

Do the same for the other two groups of metas: constraints and actions,
as they will be subject to the same bug (under different reproducer
conditions). And the same for when any of these three meta groups are
cleared, as that could also trigger the same bug.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8168
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4222>
2025-02-03 15:14:51 +00:00
Bilal Elmoussaoui
04218ac2b5 clutter: Handle accessible focus state change on Actor side
That is where it belongs anyways and would handle some missing branches
where we wouldn't update the focus state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4089>
2025-01-20 14:23:44 +00:00
Bilal Elmoussaoui
9d72f658af clutter: Add accessible state tracking
Currently, this has been living in StWidget, moving that to Clutter
allows us to properly track the accessibility state changes in the
actors provided inside Clutter as well as simplifying things for a
future move from Atk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4089>
2025-01-20 14:23:44 +00:00
Jonas Ådahl
3806c0bd44 clutter/stage: Add 'skipped-paint' signal/vfunc
This is intended to allow being notified about a stage update happening,
but painting didn't happen. This is possible today by using other
signals and keeping track of painting happened, but it saves us some
state tracking by just being told so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4067>
2025-01-16 01:04:14 +00:00
Michel Dänzer
d908984d68 clutter/frame-clock: Use vblank_duration in calculate_next_update_time_us
In this scenario:

1. Only an "empty" content update (which results in no visible output
   change) from client A arrives before the frame deadline, so a frame
   event is sent for that at the deadline.
2. Another "empty" content update from client A results in a frame event
   being scheduled for the next frame deadline.
3. A non-"empty" content update from client B arrives before start of
   vblank, and the resulting output frame manages to hit the next
   display refresh cycle.

The result was that the frame events from steps 1+2 were sent during the
same display refresh cycle, so the frame rate reported by client A was
higher than the display refresh rate.

This change fixes that, at the cost of frame events being sent out
later in the display refresh cycle if there's no new frame for the
next cycle.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3559
Fixes: 8f27ebf87eee ("clutter/frame-clock: Start next update ASAP after idle period")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3878>
2025-01-10 14:59:10 +00:00
Derek Foreman
5b214dc2b7 clutter/frame-clock: Allow scheduling an update in the future
Allow creating a queue of future times to tick at. This adds a new clock
state where we let the clock go idle, but will wake at a time in the
future to tick.

We can still schedule ticks while in this new state, but we're assured a
tick at or shortly after the scheduled time.

This will be used later by wayland code that schedules future presentation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3355>
2025-01-06 09:21:12 -06:00
Bilal Elmoussaoui
4ee657e31f cogl/texture: Drop set_auto_mipmap vfunc
As it is only relavant for 2D textures.
Allows getting rid of the is-primitive property which was enforcing only 2D textures
can use the set_auto_mipmap function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4200>
2025-01-02 18:04:27 +00:00
Bilal Elmoussaoui
5621134399 clutter: Make cairo dependant on fonts build option
As it is only used there. Once we have removed cairo usage from meta, we
can make it tests specific.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4106>
2024-12-28 12:15:12 +00:00
Bilal Elmoussaoui
32c5faf010 build: Add a new fonts option
Allowing to disable font rendering integration, making it possible to
build Mutter without pango/harfbuzz/fribidi dependencies.

This commit also adds a new clutter-pango header that is used to include
pango specific bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4106>
2024-12-28 12:15:12 +00:00
Bilal Elmoussaoui
b0b1e0ef4e clutter: Inline character direction detection helper
By doing so, we can make the fribidi dependency specific to having x11
backend or fonts rendering support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4106>
2024-12-28 12:15:11 +00:00