Commit Graph

7382 Commits

Author SHA1 Message Date
Jonas Ådahl
3944daf3c0 clutter/stage: Find devices to update after finish queue redraw
Devices are updated (repicked) as part of the stage update phase, as
their stacking, position and transform might have changed since since
the last update.

The redraw clip was used to avoid unnecessary updating of devices, if
the device in question had it's position outside of the redraw clip. If
the device coordinate was outside of the redraw clip, what was
underneith the device couldn't have changed.

What it failed to do, however, was to update devices if a relayout had
happened in the same update, as it checked the state whether a layout
had happened before attempting to do a relayout, effectively delaying
the device updating to the next update.

This commit changes the behavior to always update the device given the
complete redraw clip caused by all possible relayouts of the same update
as the device update happens in.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
b45cea301e clutter/stage: Rename find-devices-to-update function
It doesn't only update pointers, and it finds which ones to eventually
update.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
14dfe929f2 clutter/stage: Move out tracing from do_update() to callees
This makes the function a bit more cluttered, and it'll always trace
when the same functions are called from other places.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
b9a52ecfdf screen-cast: Only check queued-redraw on the relevant views
We'd check if there was any queued redraw on the stage, but this is
inappropriate for two reasons:

1) A monitor and area screen cast source only cares about damage on a
   subset of the stage.
2) The global pending-redraw is going away when paint scheduling will be
   more view centric.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
33450700dc clutter/stage: Add 'pending_finish_queue_redraws' state
This will allow anyone to finish any queued redraws making their
corresponding damage end up being posted to the stage views. This will
allow units to check whether, so far, any updates are queued on a
particular stage view.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
62f251574f clutter/stage: Always check stage views when checking for full redraw
It's an optimization to check whether there are any redraws on the stage
by checking the 'redraw-pending' field. That field is going away, so
remove that optimization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
59eebd6f6d clutter/stage-view: Pass a pointer to the stage during constuction
This is so that stage views can interact with the stage they are views
of.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
9b054f4a1b clutter/timeline: Add running timeline to frameclock if it changes
It's intended that timelines can change frame clock while running; but
up until now it'd only add itself if the frame clock was set when
started.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
f31a7acab5 clutter/timeline: Add helpers to remove/add timeline to some frame clock
Either the master clock or assigned frame clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
c302f4d379 frame-clock: Make it possible to drive timelines
Add API to add and remove ClutterTimeline objects to the frame clock.
Just as the legacy master clock, having a timeline added to the frame
clock causes the frame clock to continuously reschedule updates until
the timeline is removed.

ClutterTimeline is adapted to be able to be driven by a
ClutterFrameClock. This is done by adding a 'frame-clock' property, and
if set, the timeline will add and remove itself to the frame clock
instead of the master clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
3c4efd13c1 frame-clock: Pass timestamp to frame callback
The timestamp comes from the GSource, meaning it's a more accurate
representation of when the frame started to be dispatched compared to
getting the current time in any callback.

Currently unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
9676db4dbf clutter/master-clock: Move out private timeline declarations
They are intended to be used by other objects than the master clock, so
don't keep the declaration there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
a132c8dc8e frame-clock: Add API to inhibit/uninhibit updates
Equivalent to pause/resume, but ref counted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
cae5b99537 frame-clock: Add callback before the actual frame callback
Aimed to have the frame listener do things like processing events before
the actual frame. In between the before-frame and actual frame,
timelines will be advanced.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
6ffdfff9ee frame-clock: Add basic tracing
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
7e27fb6d56 clutter/frame-clock: Add API to schedule next frame immediately
Aimed to replace the 'skip-sync-delay' mechanism currently used by
XSyncAlarmNotify to schedule an more immediate redraw.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
e743b36cfc clutter/frame-clock: Handle immediate present feedback
In certain scenarios, the frame clock needs to handle present feedback
long before the assumed presentation time happens. To avoid scheduling
the next frame to soon, avoid scheduling one if we were presented half a
frame interval within the last expected presentation time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
96a108ed4e clutter: Add a simple frame clock base
This adds a current unused, apart from tests, frame clock. It just
reschedules given a refresh rate, based on presentation time feedback.

The aiming for it is to be used with a single frame listener (stage
views) that will notify when a frame is presented. It does not aim to
handle multiple frame listeners, instead, it's assumed that different
frame listeners will use their own frame clocks.

Also add a test that verifies that the basic functionality works.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
da633dcc52 clutter/actor: Allocate with the same box if deferred due to transition
When a transition is created for the allocation change, it will delay
the new allocation box getting set depending on transition details.
This, however, means that e.g. the 'needs_allocation' flag never gets
cleared if a transition is created, causing other parts of the code to
get confused thinking it didn't pass through a layout step before paint.

Fix this by calling clutter_actor_allocate_internal() with the current
allocation box if a transition was created, so that we'll properly clear
'needs_allocation' flag.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1345
2020-07-02 17:35:41 +02:00
Jonas Dreßler
df4eeff6f2 clutter/actor: Invalidate stage-views on transformation changes
Since we now have the neccessary infrastructure to get notified about
changes to the absolute transformation matrix, we can also invalidate
the stage-views list on updates to this matrix.

So rename absolute_allocation_changed() to absolute_geometry_changed()
to make it clear this function is not only about allocations, and call
that function recursively for all children on changes to the
transformation matrix, too.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1343
2020-06-30 20:03:53 +02:00
Jonas Dreßler
64304b0b68 clutter/actor: Cache transformations applied using apply_transform vfunc
If we want to invalidate the stage-views list reliably on changes to the
actors transformation matrices, we also need to get notified about
changes to the custom transformations applied using the
apply_transform() vfunc.

So provide a new API that allows invalidating the transformation matrix
for actors implementing custom transformations, too. This in turn allows
us to cache the matrix applied using the apply_transform() vfunc by
moving responsibility of keeping track of the caching from
clutter_actor_real_apply_transform() to
_clutter_actor_apply_modelview_transform().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1343
2020-06-30 19:59:38 +02:00
Jonas Dreßler
c5159e3184 clutter/text: Enable relayout on resource-scale changes
ClutterText needs a new allocation on resource-scale changes, which we
added proper support for in the last commit, so use that API for
ClutterText.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
280429bac8 clutter: Add private API to support resource scale affecting layout
For ClutterText, the resource scale the text is drawn with affects the
size of the allocation: ClutterText will choose a font scale based on
the resource scale, and that font scale can lead to a slight difference
in size compared to the unscaled font.

We currently handle that by queuing a relayout inside the
"resource-scale-changed" signal handler. This solution is a bit
problematic though since it will take one more allocation cycle until
the allocation is actually updated after a scale-change, so the actor is
painted using the wrong allocation for one frame.

Also the current solution can lead to relayout loops in a few cases, for
example if a ClutterText is located near the edge on a 1x scaled monitor
and is moved to intersect a 2x scaled monitor: Now the resource scale
will change to 2 and a new allocation box is calculated; if this
allocation box is slightly smaller than the old one because of the new
font scale, the allocation won't intersect the 2x scaled monitor again
and the resource scale switches back to 1. Now the allocation gets
larger again and intersects the 2x scaled monitor again.

This commit introduces a way to properly support those actors: In case
an actors resource scale might affect its allocation, it should call the
private function clutter_actor_queue_immediate_relayout(). This will
make sure the actor gets a relayout before the upcoming paint happens
afte every resource scale change. Also potential relayout loops can
be handled by the actors themselves using a "phase" argument that's
passed to implementations of the calculate_resource_scale() vfunc.

The new API is private because resource scales are not meant to be used
in a way where the scale affects the allocation. With ClutterText and
the current behavior of Pango, that can't be avoid though, so we need it
anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
98df2dbd05 clutter/actor: Always return a resource scale in get_resource_scale()
Since we now always return a resource scale, we can remove the boolean
return value from clutter_actor_get_resource_scale() and
_clutter_actor_get_real_resource_scale(), and instead simply return the
scale.

While at it, also remove the underscore from the
_clutter_actor_get_real_resource_scale() private API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
4a72ac0516 clutter/actor: Use stage-views list for resource scales
Now that ClutterActor has a convenient API for getting the stage views
an actor is presented on, we can remove a large part of the code for
resource-scale calculation and instead rely on the stage-views list.

The way this works is a bit different from the old resource scales:
clutter_actor_get_resource_scale() always returns a scale, but this
value is only guaranteed to be correct when called from a vfunc_paint()
implementation, in all other cases the value is guessed using the scale
of the parent actor or the last valid scale. Now in case the value
previously reported by clutter_actor_get_resource_scale() turns out to
be wrong, "resource-scale-changed" will be emitted before the next paint
and the actor has a chance to update its resources.

The general idea behind this new implementation is for actors which only
need the scale during painting to continue using
clutter_actor_get_resource_scale() as they do right now, and for actors
which need the resource scale on other occasions, like during size
negotiation, to use the scale reported by
clutter_actor_get_resource_scale() but also listen to the
"resource-scale-changed" signal to eventually redo the work using the
correct scale.

The "guessing" of the scale is done with the intention of always giving
actors a scale to work with so they don't have to fall back to a scale
value the actor itself has to define, and also with the intention of
emitting the "resource-scale-changed" signal as rarely as possible, so
that when an actor is newly created, it won't have to load its resources
multiple times.

The big advantage this has over the old resource scales is that it's now
safe to call clutter_actor_get_resource_scale() from everywhere (before,
calling it from size negotiation functions would usually fail). It will
also make it a lot easier to use the resource scale for complex cases
like ClutterText without risking to get into relayout loops.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
802b24a640 clutter/backend: Introduce a fallback scale set to primary monitor scale
Add private API to ClutterBackend to set a fallback resource scale
available to Clutter. This API will be used for "guessing" the
resource-scale of ClutterActors in case the actor is not attached to a
stage or not properly positioned yet.

We set this value from inside mutters MetaRenderer while creating new
stage-views for each logical monitor. This makes it possible to set the
fallback scale to the scale of the primary monitor, which is the monitor
where most ClutterActors are going to be positioned.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
162aec7802 clutter: Replace ClutterActors resource-scale property with a signal
We're going to refactor resource scales, making the notification of
changes to the resource scale a lot more important than it is right now
(we won't guarantee queried scales are correct outside the paint cycle
anymore).

Having a separate signal/vfunc for this will make the difference between
the new clutter_actor_get_resource_scale() API (which can return a
guessed value) and the notification of changes to the resource scale
(which will be guaranteed to return an up-to-date value) more obvious.

So replace the "resource-scale" property of ClutterActor with a
"resource-scale-changed" signal that's emitted when the resource scale
is recalculated.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
2020-06-30 13:15:53 +00:00
Jonas Dreßler
37256cb76b clutter/box-layout: Request the correct size for homogeneous layouts
In case the layout is homogeneous, all children aligned by the box
layout must be allocated the same size. In order to fit them all inside
the container, the size request of the box layout has to look for the
child with the largest size and use that size for all children.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2737

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1333
2020-06-29 12:15:06 +02:00
Jonas Dreßler
7f12099ead clutter/box-layout: Add spacing when computing opposite orientation size
ClutterBoxLayout calculates the preferred size of the opposite
orientation (so for example the height if the orientation is horizontal)
by getting the preferred size of the real orientation first, and then
the preferred size of the opposite orientation, using the other size as
for_width/height when doing the request.

Right now, for non-homogeneous layouts this for_width/height does not
adjust for the spacing set on the box layout. This leads to children
being passed a slightly larger for_width/height, which in case of
ClutterText might cause the line to not wrap when it actually should.
This in turn means we can end up with an incorrect preferred size for
the opposite orientation, leading to a wrong allocation.

So fix that and adjust for the spacing just as we do for homogeneous
layouts by subtracting the total spacing from the available size that is
distributed between children.

This fixes the wrong height of the checkbox label reported in
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2574.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1333
2020-06-29 10:07:26 +02:00
Georges Basile Stavracas Neto
7146a6dddb clutter/actor: Remove anchor points and gravity
Drop the bomb.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
dbce29a0ae clutter/actor: Remove scale center and gravity
They're deprecated and, as of now, unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
dc4cb562b7 clutter/actor: Remove rotation center
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
2e086c74e7 Drop ClutterRectangle
And the correcponding CallyRectangle class.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
2802d359e5 Drop ClutterBox
Nobody was subclassing or using it, except for the tests. Replace
it by ClutterActor in the tests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
d54b10b366 clutter/timeline: Remove empty deprecated header
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
d4993c4b22 clutter/stage: Remove all deprecated functions
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
ae49f89cf3 clutter/stage: Remove color property
The property is deprecated and the current implementation simply
redirects it to ClutterActor::background-color, so remove it.

Also update the tests to set the background color directly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
ce3e293a18 clutter: Drop ClutterGroup
It is now unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
8d83dec044 clutter/stage: Subclass ClutterActor
ClutterStage is the one and only subclass of ClutterGroup, but
it overrides basically everything specific to ClutterGroup to
mimic a ClutterActor. What a waste!

Subclass ClutterActor directly and remove all the now useless
vfunc overrides from ClutterStage. Adapt CallyStage to subclass
CallyActor as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
d4953c77c3 clutter/actor: Remove clutter_actor_show_all
Actors are visible by default these days, and this function
is deprecated for a long time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
237f277641 clutter/actor: Remove clutter_actor_unparent
Pretty much the same set of changes of the previous commit, but
for clutter_actor_unparent().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
59e454f01e clutter/actor: Remove clutter_actor_set_parent
Replace it by clutter_actor_add_child(), and update ClutterGroup
to not emit the 'actor-added' anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
0b4cf9c65f clutter/actor: Remove push/pop_internal declarations
They don't even exist anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
82b710688b clutter/main: Remove clutter_get_actor_by_gid
It's unused and doesn't return anything useful these days.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Georges Basile Stavracas Neto
387a13f0ab clutter/actor: Drop depth property and functions
It is deprecated in favor of the 'z-position' property, and
the implementation itself redirects to the z-position, so
just drop it and replace all get|set_depth calls to their
z-position counterparts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Daniel van Vugt
f511f94aa2 clutter-stage-cogl: Fix uninitialized variable use_clipped_redraw
I noticed my system would fall back to the slow unclipped (and
uncullable) paint path whenever a window touched the left edge of
the screen. Turns out that was a red herring. Just that
`use_clipped_redraw` was uninitialized so clipping/culling was used
randomly.

So the compiler failed to notice `use_clipped_redraw` was uninitialized.
Weirdly, as soon as you fix that it starts complaining that `buffer_age`
might be uninitialized, which appears to be wrong. So we initialize that
too, to shut up the compiler warnings/errors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1323
2020-06-23 09:11:54 +00:00
Jonas Dreßler
5c5dcd58b5 bind-constraint: Don't update preferred size if source contains actor
The ClutterBindConstraint will change the preferred size an actor
reports so it returns the same size as the source actor in some cases.
This behavior was introduced recently with 4f8e518d.

This can lead to infinite loops in case the source actor is a parent of
the actor the BindConstraint is attached to, that's because calling
get_preferred_size() on the source will recursively call
get_preferred_size() on the actor again.

So to avoid those loops, check if the source is a parent of the actor
we're attached to and don't update the preferred size in that case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1282
2020-06-19 14:59:27 +00:00
Jonas Dreßler
6ea0f8facc clutter/clone: Build scale factor for transformation during allocation
For ClutterClones we need to apply a scale to the texture of the clone
to ensure the painted texture of the source actor actually fits the
allocation of the clone. We're doing this using the transformation
matrix instead of using the scale_x/scale_y properties of ClutterActor
to allow users to scale ClutterClones using that API independently.

Now it's quite a bad idea to get the allocation boxes for calculating
that scale using clutter_actor_get_allocation_box(), since that method
will internally do an immediate relayout of the stage in case the actor
isn't allocated. Another side effect of that approach is that it makes
it impossible to invalidate the transform (which will be needed when we
start caching those matrices) properly.

So since we eventually allocate both the source actor and the clone
ourselves anyway, we can simply use the allocation box inside
clutter_clone_allocate() (which is definitely updated and valid at that
point) to calculate the scale factor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1181
2020-06-18 20:19:07 +00:00
Jonas Dreßler
0c1e5b4ee5 clutter/clone: Use scale factor of 1.0 for Z axis
It seems wrong to use the scale factor of the X axis on the Z axis and
it looks like this has been accidentally changed in commit 570fa3f044.

So use a factor of 1.0 instead to not scale the Z axis at all because
the layout machinery only works in X and Y coordinates.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1181
2020-06-18 20:19:07 +00:00
Jonas Dreßler
ad50d2cfc4 clutter/actor: Always query layout manager when getting size
There are cases where a layout manager used by an actor also wants to
return a custom size when the actor has no children, for example in case
the layout manager requests a fixed size. This is currently impossible
because we only query the layout manager when calculating the preferred
size if the actor has children.

So fix that and also use the layout managers size negotiation functions
in case the actor has no children.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1322
2020-06-18 21:16:17 +02:00
Sebastian Keller
e216d9c6ad clutter/stage: Make paint_to_buffer use the correct texture/buffer size
The size of the buffer the texture will be written to by
paint_to_buffer() is determined based on
meta_screen_cast_area_stream_src_get_specs() which uses roundf() to
calculate the width and height after scaling. Because the size of the
texture to be written to that buffer is calculated using ceilf(), it
might exceed the allocated buffer when using fractional scaling.

In 3.36 paint_to_buffer() is used from capture_view() which also uses
roundf() to allocate its buffer. Here this leads to a memory corruption
resulting in a crash when taking screenshots of an area.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2842

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1320
2020-06-17 16:14:57 +00:00
Jonas Dreßler
0ab1a9fa44 clutter/actor: Clean up clutter_actor_event()
We can easily do without the goto statement and use only one switch
statement in this function, so tidy it up a bit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:27 +00:00
Jonas Dreßler
cb0cc42651 clutter: Also remove event sequences on TOUCH_CANCEL events
We don't want to leave event sequences around when touches are
cancelled, so also remove those from the ClutterInputDevice's hashtable.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
b36cfb5bdc clutter/stage: Don't update modifier state when queuing event
The modifier state of the input device is supposed to be set to the
newest state, while the modifier state detail of the event is set to the
last state before the event (so not including the changes triggered by
the event).

So since the modifier state of the event is the last state anyway, the
state of the ClutterInputDevice is supposed to be set by the backend and
not by the stage while queuing the event, so stop setting the state
here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
7539de2320 clutter/input-device: Make clutter_input_device_get_actor() public
Make the clutter_input_device_get_actor() API public and remove
clutter_input_device_get_pointer_actor() in favour of the new function.

This allows also getting the "pointer" actor for a given touch sequence,
not only for real pointer input devices like mice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
8de91f1053 clutter/stage: Switch to clutter_seat_peek_devices()
Switch from clutter_seat_list_devices() to the new peek_devices() method
of ClutterSeat in cases where we're only looping through the returned
list without manipulating it. This way we don't have to unnecessarily
copy around the list of devices.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
45c14f74b4 clutter/seat: Add private method to peek list of input devices
Add a method to ClutterSeat that allows peeking the list of input
devices and allow looping through devices a bit faster. The API left is
private so we can make use of peeking the GList internally, but don't
have to expose any details to the outside, which means we'd have to
eventually stick with a GList forever to avoid breaking API.

Since we now have the peek_devices() API internally, we can implement
ClutterSeats public list_devices() API using g_list_copy() on the list
returned by peek_devices().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
d4457d1f7f clutter/seat: Fix a typo in an introspection doc
Make sure that function is actually skipped, gobject-introspection
should probably complain about that function which can't be found.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
0ba15df57c clutter/stage: Don't do newly queued relayouts after allocation cycle
While it's strongly discouraged, it is possible to queue a new relayout
of an actor in the middle of an allocation cycle, we warn about it but
don't forbid it.

With the introduction of the "shallow relayout" API, our handling of
those relayouts silently changed: Before introducing "shallow
relayouts", we'd handle them on the next stage update, but with the
priv->pending_relayouts hashtable and the
priv->pending_relayouts_version counter, we now do them immediately
during the same allocation cycle (the counter is increased by 1 when
queuing the relayout and we switch to a new GHashTableIter after
finishing the current relayout, which means we'll now do the newly
queued relayout).

This change in behavior was probably not intended and wasn't mentioned
in the commit message of 5257c6ecc2, so
switch back to the old behavior, which is more robust in preventing
allocation-loops. To do this, use a GSList instead of GHashTable for the
pending_relayouts list, and simply steal that list before doing the
relayouts in _clutter_stage_maybe_relayout().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1267
2020-06-16 09:39:43 +00:00
Corentin Noël
6414b8c45f clutter/stage: Set the right type for the paint-view argument
As it is a cairo_region_t, we can proide the right GType value for it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1313
2020-06-11 23:01:39 +02:00
Jonas Dreßler
77d359cdc3 clutter/align-constraint: Don't take source actors position into account
ClutterAlignConstraint currently assumes the source actor is positioned
in the same coordinate system as the actor it's attached to and
automatically offsets the adjusted allocation by the origin of the
source actor.

This behavior is only valid though in case the source actor is a sibling
of the constraint actor. If the source actor is somewhere else in the
actor tree, the behavior gets annoying because the constraint actor is
offset by (seemingly) random positions.

To fix this, stop offsetting the constraint actors allocation by the
position of the source.

To still make it possible to align the constraint actors origin with the
origin of the source, no longer override the origin of the allocation
in the AlignConstraint. This allows users to align the origin using a
BindConstraint, binding the actor position to the position of the
source, which is more flexible and also more elegant.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/737
2020-06-10 19:20:32 +00:00
Jonas Dreßler
590b9b8c86 clutter/align-constraint: Add pivot-point property
Add a new pivot-point property to the ClutterAlignConstraint, similar to
the pivot point used by ClutterActor, defining the point in the
constraint actor around which the aligning is applied to the actor.

Just as the ClutterActor property, this property is defined using a
GraphenePoint.

By default this property remains set to (-1, -1) and the actor
will always be aligned inside the source actor, preserving the existing
behavior of ClutterAlignConstraint.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/737
2020-06-10 19:20:32 +00:00
Jonas Dreßler
620dcf3364 clutter/actor: Properly detect uninitialized allocations when easing
Now that we have a proper way to mark our allocation as uninitialized,
make use of that and only disallow implicit transitions of the
"allocation" property if that is the case.

This fixes a bug where easing the allocation of an actor is impossible
when someone queued a relayout on it (or a child of it) before.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1290
2020-06-10 14:23:54 +02:00
Jonas Dreßler
eb9cd3857d clutter/actor: Set initial allocation to uninitialized ClutterActorBox
We currently initialize the ClutterActorBox of the actors allocation to
zero, but there's a difference between a valid zero-allocation and an
actor having never been allocated. Currently it's impossible for us to
detect the latter case in a reliable way and we use the needs_allocation
flag for this, which may also be set in other situations.

So initialize the allocation of actors to the newly added UNINITIALIZED
ClutterActorBox, which will make it easier to detect whether an actor
already got its initial allocation.

This also fixes another issue right now: Actors which get allocated a
(valid) zero allocation, will now notify the "allocation" property in
this case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1290
2020-06-10 14:23:54 +02:00
Jonas Dreßler
0bfb995bff clutter/actor-box: Allow marking boxes as uninitialized
Add support for an artificial UNINITIALIZED marking for ClutterActorBox,
done by setting the boxes origin to Infinity and its size to -Infinity.
That is a value that's considered an invalid allocation by Clutter and
which can never be set by sane code.

This will allow setting the allocation of ClutterActors to an
UNINITIALIZED box when creating actors or when removing them from the
scenegraph and makes it possible to explicitely detect uninitialized
allocations, which is useful in a few cases.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1290
2020-06-10 14:22:47 +02:00
Georges Basile Stavracas Neto
268336c21a clutter/actor: Allow animating content properties
ClutterActor allows animating effects, constraints, actions,
and the layout manager for property transitions. Extend this
functionality to the content as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1301
2020-06-09 15:09:26 -03:00
Jonas Dreßler
0f97196d84 clutter/actor: Don't traverse whole actor tree for updating stage-views
We currently go through the whole tree of mapped actors on every paint
cycle to update the stage views actors are on. Even if no actors need
updating of their stage views, traversing the actor tree is still quite
expensive and shows up when using a profiler.

So tone down the amounts of full-tree traversals we have to do on every
paint cycle and only traverse a subtree if it includes an actor which
actually needs updating of its stage views.

We do that by setting the `needs_update_stage_views` flag to TRUE
recursively for all parents up to the stage when the stage-views list of
an actor gets invalidated. This way we end up updating a few more actors
than necessary, but can avoid searching the whole actor tree for actors
which have `needs_update_stage_views` set to TRUE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
18c792d6f8 clutter/actor: Emit a signal when the stage-views an actor is on change
Add a new signal that's emitted when the stage views an actor being
painted on have changed, "stage-views-changed". For example this signal
can be helpful when tracking whether an actor is painted on multiple
stage views or only one.

Since we must clear the stage-views list when an actor leaves the stage
(actors that aren't attached to a stage don't get notified about the
stage views being changed/replaced), we also emit the new signal when an
actor gets detached from the stage (otherwise there would be an edge
case where no signal is emitted but it really should: An actor is
visible on a stage view, then detached from the stage, and then attached
again and immeditely moved outside the view).

Also skip the comparison of the old stage-views list and the new one if
nobody is listening to the signal to save some resources.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
675a97d58e clutter/actor: Add API to get the stage-views an actor is painted on
There are certain rendering techniques and optimizations, for example
the unredirection of non-fullscreen windows, where information about the
output/stage-view an actor is on is needed to determine whether the
optimization can be enabled.

So add a new method to ClutterActor that allows listing the stage-views
the actor is being painted on: clutter_actor_peek_stage_views()

With the way Clutter works, the only point where we can reliably get
this information is during or right before the paint phase, when the
layout phase of the stage has been completed and no more changes to the
actors transformation matrices happen. So to get the stage views the
actor is on, introduce a new step that's done on every master clock tick
between layout and paint cycle: Traversing through the actor tree and
updating the stage-views the mapped actors are going to be painted on.

We're doing this in a separate step instead of inside
clutter_actor_paint() itself for a few reasons: It keeps the code
separate from the painting code, making profiling easier and issues
easier to track down (hopefully), it allows for a new
"stage-views-changed" signal that doesn't interfere with painting, and
finally, it will make it very easy to update the resource scales in the
same step in the future.

Currently, this list is only invalidated on allocation changes of
actors, but not on changes to the transformation matrices. That's
because there's no proper API to invalidate the transformation matrices
ClutterActor implementations can apply through the apply_transform()
vfunc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
8127494e52 clutter/stage: Rename update_resource_scales to clear_stage_views
When the stage views the stage is shown on are changed, ClutterStage
currently provides a clutter_stage_update_resource_scales() method
that allows invalidating the resource scales of all actors. With the new
stage-views API that's going to be added to ClutterActor, we also need a
method to invalidate the stage-views lists of actors in case the stage
views are rebuilt and fortunately we can re-use the infrastructure for
invalidating resource scales for that.

So since resource scales depend on the stage views an actor is on,
rename clutter_stage_update_resource_scales() and related methods to
clutter_stage_clear_stage_views(), which also covers resource scales.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
670f4f22fe clutter/stage: Remove _clutter_stage_get_max_view_scale_factor_for_rect
Since we now have _clutter_stage_get_views_for_rect(), we can easily
replace _clutter_stage_get_max_view_scale_factor_for_rect() with it and
remove that private method.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
e27d2702a8 clutter/stage: Add private method to get the stage-views of a rectangle
We'll need this method for implementing a new stage-views-on API for
ClutterActor which lists the stage views an actor is on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
Jonas Dreßler
90c20b185b clutter/actor: Disconnect from "layout-changed" signal on destroy
While the layout manager of a ClutterActor does get properly unset when
destroying an actor, we currently forget to disconnect the
"layout-changed" signal from it.

So do that, and while at it, also switch to using the signal id for
disconnecting from the signal instead of
g_signal_handlers_disconnect_by_func(), which caused problems before
because it might traverse the signal handler list.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1281
2020-06-08 17:23:05 +00:00
Jonas Dreßler
4d7c8d68bc clutter/actor: Mark offscreen-redirect property as flag everywhere
We currently are confusing g_param_spec_enum and g_param_spec_flags for
the offscreen-redirect property of ClutterActor. Since it's actually a
flag, make it a flag everywhere.

Fun fact: This was already partly done with
d7814cf63e, but that commit missed the
setter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1292
2020-06-08 15:25:11 +00:00
Jonas Dreßler
455de5d6d3 clutter/align-constraint: Listen to queue-relayout signal of source
Just like the ClutterBindConstraint, the ClutterAlignConstraint should
listen to "queue-relayout" of its source actor, not
"notify::allocation". That's because the latter will queue a relayout
during an allocation cycle and might cause relayout loops.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1296
2020-06-08 14:58:15 +00:00
Jonas Ådahl
01609de587 clutter/stage: Clear pick stack when hiding
Hiding a compositor stage is not something that's really supported, but
will still be used by tests, to get closer to a "fresh" stage for each
test case, when the tests eventually start using the mutter provided
stage.

It'll use that stage simply because creating standalone stages isn't
supported.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Jonas Ådahl
1a915f06cf clutter: Remove CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD
It was unused, and will simplify things when we're without a master
clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Jonas Ådahl
6754195580 clutter/script-parser: Don't skip construct parameters when constructing
The script parser only included G_PARAM_CONSTRUCT_ONLY parameters when
constructing objects. This causes issues if an object requires a
parameter to be set during construction, but may also change after. Fix
this by including G_PARAM_CONSTRUCT parameters when constructing script
objects as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Jonas Ådahl
9fc428f2e7 clutter/stage: Remove unused function clutter_stage_ensure_redraw()
Not used by anything, and redraws are eventually not going to be stage
global anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
Jonas Ådahl
a05dd813da clutter/timeline: Remove clutter_timeline_clone()
It was deprecated long ago, and users should switch to using te regular
constructors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
Jonas Ådahl
08b30d6fe2 clutter/timeline: Remove deprecated 'loop' property
It was since long ago replaced by a 'repeat-count' property.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
Jonas Ådahl
84f55d38dd clutter/pan-action: Clean up line lengths
The file stood out and was hard to read because lines were very long
compared to the rest of clutter and mutter. Clean that up by cutting
lines into pieces where appropriate.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
Jonas Ådahl
75b5e079cf clutter/timeline: Add meaning to constructor argument variable name
Start follow the convention used in ClutterFrameClock by including the
meaning as well as time granularity in the variable name. The
constructor takes the intended duration of the constructed timeline in
milli seconds, so call the constructor argument `duration_ms`. This is
done in preparation for adding more constuctors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
Jonas Dreßler
dcb42d3b25 clutter/actor: Sanity check new allocations
Apparently some shell extensions are setting invalid NaN allocations,
leading to weird crashes like
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849.

Even though an implementation error like this probably deserves a crash,
those can be hard to debug since the crash can happen anywhere the
allocation is being used later. So let Clutter be the good guy and
prevent implementations from setting invalid allocations by
sanity-checking the ClutterActorBoxes using g_return_if_fail.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1280
2020-06-02 20:53:12 +00:00
Jonas Dreßler
720360b07a clutter/actor: Don't allocate actors if only the absolute origin changed
For actors which don't have needs_allocation set to TRUE and where the
new allocation wouldn't be different from the old one, the allocate()
vfunc doesn't have to be called. We still did this in case a parent
actor was moved though (so the absolute origin changed), because we
needed to propagate the ABSOLUTE_ORIGIN_CHANGED allocation flag down to
all actors.

Since that flag is now removed and got replaced with a private property,
we can simply notify the children about the absolute allocation change
using the existing infrastructure and safely stop allocating children at
this point.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Jonas Dreßler
9b39e37fee clutter/actor: Notify hidden actors about absolute allocation changes
With commit 0eab73dc2e we introduced an optimization of not doing
allocations for actors which are hidden. This broke the propagation of
absolute origin changes to hidden actors, so if an actor is moved while
its child is hidden, the child will not get
priv->needs_compute_resource_scale set to TRUE, which means the resource
scale won't be updated when the child gets mapped and shown again.

Since we now have priv->absolute_origin_changed, we can simply check
whether that is TRUE for our parent before bailing out of
clutter_actor_allocate() and if it is, notify the whole hidden sub-tree
about the absolute origin change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Jonas Dreßler
38104755a2 clutter/stage: Make set_viewport() a static method
Since clutter_stage_set_viewport() is only used inside clutter-stage.c
anyway, we can make it a static method. Also we can remove the x and y
arguments from it since they're always set to 0 anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Jonas Dreßler
7abf0f1e2d clutter/stage: Set viewport without getting the last allocation
When getting the last allocation using
clutter_actor_get_allocation_box(), Clutter will do an immediate
relayout of the stage in case an actor has an invalid allocation. Since
the allocation is always invalid when the allocate() vfunc is called,
clutter_stage_allocate() always forces another allocation cycle.

To fix that, stop comparing the old allocation to the new one to find
out whether the viewport changed, but instead use the existing check in
_clutter_stage_set_viewport() and implement the behavior of rounding the
viewport to the nearest int using roundf() (which should behave just as
CLUTTER_NEARBYINT()) since we're passing around floats anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Jonas Dreßler
0a37c32a72 clutter/actor: Update absolute_origin_changed inside set_allocation()
When manipulating the allocation of a ClutterActor from an allocate()
vfunc override, clutter_actor_set_allocation() is used to let Clutter
know about the changes.

If the actors allocation or its absolute origin did not change before
that, this can also affect the actors absolute_origin_changed property
used by the children to detect changes to their absolute position.

So fix this bug (which luckily didn't seem to affect us so far) and set
priv->absolute_origin_changed to TRUE in case the origin changes inside
clutter_actor_set_allocation_internal(). Since this function is always
called when our allocation changes, we no longer need to update
absolute_origin_changed in clutter_actor_allocate() now.

Since a change to the absolute origin always affects the resource scale,
too, we also need to move that check from clutter_actor_allocate() here
to make sure we update the resource scale.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Jonas Dreßler
9f121a211d clutter/actor: Always reset absolute_origin_changed after relayout
Since the introduction of the shallow relayout functionality it's
possible to start an allocation cycle at any point in the tree, not only
at the stage. Now when starting an allocation at an actor that's not the
stage, we'd still look at the absolute_origin_changed property of this
actors parent, which might still be set to TRUE from the parents last
allocation.

So avoid using the parents absolute_origin_changed property from the
last allocation in case a shallow relayout is being done and always
reset the absolute_origin_changed property to FALSE after the allocation
cycle.

This broke with the removal of the ABSOLUTE_ORIGIN_CHANGED
ClutterAllocationFlag that was done in commit dc8e5c7f.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
Carlos Garnacho
f8e2234ce5 backends/native: Drop external keyboard detection for ::touch-mode
This cannot be made to work reliably. Some factoids:

- Internal devices may be connected via USB.
- The ACPI spec provides the _PLD (Physical location of device) hook to
  determine how is an USB device connected, with an anecdotal success
  rate. Internal devices may be seen as external and vice-versa, there is
  also an "unknown" value that is widely used.
- There may be non-USB keyboards, the old "AT Translated Set 2 Keyboard"
  interface does not change on hotplugging.
- Libinput has an internal series of quirks to classify keyboards as
  internal of external, also with an "unknown" value.

These heuristics are kinda hopeless to get right by our own hand. Drop
this external keyboard detection in the hope that there will be something
more deterministic to rely on in the future (e.g. the libinput quirks
made available to us directly or indirectly).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2378
Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2353

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1277
2020-05-29 14:37:21 +00:00
Jonas Dreßler
0b6a3166ed clutter/text: Also queue relayout if the actor has no valid allocation
In clutter_text_queue_redraw_or_relayout() we check whether the size
of the layout has changed and queue a relayout if it did, otherwise we
only queue a redraw and save some resources.

The current check for this also queues a redraw if the actor has no
valid allocation. That seems right on the first glance since the actor
will be allocated anyway, but we actually want to call
clutter_actor_queue_relayout() again here because that also invalidates
the size cache of the actor which might have been updated and marked
valid in the meantime.

So make sure the size cache is always properly invalidated after the
size of the layout changed and also call clutter_actor_queue_relayout()
in case the actor has no allocation.

This fixes a bug where getting the preferred width of a non-allocated
ClutterText, then changing the string of the ClutterText, and then
getting the preferred width again would return the old cached width (the
width before we changed the string).

The only place where this bug is currently happening is in the overview,
where we call get_preferred_width() on the unallocated ClutterText of
the window clone title: When the window title changes while the
ClutterText is unallocated the size of the title is going to be wrong
and the text might end up ellipsized or too large.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1150
2020-05-27 08:41:31 +00:00
Jonas Ådahl
99c9a14bc8 clutter/stage: Make clutter_stage_schedule_update() public API
It's effectively used by mutter by abusing a ClutterTimeline to scedule
updates.  Timelines are not really suited in places that is done, as it
is really just about getting a single new update scheduled whenever
suitable, so expose the API so we can use it directly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Ådahl
b8003807b0 clutter/stage: Make clutter_stage_schedule_update() always schedule
We could call clutter_stage_schedule_update() and it wouldn't actually
schedule anything, as the master frame clock only tries to reschedule if
1) there is an active timeline, 2) there are pending relayouts, 3) there
are pending redraws, or 4) there are pending events. Thus, a call to
clutter_stage_schedule_update() didn't have any effect if it was called
at the wrong time.

Fix this by adding a boolean state "needs_update" to the stage, set on
clutter_stage_schedule_update() and cleared on
_clutter_stage_do_update(), that will make the master clock reschedule
an update if it is TRUE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Dreßler
8e1bd64e05 clutter/stage-cogl: Use view fb instead of onscreen fb for debug-drawing
We need to use the framebuffer of the view instead of the onscreen
framebuffer when painting the damage region, otherwise the redraw clips
on rotated monitors won't be shown correctly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
5aa56aa7f5 clutter/stage-cogl: Remove unneeded helper
The helper called a single function; lets just call it directly instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
c2c4f74923 clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.

This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
ae4d299499 clutter/stage-cogl: Extract damage history logic
Move the damage history tracking to a new ClutterDamageHistory helper
type. The aim is to be able to track damage history elsewhere without
reimplementing the data structure and tracking logic.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
8798325489 clutter/stage-view: Only blit the damage part of the shadow buffer
This fixes the last "copy everything" paths when clutter doesn't
directly paint onto the onscreen framebuffer. It adds a new hook into
the stage view called before the swap buffer, as at this point, we have
the swap buffer damag regions ready, which corresponds to the regions we
must blit according to the damage reported to clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
9e34028742 clutter/stage-cogl: Only construct damage array if it'll be used
It's only used when we actually swap buffers, which we only do if the
target framebuffer is an onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
258f859e8d clutter/stage-view: Only paint redraw clip from offscreen
The rest didn't change, so only actually paint the part of the offscreen
that was composited as part of the stage painting. In practice, this
means that, unless a shadow buffer is used, we now only paint the
damaged part of the stage, and copy the damage part of the offscreen to
the onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
9d3e4fd402 clutter/stage-cogl: Use buffer age when view monitor is rotated
We failed to use the buffer age when monitors were rotated, as when they
are, we first composite to an offscreen framebuffer, then later again to
the onscreen. The buffer age checking happened on the offscreen, and an
offscreen being single buffered, they can't possible support buffer
ages.

Instead, move the buffer age check to check the actual onscreen
framebuffer. The offscreen to onscreen painting is still always full
frame, but that will be fixed in a later commit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
db975bd2a8 clutter/stage-view: Simplify painting of offscreen slightly
We will only ever have an "offscreen" if we're painting transformed in
some way, so the 'can_blit' checking is unnecessary. Remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
4e27a4ea1d clutter/stage-view: Always use cogl_blit_framebuffer() from shadowfb
It should only be used when direct blitting is supported, so there is no
reason we should have to deal with pipelines etc when blitting from the
shadow buffer to the onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
19550c28f9 clutter/stage-view: Change set_dirty..() API to invalidate..()
The manual "cleaning" of the viewport and projection state is removed,
and we only ever try to invalidate the state so that it'll be updated
next time. Change the API used to reflect this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
c4949b553d clutter/stage-view: Move fb viewport and projection setting to here
The stage would fetch the front framebuffer and set the viewport and
projection matrix, but if we are going to more than one front buffer,
that won't work, so let the stage just pass the viewport and projection
matrix to the view and have the view deal with the framebuffer(s).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
675a2d13b9 clutter/stage-view: Move shadowfb struct fields into anonymous struct
With the aim to collect shadow buffer related things in one place, place
them in an anonymous struct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
f4d9953b9c renderer-native: Move shadow fb construction to the stage view
The stage view will need a more involved approach to shadow buffers, in
order to implement things such double buffered shadow buffers and damage
detection.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
6db94a0b77 clutter/stage-view: Add name property
Will be used for logging to identify what view a log entry concerns. For
the native and nested backend this is the name of the output the CRTC is
assigned to drive; for X11 it's just "X11 screen", and for the legacy
"X11 screen" emulation mode of the nested backend it's called "legacy
nested".

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Dreßler
2791f5b466 clutter/actor: Make has_mapped_clones() factor in parent actors
All existing users of clutter_actor_has_mapped_clones() actually want to
know whether the actor is being cloned by a visible clone, it doesn't
matter to them if that clone is attached to an actor somewhere else in
the tree or to the actor itself.

So make clutter_actor_has_mapped_clones() a bit more convenient to use
and also check the clones of the parent-actors in that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
e12b2c417e clutter/actor: Use priv->allocation instead of get_allocation_box()
The comment in _clutter_actor_get_allocation_clip() explicitely notices
that it doesn't need the behavior of doing an immediate relayout as
clutter_actor_get_allocation_box() does. The comment is also still valid
since the code calling _clutter_actor_get_allocation_clip() checks for
priv->needs_allocation just before.

So let's just use the allocation directly here instead of going through
that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1264
2020-05-23 10:35:25 +00:00
Jonas Dreßler
c42c11583d clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterAction and subclasses
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
2020-05-22 08:56:23 +00:00
Jonas Dreßler
8c131b32b1 clutter/actor-meta: Use G_DECLARE_DERIVABLE_TYPE
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
2020-05-22 08:56:23 +00:00
Florian Müllner
11f224f4b0 clutter/box-layout: Remove child meta
ClutterBoxLayout's layout policy of using the generic ClutterActor
align/expand properties for children that are expanded and a custom
meta otherwise is confusing, in particular as the x-fill/y-fill
defaults don't match the default CLUTTER_ACTOR_ALIGN_FILL align.

StBoxLayout's own custom child meta (which was deprecated last
cycle) is probably the only consumer. And luckily, the St meta
uses different x-fill/y-fill default that match the ClutterActor
defaults, so removing it will not affect code that doesn't use
the deprecated properties themselves.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
Florian Müllner
82d96aebe1 clutter/box-layout: Remove deprecated API
This stuff has been deprecated for a very long time, and given that
ClutterBoxLayout is most commonly used via StBoxLayout, the impact of
removing it should be low. It will however open the door to further
cleanups.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
Jonas Dreßler
e50e14af82 clutter/actor: Remove "allocation-changed" signal
Since we now no have ClutterAllocationFlags, there's no reason anymore
for keeping the "allocation-changed" signal, so remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
787d9a5a15 clutter: Use notify::allocation instead of allocation-changed
We're going to remove the "allocation-changed" signal from ClutterActor
since it's no longer needed now that ClutterAllocationFlags are gone.

So listen to "notify-allocation" instead, which has been the recommended
thing to do for some time now anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
3c29bf7491 clutter: Remove allocation flags
Since there are now no more allocation flags, we can remove
ClutterAllocationFlags from Clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
dc8e5c7f8b clutter/actor: Replace ABSOLUTE_ORIGIN_CHANGED flag with a property
The ABSOLUTE_ORIGIN_CHANGED allocation flag is only really useful to
propagate the information of the absolute origin of an actor having
changed inside Clutter. It wasn't used anywhere else besides for some
debug messages and it probably shouldn't be used in custom layout
implementations anyway since 1) actors shouldn't have to be aware of
absolute allocation changes and 2) it doesn't factor in changes to the
transformation matrix of a parent.

Also the propagation of absolute origin changes using this flag broke
with commit 0eab73dc2e and now hidden actors are no longer notified
about those changes.

Additionally, this flag gets in the way of a few potential optimizations
since it has to be propagated even if the allocation box of the child
hasn't changed, forcing a reallocation of the child.

So replace this flag with a simple new private property of ClutterActor
absolute_origin_changed, but keep the exact same behavior for now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
04e983383f clutter/stage: Remove ABSOLUTE_ORIGIN_CHANGED flag from debug message
The ABSOLUTE_ORIGIN_CHANGED allocation flag is going to be removed from
Clutter, so stop using it for this debug message.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
7ae6e0101c clutter/actor: Remove clutter_actor_maybe_layout_children()
Since we now only layout the children ourselves in case the actor
implementation doesn't override the allocate vfunc, we can remove
clutter_actor_maybe_layout_children() and move the functionality inside
clutter_actor_real_allocate().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
affb3de829 clutter/actor: Don't layout children inside set_allocation()
Now that we no longer have the DELEGATE_LAYOUT we expect all actors
overriding the allocate() vfunc to allocate their children themselves.

Since clutter_actor_set_allocation() is only called from custom
vfunc_allocate() implementations, the condition in
clutter_actor_maybe_layout_children() would always fail, which makes
calling the function useless anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
Jonas Dreßler
24d7a7ad0b clutter: Remove DELEGATE_LAYOUT allocation flag
The CLUTTER_DELEGATE_LAYOUT flag is unintuitive and makes the allocation
process inside Clutter unnecessarily complicated. It's very easy for
actors overriding the allocate() vfunc to layout their children
themselves (in fact most of them do this), and it also never made sense
that clutter_actor_set_allocation() does eventually layout children.

There was no ClutterActor implementation in mutter or gnome-shell which
actually used the DELEGATE_LAYOUT flag, but even without it, it's fairly
easy to archive the same behavior now: In the allocate() override,
adjust the allocation as wanted, then chain up to the parent vfunc
without calling clutter_actor_set_allocation().

So remove the CLUTTER_DELEGATE_LAYOUT flag, which will allow making the
relayout code in Clutter a bit easier to follow.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
Jonas Dreßler
4729cb779e clutter/stage: Stop using DELEGATE_LAYOUT allocation flag
We're going to remove allocation flags, so stop depending on the
DELEGATE_LAYOUT flag in ClutterStage and call
clutter_layout_manager_allocate() directly, which is pretty
straightforward.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
Jonas Dreßler
a7bf6322e3 clutter/actor: Use priv->parent instead of public API sometimes
The public API to get the parent actor, clutter_actor_get_parent() does
a type check whether the actor is actually a ClutterActor. In case of
_clutter_actor_apply_relative_transformation_matrix(), which is called
recursively and very often during the paint process, this type check
shows up with almost twice the amount of hits than the actual matrix
multiplication.

So use the parent pointer directly in some code paths that are executed
very often and avoid the expensive type checking there, we can do that
since both places are not public API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1259
2020-05-19 08:17:09 +00:00
Jonas Dreßler
fbfa136bbb clutter/stage-cogl: Cleanup damage history (un-)scaling a bit
Reverting the scale and offset applied to the damage history can be done
in one step, using a few less temporary allocations by passing the
offset right away to a new scale_offset_and_clamp_region() function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:54 +00:00
Jonas Dreßler
434845dbe5 clutter/stage-cogl: Don't loop through region rects twice
There's no reason for using two loops to fill the rects array in
offset_scale_and_clamp_region(), we can do that using only one loop.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:54 +00:00
Jonas Dreßler
967511be61 clutter/stage-cogl: Don't intersect the damage region with the view
Since the damage history region is tracked per-view, all the regions it
includes should be inside the current view anyway, so don't
unnecessarily intersect that region with the view.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
43c7a82461 clutter/stage-cogl: Cleanup setting of the damage history
Since we now check for the buffer age before setting up the
fb_clip_region, that region will be set to the full extents of the view
in case the buffer age is invalid. This in turn means we don't have to
do this again later and can simply fill the damage history with the
fb_clip_region that's already set for us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
066e78c9b3 clutter/stage-cogl: Warn if the fb_clip_region is empty
Since a NULL redraw_clip means that a full view redraw should be done
and an empty redraw clip may never be set (see the width/height checks
in clutter_stage_view_add_redraw_clip()), the fb_clip_region should
always be set to a reasonable region that's either the whole view or
individual regions inside the view.

So make sure that's actually the case by warning and that the
fb_clip_region isn't empty, which allows dropping another few lines of
code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
08f47fee16 clutter/stage-cogl: Check for DISABLE_CLIPPED_REDRAWS earlier
Right now we're checking for the DISABLE_CLIPPED_REDRAWS debug flag
after creating the fb_clip_region and adjusting the redraw_clip. That
means that if may_use_clipped_redraw was TRUE, the redraw_clip will
still be set to the region and thus cause the stage to only be partially
redrawn. Since we don't push a clip to the framebuffer though
(use_clipped_redraw is now FALSE), parts of the view will get corrupted.

To fix that, disable clipped redraws right away if the debug flag is
set. This also allows removing the may_use_clipped_redraw bool and
replacing it entirely with use_clipped_redraw.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
afe4cd482e clutter/stage-cogl: Stop painting redraw clip outline
We already have a better way to paint the redraw clip: Painting the
damage region paints the individual rects of the clip region and not
only the bounding rect.

So stop painting an outline around the redraw clip bounding rect when
CLUTTER_DEBUG_REDRAWS is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
3fed768db4 clutter/stage-cogl: Don't push scissor clip with one clip rectangle
While this is meant as an optimzation to only use the scissor clip and
not the stencil buffer if there's only one clip rectangle, it's not
needed since this optimization is going to be applied to region clips
anyway inside _cogl_clip_stack_gl_flush() (see cogl-clip-stack-gl.c).

So remove the unnecessary optimization here and rely on cogl-clip-stack
to do it for us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
8c52b431bb clutter/stage-cogl: Stop doing subpixel compensation
This was introduced with commit 9ab338d7b6 because the clipping of
fractionally scaled redraws caused glitches, it seems like this is no
longer needed nowadays, so let's remove it.

This should make obscured region culling work a bit better for
fractionally scaled framebuffers because because we overdraw a slightly
smaller region than the actually damaged one. We still do overdraw
though since the clipping region is stored using integers and thus
any non-integer values have to be extended to the bounding rect.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
d9ffbf0576 clutter/stage-cogl: Don't clip when clipped redraws are disabled
It doesn't make sense to set the redraw clip when painting the stage if
clipped redraws are disabled. That's because when visualizing the redraw
clip and any new redraws are clipped, the old visualiziations would
remain visible, leaving multiple confusing rectangles on the screen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Jonas Dreßler
b0953b92ba clutter/stage-cogl: Remove scale_and_clamp_rect() function
This function  is only used in offset_scale_and_clamp_region() and can
simply be included there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
Daniel van Vugt
1880e22229 clutter-actor: Remove unused clutter_actor_get_allocation_vertices
It was also apparently broken (mutter#1126)

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1126
2020-05-08 09:52:49 +00:00
Jonas Ådahl
322b51cded clutter: Remove ClutterAnimation
This removes ClutterAnimation and related tests. ClutterAnimation has
been deprecated for a long time, and replacements exist and are used by
e.g. GNOME Shell since a while back.

This also disables a few relatively unrelated interactive tests, as they
rely on ClutterAnimation to implement some animations they use to
illustrate what they actually test.

As interactive tests currently are more or less untestable due to any
interaction with them crashing, as well as they in practice means
rewriting the tests using non-deprecated animation APIs, they are not
ported right now. To actually port the interactive tests, it needs to be
possible to fist interact with them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
da5be1fdea clutter/animatable: Remove left-over vfunc
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
bc18438cb0 clutter/box-layout: Make 'easing-mode' be an enum
In the past, it was a odd mix of possible different types, all coalesced
into an unsigned integer. Now, hovewer, it's always a
ClutterAnimationType, so lets change the name of getter, setter and
property to what it really is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
73cb96ddb9 clutter: Remove 'ClutterAlpha'
It was some kind of deprecated interpolation mechanism used in
ClutterAnimation. We're not using it, and have non-deprecated
replacement functionality, so lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
1cb59f44ab clutter/layout-manager: Remove unused animation API
One less unused animation API to care about.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
a55a286b15 clutter: Remove deprecated 'ClutterState'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Dreßler
c38fa4fa5c clutter: Remove CLUTTER_ACTOR_IN_REPARENT flag
The CLUTTER_ACTOR_IN_REPARENT and the CLUTTER_IN_REPARENT flag are never
set and the logic for skipping unmap, unrealize and the emission of the
"parent-set" signal during reparents has been solved differently by
leaving out the CHECK_STATE and EMIT_PARENT_SET flags when calling
add_child_internal() and remove_child_internal().

The only place where those REPARENT flags are theoretically still useful
is in the clutter_actor_verify_map_state() debugging function, but that
is never called during reparent anyway, so simply leave the comment
regarding reparent there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1228
2020-05-07 09:01:31 +00:00
Jonas Dreßler
793a9d45e1 clutter/stage-cogl: Fix painting the redraw clip with the damage region
The redraw clip that's painted together with the damage region has to be
copied earlier than we do right now. That's because if
PAINT_DAMAGE_REGION is enabled, buffer age is disabled and thus
use_clipped_redraw is FALSE. That means the redraw_clip is updated and
set to the full view-rect. If we copy the queued_redraw_clip after that,
it's also going to be set to the full view-rect. So copy the redraw clip
a bit earlier to make sure we're actually passing the real redraw clip
to paint_damage_region().

Also keep the queued_redraw_clip around a bit longer so it can actually
be used by paint_damage_region() and isn't freed before that.

While at it, move paint_damage_region() from swap_framebuffer() into
clutter_stage_cogl_redraw_view() so we don't have to pass things to
swap_framebuffer() only for debugging.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1208
2020-04-25 16:42:30 +02:00
Jonas Ådahl
c4535fdf85 screen-cast: Add RecordArea for screen cast arbitrary area
It takes coordinates in stage coordinate space, and will result in
a screen cast stream consisting of that area, but scaled up by the scale
factor of the view that overlaps with the area and has the highest scale
factor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
d2c3272eb7 clutter/paint-context: Add 'no-cursors' paint flag
Will be used by the stage to not paint the overlays. We skip all
overlays since overlays are only ever used for pointer cursors when the
hardware cursors cannot or should not be used.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
b7bf42e778 clutter/stage: Add API to paint to a custom target
Either onto a framebuffer, or into a CPU memory buffer. The latter will
use an former API and then copy the result to CPU memory. The former
allocates an offscreen framebuffer, sets up the relevant framebuffer
matrices and paints part of the stage defined by the passed rectangle.

This will be used by a RecordArea screen cast API. The former to paint
directly onto PipeWire handled dma-buf framebuffers, and the latter for
PipeWire handled shared memory buffers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
a4f55d4986 clutter/paint-context: Allow passing redraw clip to offscreen paint context
So that we can mark the redraw clip of the part of the stage we're
painting.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
1b33a5a3a7 clutter/paint-context: Add paint flag
A paint flag affects a paint operation in ways defined by the flags.
Currently no flags are defined, so no semantical changes are defined
yet. Eventually a flag aiming to avoid painting of cursors is going to
be added, so that screen cast streams can decide whether to include a
cursor or not.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
65a6c4c361 compositor: Add support for direct scanout of Wayland surfaces
Try to bypass compositing if there is a fullscreen toplevel window with
a buffer compatible with the primary plane of the monitor it is
fullscreen on. Only non-mirrored is currently supported; as well as
fullscreened on a single monitor. It should be possible to extend with
more cases, but this starts small.

It does this by introducing a new MetaCompositor sub type
MetaCompositorNative specific to the native backend, which derives from
MetaCompositorServer, containing functionality only relevant for when
running on top of the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
753066598f clutter/view: Make it possible to assign a temporary direct scanout
Make it possible to cause the next frame to scan out directly from the
passed CoglScannout. This makes it possible to completely bypass
compositing for the following frame.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
bc178b711f clutter/actor: Add semi-private API to check for transitions
Transitions are used for animating actors when e.g. going from/to
fullscreen, and the like. We need to know such things when deciding
whether to avoid compositing a window actor, so make add API visible to
mutter that checks whether there are any transitions active.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Elias Aebi
425a10de11 clutter: Use #mesondefine
Use #mesondefine instead of manual concatenation.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1179
2020-04-15 12:56:34 +00:00
Georges Basile Stavracas Neto
0d0834f87c Revert "clutter/click-action: Do not process captured event if action is disabled"
This reverts commit 5f5ce08ba4. There is
no way to reach this callback when the click action is disabled.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1188
2020-04-08 20:31:58 +00:00
Georges Basile Stavracas Neto
676997e0af clutter/click-action: Make sure to never schedule more than one timeout
click_action_query_long_press() can potentially schedule more than
one timeout, since it doesn't clear any already-existing timeout.

Make sure to clear the long press timeout before scheduling a new
one.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1188
2020-04-08 20:31:58 +00:00
Georges Basile Stavracas Neto
633d5d1b84 clutter/gesture-action: Cancel gesture when disabling the action
Like the click action, it makes sense to cancel the ongoing gesture
when the action is disabled. Do so by overriding our new friend,
ClutterActorMeta.set_enabled, and canceling the gesture when disabling
the action.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1188
2020-04-08 20:31:58 +00:00
Georges Basile Stavracas Neto
f620f43353 clutter/click-action: Release when disabling
ClutterClickAction, like other actions, can potentially be disabled
at any time (that is not during painting). When that happens with
ClutterClickAction, it must release all timeouts and disconnect from
the stage's 'capture-event'.

Override ClutterActorMeta.set_enabled and release the click action
when the action is being disabled.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1188
2020-04-08 20:31:58 +00:00
Jonas Dreßler
eb6e1f694a clutter: Remove drag and drop actions
We aren't using those actions in the shell or anywhere in Mutter, our
DnD support is implemented on the shell side.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/789
2020-04-08 20:21:31 +00:00
Georges Basile Stavracas Neto
6aead84d7a clutter/offscreen-effect: Override ClutterActorMeta.set_enabled
Again, the same case of the previous commits.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1187
2020-04-08 12:14:02 -03:00
Georges Basile Stavracas Neto
5b984c1e53 clutter/constraint: Override ClutterActorMeta.set_enabled
Pretty much like the previous commit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1187
2020-04-08 12:14:00 -03:00
Georges Basile Stavracas Neto
7660ca2579 clutter/effect: Override ClutterActorMeta.set_enabled
Instead of using GObject.notify to queue a redraw, use the new
ClutterActorMeta.set_enabled vfunc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1187
2020-04-08 12:13:57 -03:00
Georges Basile Stavracas Neto
ac52631e8a clutter/actor-meta: Add a new 'set_enabled' vfunc
Various subclasses of ClutterActorMeta need to reacto to being
disabled. Right now, however, the only way to do that is by
overriding GObject's 'notify' vfunc, and doing a string comparison
against "enabled".

Add a new vfunc to ClutterActorMeta in order to replace this bad
practice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1187
2020-04-08 12:13:47 -03:00
Carlos Garnacho
a5294ce55f cogl: Remove CoglPath and the tesselator
This was barely used, and doesn't represent the way we want to
do 2D rendering.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:38:48 +02:00
Carlos Garnacho
553372ffb7 clutter: Drop CoglPaths handling from ClutterPaintNode
This seems unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:38:46 +02:00
Carlos Garnacho
f672d6ee3b clutter/text: Drop usage of ClutterPath
In the unlikely case we have multiple rectangles in our selection
(selection spanning several lines, or across LTR/RTL bounds), paint each
of those instead of setting a CoglPath-based clip/fill.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:37:11 +02:00
Jonas Dreßler
e74c2e42cf clutter/stage: Don't assume stage relayouts reallocate everything
With the introduction of "shallow" relayouts, we are now able to enter
allocation cycles not only at the stage but also deeper down the
hierarchy if we know an actors allocation isn't affected by its children
since the NO_LAYOUT flag is set.

Now that means when queuing relayouts it's possible that
`priv->needs_allocation` gets set to TRUE for some actors down the
hierarchy, but not for actors higher up in the hierarchy. An actor tree
where that happens could look like that:

stage -> container -> container2 (NO_LAYOUT) -> textActor

With that tree, if the "textActor" queues a relayout, "container2" will
be added to the relayout hashtable of the stage and the actors "stage"
and "container" will have `priv->needs_allocation` set to FALSE.

Now if another relayout on the stage actor is queued,
`clutter_stage_queue_actor_relayout()` currently removes all the other
hashtable entries in favour of the stage entry, (wrongly) assuming that
will allocate everything. It doesn't allocate everything because in the
example above "container" has `priv->needs_allocation` set to FALSE,
which makes clutter_actor_allocate() return early before allocating its
children, so in the end "container2" will never get a new allocation.

To fix this, stop flushing the relayout hashtable when queuing a
stage-relayout and still add new entries to the hashtable if a stage
relayout is already queued to make sure we still go through all the
previously queued "shallow" relayouts. That shouldn't hurt performance,
too, because as soon as an actor got allocated once, it doesn't need an
allocation anymore and should bail out in clutter_actor_allocate() as
long as it's absolute position didn't change.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1173
2020-04-07 14:34:52 +00:00
Jonas Ådahl
08431a127a clutter/stage: Remove ability to set custom perspective
Unused, and complicates things, so drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
3f068d1138 clutter/stage: Remove unused paint_data/notify fields
It's usage was removed in ec911dc8b9 back
in 2014. Lets get rid of the left over fields.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
6f0e5b0b56 clutter/stage: Remove 'accept-focus' property
Also unused, only valid on X11. Meant for applications. Lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
fe27a6ea3b clutter/stage: Remove hide/show cursor API
This removes it from the stage window API too. It's managed by the
mutter backends, so we don't need the stage window to do it as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
1301770dcb clutter/stage: Remove 'alpha' property
Was unused except for in a test, lets remove it. Half transparent
monitors will probably have to be dealt with some other way anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Georges Basile Stavracas Neto
7d2df52336 clutter/offscreen-effect: Rename CoglPipeline field to 'pipeline'
This is the same case of the layer node: a CoglPipeline field that
is not called 'pipeline' makes it harder to figure out what it
really is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:40 -03:00
Georges Basile Stavracas Neto
5d27e5415d clutter/layer-node: Use non-deprecated cogl_texture_2d_new_with_size()
Use the non-deprecated cogl_texture_2d_new_with_size() function to create
the texture backing the FBO, and set it to pre-multiplied before allocating
it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
625773fba4 clutter/layer-node: Trivial code cleanup
Both the valid and the error code paths end up unreffing
the texture. Move the unref to the shared code path.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
7d79ae7b07 cluter/layer-node: Remove CoglTexture from structure
It is not used anywhere beyond the initializer, and won't be
used later on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Georges Basile Stavracas Neto
5817779656 clutter/layer-node: Rename CoglPipeline field to 'pipeline'
So it clearly reads what it actually is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1167
2020-04-02 15:50:14 -03:00
Andre Moreira Magalhaes
5f5ce08ba4 clutter/click-action: Do not process captured event if action is disabled
Disabling a click action after a button-press but before a
button-release is captured makes ClutterClickAction connect to
captured-event and never disconnect.

This change fixes it by making sure the captured-event is only
processed if the action is still enabled, otherwise releasing
the action (reset state) and propagating the event.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1170
2020-04-02 13:13:51 -03:00
Jonas Ådahl
223f033780 clutter/offscreen-effect: Don't ever early out out of post paint
If we would, we'd miss popping the framebuffer from the pant context
framebuffer stack.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1166
2020-04-01 18:40:39 +00:00
Jonas Ådahl
50e0ae3cf3 clutter/actor-meta: Warn if an actor modifier is altered mid paint
Nothing should ever disable an actor modifier (e.g. effect) during the
paint sequence, nor should any actor be set or unset on it. If this
would happen, log warnings so that it can be tracked down.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1166
2020-04-01 18:40:39 +00:00
Andre Moreira Magalhaes
902302a174 clutter/actor: Fix pick when actor is not allocated
When selecting the pick regions for an actor we were not considering
whether the actor was allocated and that was causing issues where the
preferred width/height of the actor was used when deciding whether
the actor should be considered as a pick target.

Check if the actor has a valid allocation, in addition to being mapped
and being in pick mode, in clutter_actor_should_pick_paint().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:06 -03:00
Takao Fujiwara
2cfdbbd730 clutter: Enable negative offsets in delete surrounding text
The input method can assign a negative value to
clutter_input_method_delete_surrounding() to move the cursor to the left.
But Wayland protocol accepts positive values in delete_surrounding() and
GTK converts the values to the negative ones in
text_input_delete_surrounding_text_apply().

https://gitlab.gnome.org/GNOME/mutter/issues/539
2020-03-29 11:37:27 +00:00
Georges Basile Stavracas Neto
73250b8f4c clutter/actor: Add culling inhibiting API
This will allow us to continue painting actors that are
outside the visible boundaries of the stage view.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Jonas Dreßler
92710d8f89 clutter/stage-cogl: Check for buffer age early
Fix a regression that got introduced with
c483b52d24 where we started passing the
redraw_clip to paint_stage() instead of creating a temporary view_region
for unclipped redraws: In case we detect an invalid buffer age, we fall
back to doing an unclipped redraw after we passed the first check
setting up may_use_clipped_redraw. That means we didn't reset the
redraw_clip to the view_rect, and we're now going to redraw the stage
using the original redraw clip even though we're swapping the full
framebuffer without damage.

To fix that, check for the buffer age before setting up the
fb_clip_region and the redraw_clip and set may_use_clipped_redraw to
FALSE if the buffer age is invalid, too. This ensures the redraw_clip is
always going to be correctly set to the view rect when we want to force
a full redraw.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1128
2020-03-27 16:37:45 +00:00
Jonas Ådahl
32c99513c8 clutter/actor: Inherit cloned painting when calculating resource scale
When calculating the resource scale of a clone source, we might end up
in situations where we fail to do so, even though we're in a paint. A
real world example when this may happen if this happens:

 * A client creates a toplevel window
 * A client creates a modal dialog for said toplevel window
 * Said client commits a buffer to the modal before the toplevel

If GNOME Shell is in overview mode, the window group is hidden, and the
toplevel window actor is hidden. When the clone tries to paint, it fails
to calculate the resource scale, as the parent of the parent (window
group) is not currently mapped. It would have succeeded if only the
clone source was unmapped, as it deals with the unmapped actor painting
by setting intermediate state while painting, but this does not work
when the *parent* of the source is unmapped as well.

Fix this by inheriting the unmapped clone paint even when calculating
the resource scale.

This also adds a test case that mimics the sequence of events otherwise
triggered by a client. We can't add a Wayland client to test this, where
we actually crash is in the offscreen redirect effect used by the window
dimming feature in GNOME Shell.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1147
2020-03-26 11:42:23 +01:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Robert Mader
ed4b80cee5 clutter/stage: Rename parameters to match documentation
To silence warnings during GIR generation.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1133
2020-03-18 02:45:43 +01:00
Corentin Noël
b310e1d9d7 clutter-stage: Add annotations to clutter_stage_capture
Especially document that out_captures is an array that is given as output.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1131
2020-03-17 15:14:57 +01:00
Daniel van Vugt
73e3207a85 clutter-actor: Add detail to captured-event
So that subscribers can choose the class of events they're interested in
and not be woken by everything else.

Needed by: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/925

Related to: https://gitlab.gnome.org/GNOME/mutter/issues/283

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1000
2020-02-29 13:34:00 +00:00
Christian Hergert
b7f47ea17f clutter: add tracing for frameclock cycle
This adds a new frameclock tracing mark for a single cycle of the frame
clock. Doing so allows Sysprof to potentially do more with the information
that happens during the frameclock. For example, we can now find
allocations that happen while the frame clock is advancing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1088
2020-02-26 12:33:00 +00:00
Sebastian Keller
71101cab82 clutter/cogl/stage: Remove duplicate region union
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1089
2020-02-26 07:26:10 +00:00
Sebastian Keller
c4b28b0939 clutter/cogl/stage: Don't leak FB damage region on redraw
offset_scale_and_clamp_region() creates a new region resulting in
view_damage which at this point is the only thing left pointing to what
originally was fb_damage getting overwritten and being leaked.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1089
2020-02-26 07:26:10 +00:00
Jonas Ådahl
159c83b914 clutter: Move redraw clip management to views
The stage window handled the redraw clip in a global manner; this would
interfere if we want to paint views individually as it'd mean
intersecting views (i.e. mirrored monitors) would loose the redraw clip
once the first view was painted. It also is awkward to have a global
state for something that is built up before redrawing, and only really
valid during paint, due to buffer damage history.

This commits removes all redraw clip management from the stage window,
moving it all into the stage views. When a redraw clip is added to the
stage, every affected view will get the same redraw clip added to it,
and eventually when painted, the stage window (ClutterStageCogl) will
retrieve the redraw clip for each view as it repaints them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
b68c630329 clutter/cogl/stage: Use g_clear_pointer() to clean up regions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
fe1ccea1e1 clutter: Pass redraw clip via paint context
Instead of users fetching it via `clutter_stage_get_redraw_clip()`, pass
it via the paint context. This is helpful as it is only valid during a
paint, making it more obvious that it needs to be handled differently
when there is no redraw clip (i.e. we're painting off-screen).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
c483b52d24 clutter/stage: Pass redraw clip instead of extents when painting view
That's the struct we have ready, the callee can just call
cairo_region_get_extents() if it only cares about the extents rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
f3dcba27f5 clutter/cogl/stage: Simplify region transform code
Add a helper that scales and clamps a region, aimed to be used when
transforming between framebuffer coordinate space and view coordinate
spaces.

This helps readability by moving out the verbose for loops that deals
with the individual rects of a region to the helper, making the logic
where it's used much simpler.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
86ccc28413 clutter/cogl/stage: Rename have_clip to is_full_redraw
The 'have_clip' variable has repeatedly confused me to meaning that
there is a clip. What it actually means is that the effective clip
covers the whole view; the 'redraw_clip == NULL' meaning full redraw is
an important implementation detail for the context, and makes the
intention of the variable unclear; especially since we will after a
couple of blocks will *always* have a clip, just that it covers the
whole view.

Rename the variable to 'is_full_redraw' and negate the meaning, aiming
to make things a lot more clear.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
0d039c3ba3 clutter/view: Don't take paint rect after paint
It was unused, and will be become unused by the primary paint function
as well, so go ahead and remove it here first.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
adcbc2aa5f clutter/cogl/stage: Use fb size for for fallback fb clip region
When calculating the fallback framebuffer clip region, which should be
the region in framebuffer coordinates, we didn't scale the view layout
with the view framebuffer scale, meaning for any other scale than 1,
we'd draw a too small region of the view. Fix this by just using the
size of the framebuffer directly, avoiding any scale dependent
calculation all together.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00