ClutterClickEvent currently doesn't check if button press and release
happen within the drag threshold, which can be surprising sometimes.
Only emit the "clicked" signal if the button press and release happen
within the area of drag threshold.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1667>
In clutter_timeline_set_actor() we currently always unset the
priv->frame_clock pointer of the old actor when a new actor gets set.
The priv->frame_clock pointer takes a reference on the ClutterFrameClock
though, so we leak ClutterFrameClocks here.
To fix it, simply rely on update_frame_clock(), which will call
set_frame_clock_internal() unconditionally to update the
priv->frame_clock pointer for us.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1632>
Some effects such as the BrightnessContrastEffect try to skip rendering
by returning early with a FALSE return value in pre_paint() in cases
where the effect would not change the rendering. This stopped working
when effects were ported to paint nodes.
In the case of OffscreenEffects, like BrightnessContrastEffect,
pre_paint() is responsible for setting up the offscreen buffer which is
then used in paint_node(). However if pre_paint() fails, this buffer is
not created and attempting to use it will result in several error
messages and broken rendering.
Instead of trying to call paint_node() of the effect if pre_paint()
failed, just draw the actor.
Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1576
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1658>
When using alt-tab to switch between windows, on a key handler we
undo the compositor grab, which triggers a repick, which generates
crossing events, which are handled in place, and trigger these
reentrancy checks.
On one hand, we do intend these crossings to take effect in place,
rather than being queued (possibly after a number of already queued
events). On the other hand, we now outright discourage generating
events from random places (and hope to make it just not possible,
eventually) thus we can afford not to protect against reentrancy
caused by API misuse.
So just drop these checks, and let these crossing events be
properly handled.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
This is the very same code than meta_wayland_pointer_repick(),
made part of Clutter, so triggering repicks on the same pointer
coordinates is made easy.
The intention is to remove meta_wayland_pointer_repick() in favor
of this call.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
Updating the state before emitting the CLUTTER_LEAVE event allows its
handlers to query the pointer actor, and avoid getting the same actor
again. Conceptually, this makes picking more "atomic", and the events a
notification of the change.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
Turns out GObject implicitly notifies all properties by default as soon
as a property setter is called, no matter if the property actually
changed or not. One can opt-out of this behavior by setting the
G_PARAM_EXPLICIT_NOTIFY flag.
So since almost all our properties get notified explicitely (well,
except ClutterActors deprecated show-on-set-parent property), set this
flag for all properties of ClutterActor and ClutterStage now. This
significantly reduces the number of notify:: signals emitted on
ClutterActors, because in gnome-shell javascript we usually set GObject
properties directly, not by going through the extra setter method.
More cleanups can be done in the future, since this flag is suitable for
almost every property in Clutter and even Mutter.
This fixes a crash where we'd hit a newly introduced assertion in
on_device_actor_reactive_changed() of ClutterStage because
notify::reactive got emitted multiple times.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1651>
Due to a few reasons currently the updating of input devices after stage
relayouts isn't working right now. Since we now have a list of pointer
devices in ClutterStage, we can simply use that list and can avoid
asking the input thread. Also we no longer need to check whether the
devices are pointer devices, since our list only consists of pointer
devices.
So switch to ClutterStages private list of pointer devices, which also
includes the core pointer (as opposed to the list returned by
clutter_seat_peek_devices()). This fixes picking after relayouts.
Note that this doesn't catch every possible change that might need a
repick, actors might also need a repick after transformation changes or
in case their custom clip has been changed.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1634>
As planned and prepared with the last commits, let ClutterStage take
care of tracking input devices and their respective actors. This means
we now can remove the old infrastructure for this from
ClutterInputDevice.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
We're moving keeping track of input devices and their associated actors
out of ClutterInputDevice, this commit basically adds replacements for
clutter_input_device_update() and clutter_input_device_set_actor() to
clutter-main and shuffles the internals of those functions around a bit
for clarity.
clutter_stage_update_device() is made available in clutter-mutter.h
because we need to update the actor of input devices not only from
ClutterStage (when repicking after relayout), but also from
MetaWaylandPointer (inside meta_wayland_pointer_repick()).
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
With the introduction of the input thread, we want to avoid modifying
ClutterInputDevices from the main thread, since they're owned and
updated by the thread.
There's one part of ClutterInputDevice that's still modified from the
main thread though, that is device-actors of pointer devices, and we're
going to move that state-tracking into ClutterStage instead.
So start that by adding the infrastructure to ClutterStage to keep track
of those things. It consists of two hashtables which associate devices
and touch sequences with actors, those hashtables get updated using
clutter_stage_update_device_entry() and
clutter_stage_remove_device_entry(), they can be queried by calling
clutter_stage_get_device_actor(), which will replace
clutter_input_device_get_actor().
clutter_stage_get_device_coords() is added and made available in
clutter-mutter.h because we need to get the coordinates when repicking
in meta_wayland_pointer_repick().
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
The n_steps variable corresponds to the number of *pairs* of
texture lookups that the blur shader does. For example, when
n_steps = 1, the for-loop reads 1 pixel before and 1 pixel
after the current one.
Our blur shader is heavily inspired in WebRender's blur shader,
the biggest difference being that we calculate the gaussian
samples in the fragment shader itself, and not in the vertex
shader. (This could be an improvement in performance for the
future though!)
WebRender's blur shader calculates n_steps differently than what
we currently do, though. It calculates n_step in such a way that
at least 2 steps are performed for evey non-zero sigma value.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
The shader already operates on floating point sigma, and
there's just no reason for us to force it to be an unsigned
integer. It's still important that sigma must be positive
though.
Make sigma a float, and make sure it's a positive number.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
Yet another way to reduce the instruction count of the fragment
shader. Passing a pair of floats once is virtually free, compared
to computing horizontal and vertical on each fragment run.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
New entries indirectly added to `pending_queue_redraw` during the loop
would make our iterator invalid and cause `g_hash_table_iter_next` to
fail without having visited all elements. That was seen as assertion
failures but also likely resulted in incomplete paint clips.
Now we steal the iterator's entry before such corruption can happen,
free it manually, and reset the iterator to the beginning on every
iteration. This is actually safe and efficient because we're removing each
entry we visit. So no time is wasted in resuming from the (new) beginning
of the hash table.
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1557
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1615>
Add a new pair of APIs corresponding to CoglFramebuffer's draw_rectangles()
and draw_textured_rectangles(). They're generally more performance compared
to adding multiple single-rect operations. These variants are heavily used
by GNOME Shell's CSS implementation.
The op array is built to match cogl_framebuffer_draw_textured_rectangles()
always, which means it's a series of 8 floats composed (x1 y1 x2 y2) and
(s1 t1 s2 t2). To avoid adding new struct fields to ClutterPaintOperation,
which is a performance and memory sensitive structure, simply divide the
array length by 8 (which is guaranteed to be correct).
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
Setting an ortho projection gives us pretty much the same result as
manually calculating the projection matrix. The ortho projection is
actually more "complete" than the custom projection we've been using,
as it also considers z-near and z-far, but in practice the generated
pixels are exactly equal.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1642>
In the purely paint node based rendering future, ClutterEffects
simply add more paint nodes to the tree when painting the actor.
This is the leap to achieve that future.
Add paint nodes to pre_paint, paint, and post_paint, and move the
ClutterEffectNode creation to _clutter_effect_paint().
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
The paint node tree that ClutterOffscreenEffect generates is
simple:
Root
|------------+
| |
Layer Pipeline
|
Actor
Right now, both pre-paint and ClutterLayerNode push the offscreen
to the framebuffer stack. That's harmless, and will go away soon
anyway.
The actor node is created and added in a separate function because
it'll be reused by the next commit.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
Add a new ClutterPaintNode parameter to the paint_target() vfunc.
For now, create a temporary ClutterEffectNode that is passed to
paint_target() and immediately painted; next commits will move
this to upper layers.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
The blur pipeline is still cached on ClutterBlurEffect, and we
simply update the uniforms when asked to create the pipeline.
Now that ClutterOffscreenEffect will use the blur pipeline, it
doesn't need to override the paint_target() vfunc anymore.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
The most annoying aspect of ClutterOffscreenEffect right now, and
the reason for all its subclasses to override pre-paint, is that
the pipeline creation isn't under subclasses' control. That means
all subclasses must ask ClutterOffscreenEffect to run pre-paint
and create the pipeline, then they all create their own pipelines
to paint.
To reduce this complexity, add a new create_pipeline() vfunc to
ClutterOffscreenEffect. Next commits will port effects to use this
new vfunc.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
ClutterLayerNode currently skips pushing the offscreen framebuffer when
no operations are set. This was added at the time because pushing and
popping was a synchronization point in Cogl, slow enough to force the
layer node to have this protective measure. Nowadays, pushing and
popping on the paint context is free.
Make ClutterLayerNode always push and pop in pre and post paint.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
ClutterBlurNode is a paint node based on ClutterLayerNode
that draws all children in an offscreen framebuffer, blurs
this framebuffer, and finally paints the blurred contents
according the the paint operations added.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
Copy-paste error sneaked ClutterTransformNodeClass in
clutter_blit_node_class_init(). It wasn't problematic
because they both typedef to ClutterPaintNodeClass, but
fix it anyway.
Also switch to g_object_ref() in clutter_blit_node_new().
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
Until now we would `clutter_input_focus_set_cursor_location` with
cursor-rectangle-in-physical-pixels + actor-location-in-stage-coordinates.
But those use different scaling factors so it only got the right answer
when the framebuffer scale was 1.0.
This directly determines the geometry of the invisible dummy cursor in
gnome-shell ibusCandidatePopup.js:
```
panelService.connect('set-cursor-location', (ps, x, y, w, h) => {
this._setDummyCursorGeometry(x, y, w, h);
});
```
And because it's invisible it wasn't obvious that it was wrong until you
enable `CLUTTER_PAINT=damage-region` and you can see its ghost at the wrong
offset and scale.
So now we `clutter_input_focus_set_cursor_location` using purely unscaled
stage coordinates. And `CLUTTER_PAINT=damage-region` shows that
gnome-shell's `_dummyCursor` is placed precisely over the visible cursor.
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3399
and probably other IBus issues that arise when using framebuffer scaling.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1576>
`priv->cursor_rect` is stored in physical pixels, not local coordinates.
So unscale it before returning from `clutter_text_get_cursor_rect`, which
is explicitly documented as returning "actor-relative coordinates".
This went missed with fractional scaling support, and unnoticed as nobody
uses `clutter_text_get_cursor_rect` yet. But that will soon change.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1576>
Before now it was assumed that the only negative local coordinates would
be those introduced by `_clutter_actor_box_enlarge_for_effects`, and we
used the difference for `fbo_offset_x/y`. But that was misguided (of me)
because gnome-shell can give us paint volumes at negative coordinates too,
like when rendering `box-shadow` on the top or left edge of an actor.
The maximum extents of negative coordinates we might need to render are
in fact the (enlarged) left and top edges of the paint volume. So use
those as the FBO offset. This places the actor's local origin correctly
within the FBO and thus also ensures it's not over-clipped at the edges
of the FBO, which now line up with the enlarged extents of the paint
volume.
This fixes one third of
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1090
The other fixes required are !1053 and gnome-shell!1417.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1538>
Apparently it can happen that a timeline tries to pick a frame clock
from an actor that's on a stage, but the actor still doesn't find a
frame clock and returns NULL.
This probably is the case when starting a timeline right after attaching
an actor to a newly created stage, so before the first stage-update
cycle. In this case clutter_actor_update_stage_views() will not have run
and the stage-actor will have priv->stage_views set to NULL even though
there are stage views.
To prevent this from happening, use the complete list of stage views
maintained by the backend when picking a frame clock for the stage.
This doesn't fix any issue appearing on master, but is correct
nonetheless.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1631>
Instead of using native backend platform data specifically, store
this info in ClutterMotionEvent. This includes time in usec since
it's just used for motion events, in the future it could make sense
to make these general to all events again, but it could make sense
to make ClutterEvent structs private before.
In order to express that a motion event has relative motion info,
the CLUTTER_EVENT_FLAG_RELATIVE_MOTION event flag has been added
for it.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
We had code in both backends that sort of independently associated
sequences to slots. Make both transform slots to sequences the same
way, so they may share the implementation convert those back to slots.
This helper now lives in Clutter API.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
We have this as platform-dependent data in the native backend, and
a bunch of fallback code done in place in the evcode users. Stop
making this platform-dependent data, and move it to the relevant
ClutterEvents.
The fallback code for the X11 backend case is about the same, but
now it is done directly by the X11 backend.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
Making this an event is overly convoluted, accounting that we
emit the event, then convert it to a ClutterStage signal, then
its only consumer (a11y) sets the active ATK state.
Take the event out of the equation, unify activation/deactivation
of the stage in MetaStage, and use it from the X11 backend too.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
It is not possible to express a blit operation using paint
nodes as of now. This is a requirement for GNOME Shell, e.g.,
to implement its blur effect.
Add a new ClutterBlitNode node that takes two framebuffers as
input, and blits the source framebuffer into the current one
according to added rectangles.
Because this paint node uses the rectangles in a different way
compared to all the other nodes, add an auxiliary method to
ensure all blit operations are valid.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
ClutterLayerNode is the "offscreen framebuffer" node, that paints it's
child nodes in a separate framebuffer, and then copies that framebuffer
to the parent one.
It'll be useful to hand ClutterLayerNode which framebuffer and pipeline
to use, as this is a requirement for porting e.g. ClutterOffscreenEffect
and subclasses.
Add a new clutter_layer_node_new_to_framebuffer() API.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
Some effects, such as ShellBlurEffect and ClutterOffscreenEffect, need
to make sure the actor is painted fully opaque. With ClutterActorNode,
however, that is currently not possible.
Add a new 'opacity' parameter to clutter_actor_node_new(). It follows
the opacity override heuristic, where -1 means disable, and anything
else is clamped to [0, 255].
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
Introduce a new paint_node vfunc that, if implemented, allows
the effect to add nodes to a transient paint node that is
immediately painted. This is a transitional step until we
have fully delegated paint node rendering.
The most basic implementation of a ClutterEffect.paint_node
vfunc, and also the default implementation, is with an actor
node, as follows:
```
static void
foo_bar_paint_node (ClutterEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context,
ClutterEffectPaintFlags flags)
{
g_autoptr (ClutterPaintNode) actor_node = NULL;
actor_node = clutter_actor_node_new (effect->actor);
clutter_paint_node_add_child (node, actor_node);
}
```
This example gives the exact same behavior of simply calling
clutter_actor_continue_paint(). In the future, the paint node
itself will be a parameter of clutter_actor_continue_paint()
and we'll be able to simplify it event more.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
ClutterEffectNode is a private ClutterPaintNode implementation
that does effectively nothing, but helps organizing the paint
node tree. It also helps debugging, since it can output the
effect class and name to the JSON debugging routines.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
The idea of having a paint node tree is that we don't really need
to retrieve the framebuffer from ClutterPaintContext. For example,
ClutterLayerNode draws into an offscreen framebuffer; if any child
of a layer node needs to retrieve a framebuffer to draw, the layer
node's offscreen framebuffer should be used.
However, clutter_paint_node_get_framebuffer() goes straight to the
root node of the tree, skipping any potential paint nodes with a
custom framebuffer.
Modify clutter_paint_node_get_framebuffer() to walk up the paint
node tree until a node with a custom framebuffer appears. In many
cases, this will end up either in dummy or layer node's custom
framebuffer implementations.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
Fixes a compiler warning with -Wmaybe-uninitialized enabled:
../../../../Source/gnome/mutter/clutter/clutter/clutter-actor.c: In function ‘clutter_actor_paint’:
../../../../Source/gnome/mutter/clutter/clutter/clutter-actor.c:3808:50: warning: ‘result’ may be used uninitialized in this function [-Wmaybe-uninitialized]
3808 | else if (result == CLUTTER_CULL_RESULT_OUT && success)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Which might presumably happen in the unlikely case that there's no clip
frusta.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1624>
Instead of going through the event queue, stage handling code, and
back to the input device via a vmethod call, do this directly in the
MetaSeatImpl. This is not too different from X11, where everything
happens inside the backend.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
All that is left in the "public" struct is all state that ClutterStage
delegates on ClutterInputDevice. That should move somewhere else, but
not here, not now.
All private fields belong to construct-only properties, with only getter
API, and idempotent vmethods (except keyboard a11y, atm). This should
be enough to make ClutterInputDevice obviously thread safe, outside the
backend.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
Depending on the backend, we want to integrate this object at different
levels. It will sit close to the MetaBackendX11/MetaSeatX11 in X11, but
it will be put deep down with MetaSeatImpl in the native backend, in a
separate thread.
Since we can't depend on a single object type, nor are able to track
ClutterSeat signals neatly, make this API something to be called
explicitly by backends.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This will query a device state; position and modifiers.
Note that ClutterSeat subclasses don't implement the vmethod yet,
so calling clutter_seat_query_state() may crash ATM.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
Testing points and rays against boxes is substantially cheaper - in
fact, almost trivial - compared to triangles. Check if the actor's
paint volume doesn't intersect with the current pick point / ray,
and skip recursing altogether in those cases.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
The cached pick mode never actually cached anything, since it is
always, unconditionally reset when painting. Furthermore, next
commits will cull out actors during pick, which makes the pick
stack uncacheable.
Remove the cached pick mode.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
Users of Debian arm64 (aarch64) report that on at least some GPUs
or screens, after time-based screen blanking has occurred, it is not
possible to unlock the screen. Bisection indicates that this regressed
in commit 209b1ba3, so presumably this is because a refresh rate of 0
is reported while the screen is blanked, leading to the frame clock
pausing forever.
Fixes: 209b1ba3 "clutter/frame-clock: Adapt refresh rate from to frame info"
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1536
Bug-Debian: https://bugs.debian.org/974172
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1601>