1
0
Fork 0
Commit graph

8379 commits

Author SHA1 Message Date
Jonas Dreßler
540cdc0d93 clutter/stage: Don't set implicit_grab_cancelled to TRUE if there are none
The assertion for !implicit_grab_cancelled in the
`grab_actor == old_grab_actor` case of
clutter_stage_notify_grab_on_pointer_entry() is meant to do a simple
sanity-check to ensure the grab machinery is working as intended: During a
seat grab, all input gets delivered to the tree inside the grab, and all
implicit grabs outside of that tree are cancelled.

When a new seat grab on the same actor as the existing one happens, we run
through the cancellation machinery for implicit grabs anyway, so we might as
well check that the assumption mentioned above holds true: By asserting that
no implicit grabs were cancelled, we know that no implicit grabs exist
outside of the existing seat grab tree.

This assertion is slightly over-eager though due to the way we set
implicit_grab_cancelled: We initialize it to TRUE in the
entry->press_count > 0 case and then only set it to FALSE once we find an
implicit grab that may remain active. If there are no implicit grabs though
(while entry->press_count is still >0), we never set implicit_grab_cancelled
to FALSE, triggering the assertion in question even though no implicit grabs
got cancelled.

There's two possible solutions for this: Either dropping the assertion, or
refactoring it so it observes the situation where the implicit grabs were
already undone. This commit implements the latter.

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

Fixes: debbd88f8c ("clutter/stage: Cancel parts of implicit grabs when ClutterGrabs happen")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3216>
2023-09-03 10:15:46 +00:00
Jonas Dreßler
a243050bab clutter/stage: Fix an indentation mistake
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3216>
2023-09-03 10:15:46 +00:00
Daniel van Vugt
025e5d5327 Remove unused *.pc.in
It seems *.pc are instead now entirely generated from meson.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3226>
2023-08-31 09:47:50 +00:00
Daniel van Vugt
491e2875aa clutter: Mutter-clutter requires mutter-mtk
Because the public headers of the former reference the latter.

Fixes: 765a918a62
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6969
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3225>
2023-08-31 14:20:00 +08:00
Bilal Elmoussaoui
1abef24154 mtk: Move Rectangle.from_graphene_rect from Meta
And drop the clutter helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
152fdc89fc clutter: Drop _clutter_util_rectangle_offset
It is only used once so there is no need to port it to Mtk

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
a93471eb90 mtk: Move Rectangle.to_graphene_rect from Meta
Also drops the clutter equivalent

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
565acaed9c mtk: Move Rectangle.intersect from Meta
Also replaces it usage everywhere & remove the Clutter helper. Note the
tests were not moved yet to mtk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
6f66dd9944 mtk: Move Rectangle.union from Meta
Similar to Rectangle.equal. The clutter helper was not used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
9b2cba4e86 mtk: Move Rectangle.equal from Meta
Moves equal the equal function and removes the clutter equivalent. The
tests were not moved until all the remaining helper functions are moved.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
c1703337e4 clutter: Remove no longer needed cairo includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
06b5cb0761 clutter: Replace cairo_rectangle_int_t with MtkRectangle
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Sandro Bonazzola
ff4d87727b Update license access method
Dropped obsolete Free Software Foundation address pointing
to the FSF website instead as suggested by
https://www.gnu.org/licenses/gpl-howto.html
keeping intact the important part of the historical notice
as requested by the license.

Resolving rpmlint reported issue E: incorrect-fsf-address.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3155>
2023-08-30 08:48:23 +02:00
Bilal Elmoussaoui
b004d1c577 cleanup: Drop empty vfuncs overrides
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3209>
2023-08-29 23:38:32 +00:00
Carlos Garnacho
70a987f7e7 clutter: Do not trigger repick during relayout
This is at best pointless, since the relayout will change pointer
picking conditions, and buggy at worst, since the actor being
relayout is not at an state that it can be asked during picking.

This specifically fixes warnings like:

Can't update stage views actor <unnamed>[<Gjs_ui_workspacesView_WorkspacesDisplay>:0x5601dd557050] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_workspacesView_WorkspacesView>:0x5601edcf6aa0] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_workspace_Workspace>:0x5601ee163dc0] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_workspace_WorkspaceBackground>:0x5601ee1c85b0] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<ClutterActor>:0x5601ee4db280] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_windowPreview_WindowPreview>:0x5601ee1840c0] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_workspace_Workspace>:0x5601ebe1d1b0] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<Gjs_ui_workspace_WorkspaceBackground>:0x5601edbd3420] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<ClutterActor>:0x5601ee3cd630] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<StLabel>:0x5601ee685730] is on because it needs an allocation.
Can't update stage views actor <unnamed>[<ClutterText>:0x5601ed5b5f20] is on because it needs an allocation.

When trying to dismiss the overview with a 3fg touchpad gesture
while the pointer is over a window clone.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6935
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3220>
2023-08-28 20:07:43 +00:00
Jonas Ådahl
b21294dcac clutter/actor: Add cloned/decloned signals
This are called when a clone directly attaches to an actor. While not
reliable to know whether a particular actor is cloned or not, one can at
least this way get notified about whether an actor in particular is
cloned.

This can be useful for e.g. the MetaWindowActor, as it's what's most
likely cloned, e.g. for alt-tab views etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:57 +00:00
Christian Hergert
150a9e35ad clutter: Add va_marshallers for stage signals
Adds va_marshallers to the ClutterStage signals. This allows for better
stack traces to be retrieved when profiling. Additionally, since the
generic marshaller was using GBoxedCopy/GBoxedFree functions for the
GValue usage, the previous code was acquiring a global reader/writer
lock in GObject via g_boxed_free() usage.

With G_SIGNAL_TYPE_STATIC_SCOPE, the generated marshallers can avoid
the additional copy/free on the instance.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3204>
2023-08-24 16:04:27 +00:00
Carlos Garnacho
7a4c98438a clutter: Ensure pick on CLUTTER_PROXIMITY_IN
Same reasoning holds than with touchpad gesture events in the
previous commit, this will be the first event seen from a specific
device and will require early handling, or crashes may follow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3198>
2023-08-22 09:15:35 +00:00
Carlos Garnacho
26c2633b2c clutter: Update device on touchpad gesture events
With commit be3bca01a7 in place, we now possibly skip early calls
to clutter_stage_repick_device() happening early during initialization.
These were also indirectly the ones that eventually ended up in
the first call to clutter_stage_pick_and_update_device() actually
initializing the PointerDeviceEntry.

With this no longer happening, we may end up with no PointerDeviceEntry
implicitly set up after initialization, which may fail if the first
event received from the seat pointer does not in fact trigger the
clutter_stage_pick_and_update_device() call necessary to make things
work from there on.

And this does indeed happen on touchpads, since the first input event
obtained after CLUTTER_DEVICE_ADDED is CLUTTER_TOUCHPAD_* instead
of CLUTTER_MOTION. This finds an unset PointerDeviceEntry and crashes
since the pointer device does still have no "presence" on the stage.

Fix this by making CLUTTER_TOUCHPAD_* events also trigger a
device update, so the fist event handled does always trigger the
necessary device update.

Fixes: be3bca01a7 ("clutter: Check that pointer has coordinates prior to repick")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2978
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3198>
2023-08-22 09:15:35 +00:00
Carlos Garnacho
13618014dd clutter: Regain full time precision in input-method generated events
Get the time in microseconds, instead of converting from milliseconds.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
2e3550320a clutter: Make all events contain int64_t microsecond precision times
Make this something common to all events, as opposed to just some motion
events. The clutter_event_get_time() function now converts to milliseconds
from this data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
09ade38002 clutter: Drop ClutterEventPrivate struct
This is no longer necessary to wrap the public event data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
5bea0d759f clutter: Move input devices to ClutterAnyEvent
This data is commonplace enough that it makes sense to keep it
as generic event data. Make these fields take a hard refcount, like
the private data used to do, and drop these fields from the
ClutterEventPrivate struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
7d90338d29 clutter: Move tool to specific event structs
Move this field out of ClutterEventPrivate, and into the specific
event structs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
c1fc359e76 clutter: Move scroll deltas from ClutterEventPrivate to scroll event
This can now be done without API/ABI concerns.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
7ab1a7111e clutter: Drop unused ClutterEventPrivate fields
These fields are now unused and may be removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
02e90f4358 clutter: Drop _clutter_event_get_platform_data()
This is not ever set, and unused in backends. This may be
safely removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Carlos Garnacho
7f7bcf1f5d clutter: Check ClutterEventFlags under clutter_event_is_pointer_emulated()
This function checks a field that is now never set. Make this function
useful again by checking CLUTTER_EVENT_FLAG_POINTER_EMULATED as these
events are now set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Georges Basile Stavracas Neto
fdc3f3fec3 cogl/renderer: Pass pixel format to DMA-BUF constructor
In future commits, we will want to create DMA-BUFs with pixel
formats other than COGL_PIXEL_FORMAT_BGRX_8888. In preparation
for that, let's start passing a new pixel format parameter to
this function, and the corresponding winsys vfunc.

All callers of this function pass COGL_PIXEL_FORMAT_BGRX_8888
for now. Next commits will change that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Jonas Ådahl
03ee48094e clutter/stage: Add is-grabbed property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Carlos Garnacho
be3bca01a7 clutter: Check that pointer has coordinates prior to repick
This might fail during initialization, or after first pointer
interaction on a pointer-less (e.g. touch-only) session.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2964
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3183>
2023-08-15 22:46:08 +00:00
Carlos Garnacho
88af55b857 clutter: Add boolean return value to clutter_stage_get_device_coords()
The device/sequence may not currently have a set of coordinates to return.
We correctly leave the out values uninitialized, but don't tell the upper
layers in any way.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3183>
2023-08-15 22:46:08 +00:00
Bilal Elmoussaoui
cd27cb5c85 cleanup: Fix various typos
Using the typos cli app

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3169>
2023-08-12 20:13:37 +00:00
Bilal Elmoussaoui
f2f9e63568 build/gi: Set header & pkgconfig names
So that the docs generated by gi-docgen contains them

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3087>
2023-08-12 19:34:20 +00:00
Carlos Garnacho
4d76a21029 clutter: Trigger repick on animation-less transform changes
We have a mechanism to trigger repick after animations on
clutter_actor_set_final_state(), but this will not happen if
animations are disabled.

In this case, shell transitions and other typically animatable
changes on the transform of actors will not naturally trigger
a pointer repick when those get instantly changed to the final
state, possibly preserving the cached state and missing the
just popped in actor altogether.

Trigger an instant repick on animation-less transform changes,
so that these situations are also handled correctly, and the
pointer drops the cached state and is able to find the new
actor.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2918
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3168>
2023-08-10 21:18:56 +00:00
Carlos Garnacho
d99407b2e8 clutter: Drop misguided assert
The clutter_seat_handle_event_post() function wants to handle
CLUTTER_DEVICE_ADDED/REMOVED to perform signal emission, but
checks (and asserts) that every event going through it has a
source device.

This is no longer quite true for IM events (they are attached
to the ClutterSeat's keyboard, not a HW device), so the assert
can now fire off (of course undesiredly).

But anyways, for events built through
clutter_event_device_notification_new() (the ones this function
is interested in, after all), it is already a precondition check
that the device is proper at the time of creating the event, so
asserting for it here is redundant.

We can drop this overly generic assert, this is already ensured
for the events that matter, anyways.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3167>
2023-08-09 14:40:58 +02:00
Carlos Garnacho
1d6d8d45d0 clutter: Update ClutterActorClass event vmethods to use ClutterEvent
With the ClutterEvent subtype structs sealed, this remains the only useful
struct type that is now usable on the Javascript side. Make all
ClutterActorClass event vmethods use ClutterEvent, and update all users
to this change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3163>
2023-08-09 11:53:18 +00:00
Carlos Garnacho
46cb355799 clutter: Make ClutterEvent structs private
All ClutterEvent users have been changed to use getter methods
instead of direct field access. We may now make the ClutterEvent
union/structs entirely opaque by moving the definitions out of
public headers.

All future usage of ClutterEvent data should be done through
getter methods.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
440c249031 clutter: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
1708becaea cally: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
ded1a9b351 clutter: Use brand new event to contain compressed motion information
Avoid overwriting ClutterEvent fields, and build a new ClutterEvent from
the previous information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
9dd2edac18 clutter: Add private call to describe an event
Move the string construction bits in the event logging happening in
MetaSeatImpl to a clutter_event_describe() call, so that it has more
freedom in fiddling with ClutterEvent internals, and may be potentially
reused in other places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
97213041e8 clutter: Add getters/arguments for missed ClutterEvent fields
Add methods, and change the API of some rarely used methods, in order
to make all event info currently held/necessary accessible through
ClutterEvent getters, instead of direct field access.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
fec26f201a clutter: Drop all ClutterEvent setter functions
All events are now created through the dedicated constructors,
thus no post-creation event fiddling should be necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
322b40ad39 clutter: Drop "state full" event getter and setter
The full decomposed modifier state is pretty much unused, relying
in keymap signals/properties to track latched modifiers state instead.
The events can be simplified without having this information, and if
it were ever needed in the future, it would be nicer that it had a
dedicated struct and didn't increase the number of arguments in
ClutterEvent constructors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
b809023f4d clutter: Create full event copy when handling unfiltered IM key events
We need to change at least event flags in the event we reinject after
it was let through by the IM, in order to avoid doubly handling.
Create a full event copy from the original event parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
c341bf5af9 clutter: Drop ClutterStage field from ClutterEvent
Avoid setting in ClutterEvents the stage they will end up
delivered through. This is now handled explicitly where it
matters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
845277f7fb clutter: Make clutter_event_get_source() only about crossing events
Avoid peeking in the stage for loosely related actors, since the same
event could be handled by different actors across the picking stack.

This getter is also unused, so there's wiggle room here for changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
36fda95217 clutter: Get stage in ClutterClickAction through actor
Avoid accessing the event for this information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
043ff8f98f cally: Avoid access to stage through ClutterEvent
Pass the stage explicitly, in order to avoid having to peek to it
through the event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
a8c62251f8 clutter: Port stage crossing events to new constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
6aa42d6dad clutter: Port ClutterInputMethod generated events to new constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:53 +02:00
Carlos Garnacho
a4639db847 clutter: Add new private set of event constructors
These constructors take all the necessary arguments to build the
event from the get go, so the callers are not left up with the task
of setting up the event struct data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:02 +02:00
Carlos Garnacho
d5938958c0 clutter: Drop ClutterBackend translate_event vmethod
Despite the attempt to make this a generic interface, this was
pretty much used only by the X11 backend, and now it ported away
from it.

This now stands unused and may be removed, in favor of backends
each creating and injecting events as they please.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
a08eea7f10 backends: Do not use clutter_event_[set|is]_pointer_emulated()
Add a new ClutterEventFlag to propagate this information, affecting
a few selected events on each backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
e648ef7980 clutter: Pass stage to emit_event()
Avoid poking at the event field, and use an explicit parameter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
b52aa487c8 clutter: Change _clutter_process_event name/signature
Avoid using the ClutterEvent stage field, and pass the stage
explicitly. Also rename to clutter_stage_process_event(), so that
its ownership/namespace is clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
2e3d55c948 clutter: Change clutter_do_event() name/signature
It is a bit backwards that events contain information about
the stage they are being handled by. It makes more sense to
specify in the ClutterEvent handling entrypoint the stage
that will handle the event.

As a first step, add this ClutterStage argument, even though
the information is still carried through the event in order to
keep satisfying calls to the getter function.

This entrypoint has been also renamed to clutter_stage_handle_event(),
so that its ownership/namespace is clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Bilal Elmoussaoui
a955f0e47c cleanup: Make include macro usages consistent
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
e0ed157e5d clutter: Remove empty private headers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
8008e365b3 clutter: Remove Settings::backend deprecated property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
68b4cc661d clutter: Remove deprecated & unnused enums
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
185058456f clutter: Remove deprecated BoxLayout pack-start property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
8d038789f6 clutter: Remove deprecated macros usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Daniel van Vugt
7c0caf5727 clutter/frame-clock: Limit jitter measurements to one frame interval (100%)
Measurements above 100% were originally allowed to show when frame skipping
was occurring so you didn't have to also check the frame rate. But that
also resulted in arbitrarily high jitter values being reported when
returning from idle. And those are frequent enough to look like a bug or
untrustworthy so let's not do that anymore.

Taking the remainder of a high jitter value is still a meaningful jitter
value.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2906
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3123>
2023-07-21 12:32:37 +00:00
Michel Dänzer
9c021b0bc2 clutter/frame-clock: Clamp recorded maxima to refresh interval
clutter_frame_clock_compute_max_render_time_us clamps to the refresh
interval anyway, so the only effect a higher recorded maximum can have
is to delay it falling below the refresh interval again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3090>
2023-07-20 22:34:58 +00:00
Michel Dänzer
69afa7a142 clutter/frame-clock: Use single pair of maxima for render time estimate
Instead of separate pairs of short- and long-term maxima for each
measured step of the frame update process.

This should result in the render time estimate rising less often:
Previously it did whenever the measurement of any of at least 3 out of
4 steps reached a new maximum, even if that didn't result in a new
maximum for the whole update duration. Now it's only in the latter
case.

This should also result in a lower render time estimate (and thus
input→output latency) in general, since the variability of
measurements for each 3/4 steps doesn't always add up anymore. The flip
side of this is that it might result in missing a display refresh cycle
more often.

v2:
* Fix coding style in maybe_update_longterm_max_duration_us.
  (Robert Mader)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3090>
2023-07-20 22:34:58 +00:00
Bilal Elmoussaoui
b852bbba47 cleanup: Stop translating nick/blurb for pspecs
As those strings are intended to be used by some UI but nothing uses
that in reality except GStreamer.
So drop them similar to what GTK did at
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4717

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3101>
2023-07-19 11:33:59 +00:00
Robert Mader
42336f69cc clutter/backend: Fix core profile description
Cogl actually requests 3.1.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
2023-07-19 10:39:54 +00:00
Jonas Ådahl
f4b76727db stage-view: Add API to inhibit cursor overlay painting
This adds some plumbing to get the "default" paint flags for regular
stage painting, where one either wants to paint the overlay, or not.

If inhibited, the 'no-cursors' paint flag is used, otherwise the 'none'
flag. This will be used to allow having a per stage view hw cursor
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 23:42:38 +02:00
Jonas Ådahl
38d1666049 clutter/event: Set the constrained relative motion too
When a relative pointer motion gets constrained (e.g. a monitor edge or
barrier), save the constrained relative motion delta too.

This will later be used to send the remaining motion delta to input
capture clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
a2bdce2c8e clutter/seat: Add seat name
This is similar to the existing seat-id that is part of MetaSeatNative,
but meant to be passed to created input capture seats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
e917b7de43 clutter/stage: Add input-only grabs
An input only grab is a ClutterGrab on the stage that doesn't have an
explicit actor associated with it. This is useful for cases where event
should be captured as if focus was stolen to some mysterious place that
doesn't have anything in the scene graph that represents it.

Internally, it's implemented using a 0x0 sized actor attached directly
to the stage, and a clutter action that consumes the events. An
input-only grab takes a handler, user data and a destroy function for
the user data. These are handed to the ClutterAction, which handles the
actual event handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
b32ee7225d clutter/event: Add clutter_event_get_name()
This is useful for debug logging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Daniel van Vugt
2305efa990 clutter/paint-volume: Don't over-enlarge 2D actorless paint volumes
A 2D actorless paint volume can't ever need `enlarge_for_effects` because
it has no depth. Clamping to the pixel boundary is sufficient in this case
and avoids extending volumes on the edge of the view into the next view.
Which then avoids unnecessary secondary monitor updates.

Paint volumes correctly become actorless where `clutter_actor_finish_layout`
calls `_clutter_paint_volume_transform_relative`.

Relates to: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6819

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3112>
2023-07-14 15:04:42 +00:00
Bilal Elmoussaoui
3590640932 clutter: Drop unnused private IDPool APIs
Nothing uses them

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3100>
2023-07-14 13:48:49 +00:00
Florian Müllner
9f46258ff9 clutter/actor: Make sure expand_set flags are set correctly
If an actor's expand properties haven't been set explicitly, its
expand flags are computed by traversing its children.

However we currently also traverse into children when explicitly
setting "expand" to FALSE, because that is the default value and
the properties are only marked as explicitly-set when the value
actually changed.

Fix this, so propagating expand flags can be stopped without
hacks like
```c
  g_object_set (actor, "x-expand", TRUE, NULL);
  g_object_set (actor, "x-expand", FALSE, NULL);
``

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3088>
2023-06-22 21:58:23 +02:00
Dor Askayo
e30eb78891 clutter/frame-clock: Treat GPU rendering duration of 0 as valid
This is expected for the common case of direct scanout of Wayland
buffers where transactions guarantee that all buffer fences are
signalled before a buffer is included in a frame.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3080>
2023-06-20 15:32:25 +00:00
Daniel van Vugt
e7a210d963 clutter/frame-clock: Add dispatch jitter to frame timing measurements
Dispatch jitter is how much the dispatch interval has changed between
frames. It's a measure of sampling smoothness for events that are occurring
at a higher rate than the screen is refreshing:

 * Mouse movement
 * Clients rendering at swap interval zero
 * Keyframe animation position

Zero jitter is ideal but will practically never happen, and a jitter value
of several thousand microseconds will be visible to the naked eye as stutter
even if you're maintaining a perfect frame rate.

To make the numbers easier to interpret we also log the jitter as a
percentage of the refresh interval.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3082>
2023-06-20 10:35:51 +00:00
Daniel van Vugt
be0aa2976e clutter/frame-clock: Avoid rapidly toggling dynamic max render time
This could happen when moving the cursor over GUIs that only redraw
in response to cursor movement. Mutter would experience alternating
cursor-only updates and page flips, and so the `max_render_time_allowed_us`
would jump between pessimised and optimised resulting in inconsistent
frame pacing.

Aside from fixing the smoothness problem this should also provide
lower latency cursor movement.

Fixes: https://launchpad.net/bugs/2023766
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3074>
2023-06-20 09:47:23 +00:00
Carlos Garnacho
c01580cec6 clutter: Remove some unused code
The drag actors were practically unused, and became wholly
unused API with commit eb6e1f694a. There is no provision for
using this in the future, so drop this internal API.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Jonas Ådahl
49e6ce459c backend: Dispatch initial burst of events synchronously on init
This will consist of device-added events, meaning before init finishes,
we can derive some state that depends on the set of input devices
available on startup, such as cursor visibility.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Robert Mader
c36f3f0101 clutter/actor: Some code-style fixes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Dreßler
b408be0b1e clutter/actor: Return NULL instead of FALSE when type check fails
Fix a small oversight in clutter_actor_peek_stage_views(), it should return
NULL instead of FALSE when the check fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Dreßler
26344fb533 clutter/actor: Don't store a second stage-views list for the stage
The stage already maintains its own list of stage-views via
clutter_stage_peek_stage_views(), it's a bit superfluous to copy that list
around all the time into priv->stage_views of ClutterActor. Let's deal with
that by returning clutter_stage_peek_stage_views() when
clutter_actor_peek_stage_views() gets called for the stage.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Dreßler
2ef4960b4f clutter/actor: Cache absolute modelview matrices
While we're now doing a fairly good job at not needing those matrices
all the time anymore, we still need it multiple times during every paint
cycle, so it definitely makes sense to introduce some caching here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Dreßler
4579e86330 clutter/actor: Avoid always traversing actor tree on finish_layout
With commit 5a565b4258, we changed
clutter_actor_finish_layout() to be not only about updating stage views,
but also take care of updating the visible_paint_volume, for that we
started doing a full tree traversal of all mapped actors.

This can be quite a performance issue, apparently especially on certain
ARM devices, where the simple tree traversal can take as long as 2ms.
This is precious time we need to paint our next frame, so lets do a bit
more work to avoid those useless traversals.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/2459

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Dreßler
261f516af4 clutter/stage: Avoid queueing stage updates when they're already queued
We're using clutter_stage_schedule_update() now from ClutterActor to kick
off the stage updating machinery when a redraw needs to happen.

This introduced a bunch of unnecessary calls to
clutter_stage_schedule_update() and thus
clutter_stage_view_schedule_update() when multiple actors request redraws
during the same stage update cycle, which is a very common case.

Cut off all those unnecessary calls by bailing out in
clutter_stage_schedule_update() when updates are already queued.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:00 +00:00
Jonas Dreßler
d2d730ec0b clutter/actor: Use GArray to store redraw clips
Using a list of heap allocated ClutterPaintVolumes adds quite a bit of
unnecessary overhead: It means for every single redraw clip we allocate a
list and a paint volume on the heap.

Let's avoid all those heap allocations by using a GArray with static
ClutterPaintVolumes instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:00 +00:00
Jonas Dreßler
699e1b305b clutter/actor: Refactor redraw clip to be centered around ClutterActor
So far our logic for queueing redraws goes like this: Actor notices that it
needs to redraw -> actor tells stage that it needs to redraw via
clutter_stage_queue_actor_redraw() -> stage collects more and more redraws
into a QueueRedrawList before the actual stage update happens -> when
that happens, the stage collects the actual redraw clips from the actors via
clutter_actor_get_redraw_clip().

The logic behind this QueueRedrawList was that by storing a list of
redraw entries on the stage, way we can avoid traversing the whole actor
tree one more time to build the redraw clip before the stage update.

These days we have clutter_actor_finish_layout() though, which is basically
exactly that, a whole actor tree traversal that happens before every stage
update.

Since we have that now, we might as well get rid of the whole dance back and
forth between ClutterStage and ClutterActor, and simply merge the logic to
queue redraws into the finish-layout step.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:00 +00:00
Jonas Dreßler
4cad96ed24 clutter/actor: Cache the visible paint volume
If no actors have changed their positions and we're only repainting
because a window needs a repaint, the paint volumes of all actors
remain unchanged. There is no reason to redo those paint volumes on every
stage update.

So introduce caching and invalidation logic for the visible_paint_volume
that allows us to avoid a ton of matrix multiplications that right now
are happening for the whole mapped actor tree on every redraw.

Note that this removes two places where the visible paint volume is set
to an empty paint volume: This is a compromise so that we can keep
around the cached pv when hiding and showing an actor, it does "regress"
one case though: When hiding -> moving -> showing an actor, we'll now
include the old paint volume of the actor in the redraw clip on show (even
though redrawing that old region is not necessary, the actor was hidden
after all). This results in a bit of overpaint in this very specific case,
but for the sake of simplicity let's not care about that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:00 +00:00
Robert Mader
64feb2e5f0 clutter/actor-box: Avoid rounding compensation for empty boxes
Empty boxes should not be enlarged to non-empty boxes, otherwise we
potentially confuse tests where we expect a zero-sized actor to also be on
zero stage views.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:00 +00:00
Pascal Nowack
30a5178204 clutter/clutter-stage: Get rid of an unused variable warning
When building mutter with -Ddebug=false, a warning appears, that
`ClutterStagePrivate *priv` is unused.
Simply remove this variable and directly use `stage->priv` in
`CLUTTER_NOTE` to get rid of this warning.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3040>
2023-06-01 16:10:13 +00:00
Georges Basile Stavracas Neto
52579c545b clutter/text: Use named pipelines
Cleanup the static color pipeline in favour of using named
pipelines. This is a more modern approach, and helps when
tearing down CoglContext.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
Georges Basile Stavracas Neto
8f6ebe4800 clutter/text: Don't paint background
The background is already painted by clutter_actor_paint_node(),
there's no need to (re)paint the background.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
Georges Basile Stavracas Neto
28774a23aa clutter/text: Plug a pipeline leak
ClutterText paints selected text using the selection_paint()
function. This function has to main branches of execution:
when the position is in the selection bound, or not. In the
former, we are leaking the CoglPipeline created by copying
the default color pipeline.

Unref the copied pipeline after using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
Georges Basile Stavracas Neto
0e8356936c clutter/actor: Move root node to ClutterStage
For now, it goes the "easy" way of creating the root node and
immediately painting and destroying it. From now on, the main
root node is created only by ClutterStage itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
msizanoen1
ab835787bd clutter/actor: Publish get_relative_transformation_matrix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
f671cec514 clutter/paint-volume: Do not use nearest rounding for actor bounds
This ensures clipped redraw work properly with transformed actors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ddc5de610b clutter/actor: Introduce notify_transform_invalid
This allows clients to maybe avoid triggering a redraw if they don't know
beforehand if the transform would actually change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
Jonas Ådahl
61b42e5303 build: Use / operator instead of join_paths everywhere
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Sebastian Keller
5b26db8ae8 clutter: Remove struct paddings
Due to clutter being a private library we don't need worry about ABI
compatibility.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2986>
2023-05-04 12:11:26 +00:00
msizanoen1
4048562961 stage: Keep queued actor redraw clip volumes separate
This aims to reduce the amount of pixels that have to be redrawed on the
screen on a clipped actor redraw in case using the union of two
different clips in a surface will substantially increase the redrawn
area.

This should not result in excessive memory consumption as callers of
`clutter_actor_queue_redraw_with_clip` are expected to ensure that the
redraw clip rectangles are adequately deduplicated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2965>
2023-05-03 08:53:36 +00:00
Marco Trevisan (Treviño)
17414fd242 clutter: Remove class paddings
mutter-clutter is a private library that is only used by the shell and
not meant to be ABI/API compatible in between versions, so there's no
need to add padding to classes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2903>
2023-05-02 19:48:03 +00:00
Jonas Ådahl
429cc9a674 clutter/backend: Allow unsetting input method
This is needed by GNOME Shell to remove itself as a input method
implementation during its shutdown sequence. We can't do it ourself
later because at mutters own shutdowns equence, the GNOME Shell
Javascript context has by that time already been teared down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2934>
2023-04-18 14:04:41 +00:00
Robert Mader
87b3843615 clutter/stage-view: Add destroy signal
It will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Robert Mader
ff246a2dc8 clutter/frame: Add API to query minimal render time of a frame
It will be used to schedule Wayland frame events independently from both
update and presentation time, as the former may happen multiple times
frame and the later not at all.

For frame events we want a timing that is just late enough to ensure
that a following commit by a Wayland client will not get included into
the current frame any more.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Georges Basile Stavracas Neto
81c9c43d26 clutter/stage: Assign frames to paint context
When rendering through the 'paint-view' handler, assign the frame
to the paint context. Otherwise, when rendering outside of the
frame clock schedule, don't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:19:23 +02:00
Georges Basile Stavracas Neto
82b037e74c clutter/paint-context: Allow assigning a ClutterFrame
This is not yet used, but next commits will need to assign a frame
to the paint context whenever painting onscreens.

Assigning a frame to the paint context is a one-way operation, and
treats multiple assignments strictly as a programming error.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2951>
2023-04-07 11:30:40 +02:00
Sebastian Keller
679d2fb4e0 build: Don't disable checks in release builds
Both Clutter and Cogl use g_return(_val)_if_fail() to safeguard
introspected API. Release builds were dropping these checks, which could
result in a much more crashy experience, especially when considering
extensions, but also due to bugs in the shell code itself.

This won't affect any major distro, because they all use "plain" builds.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2930>
2023-03-24 12:51:49 +00:00
Emmanuele Bassi
bc9cad5124 clutter: Safely transform paths to strings and vice versa
GValues containing objects and strings can be set to NULL, which means
the transformation functions from ClutterPath to string and vice versa
must be NULL-safe.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2625
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2929>
2023-03-21 13:47:51 +00:00
Jonas Ådahl
7eec97626d clutter/frame-clock: Warn if frame clock is disposed while dispatching
This shouldn't happen, but warn anyway to be a bit more helpful if
things go bad.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2901>
2023-03-18 13:52:10 +00:00
Florian Müllner
4a97da3675 cally: Use g_string_free() return value
glib now warns if the return value is not used, so use the API as
intended instead of assigning the character data separately before
freeing the GString.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2889>
2023-03-04 19:31:52 +00:00
Jonas Ådahl
f9802ca2a4 clutter/frame-clock: Debug log frame drops per second if there were any
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
135ed27d27 clutter/frame: Allow setting a backend release function
The one set by the native backend is empty, but it will be used later.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
678dc3243f clutter/stage-view: Allow stage view to allocate frame
This will be used to allow the native backend to allocate a KMS update
that'll be used for one frame.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
b80e84dea6 clutter/frame-clock: Allow frame clock listener iface allocate frame
This will allow the frame clock listener to allocate larger structs
where it can keep e.g. backend specific frame state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:39:16 +01:00
Jonas Ådahl
71b787f169 stage-view: Add short cut to clutter_frame_clock_update_now()
Stage view users can schedule updates at ease with
clutter_stage_view_schedule_update(), but couldn't schedule update
"now". Make that easy too by adding
clutter_stage_view_schedule_update_now().

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
2023-03-01 23:57:32 +00:00
Jonas Ådahl
b2579750a7 cogl: Remove legacy OpenGL driver support
This means the two Cogl drivers left are OpenGL >= 3.1 and GLES >= 2.0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2672>
2023-02-21 18:09:28 +00:00
Jonas Ådahl
e5195c08a4 clutter: Remove some unused macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2672>
2023-02-21 18:09:28 +00:00
Carlos Garnacho
e58f716fb1 clutter: Pass source device onto crossing event generation machinery
For motion-induced crossing events, this will be the device that generated
the motion. For code-induced crossing events (e.g. grabs or actors disappearing)
this will be none.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Jonas Dreßler
f6da583d06 tests/clutter/event-delivery: Add tests for implicit grabbing
Add a few tests to make sure all the hairy details of crossing behavior etc
don't fall apart again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
065ae39d61 clutter: Add CLUTTER_EXPORT_TEST define
Just like in mutter, add a define for exporting functions so that they
can be used in tests. This will be useful in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
dbf56621ff clutter/text: Use implicit grab instead of grabbing all events
Clutter has implicit grabbing now, so no need for grabbing all events
using clutter_stage_grab() anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
53b6d4abb1 clutter/gesture-action: Let lower layers cancel gesture on stage grab
Since the last commit, ClutterStage automatically cancels an implicit
grab (including all its ClutterActions) when a conflicting ClutterGrab
appears.

This means we no longer have to look out for GRAB_NOTIFY crossings in
ClutterGestureAction and can instead depend on the sequence_cancelled()
vfunc for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
debbd88f8c clutter/stage: Cancel parts of implicit grabs when ClutterGrabs happen
A ClutterGrab takes precedence over implicit grabs, so when one happens,
let's check which part of the implicit grab tree is inside the new
ClutterGrab. Cancel and remove the parts which aren't, and if nothing
is in there anymore, cancel the whole implicit grab.

Emitting crossing events correctly here is getting quite tricky:

- When the implicit grab didn't get cancelled by the ClutterGrab, we
simply want to emit all GRAB_NOTIFY crossings to the implicit grab, as
we do with all other crossings.

- When the implicit grab did get cancelled and the new ClutterGrab wants
to emit ENTER crossings, we want those to be emitted to the actual
targets, so cancel the implicit grab before emission.

- In the last case where the implicit grab did get cancelled and the new
ClutterGrab wants to emit LEAVE crossings, those should be emitted to
the implicit grab again, so we cancel the grab only after the emission
of those.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
2dd851d9f4 clutter: Add a GRABS debug flag
Now that we have two kinds of grabs, the intricacies of event delivery
got slightly more complicated. So this seems like a good point to
introduce a new GRABS debug flag that gives an overview of which grabs
are currently in effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
9d1c212a04 clutter/actions: Implement new sequence_cancelled vfunc
Now that we have more robust API to get notified about points that got
cancelled, make use of it to cancel ClutterGestureActions and
ClutterClickActions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
cf2d44d2c2 clutter: Notify ClutterActions about sequences that were cancelled
We're almost there, everything is in place to notify ClutterActions
about a sequence getting pulled away under its feet.

The only thing that's missing is the actual notification to actions now,
so let's do that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Jonas Dreßler
b3de224406 clutter/stage: Allow claiming sequence outside of event handling context
Another baby step just like the last commit: This commit takes care of
the opposite case: An action handling a sequence event stops further
emission of events to actors.

Since sequences remain around for longer than the context of just a
single event, it makes sense to provide a way to "claim" those sequences
even when outside of event handling context, so introduce API for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
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
Carlos Garnacho
2e94efddc9 clutter: Only emit regular crossing events in the actors they make sense
Instead of propagating ENTER/LEAVE all the way from the stage, emit those
events only in the actors that are actually entered or left.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
3e9d14c5c7 clutter: Notify grab changes on the key focus
Dissociate clutter_stage_set_key_focus() from the actors focused
state, so that it obeys stage grabs. The key focus actor state may
also change due to grab changes, add the code to notify about this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
ec3b8fe85b clutter: Propagate events only inside the grab
The grab actor becomes the "root" of the events being handled, events
inside propagate normally, but become silenced when falling outside
the grab area.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
ba895ca8e2 clutter: Emit crossing events along with ClutterGrabs becoming active
Emit crossing events whenever a grab coming or going would cause a
pointer/touchpoint to become inactive on their position. Depending
on whether the pointer lies inside the old or new grab widgets,
enter or leave events would be generated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
4595da008c clutter: Separate crossing event creation from emission
We will want to be more specific about the portions of the actor
hierarchy that receive this event, separate creation and emission
so each place does what is relevant.

However, this commit brings no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
40793e7077 clutter: Make crossing events unstoppable
These events are not meant to be ever silenced away, every actor
that is meant to receive one should do so. Make it sure that those
events cannot be stopped, despite the event signal handlers return
values.

This opens the debate about whether crossing events should be
ClutterEvents, since they are more and more uncommon at being one,
maybe this notification mechanism should be taken away from the
event machinery, but that's something for future refactors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
a60658f15e clutter: Add parameter to control the event emission root
Grabs will alter the topmost actor from where it makes sense to emit
events, add infrastructure so we can tell which actor is that when
emitting a ClutterEvent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
bbc95c1688 clutter: Add yet another grab API
Hopefully, the one to make them all converge. This new ClutterGrab
represents a handle on a created grab. These are stacked, so grabs
can be overridden and remain inactive until there is a time that
they become active again, although undoing these early is optional.

These grabs are global, they do apply to all pointer, touchpoint
and keyboard foci.

At the moment, only the API to create and stack those is added,
the actual functionality is added in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Florian Müllner
5f2779bfb6 clutter/box-layout: Deprecate :pack-start
A property for reversing the visible order of children is a bit odd.

It has also been unused by actual gnome-shell code since 2010, and the
somewhat related pack_start()/pack_end() API in GtkBox(Layout) is gone
in GTK4.

With that in mind, turn the property into a no-op and deprecate it,
so that it can be dropped next cycle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2206>
2022-01-07 21:14:09 +00:00
Fernando Monteiro
3646126b00 clutter/cally: Drop deprecated focus_clutter function
This is unused anywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2183>
2022-01-05 21:43:29 +00:00
Daniel van Vugt
3de1696c59 clutter/timeline: Minor documentation corrections
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161>
2022-01-05 15:57:45 +00:00
Daniel van Vugt
44c09dcefe clutter: Remove unused time_us parameter from ClutterFrameListenerIface
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161>
2022-01-05 15:57:45 +00:00
Daniel van Vugt
7e3d1e26a1 clutter/frame-clock: Advance timelines according to presentation time
This ensures they remain perfectly smooth regardless of how the
dispatch time has been adjusted/optimized/delayed/jittered.

Idea by Ivan Molodetskikh <yalterz@gmail.com>

For example, dragging a window on a 60Hz monitor:

BEFORE

delta(time_us) = 17014μs
delta(time_us) = 15998μs
delta(time_us) = 17006μs
delta(time_us) = 16975μs
delta(time_us) = 16001μs
delta(time_us) = 17002μs
delta(time_us) = 17006μs
delta(time_us) = 16004μs

AFTER

delta(time_us) = 16667μs
delta(time_us) = 16667μs
delta(time_us) = 16670μs
delta(time_us) = 16667μs
delta(time_us) = 16669μs
delta(time_us) = 16668μs
delta(time_us) = 16664μs
delta(time_us) = 16674μs

Caveat 1: Because we don't know a "next presentation time" on the first
frame, the interval between the first and second frame will usually be
different to the subsequent steady interval. So this change increases the
jitter of just frame 2, but eliminates jitter thereafter.

Caveat 2: `clutter_frame_clock_schedule_update_now` schedules updates
earlier than `clutter_frame_clock_schedule_update`. This means potentially
you could get multiple frames targeting the same "next presentation time".
That doesn't really change here though - we're dispatching at the same
times as we used to and just giving timelines a better vsync-aligned
timestamp now.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/25
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161>
2022-01-05 15:57:45 +00:00
Daniel van Vugt
b77cb09bac clutter/frame-clock: Make SYNC_DELAY_FALLBACK a fraction
This won't change anything for 60Hz displays but higher refresh rate
users will benefit.

Using Nvidia EGLStreams on a 240Hz monitor for example (refresh interval
~4.1ms), the maximum render time allowed before dropping to 120Hz is now
3.6ms whereas it was previously 2.1ms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2158>
2021-12-17 12:12:31 +00:00
Daniel van Vugt
8b8690c405 clutter/frame-clock: Don't recalculate refresh_interval_us
It was moved to a central location in ba1490ec9c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2157>
2021-12-13 17:25:35 +08:00
Carlos Garnacho
961419b331 clutter: Trigger pointer repick after animatable property changes
This is notably necessary with transformations, since these don't
trigger allocation machinery, but may affect the actor under the
pointer.

Visible e.g. with GNOME Shell's "Application does not respond"
dialogs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
bdd03b9ccd clutter/stage: Do not opt styli out of Clutter motion compression
With Wayland handling all events as they come, this code now just
performs motion compression for events that will be handled by Clutter
widgetry.

The intent to opt tablets and styli out of motion compression was
early and fast client handling, since that is now covered in a generic
manner, this code is superfluous. We don't really need the extra events
for these devices in compositor widgetry either.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
28009e8e63 clutter/stage: Ensure that generated crossing events go through filters
We essentially create those at the time they need to be handled, and
use shortcuts that avoid the event from being queued up. It's too much
of a short cut though, these events are also of interest to the Wayland
event handlers, e.g. to handle pointer state changes (e.g. repicks due
to the pick actor being destroyed) immediately, instead of at the next
event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
757d595fa3 clutter/stage: Update stored pointer coordinates in fast paths
If we are still under the "clear area" of the pick actor, we forget
to update the coordinates. This is usually not needed, unless we
need to repick again for non-event circumstances (e.g. pick actor
is destroyed). This will ensure the right pointer coordinates are
used afterwards in those situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
9475b872c0 clutter: Trigger immediate repick when pick actor is destroyed
Traditionally, the next repaint would also involve picking, which
would correct the actor under the pointer. This now does not happen
out of the box, so we really are waiting for the next pointer event
here.

To avoid the pointer/cursor to lag behind, trigger an immediate
repick here, that will look up the new actor under the pointer
coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
8406882552 clutter: Store the per-pointer picked actor's clear area
And resort to it first, unless we are told to ignore the cache
(e.g. after relayouts). This avoids further pick context operations
while the pointer is on the current actor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
19cdba8abe clutter: Calculate "safe area" during pointer pick
This safe area is the region (in stage coordinates) where the pointer
is ensured to stay within the current actor. This is not used yet, but
will be used for optimizations in pointer picking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
5428b96f1b clutter: Also log overlap regions in ClutterPickContext/Stack
These may be used for optimizations once we find the pick actor,
so picking can be avoided in areas we know didn't cross into
other actors. Nothing makes use of it yet though, just log these
so far.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
39b2a18f90 clutter: Move ClutterStage methods where they belong
These were awkwardly defined at clutter-main.c due to historical
reasons, but it does not make sense anymore to have them there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
340acb3fdf clutter: Unify picking and device updating
Add a clutter_stage_pick_and_update_device() method that is the only
single entry point for updating a device position as seen by the
stage.

Also, update all callers to use it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
6aea319c5c clutter: Do not export _clutter_stage_do_pick()
The clutter_stage_get_actor_at_pos() calls it almost 1:1 underneath
and is public API, we can have all callers use this, and stop using
this function outside of clutter-stage.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
b9a99f03d9 clutter: Small style fix
Fix indentation of a code line.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
1c5a90d9d2 clutter: Add missing G_GNUC_FALLTHROUGH
We do actually fall through here, so let it known that it's intentional.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
a34be31d63 clutter: Shuffle some clutter-main code
Move update_device_for_event() definition above the only point
it's now called.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
b8f92a6ce4 clutter: Move event filter handling to happen before throttling
As event handling goes:
1) Events get generated and queued by the seat (from another thread in
   native, in the same thread in X11)
2) The MetaBackend gets those events and forwards them to Clutter
   via clutter_do_event()
3) The events get queued in the ClutterStage
4) At the time of processing a frame, the input events are processed,
5) Motion events are throttled, only the last is effectively handled
6) Events are filtered, wayland and WM handling happens here
7) Events maybe reach to clutter

This commit moves 6 to happen between 2 and 3. The end result is that:

- Throttling only applies to Clutter event handling, The wayland event
  forwarding bits will handle the event stream as soon as it comes, as
  timely as possible.
- WM event handling is also unthrottled, but that's more of a side
  effect.
- This all still happens on the main thread, so there's the possibility
  that other busy areas (e.g. relayout) temporarily block this event
  forwarding.
- Sending events unthrottled inherently means more CPU, probably
  dependent on input devices' frequency. The impact is not measured.

This should bring the best of both worlds with e.g. 1000Hz mice, wayland
clients get unthrottled events, while GNOME Shell UI still behaves like
it used to do.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
c484f13b34 clutter/stage: Free pointer/touch info early during dispose
If we wait till finalize, dispose will destroy the actor hierarchy
and cause untimely repicks. Ensure to free the pointer/touch info
first, so the hooked signal callbacks are gone when destroying the
actors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Fernando Monteiro
44aa6ab735 cogl: Remove cogl_texture_new_with_size
Replace the deprecated function with the suggested alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
612da58c72 cogl: Remove cogl_texture_new_from_sub_texture
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
913458381f cogl: Remove usages of framebuffer_draw_primitive
We were already returning cogl_primitive_draw in framebuffer_draw_primitive,
so replace all usages and remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Carlos Garnacho
f2154ceaad clutter: Always snoop key events for a11y
In the case a11y is required, the screen reader is very much
interested in getting an uninterrupted flow of key events. It attempts
so by setting a ::captured-event callback on the ClutterStage, but
that falls short with our MetaDisplay event handler, as clutter events
can be stopped before a11y gets a chance to see them.

This kind of selective amnesia wrt key events is not new, in X11 those
go unheard of by the WM as long as a client is focused and no grabs hold,
so it is clients' responsibility to talk with AT bridge.

This commit doesn't yet change that for X11, but we can do this right
away from the compositor on Wayland, and without any chance to be
tampered by clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1328>
2021-12-07 14:29:18 +00:00
JoseExposito
af1f3304e4 clutter/event: Add ClutterEventType.CLUTTER_TOUCHPAD_HOLD
Add a enum for hold gestures in ClutterEventType as well as the
required functions to get information about the event: coordinates,
finger count, event phase, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
aa5569356e clutter/event: Add touchpad hold event definition
Add new Clutter event (ClutterTouchpadHoldEvent) with the required data to
represent a hold event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Corentin Noël
62ab4c09d9 clutter/actor: Add missing nullable annotations
Also change all the deprecated allow-none into optional or nullable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2108>
2021-11-26 17:30:35 +00:00
Sebastian Keller
92c98d5522 clutter/timeline: Make the warning about detached actors more helpful
By including the debug name of the actor and the duration of the
animation the source of such detached actors can be more easily
determined.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2011
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2088>
2021-11-15 13:52:14 +00:00
Sebastian Keller
e25df6675a clutter/content: Mark optional parameters as such in annotation
The width and height parameters of clutter_content_get_preferred_size()
are optional, but were not marked as such. With a current gjs this will
result in a warning if a caller does not use them.

Found by Evan Welsh

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1945
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2079>
2021-11-08 15:46:09 +00:00
Jonas Ådahl
802d4e0cf8 clutter/actor: First clear all stage views before emitting they changed
If one would end up with an actor attached to mapped actor, where the
attached actor doesn't itself have an up to date stage view list while
listening on the stage for updating, when clearing the stage views of
the list, anything that would query the stage views list at this time
would end up accessing freed memory.

This could happen if

 1) An actor was added to a newly created container actor attached to
    the stage
 2) The actor got a timeline attached to it
 3) The actor was moved to a container that already was mapped
 4) A hotplug happened

After (1) both the container and actor would not have any stage views.
After (2) the timeline would listen on the stage for stage views
updates. After (3) the actor would still listen on the stage for stage
views updates. When (4) happened, the actor would be signalled when the
stage got its stage view cleared, at which point it would traverse up
its actor's tree finding an appropriate stage view to base its animation
on. The problem here would be that it'd query the already mapped
container and its yet-to-be-cleared stage view list, resulting in
use-after free, resulting in for example the following backtrace:

  0)  g_type_check_instance_cast ()
  1)  CLUTTER_STAGE_VIEW ()
  2)  clutter_actor_pick_frame_clock ()
  3)  clutter_actor_pick_frame_clock ()
  4)  update_frame_clock ()
  5)  on_frame_clock_actor_stage_views_changed ()
  6)  g_closure_invoke ()
  7)  signal_emit_unlocked_R ()
  8)  g_signal_emit_valist ()
  9)  g_signal_emit ()
  10) clear_stage_views_cb ()
  11) _clutter_actor_traverse_depth ()
  12) _clutter_actor_traverse ()
  13) clutter_actor_clear_stage_views_recursive ()
  14) clutter_stage_clear_stage_views ()
  ...

Avoid this issue by making sure that we don't emit 'stage-views-changed'
signals while the actor tree is in an invalid state. While we now end up
traversing tree twice, it doesn't change the Big-O notation. It has not
been measured whether this has any noticible performance impact.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1950
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2025>
2021-11-06 14:25:40 +00:00
Carlos Garnacho
3d37602c54 clutter: Drop click count from button events
This does two things to frown upon:
- Modifies ClutterEvent structs, while the effort is to have those
  completely opaque, and readonly after creation from the input
  thread side.
- Stores state in the ClutterInputDevice struct, event though those
  are also considered static after creation, managed by the input
  thread, etc.

Stop doing that. This makes all events just forwarded as-is in
the ClutterStage/clutter-main.c code.

Handling of click count sounds like material for a ClutterGestureAction
(or perhaps ClutterClickAction), all of both callers now do it in place
at the moment, while gestures lack a better state tracking and management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
8c4c3f0308 clutter: Make ClutterClickAction independent of click count
This will trigger for every button press/release that is obtained,
regardless of the click count.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
a235d03550 clutter: Carry accounting on double/triple clicks in ClutterText
Instead of using the ClutterEvent information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
6d0b7381da clutter: Move ClutterGestureAction to the handle_event vfunc
This will not try the captured-event shenanigans to emulate grab
behavior, instead relying on event delivery being influenced by
other grab mechanisms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
5133815cc1 clutter: Move ClutterClickAction to the handle_event vfunc
This will not try the captured-event shenanigans to emulate grab
behavior, instead relying on event delivery being influenced by
other grab mechanisms.

While at it, improve handling of additional touchpoints by
cancelling the click action right away, as the differences in
event handling make this unwanted behavior surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
7885f6dbcc clutter: Add handle_event vfunc to ClutterAction
This will be the entry point for events into these actions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
0e57fd42e3 clutter: Add information about event phase in ClutterActions
These will stick to a single phase, instead of juggling capture and
bubble event handlers to do whatever they want.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
2fc40da1cb clutter: Drop ClutterZoomGesture's zoom-axis property/methods
This can be done on the caller, seems rarely useful if at all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
85bcc48b53 clutter: Drop ClutterSwipeAction::swipe default vmethod
This is already empty, no need to do anything here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
94abaf247b clutter: Drop default "zoom" action in ClutterZoomAction
Separate mechanism and effect, and let any ClutterZoomAction
users apply any necessary transformations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
f4b26559d3 clutter: Drop default "rotate" action in ClutterRotateAction
Separate mechanism and effect, and let any ClutterRotateAction
users apply any necessary transformations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
0ed9c6e524 clutter: Drop default action of Pan action
By default, the pan action performs matrix translations on the
child widget. Nobody wants that (or, nobody wants *just* that).
It's cleaner not to mix mechanism and effect in ClutterGestureAction
subclasses, so drop this base implementation, and change the signal
accumulator so it's more similar to event signals (not that it's
used any longer, anyway).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-28 23:52:04 +02:00
Carlos Garnacho
90ad8b88d4 clutter: Plug leak on error condition
The ClutterContext is leaked if not properly initialized.

CID: #1508079
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
e50460e396 clutter: Turn warning into assert
This warning is actually dead code, since should_be_mapped and
must_be_realized are always set to the same value, so it does not
make sense to check for "a && !b".

Turn this into an assert so we avoid the dead branch, but do not
remove the variable duplication so the more aptly named variable
is used where it belongs, for clarity.

CID: #1506254
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
3b6f9111c7 clutter: Only reset preedit text if set
On ClutterInputFocus::reset, avoid to unset the preedit text if
none was set earlier. This seems to trick GTK clients into focusing
the cursor position again, even when we are moving away from it.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4647
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2059>
2021-10-19 17:52:54 +00:00
Jonas Ådahl
7058013660 clutter/stage: Remove 'minimum window size' logic
It was a feature relevant for when Clutter was an application toolkit
that wanted the application window to communicate a minimum size to the
windowing system.

Now, clutter is part of the windowing system component, so this feature
doesn't make any sense, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
b73bbecaad clutter/feature: Remove static vs multiple stage feature
This feature was configured depending on whether the Cogl backend
reported COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN or not. All cogl backends
do report this, so any code handled the 'static' case were never used.

While we only ever use one stage, it's arguable more correct to
consilidate on the single stage case, but multiple stages is something
that might be desirable for e.g. a remote lock screen, so lets keep this
logic intact.

This has the side effect of completely removing backend features, as
this was the only left-over feature detection that they handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
57964becb6 clutter/features: Remove 'swap-events' feature
We still use swap events, but it's a backend detail, doesn't need to be
exposed anywhere else.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
d9f0d937d9 clutter/features: Remove 'offscreen' feature
It's also unused. Offscreen framebuffers are still used however, but
it's assumed to exist.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
85de82bb4e clutter: Remove 'stage cursor' feature
It was unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
3b9409a139 clutter: Remove left over fb bit masks
Was used for picking, but we use geometric picking, lets remove these
left overs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
33cdb45c8f clutter: Remove CLUTTER_DEFAULT_FPS and default rate
It isn't used, and is not useful. Lets remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
8008f0b7b0 Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.

The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().

During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.

This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.

This function now explicitly creates the backend, without having to go
via the previously set global vfunc.

This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.

The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.

This also removed the unused option parsing that existed in clutter.

In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.

The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
528ae91385 clutter: Remove option parsing support
For a long time we always passed NULL, lets take it one step further and
just remove all the options parsing stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Sebastian Keller
3768efef2b clutter/offscreen-effect: Consider paint volumes at negative coordinates
When basing the offscreen texture position off the paint volume, the
code was assuming that the paint volume was always starting at 0,0 but
this is not the case if child widgets are placed at negative coordinates
or the widget itself is transformed. This could cause such widgets that
have been flattened and therefore rendered to an offscreen texture to
appear cut off in the top/left.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4561
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1923
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2031>
2021-10-15 20:21:09 +00:00
Georges Basile Stavracas Neto
fbcb078513 clutter/container: Remove clutter_container_get_children
This one is a trivial wrapper around clutter_actor_get_children(), so just
use that in the two places where clutter_container_get_children() is used,
and remove clutter_container_get_children().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2057>
2021-10-15 14:22:37 -03:00
Georges Basile Stavracas Neto
8d1105ae6c clutter/container: Remove clutter_container_raise_child
Also unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2057>
2021-10-15 14:22:37 -03:00
Georges Basile Stavracas Neto
d5dd8ebfa9 clutter: Remove clutter_container_lower_child
Also unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2057>
2021-10-15 14:22:37 -03:00
Georges Basile Stavracas Neto
1a978df4a7 clutter: Remove clutter_container_sort_depth_order
Unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2057>
2021-10-15 14:22:37 -03:00
Robert Mader
136caca5d5 clutter/stage: Only add paint volumes of mapped actors to stage clip
Right now we damage the stage even if an actor is not mapped, for
example in the overview.

Stop doing so, reducing over-paint significantly in some situations.
Clones will still do stage damage on their own.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2035>
2021-10-15 15:59:32 +00:00
Sebastian Keller
867db93043 clutter/text: Invalidate actor paint volume when it has changed
ClutterText implements its own get_paint_volume() with its own cache,
but was not invalidating the actor paint volume when when it has
changed. This sometimes could result in labels, especially quickly
changing ones, using the old paint volume which either would cut off the
label or leave parts of the old label on screen.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1943
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2006>
2021-10-06 20:16:09 +00:00
Corentin Noël
89a13b4557 clutter/stage: Remove inout from paint_to_buffer
Remove the (inout) annotation as we are only using the byte array directly and not
a pointer to the array.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2026>
2021-09-29 09:56:20 +02:00
Jonas Ådahl
b10b77cc46 clutter/backend: Propagate error when initializing context
Any caught error message was silently dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1994>
2021-09-20 16:37:37 +00:00
Michel Dänzer
62cdf8de5e clutter/stage: Remove clutter_stage_capture_into
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Carlos Garnacho
f4a32cb7cd clutter: Forward button press/touch down onto ClutterText IM focus
So these can properly trigger reset of the IM.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1940>
2021-09-03 22:05:46 +00:00
Carlos Garnacho
765f41de80 clutter: Add ClutterPreeditResetMode hint to preedit text
This mode is passed along by the ClutterInputMethod, the
ClutterInputFocus will preserve it and ensure it is honored
whenever the IM is being reset.

This mode is immediate. The ClutterInputFocus commits the
text directly without queueing a CLUTTER_IM_COMMIT event.
This is important so events are serialized in the right order
in the wayland implementations (i.e. commit before wl_pointer.press).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1940>
2021-09-03 22:05:46 +00:00
Carlos Garnacho
9c20b4144a clutter: Handle touch down and button press events in ClutterInputFocus
In line with GTK, the input method context should be reset when clicks
are handled by the ClutterInputFocus user. The reset action can then
either clear or commit the preedit text, as configured by the IM module.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1940>
2021-09-03 22:05:46 +00:00
Daniel van Vugt
da3ff9f6d0 clutter/frame-clock: Correct indentation
To resolve CI warnings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1972>
2021-08-24 16:43:49 +08:00
Jonas Ådahl
18c414cca4 clutter/stage-view: Initialize view as damaged and awaiting frame
Make sure that when we've recreated views that we'll actually paint a
new frame for it. This was very rarely a problem, as views tend to
result in getting damage etc being queued as side effects of various
things, like layout, but e.g. when running certain tests, this might not
happen. There is no situation where we want to create a new view that
should remain unpainted, so just make sure we initialize it to become up
to date.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
2021-08-22 17:06:53 +00:00
Ivan Molodetskikh
13a2a33257 clutter: Add clutter_stage_paint_to_content ()
Used in the new screenshot UI.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1899>
2021-08-22 12:44:38 +00:00
Florian Müllner
9252b7c6b4 clutter/text: Don't query preferred size without allocation
The size request functions query the resource scale, which hits
an assert if headless. The returned sizes are already only used
when clutter_actor_has_allocation() is true, so this doesn't
change the condition for calling either redraw or relayout.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4522

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1956>
2021-08-05 13:20:54 +02:00
Carlos Garnacho
a4c50ad123 clutter: Add COGL_HAS_TRACING checks around tracing code
This code sneaked unconditionally, even though we can disable
tracing code with -Dprofiler=false. Add some COGL_HAS_TRACING
checks so that this code is also optionally built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1951>
2021-08-02 17:15:10 +02:00
Jonas Ådahl
6b1f49c153 clutter/actor: Optionally trace allocations
If 'detailed-trace' is enabled, trace the allocation of every actor every
frame, and pass along the type and name of the actor to sysprof.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:48 +02:00
Jonas Ådahl
5c7795dfa9 clutter/actor: Optionally trace painting
If 'detailed-trace' is enabled, trace the painting of every actor every
frame, and pass along the type and name of the actor to sysprof.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:29 +02:00
Jonas Ådahl
9d22e7153c clutter/actor: Sneakily remove the g from the debug names gchar
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:12 +02:00
Jonas Ådahl
6a0dd2a0fa clutter/actor: Always generate the same debug name
It's useful also for non-debug builds to have a more proper name for
actors, e.g. when tracing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:12 +02:00
Jonas Ådahl
796eb005bc clutter/main: Add 'detailed-trace' debug flag
Will be used to trace a lot more, and with more details, and thus may
have a larger impact on what is actually measured. This potential impact
is the reason for enabling only when needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:12 +02:00
Jonas Ådahl
96b1ebb2fd clutter/layer-paint-node: Handle failure to allocate offscreen
The failure to allocate was not properly handled, causing crashes later
on due to the offscreen being NULL.

 #0  cogl_gl_framebuffer_bind (target=36160, gl_framebuffer=0x0)
 #1  _cogl_driver_gl_flush_framebuffer_state (...)
 #2  cogl_context_flush_framebuffer_state (read_buffer=0x55f48f386780, draw_buffer=0x55f48f386780, ...)
 #3  cogl_framebuffer_clear4f (framebuffer=0x55f48f386780, ...)
 #4  clutter_layer_node_pre_draw (...)
 #5  clutter_paint_node_paint (...)

...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1942>
2021-07-29 11:16:21 +00:00
Jonas Ådahl
5e5c7fe1af clutter/layer-paint-node: Fix variable naming
It's elsewhere in the file referred to as lnode. No idea what "res"
means.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1942>
2021-07-29 11:16:21 +00:00
Carlos Garnacho
c80ef12c79 clutter: Remove unused EGL header
This just pulled cogl headers, so not very useful.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
1f67e4650c clutter: Remove leftovers from backend code in build system
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
229b52872e clutter: Drop generation of x11 pkgconfig file
This is no longer needed, at least from the Clutter API perspective.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
dc6d3cead2 backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11
We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
1e84c00d86 clutter: Drop dead X11 code
We don't use the ClutterBackendX11 direct constructor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
7fcc7a6edb clutter: Drop Xsettings client code
We only listen to it for 2 settings (drag threshold, double click
time), and we already have the stock ClutterSettings object tracking
the source of these. This code is redundant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
8f839b2f9c clutter: Move ClutterStageCogl[View] code to src/backends
This is now MetaStageImpl in backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
7712b58170 clutter: Export private function to get debug flags
We're shuffling some code into src/backends, that needs knowing
about these flags to minimize immediate refactors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
dd9d40aedb clutter: Make ClutterStageView API public to mutter
All subclasses and stage implementations will come from src/backends,
so this internal API must be accessible there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
5beba8b99b clutter: Make ClutterDamageHistory API public to mutter
We are moving things to src/backends, make this helper object able
to be used there. This is a temporary measure as ClutterDamageHistory
itself should be moved too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
c58909dc0f clutter: Demote CLUTTER_NOTE to g_debug in clutter-stage-cogl.c
This code is being shuffled out of Clutter code, so cut the ties with
it before doing that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
07384e18c5 clutter: Remove clutter_init_with_args()
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Daniel van Vugt
0555a5bbc1 clutter/frame-clock: Apply error diffusion (dithering) to dispatch times
But only the dispatch times used when `last_presentation_time_us == 0`
(Nvidia + Xorg).

This ensures the average dispatch interval is always precisely equal
to the refresh interval, regardless of any jitter in the mainloop.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1751,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/1758,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/1870

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1826>
2021-07-13 17:18:17 +08:00
Daniel van Vugt
ba1490ec9c clutter/frame-clock: Remember the refresh interval
Instead of recalculating it every time we need it. The performance
gain is not important; this is more because it will be needed in
multiple functions soon.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1826>
2021-07-13 17:18:14 +08:00
Ivan Molodetskikh
a5d1d48bf1 clutter: Add a max render time debug HUD
Not sure how to update the damage or redraw clip or something; at least
this works properly when under a constantly-redrawing window, which is
ok for debugging purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
f55c9af618 clutter: Add an lg command to set max render time constant
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
565e34b4d2 clutter: Add a flag to disable heuristic max render time
Debugging purposes: allows to check if frame drops are caused by
heuristic max render time or if they are there even with the old
behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
592fbee065 clutter: Compute max render time heuristically
Max render time shows how early the frame clock needs to be dispatched
to make it to the predicted next presentation time. Before this commit
it was set to refresh interval minus 2 ms. This means Mutter would
always start compositing 14.7 ms before a display refresh on a 60 Hz
screen or 4.9 ms before a display refresh on a 144 Hz screen. However,
Mutter frequently does not need as much time to finish compositing and
submit buffer to KMS:

      max render time
      /------------\
---|---------------|---------------|---> presentations
      D----S          D--S

      D - frame clock dispatch
      S - buffer submission

This commit aims to automatically compute a shorter max render time to
make Mutter start compositing as late as possible (but still making it
in time for the presentation):

         max render time
             /-----\
---|---------------|---------------|---> presentations
             D----S          D--S

Why is this better? First of all, Mutter gets application contents to
draw at the time when compositing starts. If new application buffer
arrives after the compositing has started, but before the next
presentation, it won't make it on screen:

---|---------------|---------------|---> presentations
      D----S          D--S
        A-------------X----------->

                   ^ doesn't make it for this presentation

        A - application buffer commit
        X - application buffer sampled by Mutter

Here the application committed just a few ms too late and didn't make on
screen until the next presentation. If compositing starts later in the
frame cycle, applications can commit buffers closer to the presentation.
These buffers will be more up-to-date thereby reducing input latency.

---|---------------|---------------|---> presentations
             D----S          D--S
        A----X---->

                   ^ made it!

Moreover, applications are recommended to render their frames on frame
callbacks, which Mutter sends right after compositing is done. Since
this commit delays the compositing, it also reduces the latency for
applications drawing on frame callbacks. Compare:

---|---------------|---------------|---> presentations
      D----S          D--S
           F--A-------X----------->
              \____________________/
                     latency

---|---------------|---------------|---> presentations
             D----S          D--S
                  F--A-------X---->
                     \_____________/
                      less latency

           F - frame callback received, application starts rendering

So how do we actually estimate max render time? We want it to be as low
as possible, but still large enough so as not to miss any frames by
accident:

         max render time
             /-----\
---|---------------|---------------|---> presentations
             D------S------------->
                   oops, took a little too long

For a successful presentation, the frame needs to be submitted to KMS
and the GPU work must be completed before the vblank. This deadline can
be computed by subtracting the vblank duration (calculated from display
mode) from the predicted next presentation time.

We don't know how long compositing will take, and we also don't know how
long the GPU work will take, since clients can submit buffers with
unfinished GPU work. So we measure and estimate these values.

The frame clock dispatch can be split into two phases:
1. From start of the dispatch to all GPU commands being submitted (but
   not finished)—until the call to eglSwapBuffers().
2. From eglSwapBuffers() to submitting the buffer to KMS and to GPU
   work completing. These happen in parallel, and we want the latest of
   the two to be done before the vblank.

We measure these three durations and store them for the last 16 frames.
The estimate for each duration is a maximum of these last 16 durations.
Usually even taking just the last frame's durations as the estimates
works well enough, but I found that screen-capturing with OBS Studio
increases duration variability enough to cause frequent missed frames
when using that method. Taking a maximum of the last 16 frames smoothes
out this variability.

The durations are naturally quite variable and the estimates aren't
perfect. To take this into account, an additional constant 2 ms is added
to the max render time.

How does it perform in practice? On my desktop with 144 Hz monitors I
get a max render time of 4–5 ms instead of the default 4.9 ms (I had
1 ms manually configured in sway) and on my laptop with a 60 Hz screen I
get a max render time of 4.8–5.5 ms instead of the default 14.7 ms (I
had 5–6 ms manually configured in sway). Weston [1] went with a 7 ms
default.

The main downside is that if there's a sudden heavy batch of work in the
compositing, which would've made it in default 14.7 ms, but doesn't make
it in reduced 6 ms, there is a delayed frame which would otherwise not
be there. Arguably, this happens rarely enough to be a good trade-off
for reduced latency. One possible solution is a "next frame is expected
to be heavy" function which manually increases max render time for the
next frame. This would avoid this single dropped frame at the start of
complex animations.

[1]: https://www.collabora.com/about-us/blog/2015/02/12/weston-repaint-scheduling/

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
4a4e61c1f1 clutter: Add FRAME_TIMINGS debug key
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
8d51c5ac55 clutter/frame-clock: Store dispatch timings
Will be used to adjust max render time dynamically.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
8c4a91ddd6 clutter: Add swap time and GPU rendering duration to FrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:43 +00:00
Ivan Molodetskikh
8c258d1de1 cogl: Add CPU swap time and GPU rendering query to CoglFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
3aa0e3074f clutter: Store vblank duration in ClutterFrameClock
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00