Commit Graph

7702 Commits

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