Commit Graph

7992 Commits

Author SHA1 Message Date
Jonas Dreßler
6939bed55c clutter/stage: Make sequences exclusive to actors vs actions
As soon as any event of a sequence is handles/stopped during emission,
all actors and actions that would have gotten to see it afterwards have
a big problem: If that event was a TOUCH_END event, the actor/action is
forever going to think that this touch is still active.

For ClutterActions, we're going to handle this by introducing a way to
send them a notification when stuff like this happens.

As a baby step towards all that, make event emission exclusive to actors
as soon as any actor stopped an event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
bac66fcbc4 clutter: Implicitly grab on button and touch event sequences
We'll soon introduce a new gesture tracking framework which heavily
depends on ClutterActions seeing all events of a sequence. For this to
work, a larger change to event delivery is needed: Implicit grabbing of
all events for button and touch press->motion->release sequences to
ensure ClutterActions continue receiving events for the whole sequence.

This commit takes care of that: At the start of an event sequence we
collect all the event-handling actors and actions to a GArray that lives
in the  PointerDeviceEntry, and then deliver all events belonging to
that sequence to the same actors/actions until the sequence ends.

To avoid events getting pulled from under our feet when mutters event
filter returns CLUTTER_EVENT_STOP, this also introduces private API
(maybe_lost_implicit_grab()) on ClutterStage so that we can't end up
with stale sequences.

Note that this also slightly changes behavior when it comes to event
delivery to actions: Because we now store actions separated from their
actors, any action returning CLUTTER_EVENT_STOP now stops event
propagation immediately. That was different before, where we'd emit
events to all actions of the actor and only then stop propagation.

Note that this isn't handling ClutterGrabs correctly right now,
this will be a little tricky, so we'll take care of that in a future
commit.

To handle actors getting destroyed or unmapped during a grab, listen to
notify::grab on the deepmost actor in the implicit grab tree. This gives
us a notification when any actor inside the tree goes unmapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
d795710a14 clutter: Move emitting events to ClutterActions to the stage
A fairly small refactor, move the emission of events to actions from
clutter_actor_event() to stage level.

We do this because in the future we'll need to know on stage level
whether events were handled by an actor or by an action.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
c6b3c90e41 clutter/actor: Introduce private function to peek actions
We'll need to take a look at the actions of actors twice for every
single event emission once we move emission to the stage, let's not copy
around lists for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
4358f8da7c clutter: Reuse GPtrArray for event emission
_clutter_actor_handle_event() currently allocates a new GPtrArray on the
heap for every single event emission, let's avoid this by keeping an
array around in ClutterStage and reusing that.

This is moving the last few bits of event emission into ClutterStage,
which will be useful when we introduce implicit grabbing in subsequent
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
a62ae73478 clutter: Propagate PROXIMITY events up and down the tree
There's no real reason to keep those events exclusive to the stage, some
actors or actions might want to get notified about proximity events too,
so propagate them like any other event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
0f0466fa8e clutter: Make the stage the central instance emitting events
Right now and due to loads of refactorings lately, the event emission
paths are a bit cluttered (ha ha ha) around in Clutter. For example the
event target actor gets set in clutter-main.c, but event emission is
actually managed by ClutterStage these days.

Since we'll introduce implicit grabbing of touch/button-press sequences
soon, let's shuffle things around a bit to make that easier:

Move event emission to the stage, it now gets a ClutterEvent without any
extra context like the target actor from clutter-main. The stage then
looks up the target actor itself and emits the event to the appropriate
actors in the scenegraph. A special path is introduced for emitting
crossing events, because here the event-receiving actors don't follow
the "capture+bubble from pointer actor to grab actor" rule.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
ccb49f75e4 clutter/actions: Never stop crossing events
Crossing events should never be stopped during event emission. We
already have a check that enforces this in clutter_actor_event(), but
ClutterActions still sometimes try to stop crossing events from
propagating.

Improve that situation and return CLUTTER_EVENT_PROPAGATE when handling
crossings in ClutterActions, too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Niels De Graef
fbe7a8df3a clutter: Fix ClutterMainContext leaking events
There's still a possibility that some events remain within the
`ClutterMainContext` when it's being unref-ed for the last time (as seen
on asan logs). Make sure they get freed by using
`g_async_queue_new_full()` and specifying the appropriate destroy
function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2817>
2023-02-01 13:16:29 +00:00
Robert Mader
678bc69e72 clutter/frame-clock: Clamp next_update_time to the current time
Calculating a timestamp from the past distorts the dispatch lateness
calculation, leading to an inflated max_render_time, which again
increases the likelyhood of next_update_time being in the past.

Fixes 99850f4645

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2819>
2023-02-01 12:21:44 +00:00
Sebastian Keller
cff631cb39 clutter/text: Don't call clutter_text_set_buffer() on finalize
clutter_text_set_buffer() tries to freeze/thaw notify, which is not
allowed during finalize and recent glib versions started warning about
this. This call can simply be removed, because the buffer is already set
to NULL on dispose, making the call in finalize redundant.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2566
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2790>
2023-01-25 22:10:03 +00:00
Jonas Ådahl
08b0e563d4 clutter: Pass 'ClutterFrame' in all stage update signals
That means before-update, prepare-paint, before-paint, paint-view, after-paint,
after-update. While yet to be used, it will be used as a transient frame
book keeping object, to maintain object and state that is only valid
during a frame dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 15:57:50 +01:00
Jonas Ådahl
c54b350313 clutter/frame: Turn into boxed type
This will allow us to pass a ClutterFrame in interfaces, including ones
that end up being introspected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
56da8418f9 clutter/frame: Carry target presentation time
This will be used, when available, to both check whether frames missed a
vsync cycle, or to calculate when page flips should be queued.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
916b21674e clutter/frame-clock: Pass ClutterFrame via the frame clock interface
Let the ClutterFrame live for the whole frame, and be carried as an
argument to the frame clock listener interface functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
1c574068e0 frame-clock: Store interface pointer in variable
It's accessed a few times, so keep it around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Niels De Graef
768ec7b0c1 clutter/stage-view: Properly chain up finalize
Fix a silly copy-paste mistake. Since `GObject` is the parent class,
chaining up to `dispose()` from within your `finalize()`
implementation just leads to a little memory leak and nothing worse.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2799>
2023-01-22 18:49:15 +01:00
Carlos Garnacho
9e0b5b1886 clutter: Avoid string translation to find text direction
Use Pango and Harfbuzz for the task, getting the default language,
then its scripts, then their directions. We pick the first valid
horizontal direction, resorting to LTR as a fallback.

Related: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5385
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2780>
2023-01-13 11:46:13 +00:00
Daniel van Vugt
a09b5ecd7a clutter/frame-clock: Remove extraneous whitespace
It's causing code review warnings whenever another MR tries to change
the same source file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2784>
2023-01-06 17:27:14 +08:00
Bilal Elmoussaoui
6aeb9eef4e clutter: Add keyval helpers
Infrastructure for adding meta_accelerator_name

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
8207df77e8 clutter: Generate keynames table
Infrastructure to provide a meta_accelerator_name and
avoid libmutter clients from depending on GTK for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
c710f14cc5 core: Replace gtk_get_default_locale usage
Clutter has an API to get the text direction but used to depend
on gtk3's translation domain. In order to avoid broken i18n
in case gtk3 is not installed, move the transtalable string to
clutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Michel Dänzer
a16df485db clutter: Reduce default clutter_max_render_time_constant_us to 1000
Now that dynamic max render time uses a new algorithm and takes dispatch
lateness into account, this seems worth a shot. We'll see how it works
out in the wild.

The net result compared to before these changes is still slightly higher
(by ~0.5 ms) minimum latency for me, as measured by
weston-presentation-shm. It should be less vulnerable to frame drops
though.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2500>
2022-12-17 23:45:19 +00:00
Michel Dänzer
ca341ef1ea frame-clock: Simplify dynamic max render time calculation
Store only two values per kind of duration: The short term and long term
maximum.

The short term maximum is updated in each frame clock dispatch. The long
term maximum is updated at most once per second: If the short term
maximum is higher, the long term maximum is updated to match it.
Otherwise, a fraction of the delta between the two maxima is subtracted
from the long term maximum.

Compared to the previous algorithm:

* The calculcations are simpler.
* The calculated max render time has a slow exponential drop-off (by at
  most a few milliseconds every second) instead of potentially abruptly
  dropping after as few as 16 frames.

This should fix https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4830
since the short term maximum should always include a sample from the
clock's second tick.

v2:
* Use divisor 2 instead of 4.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2500>
2022-12-17 23:45:19 +00:00
Michel Dänzer
99850f4645 clutter/frame-clock: Use dispatch lateness for dynamic max render time
Dispatch lateness is the difference between when we wanted frame clock
dispatch to run and when it actually started running. This can be up to
1ms even under normal circumstances due to process scheduling
granularity, or even higher under load.

This keeps track of dispatch lateness of the last 16 frame clock
dispatches, and incorporates the maximum into the dynamic render time
estimate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2500>
2022-12-17 23:45:19 +00:00
Jonas Ådahl
71371750d2 clutter/input-device: Remove backend property
It will conflict with a MetaInputDevice property that'll have the same
name.

Wasn't set by the native backend anyway, so probably harmless.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 13:52:51 +00:00
Robert Mader
cef925c37f clutter/actor: Make is_effectively_on_stage_view() match has_mapped_clones()
The clone handling did not take certain cases into consideration,
thus copy over some extra checks from `has_mapped_clones()`,
ensuring consistent behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2671>
2022-12-16 16:27:33 +00:00
Jonas Ådahl
a897542876 clutter/actor: Stop transitions in children when removing
When we remove a child, we stop its transitions (animations), but we
didn't stop animations on grand children. What we did, however, was to
clear the stage views of the grand children, and this caused a bunch of
orphaned transitions (ClutterTimeline) and accompanied warnings.

Make it so that if we stop transitions, and clear stage views, also stop
transitions for the grand children. Detached children don't have a way
to continue animating anyway, since they have no stage view (thus frame
clock) to be driven by.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2716>
2022-11-25 10:26:52 +00:00
Jonas Dreßler
61cc31c3ce clutter/actor: Show on all stage-views when actors have no allocation
When a badly behaving ClutterActor implementation manages to invalidate
the allocation after the layout phase and before painting, we have no
idea where the actor should be painted without running the whole layout
machinery again.

For paint volumes in this case we pretend the actor covers the whole
stage and queue full-stage redraws. When updating stage-views, we're
also handling this case, but not in the most graceful way. Just like
with paint volumes, we should assume an actor without a valid allocation
is simply everywhere, so set priv->stage_views to all available stage
views in that case.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6054
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2694>
2022-11-25 10:06:14 +00:00
Jonas Dreßler
fe01e423a3 clutter/stage: Always queue events in _clutter_stage_queue_event()
We've been sending all events to clients immediately for quite some time
now, so this is only really impacting the Clutter scene graph, not
clients anymore.

That makes this behavior a somewhat unnecessary optimization (it was
useful at the time it was added, but it's not anymore), which will only
make our lives harder when we actually expect an event to be queued
(eg. in tests), so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2697>
2022-11-22 20:31:42 +00:00
Bilal Elmoussaoui
bb5af3a6bd g-i: Drop unneeded since/stability annotations
They are no longer useful since the merge of cogl inside mutter

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2708>
2022-11-22 13:32:52 +01:00
Jonas Dreßler
4fa1dab918 clutter/main: Refactor to remove devices in a single place
As suggested by Carlos in a review of this MR, refactor the logic of
clutter_do_event() to have both adding and removing of devices from the
devices list in a single place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
2022-11-21 16:51:00 +00:00
Jonas Dreßler
edc226a04d clutter: Process device removing events immediately when they come in
Having the stage device list be responsible for delivering the
same events twice (first immediately to clients, then later to Clutter)
was expected to be tricky, a sneaky problem with it right now is the
following case:

While collecting events for a stage update cycle, we get three touch
events from the backend: TOUCH_BEGIN(seq=1) -> TOUCH_END(seq=1) ->
TOUCH_BEGIN(seq=1)

What we do right now when we see a TOUCH_BEGIN event is adding a device
to the stage right when it comes in from the backend. And when we see
a TOUCH_END, we remove the device from the stage not immediately but
only after it went through the queue.

In the case of the three events mentioned above, with the current
behavior, this will happen when they come in from the backend:

- TOUCH_BEGIN(seq=1): device gets added to the stage with seq 1, event
 gets queued
- TOUCH_END(seq=1): Nothing happens, event gets queued
- TOUCH_BEGIN(seq=1): we try to add device to the stage, but seq 1 is
 already there, event gets queued

Now when we go through the queue and see the TOUCH_END, the device with
seq 1 gets removed, but on the subsequent TOUCH_BEGIN, we won't add a
new device, so this event (and all events with seq=1 that are still in
the queue) is now ignored by Clutter because it has no device.

What we want to do here is to cut short once the TOUCH_END event comes
in: Process queued events immediately and make sure the device is
removed from the stage list before a new device can be added. Same goes
for any other events that will lead to devices getting removed.

Small note: Since this leads to clutter_stage_get_device_actor()
returning NULL, I was wondering why we never crash because of this:
Turns out _clutter_actor_handle_event() handles self = NULL just fine
without crashing...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
2022-11-21 16:51:00 +00:00
Jonas Dreßler
874a5a6d58 clutter: Also handle DEVICE_REMOVED events filtered out by event filter
With commit 6c17aa66c6 we made sure no
stale device entries might land in the stage device list. The same can
happen for pointer devices too in theory, in practice we never really
filter them out, but it's good to handle them here anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
2022-11-21 16:51:00 +00:00
Jonas Dreßler
2d85e84136 clutter: Move check for device type into remove_device_for_event()
We'll call this function from a few more places for the
CLUTTER_DEVICE_REMOVED case, so move the check for which devices are
valid into the function itself to avoid having to check everywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
2022-11-21 16:51:00 +00:00
Carlos Garnacho
c28ab9a5c1 clutter: Add clutter_input_device_get_dimensions()
This will be used to know the size of touchscreens and tablets
by poking the backends about it. This is intended to replace code
using udev nowadays.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
3ca78fa44a clutter: Add capability flags for trackpoints and trackballs
The detection of these devices is nowadays scattered around using
udev. Add these capabilities so that we can move this detection to
seats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Jonas Dreßler
c40feb33fa clutter/actor: Remove outdated comment
Updating of the paint volume used for culling these days happens
during the finish-layout stage, not while painting. Also we have
geometry-based, not paint-based picking anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
0aba87308a clutter/actor: Clarify things about the last painted paint volume a bit
Rename the `last_paint_volume` to `visible_paint_volume`: That avoids
confusion with the `had_effects_on_last_paint_volume_update` flag and
also makes it clear that this paint volume is the currently visible one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
675321a2e5 clutter/actor: Rename paint_volume_valid to has_paint_volume for clarity
Rename the paint_volume_valid flag to has_paint_volume in order to
better reflect what it's for.

The name "paint_volume_valid" implies that the paint volume can be
invalidated and thus sounds like it's involved with some kind of
caching. The flag that's actually involved with caching is
"needs_paint_volume_update", while "paint_volume_valid" is only meant to
store whether the actor has a paint volume to work with.

So rename paint_volume_valid to has_paint_volume to avoid confusion
about which flag is used for caching.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
66d8f51da1 clutter/actor: Refactor updating of the paint volume
For clarity and for further improvements, introduce a separate function
to update the paint volume instead of doing that inside
_clutter_actor_get_paint_volume_mutable().

Also add a FIXME comment for a possible bug I noticed while working on
it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
2541979f8e clutter/text: Replace cached paint volume with the one cached by actor
Since ClutterActor now properly caches its paint volume and ClutterText
tries hard to invalidate its own cached paint volume on every redraw
anyway (that's more often than ClutterActor invalidates its own paint
volume), we can simply rely on the caching of the paint volume done by
ClutterActor and invalidate that on every redraw.

So remove the private cached paint volume from ClutterText and all its
invalidation machinery.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
830561405c clutter/actor: Clean up real_get_paint_volume() a bit
We can get rid of an indentation level and the "ret" variable here and
instead simply early-return when we need to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
93ba039b90 clutter/paint-volume: Mark a paint volume argument as const
The function _clutter_paint_volume_get_stage_paint_box() actually
doesn't modify the paint volume that's passed to it, so make that a bit
more clear by passing a const paint volume as the argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
692a8a4d93 clutter/actor: Remove get_default_paint_volume() API
These days it's possible to chain up into the default get_paint_volume()
implementation again, which renders
clutter_actor_get_default_paint_volume() unnecessary. So remove that
function and move clutter_actor_update_default_paint_volume() back into
real_get_paint_volume() where it belongs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1492>
2022-11-04 18:47:27 +00:00
Jonas Dreßler
7e7a639cc5 clutter/actor: Avoid some stage view updates
We traverse the whole screnegraph anyway these days in finish_layout(),
so no need for the whole "set the flag on parents even though we don't
need it" dance anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2667>
2022-10-18 18:43:36 +00:00
Carlos Garnacho
714f01048e clutter: Demote the new clutter_stage_grab() precondition check
There do indeed seem to be places in our own code that trigger grabs on
actors before they are realized. It was not the intention to change the
practical preconditions for GNOME 43, so make it an even lower minimum
that every caller ought to match: That the actor is attached to the stage.

Further constraining of these preconditions will have to wait until
branching for new development.

Fixes: 9c79c7234 (clutter: Only allow grabs to be created on realized actors)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2670>
2022-10-18 17:57:42 +02:00
Carlos Garnacho
9c79c72341 clutter: Only allow grabs to be created on realized actors
The bare minimum that we can ask to an actor before creating a grab
on it is that it is realized (and thus, attached to the stage). Bail
out if that is not the case when creating a grab.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2669>
2022-10-18 12:16:37 +02:00
Carlos Garnacho
e3df7b3384 clutter: Undo actor grabs along with ::unrealize
If an actor is being unrealized or otherwise unparented, it's a good
indication that its grabs are now stale and possibly harmful. Ensure
these are dropped when the actor is unparented.

This is now an unlikely event, since there is code to also dismiss
grabs when a visible grabbed actor goes unmapped. But that may be
prevented from happening, or the ordering of circumstances allow a
grab to be created and an actor destroyed without going unmapped
first. This grab dismission on unmap stays as it matches the UI-level
expectatives that an actor must be visible to be grabbed.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2475
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2669>
2022-10-18 12:16:22 +02:00
Robert Mader
07ec482e28 clutter/actor: Do not report hidden actors as present on stage view
The stage view list does not get updated when an actor gets hidden in
order to avoid unnecessary work, such as scale changes. However, we
still want `is_effectively_on_stage_view` to report `FALSE` in this
case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2662>
2022-10-15 21:45:10 +02:00
Florian Müllner
62fd18030f clutter/text: Add missing property getter/setter
The :input-purpose and :input-hints properties were added without
actually handling the get/set operations, whoops.

All code uses the (working) methods, so this only fixes expectations,
not an actual bug :-)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2659>
2022-10-14 13:21:38 +02:00
Jonas Ådahl
85ef0d1a46 compositor-view/native: Check that the actor covers the the view
If we have a window that match the size (i.e. will pass the "fits
framebuffer" low level check), that doesn't mean it matches the
position. For example, if we have two monitors 2K monitors, with two 2K
sized windows, one on monitor A, and one on monitor both monitor A and
B, overlapping both, if the latter window is above the former, it'll end
up bing scanned out on both if it ends up fitting all the other
requirements.

Fix this by checking that the paint box matches the stage view layout,
as that makes sure the actor we're painting isn't just partially on the
right view.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2387
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2624>
2022-09-20 18:47:06 +00:00
Ivan Molodetskikh
7972594d26 clutter/frame-clock: Fix dispatch lateness trace text
It was unfortunately broken by a variable overwrite in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2630>
2022-09-20 18:18:25 +00:00
Dor Askayo
01846ffd91 clutter/frame-clock: Simplify early presented event handling
A few calculations and assignments are done unnecessarily when the
last next presentation time is invalid. This increases the cognitive
complexity of the function for no reason.

No change in behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2486>
2022-09-02 13:54:30 +00:00
Robert Mader
b071a8366d clutter/stage-view: Add API to check if a shadowfb is used
As a more readable alternative to checking GObject properties.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Jonas Dreßler
8ad4056aa2 clutter/click-action: Don't stop release events if gesture is inactive
I don't see how this makes sense at all, ClutterClickAction really
shouldn't mess with BUTTON_RELEASE events that are not part of a
gesture.

So propagate those events instead of stopping them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2552>
2022-08-25 00:28:41 +00:00
Jonas Dreßler
4fce0b974b clutter: Add source field to crossing events
The source field was removed from ClutterEvent with commit
b644ea1bce because the preferred way of
getting the event actor is now to use the device/sequence actor from the
stage directly.

With crossing events it's not that easy though, as crossing events
explicitly have a source and related actor that doesn't have to be the
same actor as the device actor. Since we kept around the "related" field
there anyway, let's also introduce a "source" field in
ClutterCrossingEvent and return that actor when get_source() is called
on a crossing event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2551>
2022-08-24 22:43:54 +00:00
Jonas Dreßler
e5784bf885 clutter/actor: Add detail to ::event signal
Just like we did with the ::captured-event signal, add detail to the
::event signal too. At the first glance this might not seem necessary
since there are individual signals like scroll-event or touch-event that
get emitted at the same time, but these don't exist for touchpad gesture
events and others.

As an easy solution for that, just make it possible to use detail on the
event signal as we did with the caputured-event signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2431>
2022-08-24 22:19:15 +00:00
Dor Askayo
b4fff403b8 clutter/frame-clock: Ignore missing presentation timestamps
In some hardware configurations, presentation timestamps could be
missing from some page flip events, leading to a temporary loss of
vblank synchronization.

This occurs at least with AMD GPUs for atomic commits that only update
the cursor plane. [0]

In those cases, it's better to calculate the next update time
according to the last valid presentation timestamp instead of relying
on the dispatch lateness.

[0] https://gitlab.freedesktop.org/drm/amd/-/issues/2030

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2481>
2022-08-10 14:01:40 +00:00
Corentin Noël
8fcee7a8a5 clutter/stage: Add nullable annotation to get_*_actor methods
Allows to know when a NULL ClutterActor is possibly being returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2559>
2022-08-10 10:47:51 +00:00
Robert Mader
550f09a5e7 clutter/stage-view: Defer and accumulate redraw-clip on scanout
When taking the scanout path we still want to clear the
redraw-clip from the stage-view in order to ensure we skip
frames in `handle_frame_clock_frame()` if no new redraw-clip
was recorded.
This was not done previously as the accumulated redraw-clip was
needed for the next repaint, likely under the assumption that
scheduling a scanout repeatedly would be computationally cost-free.
This assumption does not hold in a VRR world.

In order to archive both, an accumulated redraw-clip for the next
paint and frame-skipping during scanout, introduce new API to defer
and accumulate redraw-clips until the next repaint.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2480>
2022-08-02 12:54:18 +02:00
Bilal Elmoussaoui
a73ae93d59 clutter: Remove all the since annotations
Since they are all refer to the days clutter used to be a separate
library

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2441>
2022-08-02 09:52:22 +02:00
Bilal Elmoussaoui
7b7e1c6fbd cally: Migrate to gi-docgen
Similar to the clutter commits
- Drop all the private structs documentations
- Make use of gi-docgen items linking as much as possible
- Use markdown formatting for code snippets

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2441>
2022-08-02 09:52:22 +02:00
Bilal Elmoussaoui
c8e63866f0 clutter: Migrate to gi-docgen
- Drop all the private structs documentations
- Make use of gi-docgen items linking as much as possible
- Use markdown formatting for code snippets

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2441>
2022-08-02 09:52:22 +02:00
Michel Dänzer
1f7527bbc4 clutter/frame-clock: Fix handling of equal next_presentation_time_us
This can happen with the native backend if the previous frame clock
dispatch didn't result in any KMS update, e.g. because it was triggered
by an input event, but the HW cursor didn't need updating on the stage
view. (This is likely to happen on some out of multiple stage views,
but might be possible even with a single stage view if the cursor isn't
visible)

We would previously delay next_presentation_time_us by one refresh
interval in this case, which could result in spuriously leaving one
refresh cycle unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2498>
2022-07-31 18:27:11 +00:00
Jonas Dreßler
f4416fa662 clutter/actor: Make has_pointer a counter instead of a bool
Somewhat long overdue... We've been supporting more than a single
pointer for quite a long time now, let's make sure things don't break if
two pointer devices enter the same ClutterActor: Count the number of
pointers an actor has instead of using a simple boolean value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2348>
2022-07-27 08:57:07 +00:00
Robert Mader
fad070eb40 clutter/actor: Fix indentation in add_child_internal()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2530>
2022-07-26 21:55:33 +00:00
Robert Mader
8d04b9067d clutter/actor: Queue relayouts in more clone cases
In certain edge cases it's currently possible that an actor never
gets a valid allocation and paint volume.

One such case is adding an unmapped, hidden child to an unmapped
cloned parent and then showing the child. This happens currently
 e.g. if a Wayland subsurface is added to a already mapped window
while the user is in the overview.

Ensure relayouts in two more such cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2530>
2022-07-26 21:55:33 +00:00
Robert Mader
e7a64db51a clutter/actor: Check for clones in update_default_paint_volume()
This does not fix any known bug but should help ensuring correctness
when clones are used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2530>
2022-07-26 21:55:33 +00:00
Robert Mader
b64d699709 clutter/actor: Check for clones in finish_layout()
This does not fix any known bug but should help ensuring correctness
when clones are used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2530>
2022-07-26 21:55:33 +00:00
Robert Mader
01b96d6674 clutter/actor: Remove workaround for broken clients
It's not needed in the private copy and can be quite confusing during
debugging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2530>
2022-07-26 21:55:33 +00:00
Carlos Garnacho
550b66d4e6 clutter/actor: Handle repicks when actors become reactive
The notification list in the GNOME Shell calendar popup triggers some
interesting interactions when closing a notification:

- Close button is clicked
- The notification animates to be hidden
- The next notification ends up hovered as a result of the animation
- The notification being hovered sets its close button as non-transparent
  and reactive
- The pointer is now again over a close button

At this point the reactiveness change should trigger a repick, so that
the new notification's close button is picked, and future button presses
are directed to it, but we do not handle this situation.

To fix this, handle actors becoming reactive so that if the closest
reactive parent has a pointer, it will be repicked again just in case
the pointer is over the newly reactive actor.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2364
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2532>
2022-07-26 14:18:13 +00:00
Carlos Garnacho
6dabdec10e clutter/stage: Add function to maybe invalidate pointers on an actor
The function that currently invalidates pointers over an specific actor
also asserts for the situations where this invalidation makes sense to
happen (i.e. the actor became unmapped, or non-reactive).

We want to have a function that is more forgiving, and that doesn't
enforce any guarantees about the pointer focus actually changing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2532>
2022-07-26 14:18:13 +00:00
Carlos Garnacho
f685567afe clutter: Let ClutterInputMethods pass the anchor position for preedit text
This is an API break, since users (i.e. GNOME Shell) provide the input method
implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2517>
2022-07-19 11:04:56 +00:00
Carlos Garnacho
ffac294520 clutter: Pass anchor position to ClutterInputFocus
Some implementations may need this (namely, the one that drives
the Wayland protocol), so pass this along from the IM events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2517>
2022-07-19 11:04:56 +00:00
Carlos Garnacho
190301f66b clutter: Make ClutterIMEvent able to store preedit anchor position
This is something that is exported through the protocol, but we don't
pass forward. Make the events able to store this anchor so that we
can do that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2517>
2022-07-19 11:04:56 +00:00
Daniel van Vugt
3d94c7cc2d clutter/actor: Do clutter_actor_destroy_all_children without an iterator
`clutter_actor_iter_destroy` will try to match up the iterator's `age`
with that of the parent ("root") actor:

```
g_return_if_fail (ri->age == ri->root->priv->age);
```

In a simple actor graph that's completely reasonable but somewhere in the
more complex graph of gnome-shell the parent's `age` was skipping ahead
faster than that of the iterator. This could happen in theory if the
destroy indirectly leads to more children being destroyed than the
iterator has visited.

So there's no evidence of actual corruption, only the age check might
fail in a `clutter_actor_iter_destroy` loop because the age check itself
can't handle all possible valid scenarios.

Since our only mandate is to destroy all children, we can do that reliably
without an iterator and thus without assuming anything about the parent's
`age` counter.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4747
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2074>
2022-07-18 17:13:01 +08:00
Daniel van Vugt
4a70a73e42 clutter/actor: Deduplicate child destruction loop
It's identical in clutter_actor_real_destroy and
clutter_actor_destroy_all_children, other than the latter having
some extra error checking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2074>
2022-07-18 17:13:01 +08:00
Florian Müllner
d2c4616242 clutter/fixed-layout: Ignore hidden children in size request
Hidden actors aren't only invisible, they should also not take
up any size.

Found in the context of
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2347

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2488>
2022-07-06 18:57:12 +00:00
Naveen Kumar
12c02b3f1a clutter: Attach color state information to actors
ClutterColorState, that is a GObject. each ClutterActor would own
such an object, and it'd be set via a GObject property.
It would have an API to get the colorspace, whether the actor
content is in pq or not, and things like that.
if it is NULL, it will default to color state with sRGB colorspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2443>
2022-06-09 15:00:07 +00:00
Jonas Ådahl
9a68fb19e4 clutter: Remove 'features'
There are no 'features' left, the last one, GLSL shader support, was
moved to Cogl.

This also move the Cogl context creation to a more sensible place, as it
was hidden away in the feature initialization.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2015>
2022-06-03 12:57:31 +00:00
Jonas Ådahl
74230038c9 Remove checks for GLSL
The Cogl feature was removed a while back, while Clutter just hard coded
it to TRUE. Lets remove the confusion that GLSL isn't supported and just
remove the (dead) fallback paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2015>
2022-06-03 12:57:31 +00:00
Jonas Ådahl
e7a8173f3a frame-clock: Fix constant type of condition
To avoid confusion, change the int to a float, since we're comparing
with a float.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2434>
2022-06-02 17:19:42 +00:00
Georges Basile Stavracas Neto
a2c999b6b1 clutter/image: Port to G_DECLARE_DERIVABLE_TYPE
Cleanup all the boilerplate, and port the function to use the auto
generated private helper. Remove the manual autocleanup declaration
since this is now done in the clutter-image.h header.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:28:13 -03:00
Georges Basile Stavracas Neto
ca19109ac6 clutter/image: Drop ClutterImageError
Error can be delegated to Cogl now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:27:20 -03:00
Georges Basile Stavracas Neto
f1ac534cd2 clutter/image: Port to cogl_texture_2d_new_from_data
Stop using cogl_texture_new_from_data() in favour of the undeprecated
cogl_texture_2d_new_from_data().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:27:16 -03:00
Georges Basile Stavracas Neto
f25360677f clutter/canvas: Use cogl_texture_2d_new_from_bitmap
cogl_texture_new_from_bitmap() is deprecated. Since this was the
last usage of it, also drop cogl_texture_new_from_bitmap().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Simon Schneegans
b9a5f9a373 backend: Make get_cogl_context introspectable
To be able to use the Snippet API from GJS properly,
this method is required in many cases.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2280
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2422>
2022-05-31 11:38:20 +00:00
Bilal Elmoussaoui
a81b2a49ed meson: Split x11 option into backend/xwayland
Allow disabling either the xwayland or backend implementation of x11.
Meson options were not added as this is more of a groundwork than the
actual implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2354>
2022-05-25 16:42:04 +02:00
Jonas Dreßler
3d3c88f960 clutter: Don't log filenames in debugging mode
A slightly annoying "feature" of Clutters debug messages is that it also
logs the filename and line of the current debug message. If you don't
have an ultrawide monitor, this can be very annoying and cause lots of
linebreaks in the debug logs.

So remove that debugging feature and no longer log the filename and
line number with debugging messages.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2378>
2022-05-04 19:36:46 +00:00
Jonas Ådahl
cecf4cd87c stage: Add 'prepare-frame' signal
This is a signal that will be emitted between the 'before-update' and
'before-paint'. It can be used to handle things when you know whether
there is an update, and you know whether a paint or not will happen, by
looking at the current damage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2393>
2022-04-29 20:51:25 +00:00
Jonas Ådahl
36de8baf55 display: Get the backend from the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Corentin Noël
7d3ff66724 clutter/stage: Remove unused nullable annotation
This annotation wasn't taken into account because of the colon, but shouldn't
be applied as there is no way a NULL ClutterGrab can be returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2382>
2022-04-29 08:25:31 +00:00
Jonas Dreßler
6c8e8fbba4 clutter/actor-meta: Notify actor property on changes
Seems like this was forgotten when writing the class. While at it, add
EXPLICIT_NOTIFY to the property flags.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2377>
2022-04-24 12:24:01 +00:00
Jonas Dreßler
6c17aa66c6 clutter: Remove device/sequence entry when TOUCH_END get filtered out
Mutters event filter can prevent events from getting processed by
Clutter, this can also happen for TOUCH_END/CANCEL events. Processing
these events in Clutter is crucial for proper tracking of touch
sequences though, that's because Clutter adds a PointerDeviceEntry to
the stage on a TOUCH_BEGIN *before* going through the event filter, but
removes that entry on a TOUCH_END *after* going through the filter. So
Clutter really needs to see those TOUCH_END events, or else there will
be a stale PointerDeviceEntry on the ClutterStage.

Make sure those TOUCH_END/CANCEL events always get seen by Clutter by
removing the device entry immediately when those get filtered out.

Because there might still be events belonging to this sequence in the
event queue of the stage, we need to flush the queue before removing the
entry, too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2350>
2022-04-23 18:53:33 +00:00
Carlos Garnacho
cd0c47a25a clutter: Shuffle handling of IM reset on button presses
Unfortunately we cannot do this generically since the target of the
button/touch press does matter, e.g. tapping on the OSK, or clicking
the IBus candidates window. These situations should not trigger a
reset.

So be more selective about the situations where button/touch presses
trigger an IM reset, in the case of ClutterText these are still clicks
inside the actor, for Wayland's text-input it is when clicking the
surface that has text_input focus.

For all other situations where clicking anywhere else might make
sense to trigger an IM reset are covered by the focus changing paths,
that also ensure a reset before changing focus between surfaces/actors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1961
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
b4952c1199 clutter: Reset ClutterInputFocus on focus_out
Focus changes should trigger an IM reset, as some engines do want
to maybe commit the preedit buffer before changing focus. Since
the preedit string is also cleared on reset(), we can do without
that explicit call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
a9a890164a clutter: Actively update ClutterText surrounding text on changes
Right now we have a bit of a mixed bag between an active model where
input foci set the surrounding text without being asked for (e.g.
wayland's text_input), and a passive model where the IM engines ask
for content.

Make ClutterText take the same side than text_input, so that dealing
with those is at least consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
b4cdf5e098 clutter: Fix ClutterText ::delete-surrounding IM implementation
The clutter_text_delete_text() function used underneath expects character
offsets for both start/end position. Fix the end position passed an offset
instead of that, and compesnate for the cursor position being always -1
when the caret is at the end of the string.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Jonas Dreßler
cfdca246f2 clutter/stage: Repick when pointer actor goes unmapped
I've overseen quite an important case in commit
98a5cb37d9: Repicking only when actors get
destroyed is not enough, we actually need to repick when actors go
hidden/unmapped.

While we could also listen to notify::mapped just like we listen to
notify::reactive, it seems better to avoid using property notifications
here due to the usage of g_object_freeze/thaw_notify() in ClutterActor.
It can lead to the stage receiving a notify::mapped with mapped = true
for a pointer actor, which really shouldn't happen (just like
notify::reactive with reactive = true shouldn't happen).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5124
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2333>
2022-04-22 15:54:03 +00:00
Jonas Dreßler
6e458f9462 clutter: Pass events to pointer a11y before going through filters
We want all pointer events to be passed through the pointer a11y
processing before going through event filters: Once we go through event
filters, events might be dispatched to Wayland and get filtered out.

With the changes to immediately dispatch events to wayland, this changed
and the pointer a11y is now no longer seeing any events going to wayland
clients. Fix it by shuffling things around a bit and letting pointer
a11y take a peek at events earlier.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5192
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2332>
2022-04-21 12:50:52 +02:00
Jonas Dreßler
c64803770e clutter: Bail out and warn on reentry into mapping/unmapping cycle
There's a bunch of crashes right now where the assertions in
clutter_actor_set_mapped() after calling the map/unmap() vfuncs are
failing. The only way this can happen is by re-entering
clutter_actor_set_mapped() during the map/unmap recursion.

The reason for those crashes is that the shell hides/shows some actors
in response to crossing events and key-focus changes. These in turn get
triggered by the newly introduced ungrabbing of ClutterGrabs when an
actor gets unmapped, which triggers GRAB_NOTIFY crossing events and
key-focus changes.

Since these situations are hardly avoidable (it's a valid use-case to
hide/show something in response to a crossing/key-focus event), catch
the set_mapped() call early while we reenter the mapping machinery and
log a warning instead of crashing.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3165
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2299>
2022-04-21 10:09:59 +00:00
Jonas Dreßler
4a865424cd clutter: Set event as current_event when going through event filters
With the introduction of untrottled event delivery to wayland clients,
we moved the _clutter_event_process_filters() call outside of
_clutter_process_event(). This also moved the processing of event
filters outside of the timespan where the event is added to Clutters
current_event stack, making Clutter.get_current_event() no longer
available to anything happening inside mutters event filter.

One thing that happens in mutters event filter is detecting and
triggering keybindings like the alt-tab switcher. Now the alt-tab
switcher has a special case where it finishes and activates a window
right when the keybinding gets activated, relying on the current event
time as the timestamp to activate the window.

Now since the current event time is no longer available from inside
mutters event filter, we'd pass 0 to meta_window_activate(), causing
mutter to send a notification instead of actually activating the window.

To fix this, also set a current_event for the ClutterContext when going
through event filters, this makes sure Clutter.get_current_event_time()
works when called inside keybinding handlers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2327>
2022-04-21 09:45:21 +00:00
Carlos Garnacho
f820bb3506 clutter: Keep actors dirty if a redraw was queued up during paint()
In the right combination of circumstances, and given 2 actors (parent
actor P with an offscreen effect and child actor C), we may have the
following situation happening:

- A redraw is queued on the actor C, actors C and P are marked as
  priv->is_dirty and priv->propagated_one_redraw.
- During paint() handling we paint actor P, priv->propagated_one_redraw
  is turned off.
- We recurse into child actor C, priv->propagated_one_redraw is turned
  off.
- A new redraw is queued on actor C, actors C and P are marked as
  priv->is_dirty and priv->propagated_one_redraw.
- The paint() method recurses back, actors C and P get priv->is_dirty
  disabled, priv->propagated_one_redraw remains set.
- At this point queueing up more redraws on actor C will not propagate
  up, because actor C has priv->propagated_one_redraw set, but the
  parent actor P has priv->is_dirty unset, so the offscreen effect will
  not get CLUTTER_EFFECT_PAINT_ACTOR_DIRTY and will avoid repainting
  actor C.

The end result is that actor C does not redraw again, despite requesting
redraws. This situation eventually resolves itself through e.g. relayouts
on actor P, but may take some time to happen.

In order to fix this, consider actors that did get a further redraw
request still dirty after paint().

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2188
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2353>
2022-03-31 12:39:17 +00:00
Carlos Garnacho
ce7f606d48 clutter: Refactor code marking actors dirty for paint()
Simplify the function arguments (the origin is just the actor that
the function is originally called from), and make it also handle
marking as dirty the actor that got the redraw queued up explicitly.

This makes it a single place where priv->is_dirty is being enabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2353>
2022-03-31 12:39:17 +00:00
Carlos Garnacho
1fda60f03e clutter: Add compatibility code to get input capabilities from device type
We not just have X11 devices, but also virtual devices on both backends.
In the mean time, keep these working on top of a ClutterInputDeviceType,
but transform that into capabilities on device construction so users can
rely on the new flagset.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
15d4402d08 clutter: Add ClutterInputDevice::capabilities property
This is construct-only, and assigned by the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
ff6f83f05e clutter: Add ClutterInputCapabilities flagset
This will be a truer representation of input devices in the native
backend, since a single device can have multiple capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Daniel van Vugt
b2805dd5a6 clutter/pick-stack: Avoid uninitialized cairo_region_subtract_rectangle
This fixes instances of:
```
*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug
```
seen when navigating the overview and launching apps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2349>
2022-03-29 18:13:11 +08:00
Carlos Garnacho
58bcd30ee6 clutter: Always unregister point on GRAB_NOTIFY leave event
The ClutterGestureAction base code would correctly try to cancel a
gesture if it would receive GRAB_NOTIFY leave events (that would indicate
other portions of the actor tree stole input away from the gesture actor),
but it would mistakenly do so only if the gesture was already initiated,
possibly leaving stale point information if the gesture collected input
but didn't initiate yet.

This could be indirectly seen clicking with the mouse on OSK keys with
no motions in between, clicks would accumulate on the swipeTracker
gestures until the trigger point, so the third click could drag the
workspaces.

We do always want to unregister the related device/sequence here, do that
while still cancelling any already initiated gesture.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1907
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4987
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2334>
2022-03-28 17:11:02 +00:00
Jonas Dreßler
2aad56b949 clutter: Pass target actor of events to event filter functions
We'll need the additional context of which actor the event will be
emitted to in mutters event filter (see next commit), so pass that
target actor to the event filters that are installed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
2022-03-21 23:08:40 +00:00
Sebastian Keller
703d8a77f1 clutter: Mark clutter_stage_grab() return value as transfer full
The caller is expected to unref the returned grab and all C code already
does this, but grabs requested from js were resulting in the memory
getting leaked due to it being annotated as transfer none.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2189
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2345>
2022-03-21 21:25:28 +01:00
Jonas Dreßler
0fa64f15e3 clutter/base-types: Remove weird random unicode char
Have I discovered the hidden treasure that the evil wizard has buried
when he ruled the land of Clutter through its golden years?

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2298>
2022-03-05 09:51:44 +00:00
Jonas Ådahl
ab21bedcfc clutter/gesture-action: Fix a fallthrough warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
863a519f00 clutter/desaturate-effect: Use fabs() with passed double
Fixes a warning about passing a double to fabsf().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
ad76c60ce3 clutter/click-action: Fix a couple of fall-through warnings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Carlos Garnacho
e736b04deb clutter: Remove "source" event union fields
These are no longer used, drop the last places that modify those
in event structs and remove them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
2aeaeece7d clutter: Rewrite clutter_event_[gs]et_source()
It does not make sense that the event "source" (aka the target) is
both content and recipient of a message. Not doing so, events become
largely independent of the actor that is receiving/handling an
event. This is small step toward making events opaque and immutable.

Every user of these API calls in our code have ported away from
them, but other users may remain in extensions, so make these
functions work on top of the alternative API without accessing the
soon to be removed event field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
62bd0359a9 clutter: Add clutter_stage_get_event_actor() API call
This is a small helper to retrieve the actor that is currently
beneath the device/sequence, meant to replace clutter_event_get_source().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
b644ea1bce clutter: Do not set ClutterEvent source actor anymore
This is no longer used, and can be left unset here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
6182ceeef9 clutter: Peek target actor directly when managing events
The event source will be removed, move the clutter-main.c internals
from it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
a7f85c8fc4 cally: Get key focus from stage instead of event
Avoid usage of clutter_event_get_source(), and use the stage key
focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
64671e4916 clutter: Drop unpaired special handling of LEAVE event on stage
This is just "necessary" for --nested stages, since the pointer is
allowed to leave the stage in that case. Since the only side effect
is that there is still a pointer focus somewhere inside the stage,
simply drop this.

This is a small leftover of commit b8f92a6ce4, since we stopped
handling the double ENTER event there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
fd0e7ed2f3 clutter: Move away from clutter_event_get_source() in ClutterClickAction
Instead, ask the stage for the device actor, which is equivalent and
ensured to be up-to-date.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Ivan Molodetskikh
17bb0a3de4 clutter/frame-clock: Add lateness to dispatch trace
To diagnose when missed frames are caused by dispatch being delayed
rather than repaint scheduling producing the wrong dispatch time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:14:51 +03:00
Ivan Molodetskikh
986658ade9 clutter/frame-clock: Add ready profile trace
To see in Sysprof whenever it happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:10:05 +03:00
Ivan Molodetskikh
e10084199b clutter/frame-clock: Add presented profile trace
In addition to the presented callback time, it shows the time to the
reported presentation time (which can be earlier or later than the
presented callback), as well as the GPU rendering duration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:10:05 +03:00
Ivan Molodetskikh
bcf6ee5e55 Name unnamed sources
These names show up in GLib traces in sysprof, so let's make sure they
exist.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:10:05 +03:00
Jonas Dreßler
abecf557bf clutter/box-layout: Don't cast children sizes to integers
The distribute_natural_allocation() function was copied over from Gtk to
Clutter 11 years ago with commit e636a0bbce.
Gtk only supports integers sizes in its layout machinery, while Clutter
does everything using floats.

Since this function sets the minimum_size (the size we allocate the
children in the end) to an integer, this means we're implicitly
typecasting floats to integers here, effectively floor()'ing all sizes
that we allocate the box children.

A bug this caused in gnome-shell was that a scrollView (like the one in
the endSessionDialog) was showing scrollbars even though the content
perfectly fit inside the view: Say the content and its scrollView parent
request a size of 63.9 px, but get allocated a size of 63 px by a box
layout. Now the scrollView notices that its allocated size is smaller
than the requested size and thus shows a scrollbar.

So fix that and use floats in distribute_natural_allocation() instead of
integers, as we do everywhere else in the layout machinery.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2284>
2022-02-14 14:24:41 +00:00
Carlos Garnacho
13c77c55e8 clutter: Honor pick vmethod rectangle during region caching
We retrieve the picked actor's allocation for figuring out the pick
cache clear area, but don't take into account that the pick vmethod
might have returned a different area for it.

Make sure to honor that rectangle, as that is what is accounted as
the input region.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2135
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2283>
2022-02-12 13:27:00 +00:00
Carlos Garnacho
527cc51665 clutter: Refactor event emission into a common function
Without input device grabs in play, all functions that emit
pointer/key/crossing/touch events are pretty much the same. Remove this
duplication and use a common emit_event() function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
ac4face82a clutter: Remove input device grabs
Both device-global and input-sequence-local. These are no longer used,
in favor of ClutterGrab.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
d51469ea2a clutter: Move priv variable initialization after precondition checks
In case of misuse (e.g. passing NULL stage) this might result in crashes
before the precondition checks managed to kick in. Move this priv variable
initialization after these checks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
0e234d76f4 clutter: Use ClutterGrab for ClutterText implicit grab
This is used to temporarily redirect input to the entry, while
text is being selected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
3a79b7b066 clutter: Add docs and introspection annotations to grabs
Since we want these accessed from bindings this must be a boxed
type. This has the side effect of making ClutterGrab a refcounted
object, since we want to avoid JS from pointing to freed memory
and maybe causing crashes if misusing the object after dismiss.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
ff98cbb19f clutter: Fix CLUTTER_LEAVE handling of ClutterClickAction
Toggling the click action on when leaving the actor/action sounds weird,
this was presumably meant to toggle it off on leave, and back to in_held
on enter. This way, the CLUTTER_LEAVE handling also matches what we want
to do in case of grabs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
f22ea7399c clutter: Cancel ClutterGestureActions on leave+grab_notify events
The lack of handling of regular crossing events here is dubious, perhaps
to be fixed later on. So far, ensure gestures are cancelled whenever
a grab-inducted crossing event would leave this action in the blue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
c2d7e635b1 clutter: Drop clutter_stage_[gs]et_throttle_motion_events()
This setting stays at the default and is left untouched, drop this
external switch on event handling internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
db44279997 clutter: Drop undefined function declarations
These functions arent' there anymore, drop them from the header.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
6144244201 clutter: Drop clutter_stage_[gs]et_motion_events_enabled()
This is (luckily!) unused, and it's inconvenient to have a toggle to
break the input model we are striving towards. Drop this function
and stick to the default behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
4b0e998ab8 clutter: Key events should not be delivered to non reactive actors
Drop this piece of old code that assumes all actors want key events.
We currently have the reactive flag to indicate these want input.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Robert Mader
27cbf7b23d clutter/actor: Soften the check for guessed scale
In some use cases it's useful to have scaling below 100%. Right
now the assert here prevents doing that, so soften it to `0.5` -
likely about the lower limit what people would try (and what is
exposed by default on KDE).

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1465
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2263>
2022-01-28 23:33:30 +01:00
Carlos Garnacho
dbfde95c5c clutter: Do not check redraw area for pointer repicks
This looks like a relic of glReadPixels-based picking, the pointer
might well be outside redrawn areas, yet still require a device
update (e.g. in order to reflect the actor layout changes in the
"clear area" info).

Instead, always update all devices that are inside the view after
relayouts, the tracking on the need for that update is now done
on each ClutterStageView, instead of globally in the ClutterStage.

This theoretically fixes situations where pointers might miss
updating their "clear area" after the actor tree changed.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2117
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2257>
2022-01-27 11:08:24 +00:00
Jonas Ådahl
1930cc771d clutter/virtual-input-device: Add API to get seat
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
c0fb52cfe6 stage-impl: Move properties from the stage window here
The stage window is an interface, that added properties, that were only
then actually managed by MetaStageImpl. Shuffle things slightly, and let
the MetaStageImpl object deal with these things itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Carlos Garnacho
7bfc472ad3 clutter: Add specific event flag to tag "grab notify" crossing events
These events may need some differentiation or special handling, so add
this event flag and set it in the relevant events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
eb3075074a clutter: Integrate ClutterSeat grabs into ClutterGrab
As ClutterGrab is a stack, the backend only cares about some grab
existing currently or not. Make it sure that we grab whenever we
go to >=1 grabs, and ungrab whenever we go to <1.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
e9addb0ad7 clutter: Add ClutterSeat private API to grab devices
This will be necessary to string along ClutterGrab with backend
behavior, and mostly for the X11 backend so implement this pair
of vfuncs there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
1713f791cb clutter: Carry accounting of grabs in the ClutterActors holding them
And make it required that actors must be mapped to hold a grab. These
grabs will be automatically undone when the actor is unmapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00