Commit Graph

7494 Commits

Author SHA1 Message Date
Carlos Garnacho
49b3ac2f86 clutter: Drop CLUTTER_CLIENT_MESSAGE event
This is used nowhere and emitted nowhere. We can do without it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Georges Basile Stavracas Neto
033423f6db Introduce ClutterBlitNode
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>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
4c75389baa clutter/paint-nodes: Add serialization to layer node
It's useful to know which framebuffer the layer node is holding,
so serialize that too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
63ea2dacc4 clutter/paint-nodes: Add new ClutterLayerNode API
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>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
89f9be0dd1 clutter/paint-nodes: Add opacity overriding to ClutterActorNode
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>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
5c772a634e clutter/effect: Add paint_node vfunc
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>
2020-12-08 15:14:03 +00:00
Georges Basile Stavracas Neto
e45d1c6ea6 Introduce ClutterEffectNode
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>
2020-12-08 15:14:03 +00:00
Georges Basile Stavracas Neto
3c8bfc1482 clutter/paint-node: Walk up paint node tree to find framebuffer
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>
2020-12-08 15:14:03 +00:00
Carlos Garnacho
14ab90eeba clutter/actor: Initialize out variable
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>
2020-12-08 13:35:50 +00:00
Daniel van Vugt
e91062aaec clutter/pick-stack: Add a copyright for Canonical
Where much of the logic was introduced in commit 14c706e51b

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1619>
2020-12-01 12:54:41 +00:00
Carlos Garnacho
424f3b702e clutter: Do not emit signals during ClutterBackend finalization
Missed because nobody does that ATM.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
2ff5bb4299 backends/native: Update keyboard a11y status in seat impl
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>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
f117a157dc clutter: Add vmethod to find out group for pad features
Do it so the wayland bits don't have to access native input devices
internals. The data is still readonly, idempotent, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
e0444a3d35 clutter: Move ClutterInputDevice fields to private struct
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>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
71b4c0ee02 clutter: Drop keycode_to_evdev vmethod
This is just used in the native backend, move it to an utility
function there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
c7f989c1e2 clutter: Drop ClutterInputDevice private tool maintenance API
This is just used in the native backend (with the X11 going its own
way). Just keep a HT of tools there, and drop this API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
06d577fdf3 clutter: Move scroll valuator accounting to backends/x11
This is just used there. Another X11 detail that got open coded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
d7d92b0ddc clutter: Drop ClutterInputDevice axis API
Most of this comes from X11 peculiarities that were open coded in
the Clutter ABI. We don't need this except in X11, so move this axis
handling there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
5689a843c7 clutter: Drop internal update_from_tool() vmethod
This is kinda pointless now, and will be made completely unneeded
by dropping device axes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
168ceb9905 backends: Forward event axes as array of ClutterInputAxes elements
Instead of encoding arrays in ways that we need the ClutterInputDevice
to decode them, use ClutterInputAxes as the array index.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e772f62ea7 clutter: Make axes part of the device tool
This info can be construct-only there, as opposed to devices.
Move this info to tools, so we can drop it from devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
be9c531ab9 clutter: Drop clutter_input_device_get_associated_device()
And the private setter. One may ask the seat for the pointer/keyboard
instead of asking the device for its counterpart.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c4fa5ef88a clutter: Drop clutter_input_device_get_physical_devices() API
This is unused, we have the seat for this kind of stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
699da157c7 clutter: Drop clutter_input_device_get_key()/n_keys API
And the corresponding setters. This is completely unused, and
unrecommended. In xkb we trust.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
d58e082500 clutter: Drop clutter_input_device_get_modifier_state() API
This is using ClutterSeat state queries underneath, let the only
caller do that, and drop this call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c6849a66e8 clutter: Drop clutter_input_device_get_coords() method
This is not device state anymore. It uses ClutterSeat API underneath,
so let callers do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
b789d38f68 clutter: Switch to GAsyncQueue for ClutterMainContext event queue
We will be moving to having events produced in one thread and consumed
in another. Make this an async event queue in preparation for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2c1558ddbd backends: Make device tracking at MetaInputSettings ad-hoc API
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>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c601a824e9 clutter: Update device for the current tool in backends
This should happen deeper in backends, not here in clutter-main.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2ceac4a296 clutter: Make ClutterSeat::handle_device_event vfunc more generic
Make it able to handle not just device added/removed events, but perform
any kind of post-processing that needed to be done on ClutterEvents at
the seat level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c3acaeb251 backends: Move keyboard a11y into backends
And out of Clutter API. This is mainly set via settings, or the windowing
itself, so we don't need to leak these details up our own backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
b1d12a994d clutter: Drop ClutterInputDevice::enabled and setter/getter
This is unused now, and not something we generally allow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
dea909aea7 clutter: Simplify backend-independent touch accounting
Coordinates are tracked by the ClutterSeat backends, we just need to
track the target actor at this level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2411460cff clutter: Drop clutter_input_device_set_coords()
Input devices aren't "updated" anymore, but their state queried to the
seat. This goes nowhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
3234ae2993 clutter: Drop clutter_input_device_update_from_event()
Input devices aren't "updated" anymore, but their state queried to
the seat instead. This API was only meant for embedders of Clutter,
and is pointless to us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
730da1dbe1 clutter: Pass base event to clutter_input_device_update()
So we may fetch coordinates without necessarily querying the device
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
932a5cab09 clutter: Drop clutter_input_device_set_state()
Nothing uses it anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
cb7794c19c clutter: Use ClutterSeat underneath coords/modifiers input device getters
This is not device state, but belonging to seat guts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
fba1122a3c clutter: Add ClutterSeat::query_state() vmethod
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>
2020-11-27 15:14:33 +00:00
Daniel van Vugt
17dbb98811 clutter/stage: Remove fps_timer
It's unused since a9a9a0d1c5.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1603>
2020-11-26 11:03:08 +00:00
Georges Basile Stavracas Neto
6c4b897d74 clutter/actor: Cull out when picking
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>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
1fdde25b3e clutter/paint-volume: Add new API to convert to graphene_box_t
Will be used to cull when picking based on the actor's projected
paint volume.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
c3534d3390 clutter/pick-context: Store point and ray on construction
It'll be used to do a quick box test to cull out while picking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
1b29d265a8 clutter/stage: Remove cached pick mode
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>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
3073aee7c8 clutter/pick-stack: Add autoptr support
It'll allow us use g_autoptr (ClutterPickStack) when removing the pick stack
cache, making the code a bit more modern.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Simon McVittie
1a1f1eccba clutter/frame-clock: Schedule a frame at least once per second
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>
2020-11-25 10:14:10 +00:00
Jonas Dreßler
58930e9e1f clutter/actor: Use a variable to check if culling is allowed
Since we now want to check whether culling is force-disabled using a
debug flag in two places, let's factor this out into a separate
variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1591>
2020-11-25 01:08:02 +01:00
Jonas Dreßler
0320649a1c clutter/actor: Always update last_paint_volumes during painting
It's currently possible that some last_paint_volumes don't get updated
during a paint cycle, this can happen when a ClutterOffscreenEffect is
used: The offscreen effect might skip painting the content and the
children of an actor because it uses its own offscreened texture
instead. This means the offscreen effect doesn't call
clutter_actor_continue_paint(), and thus the the last_paint_volumes of
the children won't be updated.

Now one might think that isn't a problem, because as soon as a child
changes it's size or position, the offscreened texture would get
invalidated and clutter_actor_continue_paint() would get called. It's
not that easy though: Because the last_paint_volume includes all the
transformation matrices up to eye-coordinates, it has to be updated on
any changes to matrices, which includes position/transformation changes
to any actor up the hierarchy.

Now that's where get into problems with the offscreen effect: In case of
transformation changes to the offscreened actor or an actor up the
hierarchy, the offscreened texture won't get invalidated (that makes
sense, we can simply paint it transformed) and the last_paint_volumes
won't get updated even though they should.

This leaves us around with outdated last_paint_volumes where
last_paint_volume_valid is still set to TRUE. It can cause issues with
culling and clipped redraws.

So fix that by ensuring that all children that would get painted by
Clutter get their last_paint_volumes updated in case a ClutterEffect
decided not to call clutter_actor_continue_paint().

This ignores the case where a paint() vfunc override does the same and
doesn't call clutter_actor_paint() on children. Let's ignore this case
for now, there shouldn't be any implementation which does that and
ideally in a world that's painted solely by ClutterContent, we can get
rid of that vfunc in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1591>
2020-11-25 01:07:32 +01:00
Jonas Dreßler
0da8a49719 clutter/stage: Clarify comments in add_to_stage_clip() a bit
The first comment isn't really needed anymore since
the is_full_stage_redraw_queued() underneath is quite self-explaining.

Also rephrase the second comment a bit, including that
_clutter_paint_volume_get_stage_paint_box() does the aligning to the
pixel grid.

Finally, the last comment also looks out of date since we do that
rounding inside _clutter_paint_volume_get_stage_paint_box(), so remove
it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00
Jonas Dreßler
906124b09f clutter/stage: Don't pass QueueRedrawEntries to actors
We currently pass actors a reference to their associated
ClutterStageQueueRedrawEntry when queueing a redraw. This "splitting" of
the ownership of the entry has introduced quite a few bugs in the past
and is hard to follow.

So give up the "splitting" of the ownership and exclusively handle those
entries inside ClutterStage. To still allow removing the entry when an
actor gets unrealized introduce clutter_stage_dequeue_actor_redraw()
similar to what we already have for relayouts.

To be able to efficiently find entries when actors queue redraws, make
pending_queue_redraws a GHashTable, which fits quite nicely and also
allows removing the QueueRedrawEntries actor pointer in favour of the
key of the hashtable.

Since the struct is now private to ClutterStage, we can also rename it
to QueueRedrawEntry.

While at it, also sneak in the removal of the leading underscore from
clutter_stage_queue_actor_redraw().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00