Commit Graph

7803 Commits

Author SHA1 Message Date
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