Commit Graph

7733 Commits

Author SHA1 Message Date
Jonas Dreßler
1922896f07 clutter: Also pick on TOUCH_BEGIN events
With 734a185915 an optimization was
introduced to only pick on events which can actually cause the pointer
to move. In case of touch events, the first event (TOUCH_BEGIN) will
already move the touchpoint though, and we'll send our crossing
CLUTTER_ENTER event to the actor this TOUCH_BEGIN happened on.

So fix this embarrassing bug that caused touch input to break by also
picking to find an event-actor on TOUCH_BEGIN events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1733>
2021-02-16 10:01:22 +01:00
Jonas Dreßler
734a185915 clutter: Only pick on motion or touch update events
Aside from ENTER/LEAVE, there are only two kinds of events that can move
the pointer, motion events and touch update events. Everything else
keeps the pointer at it's current position.

The reason we pick inside _clutter_process_event_details() is that we
want to set the event actor. Now if an event can't move the pointer, it
also can't change the event actor (well, it can subsequently by
triggering changes to the scenegraph, but that's handled elsewhere), so
there's no need to pick a new event actor when we get those events.
Instead, simply reuse the actor that's already associated with the
current input device as the event actor for non MOTION/TOUCH_UPDATE
events.

Events where a device or a touchpoint goes away (like DEVICE_REMOVED or
TOUCH_END/CANCEL) also affect picking, they don't need a repick, but
instead the actor associated with the device/touchpoint needs to be
unassociated. This is ensured by invoking remove_device_for_event() on
those events and will not be affected by this change.

This should improve performance while scrolling quite a bit, since
scroll events come in unthrottled and we now no longer do a repick on
each one of those.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1729>
2021-02-15 12:24:49 +00:00
Jonas Dreßler
d5b69d9cc0 clutter: Use event source directly for debug message
No need to assign things to a separate variable there, let's just read
event->any.source directly instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1729>
2021-02-15 12:24:49 +00:00
Daniel van Vugt
7e32c4196e clutter/stage-view: Reimplement CLUTTER_SHOW_FPS
Since a9a9a0d1c5 it didn't print anything. Now we reimplement it to
show FPS to a higher precision than in 3.36, add update/render times,
and separate stats per view/CRTC.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/154>
2021-02-15 08:42:18 +00:00
Jonas Ådahl
4145fbbae4 clutter/timeline: Clear stage view listener when actor destroyed
We might have a stage view listener attached to the stage itself if the
actor didn't have a suitable frame clock when the actor was associated
with the timeline. We'd then listen to stage-views-changed signals on
the stage itself to be able to attach to a frame clock when one
appeared.

What went wrong is that if an actor that didn't have a frameclock was
associated with a timeline, but then destroyed, the timeline would
disassociate itself from the actor, but it'd still listen on the
stage-views-changed signal on the stage. This would be in itself
harmless, until the timeline itself is destroyed, as at this point, it
wouldn't clean up the stage-views-changed listener on the stage, as it's
assumed to only be valid when there is an actor attached.

Fix this issue by cleaning up the stage's stage-views-changed listener
when the actor is destroyed, as we wouldn't be able to make use of it by
then anyway.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3323
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1719>
2021-02-08 19:40:05 +00:00
Ivan Molodetskikh
34a9e6a8f8 clutter/frame-clock: Fix presentation time alignment
Before this commit, next presentation time could end up behind now_us or
ahead of now_us depending on how presentation times happened to be
aligned relative to integer multiples of refresh_interval_us. It's not
clear whether this was originally intended because even if it the next
presentation time ends up behind now_us, it is moved ahead by a while
loop down below in this function.

Even though this difference in behavior didn't really matter, it made
reasoning about the subsequent branches more complex. It would also
potentially introduce bugs if the logic was to be modified. So this
commit makes it so next presentation time is always ahead of now_us.

It also adds a comment with a graph detailing the computations, and
adjusts the variable names to drop unfortunate terminology mistakes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
01b30ff9e4 clutter/frame-clock: Comment presentation time skip
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
ed93a11de6 clutter/frame-clock: Comment common case of next presentation time
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
bc7c56fa74 clutter/frame-clock: Always update last presentation time
Last presentation time is mainly used to make sure predicted
presentation time is aligned with display refreshes. Even if it went
back in time, there will be no issue as next presentation time takes
current time into account. Synthetic presentation time is not exactly
aligned with display refreshes, so using it would only result in
inconsistent animations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
8bdad733ca clutter/frame-clock: Fix typo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
dae089f79e clutter: Remove CLUTTER_ENABLE_EXPERIMENTAL_API
It is no longer used anywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
33d91937cf clutter/stage: Remove sync_delay
It is not accessed anywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
9b44aa77b6 clutter: Remove clutter_stage_set_sync_delay
The sync_delay field is never accessed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
f97d2c5f67 clutter: Remove clutter_stage_skip_sync_delay declaration
It wasn't defined or used anywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Jonas Ådahl
5104a9b2ce remote-desktop/session: Add support for SelectionTransfer/Write
When a transfer request is done to the MetaSelectionSourceRemote source,
it's translated to a SelectionTransfer signal, which the remote desktop
server is supposed to respond to with SelectionWrite.

A timeout (set to 15 seconds) is added to handle too long timeouts,
which cancels the transfer request.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
30e1c51b33 Change all g_memdup() to g_memdup2()
Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
2021-02-04 19:16:28 +01:00
Daniel van Vugt
41bf0181b9 clutter/offscreen-effect: Set the viewport correctly
Previously we were setting the FBO's viewport to be the same dimensions as
the stage itself for compatibility. This works for most cases, but not if
the actor is larger than the stage. In that case it could cause excessive
clipping if the actor's transformed screen position was negative, which
is seen in https://gitlab.gnome.org/GNOME/gnome-shell/issues/2087

Also if a small actor paints to its negative dimensions (like a box-shadow)
then we might be missing those pixels on the left or top, even though
they're inside the paint volume.

Now we set the viewport dimensions to match the area we're actually
rendering so the FBO contents are never over or under clipped.

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

Although if you try using shadows larger than that (like in
gnome-shell#1090) then you will also need gnome-shell!1417.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1053>
2021-02-02 09:42:56 +00:00
Daniel van Vugt
f887b02714 clutter/offscreen-effect: Unscale first, then translate the FBO texture
We had been doing it backwards as far back as e3966882e8 which meant
that we were translating by `fbo_offset / resource_scale` stage units
instead of just `fbo_offset`.

Because `fbo_offset` is in stage units already, it's not scaled and so
needs to be applied after the unscaling from texels to stage units.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1053>
2021-02-02 09:42:56 +00:00
Carlos Garnacho
d1c62d882a clutter: Do not read settings from ini file
We've inherited, and still keep in place, code that reads ini files
at ~/.config/clutter-1.0/settings.ini and /etc/clutter-1.0/settings.ini
to tweak different aspects of Clutter.

Some of these should use GSettings instead, some others are exposed
nowadays differently for our purposes (e.g. envvars, looking glass, ...).
Overall seems like an unexpected entry point nowadays, so remove the
parsing of these .ini files altogether.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1693>
2021-01-28 23:09:56 +01:00
Carlos Garnacho
2113eccd47 clutter: Load mouse related ClutterSettings properties from GSettings
These are forgotten here, leaving clutter with the builtin defaults.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1693>
2021-01-28 23:09:55 +01:00
Jonas Ådahl
1d4e535e7a clutter/stage: Remove 'paint' argument in capture_into()
There are more suitable API when the stage needs to be actually painted
into something. Nothing actually used this anymore too, so remove this
functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
92a0b16675 stage/cogl: Don't finish offscreen at end of paint
It'll "finish" implicitly whenever accessed, so we don't need to do
anything here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Daniel van Vugt
ad65de3790 clutter/stage-cogl: Clamp queued_redraw_clip if in use
If we are about to replace `redraw_clip` with a clamped version of itself
then we may as well do the same for `queued_redraw_clip`, so you can see
more precisely what the damage of the current frame is.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:17:44 +08:00
Daniel van Vugt
456f80022a clutter/stage-cogl: Remove unnecessary variable: fb_damage
We no longer have use for a different value to fb_clip_region, so
fb_damage no longer needs to exist.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:17:36 +08:00
Daniel van Vugt
88600c8985 clutter/stage-cogl: Ensure redraw_clip is a superset of fb_clip_region
Initially we generate the new part of fb_clip_region from the new part
of redraw_clip, scale it up and clamp. But the clamping means the new
part of fb_clip_region might now represent a slightly larger area than
the new part of redraw_clip, by one pixel.

In some rare cases where a foreground actor honours redraw_clip, but
the background actor does not (meaning it might fill all fb_clip_region),
you could find 1px rendering glitches in that gap as the background
actor paints there but the foreground actor does not.

To ensure such glitches can never happen we now regenerate the final
redraw_clip as a clamped superset of the final fb_clip_region. That's
the minimum area we must paint to ensure no gaps appear inside
fb_clip_region.

Although the fix here sounds like the intent of the old code, the old
code forgot to include the new part of fb_clip_region in the clamping
of the final redraw_clip. So the new part of redraw_clip was sometimes
kept too small for the new part of fb_clip_region.

We also move the code to the main path because technically it's also
needed when `has_buffer_age == FALSE`.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1500
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:15:01 +08:00
Jonas Ådahl
c985753442 cursor-renderer/native: Update HW state during frames
Before each frame is maybe redrawn, push any new cursor KMS state to the
pending update. It'll then either be posted during the next page flip,
or when the same frame finishes, in case nothing was redrawn.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
88b06e39f4 clutter/stage-view: Add notify_ready()
Just as with the frame clock, add an API to communicate that a frame did
not result in a presentation. This can't happen yet but will when we
emulate atomic cursor plane changes using legacy drmMode API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
84f454fd4f clutter/frame-clock: Add notify_ready()
In constrast to notify_presented(), notify_ready() also returns the
state machine to the idle state, but without providing new frame
information, as no frame was actually presented.

This will happen for example with the simple KMS impl backend will do a
cursor movement, which will trigger a symbolic "page flip" reply in
order to emulate atomic KMS behavior. When this happen, we should just
try to reschedule again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
447c51e68e renderer-native: Always post device wide updates during mode set
Don't mode set each CRTC in separate KMS updates, as reconfiguring one
CRTC might cause other CRTCs to be implicitly reset thus as well,
causing KMS return EBUSY if using atomic modesetting.

Prepare for this by compositing each CRTC first including adding steps
to the KMS update, but wait until all views has rendered at least once
before posting the initial update. After this each CRTC is posted
separately.

Using EGLStreams instead of normal page flipping seems to fail when
doing this though, so handle that the old way for the EGLStream case,
i.e. eglSwapBuffers() -> mode set with dumb buffer -> eglStream
"acquire" (resulting in page flip under the hood).

For this we also introduce a new error code so that we don't use client
buffers when doing mode sets, which could accidentally configure the
CRTC in a way that is incompatible with the primary plane buffers.

Do the same also when we're in power save mode, to only have one special
case path for this scenario in the regular swap-buffer path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
92d4cb5184 clutter/frame: Make rendering backends set the frame result
Instead of setting the frame result in the most generic layer, have the
backends do it themselves. This is necessary to communicate that a
swap-buffer call didn't really succeed completely to present the swapped
buffer, e.g. errors from KMS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
249512b068 cogl/onscreen: Add opaque user_data pointer to onscreen present calls
This argument is intended to be used by clutter to be able to
communicate with the onscreen backend, that happens to be the native
backend. It will be used to pass a ClutterFrame pointer, where the
result of page flips, mode sets etc can be communicated whenever it is
available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
72b35e07c0 clutter: Introduce ClutterFrame
ClutterFrame aims to carry information valid during dispatching a frame.
A frame may or may not include redrawing, but will always end with a
result.

A asynchronous page flip, for example, will result in a
CLUTTER_FRAME_RESULT_PENDING_PRESENTED, while a frame that only
dispatched events etc will result in CLUTTER_FRAME_RESULT_IDLE. Instead
of this being implicit, make the ClutterStageWindow implementation
handle this itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
9c500f23e4 clutter/stage-view: Always call finish_frame()
This will later be utilized to handle the frame clock result outside of
this function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
722f7ae2c3 clutter/stage-window: Pass 'view' to finish_frame() too
Not used yet, just done separately to decrease future diffs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
904116fe4d clutter/seat: Don't unref backend on finalize
We never took a ref on the backend, it's the backend that owns the seat,
not the other way around.

This silences warnings spewed on tear down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 20:29:36 +01:00
Jonas Ådahl
50607523bc clutter/backend: Clear stage window pointer after removing weak ref
Otherwise when dispose() is called multiple times we spew warnings on
tear down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 20:29:36 +01:00
Carlos Garnacho
ff43eb8745 clutter: Update settings location for font aa/hinting/rgb order
Update to the new settings location as per recent gsettings-desktop-schema.

Related: https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/issues/31
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1416>
2021-01-14 13:58:16 +00:00
Georges Basile Stavracas Neto
2c57f0986a clutter/click-action: Release if motion crosses drag threshold
When the drag threshold is crossed while the click action is pressed,
release it. This way, we can avoid spurious "clicked" signals from
being emitted.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1667>
2021-01-14 13:30:19 +00:00
Georges Basile Stavracas Neto
6239e6db18 clutter/click-action: Only emit "clicked" when within drag threshold
ClutterClickEvent currently doesn't check if button press and release
happen within the drag threshold, which can be surprising sometimes.

Only emit the "clicked" signal if the button press and release happen
within the area of drag threshold.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1667>
2021-01-14 13:30:19 +00:00
Georges Basile Stavracas Neto
8a82abc4d7 clutter/click-action: Factor out drag threshold check
Next commit will perform the same check to determine if the
button release should emit the "clicked" signal or not, so
put it in a shared function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1667>
2021-01-14 13:30:19 +00:00
Marc-Antoine Perennou
d439501faf clutter: Fix build with clang
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1668>
2021-01-11 22:52:10 +01:00
Jonas Dreßler
7871ab5437 clutter/timeline: Don't manually set frame clock in set_actor()
In clutter_timeline_set_actor() we currently always unset the
priv->frame_clock pointer of the old actor when a new actor gets set.
The priv->frame_clock pointer takes a reference on the ClutterFrameClock
though, so we leak ClutterFrameClocks here.

To fix it, simply rely on update_frame_clock(), which will call
set_frame_clock_internal() unconditionally to update the
priv->frame_clock pointer for us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1632>
2021-01-11 09:42:10 +00:00
Sebastian Keller
791761499a clutter/effect: Don't call effect paint_node() if pre_paint() failed
Some effects such as the BrightnessContrastEffect try to skip rendering
by returning early with a FALSE return value in pre_paint() in cases
where the effect would not change the rendering. This stopped working
when effects were ported to paint nodes.

In the case of OffscreenEffects, like BrightnessContrastEffect,
pre_paint() is responsible for setting up the offscreen buffer which is
then used in paint_node(). However if pre_paint() fails, this buffer is
not created and attempting to use it will result in several error
messages and broken rendering.

Instead of trying to call paint_node() of the effect if pre_paint()
failed, just draw the actor.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1658>
2021-01-02 19:00:39 +00:00
Jonas Dreßler
189eb4c7a7 clutter/actor: Remove superfluous line
This sets exactly the same thing as the line above and doesn't
manipulate any parts of the calculation, too, it's most likely a very
old copy-paste mistake, remove it.

Thanks to Rafał Mikrut for discovering it.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1660>
2020-12-31 10:17:01 +01:00
Carlos Garnacho
4fb968af76 clutter: Remove reentrancy checks at emit_event_chain()
When using alt-tab to switch between windows, on a key handler we
undo the compositor grab, which triggers a repick, which generates
crossing events, which are handled in place, and trigger these
reentrancy checks.

On one hand, we do intend these crossings to take effect in place,
rather than being queued (possibly after a number of already queued
events). On the other hand, we now outright discourage generating
events from random places (and hope to make it just not possible,
eventually) thus we can afford not to protect against reentrancy
caused by API misuse.

So just drop these checks, and let these crossing events be
properly handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Carlos Garnacho
b04e326572 clutter/main: Add clutter_stage_repick_device() call
This is the very same code than meta_wayland_pointer_repick(),
made part of Clutter, so triggering repicks on the same pointer
coordinates is made easy.

The intention is to remove meta_wayland_pointer_repick() in favor
of this call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
794962327e clutter/main: Change picked actor before emitting crossing events
Updating the state before emitting the CLUTTER_LEAVE event allows its
handlers to query the pointer actor, and avoid getting the same actor
again. Conceptually, this makes picking more "atomic", and the events a
notification of the change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-22 18:27:37 +01:00
Jonas Dreßler
3a8b714e72 clutter: Use G_PARAM_EXPLICIT_NOTIFY for actor and stage properties
Turns out GObject implicitly notifies all properties by default as soon
as a property setter is called, no matter if the property actually
changed or not. One can opt-out of this behavior by setting the
G_PARAM_EXPLICIT_NOTIFY flag.

So since almost all our properties get notified explicitely (well,
except ClutterActors deprecated show-on-set-parent property), set this
flag for all properties of ClutterActor and ClutterStage now. This
significantly reduces the number of notify:: signals emitted on
ClutterActors, because in gnome-shell javascript we usually set GObject
properties directly, not by going through the extra setter method.

More cleanups can be done in the future, since this flag is suitable for
almost every property in Clutter and even Mutter.

This fixes a crash where we'd hit a newly introduced assertion in
on_device_actor_reactive_changed() of ClutterStage because
notify::reactive got emitted multiple times.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1651>
2020-12-20 12:37:34 +01:00
Jonas Dreßler
ad65c89d3c clutter/stage: Use own list of pointer devices to find updated devices
Due to a few reasons currently the updating of input devices after stage
relayouts isn't working right now. Since we now have a list of pointer
devices in ClutterStage, we can simply use that list and can avoid
asking the input thread. Also we no longer need to check whether the
devices are pointer devices, since our list only consists of pointer
devices.

So switch to ClutterStages private list of pointer devices, which also
includes the core pointer (as opposed to the list returned by
clutter_seat_peek_devices()). This fixes picking after relayouts.

Note that this doesn't catch every possible change that might need a
repick, actors might also need a repick after transformation changes or
in case their custom clip has been changed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1634>
2020-12-18 18:32:05 +00:00
Jonas Dreßler
ae6d83fb47 clutter: Switch to storing device->actor associations in ClutterStage
As planned and prepared with the last commits, let ClutterStage take
care of tracking input devices and their respective actors. This means
we now can remove the old infrastructure for this from
ClutterInputDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 16:17:00 +01:00
Jonas Dreßler
a9a9d27ead clutter: Add function to update input device actors to clutter-main
We're moving keeping track of input devices and their associated actors
out of ClutterInputDevice, this commit basically adds replacements for
clutter_input_device_update() and clutter_input_device_set_actor() to
clutter-main and shuffles the internals of those functions around a bit
for clarity.

clutter_stage_update_device() is made available in clutter-mutter.h
because we need to update the actor of input devices not only from
ClutterStage (when repicking after relayout), but also from
MetaWaylandPointer (inside meta_wayland_pointer_repick()).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 15:13:48 +01:00
Jonas Dreßler
98a5cb37d9 clutter/stage: Add infrastructure to track devices and their actors
With the introduction of the input thread, we want to avoid modifying
ClutterInputDevices from the main thread, since they're owned and
updated by the thread.

There's one part of ClutterInputDevice that's still modified from the
main thread though, that is device-actors of pointer devices, and we're
going to move that state-tracking into ClutterStage instead.

So start that by adding the infrastructure to ClutterStage to keep track
of those things. It consists of two hashtables which associate devices
and touch sequences with actors, those hashtables get updated using
clutter_stage_update_device_entry() and
clutter_stage_remove_device_entry(), they can be queried by calling
clutter_stage_get_device_actor(), which will replace
clutter_input_device_get_actor().

clutter_stage_get_device_coords() is added and made available in
clutter-mutter.h because we need to get the coordinates when repicking
in meta_wayland_pointer_repick().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 15:09:48 +01:00
Georges Basile Stavracas Neto
49653b0b0a clutter/blur: Select a better n_steps
The n_steps variable corresponds to the number of *pairs* of
texture lookups that the blur shader does. For example, when
n_steps = 1, the for-loop reads 1 pixel before and 1 pixel
after the current one.

Our blur shader is heavily inspired in WebRender's blur shader,
the biggest difference being that we calculate the gaussian
samples in the fragment shader itself, and not in the vertex
shader. (This could be an improvement in performance for the
future though!)

WebRender's blur shader calculates n_steps differently than what
we currently do, though. It calculates n_step in such a way that
at least 2 steps are performed for evey non-zero sigma value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
5fca8f231a clutter/blur: Fix shader loop
We must iterate at least once, and i starts at 1, so use
less-or-equal in the for-loop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
0b4b341e6c clutter/blur: Make sigma a float
The shader already operates on floating point sigma, and
there's just no reason for us to force it to be an unsigned
integer. It's still important that sigma must be positive
though.

Make sigma a float, and make sure it's a positive number.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
925809ea75 clutter/blur: Pass direction as vec2
Yet another way to reduce the instruction count of the fragment
shader. Passing a pair of floats once is virtually free, compared
to computing horizontal and vertical on each fragment run.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
8588352d1d clutter/blur: Remove uniform locations from BlurPass
They're not used anywhere except when setting up the pipeline, so
make them local variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Daniel van Vugt
261447a498 clutter/stage: Steal and manually free pending_queue_redraw entries
New entries indirectly added to `pending_queue_redraw` during the loop
would make our iterator invalid and cause `g_hash_table_iter_next` to
fail without having visited all elements. That was seen as assertion
failures but also likely resulted in incomplete paint clips.

Now we steal the iterator's entry before such corruption can happen,
free it manually, and reset the iterator to the beginning on every
iteration. This is actually safe and efficient because we're removing each
entry we visit. So no time is wasted in resuming from the (new) beginning
of the hash table.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1557
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1615>
2020-12-17 16:21:17 +08:00
Georges Basile Stavracas Neto
2f01ef69e3 clutter/paint-node: Add multi-rect operations
Add a new pair of APIs corresponding to CoglFramebuffer's draw_rectangles()
and draw_textured_rectangles(). They're generally more performance compared
to adding multiple single-rect operations. These variants are heavily used
by GNOME Shell's CSS implementation.

The op array is built to match cogl_framebuffer_draw_textured_rectangles()
always, which means it's a series of 8 floats composed (x1 y1 x2 y2) and
(s1 t1 s2 t2). To avoid adding new struct fields to ClutterPaintOperation,
which is a performance and memory sensitive structure, simply divide the
array length by 8 (which is guaranteed to be correct).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
2020-12-17 03:04:03 +00:00
Georges Basile Stavracas Neto
2cef2b6b1e clutter/paint-node: Rename multitex_coords to coords
The array will be used not only for multitexture, but also for
multirectangle operations. Rename it to be generic enough to
cover both cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
2020-12-17 03:04:03 +00:00
Georges Basile Stavracas Neto
d717cc9231 clutter/blur: Shortcircuit when sigma is 0
When there's no blur to be performed, don't do any; instead,
return the original texture, and don't run the vertical and
horizontal blur pipelines.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
2020-12-17 03:04:03 +00:00
Jonas Dreßler
7de5f79ddb Revert "clutter/offscreen-effect: Use the paint volume origin as the FBO offset"
This change broke the color picker in gnome-shell, let's revert it for
now until a correct solution can be figured out.

This reverts commit 0bace8dbde.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3494

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1645>
2020-12-16 23:08:25 +00:00
Georges Basile Stavracas Neto
53f7b6c149 clutter: Simplify framebuffer setup using ortho projection
Setting an ortho projection gives us pretty much the same result as
manually calculating the projection matrix. The ortho projection is
actually more "complete" than the custom projection we've been using,
as it also considers z-near and z-far, but in practice the generated
pixels are exactly equal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1642>
2020-12-16 11:46:26 -03:00
Georges Basile Stavracas Neto
431bde921c clutter/effect: Move ClutterEffect creation to ClutterActor
As so paint node creation is centralized in a single function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 12:07:57 -03:00
Georges Basile Stavracas Neto
46c68f368f clutter/offscreen-effect: Document paint nodes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 12:07:57 -03:00
Georges Basile Stavracas Neto
4898408404 clutter/effect: Add paint nodes to all paint vfuncs
In the purely paint node based rendering future, ClutterEffects
simply add more paint nodes to the tree when painting the actor.

This is the leap to achieve that future.

Add paint nodes to pre_paint, paint, and post_paint, and move the
ClutterEffectNode creation to _clutter_effect_paint().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 11:48:28 -03:00
Georges Basile Stavracas Neto
ea20076bad clutter/offscreen-effect: Implement paint_node()
The paint node tree that ClutterOffscreenEffect generates is
simple:

  Root
    |------------+
    |            |
  Layer        Pipeline
    |
  Actor

Right now, both pre-paint and ClutterLayerNode push the offscreen
to the framebuffer stack. That's harmless, and will go away soon
anyway.

The actor node is created and added in a separate function because
it'll be reused by the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 11:48:28 -03:00
Georges Basile Stavracas Neto
26c1a5eedf clutter/offscreen-effect: Use paint nodes to paint target
Add a new ClutterPaintNode parameter to the paint_target() vfunc.
For now, create a temporary ClutterEffectNode that is passed to
paint_target() and immediately painted; next commits will move
this to upper layers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
691d31748a clutter/desaturate-effect: Switch to create_pipeline vfunc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
b3641e0833 clutter/colorize-effect: Switch to create_pipeline vfunc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
5c628083b6 clutter/brightness-contrast-effect: Switch to create_pipeline vfunc
Pretty much the exact same steps and constraints of the previous
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
5587c70c6a clutter/blur-effect: Switch to create_pipeline vfunc
The blur pipeline is still cached on ClutterBlurEffect, and we
simply update the uniforms when asked to create the pipeline.

Now that ClutterOffscreenEffect will use the blur pipeline, it
doesn't need to override the paint_target() vfunc anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
5794871977 clutter/offscreen-effect: Add new create_pipeline() vfunc
The most annoying aspect of ClutterOffscreenEffect right now, and
the reason for all its subclasses to override pre-paint, is that
the pipeline creation isn't under subclasses' control. That means
all subclasses must ask ClutterOffscreenEffect to run pre-paint
and create the pipeline, then they all create their own pipelines
to paint.

To reduce this complexity, add a new create_pipeline() vfunc to
ClutterOffscreenEffect. Next commits will port effects to use this
new vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
6654053250 clutter/paint-nodes: Make ClutterLayerNode always push/pop
ClutterLayerNode currently skips pushing the offscreen framebuffer when
no operations are set. This was added at the time because pushing and
popping was a synchronization point in Cogl, slow enough to force the
layer node to have this protective measure. Nowadays, pushing and
popping on the paint context is free.

Make ClutterLayerNode always push and pop in pre and post paint.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
2020-12-15 10:36:34 -03:00
Georges Basile Stavracas Neto
15f5087135 Introduce ClutterBlurNode
ClutterBlurNode is a paint node based on ClutterLayerNode
that draws all children in an offscreen framebuffer, blurs
this framebuffer, and finally paints the blurred contents
according the the paint operations added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
2020-12-14 09:45:50 -03:00
Georges Basile Stavracas Neto
3440fbd358 clutter: Add private ClutterBlur
ClutterBlur is a small helper structure that implements
blurring a texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
2020-12-14 09:43:08 -03:00
Georges Basile Stavracas Neto
3a3eaf5ad3 clutter/paint-nodes: Fix blit node oversights
Copy-paste error sneaked ClutterTransformNodeClass in
clutter_blit_node_class_init(). It wasn't problematic
because they both typedef to ClutterPaintNodeClass, but
fix it anyway.

Also switch to g_object_ref() in clutter_blit_node_new().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
2020-12-14 09:21:30 -03:00
Daniel van Vugt
ebf9f18080 clutter/text: Make update_cursor_location() operate in stage coordinates
Until now we would `clutter_input_focus_set_cursor_location` with
cursor-rectangle-in-physical-pixels + actor-location-in-stage-coordinates.
But those use different scaling factors so it only got the right answer
when the framebuffer scale was 1.0.

This directly determines the geometry of the invisible dummy cursor in
gnome-shell ibusCandidatePopup.js:

```
  panelService.connect('set-cursor-location', (ps, x, y, w, h) => {
      this._setDummyCursorGeometry(x, y, w, h);
  });
```

And because it's invisible it wasn't obvious that it was wrong until you
enable `CLUTTER_PAINT=damage-region` and you can see its ghost at the wrong
offset and scale.

So now we `clutter_input_focus_set_cursor_location` using purely unscaled
stage coordinates. And `CLUTTER_PAINT=damage-region` shows that
gnome-shell's `_dummyCursor` is placed precisely over the visible cursor.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3399
and probably other IBus issues that arise when using framebuffer scaling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1576>
2020-12-12 08:18:49 +00:00
Daniel van Vugt
db30a4d7b4 clutter/text: Scale down clutter_text_get_cursor_rect to actor coordinates
`priv->cursor_rect` is stored in physical pixels, not local coordinates.
So unscale it before returning from `clutter_text_get_cursor_rect`, which
is explicitly documented as returning "actor-relative coordinates".

This went missed with fractional scaling support, and unnoticed as nobody
uses `clutter_text_get_cursor_rect` yet. But that will soon change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1576>
2020-12-12 08:18:49 +00:00
Daniel van Vugt
0bace8dbde clutter/offscreen-effect: Use the paint volume origin as the FBO offset
Before now it was assumed that the only negative local coordinates would
be those introduced by `_clutter_actor_box_enlarge_for_effects`, and we
used the difference for `fbo_offset_x/y`. But that was misguided (of me)
because gnome-shell can give us paint volumes at negative coordinates too,
like when rendering `box-shadow` on the top or left edge of an actor.

The maximum extents of negative coordinates we might need to render are
in fact the (enlarged) left and top edges of the paint volume. So use
those as the FBO offset. This places the actor's local origin correctly
within the FBO and thus also ensures it's not over-clipped at the edges
of the FBO, which now line up with the enlarged extents of the paint
volume.

This fixes one third of
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1090
The other fixes required are !1053 and gnome-shell!1417.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1538>
2020-12-12 00:27:46 +00:00
Jonas Dreßler
9693462f32 clutter/actor: Use different view list when picking frame clock of stage
Apparently it can happen that a timeline tries to pick a frame clock
from an actor that's on a stage, but the actor still doesn't find a
frame clock and returns NULL.

This probably is the case when starting a timeline right after attaching
an actor to a newly created stage, so before the first stage-update
cycle. In this case clutter_actor_update_stage_views() will not have run
and the stage-actor will have priv->stage_views set to NULL even though
there are stage views.

To prevent this from happening, use the complete list of stage views
maintained by the backend when picking a frame clock for the stage.

This doesn't fix any issue appearing on master, but is correct
nonetheless.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1631>
2020-12-11 22:51:44 +00:00
Carlos Garnacho
e21929be82 clutter: Do not poke backend code for motion compression
We now have all info available in ClutterEvent, use it and stop poking
backend internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
0842ac936f clutter: Drop infrastructure to copy/free platform event data
This is now unused, all information belongs to ClutterEvents.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
b88790554b clutter: Move relative motion information to ClutterEvent
Instead of using native backend platform data specifically, store
this info in ClutterMotionEvent. This includes time in usec since
it's just used for motion events, in the future it could make sense
to make these general to all events again, but it could make sense
to make ClutterEvent structs private before.

In order to express that a motion event has relative motion info,
the CLUTTER_EVENT_FLAG_RELATIVE_MOTION event flag has been added
for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
eaa04ecee5 backends: Unify touch sequence to slot conversion
We had code in both backends that sort of independently associated
sequences to slots. Make both transform slots to sequences the same
way, so they may share the implementation convert those back to slots.

This helper now lives in Clutter API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
9f5c453fc7 clutter: Move evdev evcode data to Clutter button/key events
We have this as platform-dependent data in the native backend, and
a bunch of fallback code done in place in the evcode users. Stop
making this platform-dependent data, and move it to the relevant
ClutterEvents.

The fallback code for the X11 backend case is about the same, but
now it is done directly by the X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
4a0c56f928 clutter: Simplify stage state management
Making this an event is overly convoluted, accounting that we
emit the event, then convert it to a ClutterStage signal, then
its only consumer (a11y) sets the active ATK state.

Take the event out of the equation, unify activation/deactivation
of the stage in MetaStage, and use it from the X11 backend too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
96e320ba5a clutter: Drop CLUTTER_DESTROY_NOTIFY event
Stop propagating this as a Clutter event. DestroyNotify is only
relevant on nested X11 sessions, so handle it specifically in place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
49b3ac2f86 clutter: Drop CLUTTER_CLIENT_MESSAGE event
This is used nowhere and emitted nowhere. We can do without it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Georges Basile Stavracas Neto
033423f6db Introduce ClutterBlitNode
It is not possible to express a blit operation using paint
nodes as of now. This is a requirement for GNOME Shell, e.g.,
to implement its blur effect.

Add a new ClutterBlitNode node that takes two framebuffers as
input, and blits the source framebuffer into the current one
according to added rectangles.

Because this paint node uses the rectangles in a different way
compared to all the other nodes, add an auxiliary method to
ensure all blit operations are valid.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
63ea2dacc4 clutter/paint-nodes: Add new ClutterLayerNode API
ClutterLayerNode is the "offscreen framebuffer" node, that paints it's
child nodes in a separate framebuffer, and then copies that framebuffer
to the parent one.

It'll be useful to hand ClutterLayerNode which framebuffer and pipeline
to use, as this is a requirement for porting e.g. ClutterOffscreenEffect
and subclasses.

Add a new clutter_layer_node_new_to_framebuffer() API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
89f9be0dd1 clutter/paint-nodes: Add opacity overriding to ClutterActorNode
Some effects, such as ShellBlurEffect and ClutterOffscreenEffect, need
to make sure the actor is painted fully opaque. With ClutterActorNode,
however, that is currently not possible.

Add a new 'opacity' parameter to clutter_actor_node_new(). It follows
the opacity override heuristic, where -1 means disable, and anything
else is clamped to [0, 255].

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:04 +00:00
Georges Basile Stavracas Neto
5c772a634e clutter/effect: Add paint_node vfunc
Introduce a new paint_node vfunc that, if implemented, allows
the effect to add nodes to a transient paint node that is
immediately painted. This is a transitional step until we
have fully delegated paint node rendering.

The most basic implementation of a ClutterEffect.paint_node
vfunc, and also the default implementation, is with an actor
node, as follows:

```
static void
foo_bar_paint_node (ClutterEffect           *effect,
                    ClutterPaintNode        *node,
                    ClutterPaintContext     *paint_context,
                    ClutterEffectPaintFlags  flags)
{
  g_autoptr (ClutterPaintNode) actor_node = NULL;

  actor_node = clutter_actor_node_new (effect->actor);
  clutter_paint_node_add_child (node, actor_node);
}
```

This example gives the exact same behavior of simply calling
clutter_actor_continue_paint(). In the future, the paint node
itself will be a parameter of clutter_actor_continue_paint()
and we'll be able to simplify it event more.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:03 +00:00
Georges Basile Stavracas Neto
e45d1c6ea6 Introduce ClutterEffectNode
ClutterEffectNode is a private ClutterPaintNode implementation
that does effectively nothing, but helps organizing the paint
node tree. It also helps debugging, since it can output the
effect class and name to the JSON debugging routines.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:03 +00:00
Georges Basile Stavracas Neto
3c8bfc1482 clutter/paint-node: Walk up paint node tree to find framebuffer
The idea of having a paint node tree is that we don't really need
to retrieve the framebuffer from ClutterPaintContext. For example,
ClutterLayerNode draws into an offscreen framebuffer; if any child
of a layer node needs to retrieve a framebuffer to draw, the layer
node's offscreen framebuffer should be used.

However, clutter_paint_node_get_framebuffer() goes straight to the
root node of the tree, skipping any potential paint nodes with a
custom framebuffer.

Modify clutter_paint_node_get_framebuffer() to walk up the paint
node tree until a node with a custom framebuffer appears. In many
cases, this will end up either in dummy or layer node's custom
framebuffer implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
2020-12-08 15:14:03 +00:00
Carlos Garnacho
14ab90eeba clutter/actor: Initialize out variable
Fixes a compiler warning with -Wmaybe-uninitialized enabled:

  ../../../../Source/gnome/mutter/clutter/clutter/clutter-actor.c: In function ‘clutter_actor_paint’:
  ../../../../Source/gnome/mutter/clutter/clutter/clutter-actor.c:3808:50: warning: ‘result’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   3808 |       else if (result == CLUTTER_CULL_RESULT_OUT && success)
        |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

Which might presumably happen in the unlikely case that there's no clip
frusta.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1624>
2020-12-08 13:35:50 +00:00
Daniel van Vugt
e91062aaec clutter/pick-stack: Add a copyright for Canonical
Where much of the logic was introduced in commit 14c706e51b

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
2ff5bb4299 backends/native: Update keyboard a11y status in seat impl
Instead of going through the event queue, stage handling code, and
back to the input device via a vmethod call, do this directly in the
MetaSeatImpl. This is not too different from X11, where everything
happens inside the backend.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:34 +00:00
Carlos Garnacho
e0444a3d35 clutter: Move ClutterInputDevice fields to private struct
All that is left in the "public" struct is all state that ClutterStage
delegates on ClutterInputDevice. That should move somewhere else, but
not here, not now.

All private fields belong to construct-only properties, with only getter
API, and idempotent vmethods (except keyboard a11y, atm). This should
be enough to make ClutterInputDevice obviously thread safe, outside the
backend.

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

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

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

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

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

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

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

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

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

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

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
2c1558ddbd backends: Make device tracking at MetaInputSettings ad-hoc API
Depending on the backend, we want to integrate this object at different
levels. It will sit close to the MetaBackendX11/MetaSeatX11 in X11, but
it will be put deep down with MetaSeatImpl in the native backend, in a
separate thread.

Since we can't depend on a single object type, nor are able to track
ClutterSeat signals neatly, make this API something to be called
explicitly by backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
c601a824e9 clutter: Update device for the current tool in backends
This should happen deeper in backends, not here in clutter-main.

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

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

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

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

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

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

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
fba1122a3c clutter: Add ClutterSeat::query_state() vmethod
This will query a device state; position and modifiers.
Note that ClutterSeat subclasses don't implement the vmethod yet,
so calling clutter_seat_query_state() may crash ATM.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Daniel van Vugt
17dbb98811 clutter/stage: Remove fps_timer
It's unused since a9a9a0d1c5.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1603>
2020-11-26 11:03:08 +00:00
Georges Basile Stavracas Neto
6c4b897d74 clutter/actor: Cull out when picking
Testing points and rays against boxes is substantially cheaper - in
fact, almost trivial - compared to triangles. Check if the actor's
paint volume doesn't intersect with the current pick point / ray,
and skip recursing altogether in those cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
1fdde25b3e clutter/paint-volume: Add new API to convert to graphene_box_t
Will be used to cull when picking based on the actor's projected
paint volume.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Georges Basile Stavracas Neto
1b29d265a8 clutter/stage: Remove cached pick mode
The cached pick mode never actually cached anything, since it is
always, unconditionally reset when painting. Furthermore, next
commits will cull out actors during pick, which makes the pick
stack uncacheable.

Remove the cached pick mode.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
2020-11-25 16:34:29 +00:00
Simon McVittie
1a1f1eccba clutter/frame-clock: Schedule a frame at least once per second
Users of Debian arm64 (aarch64) report that on at least some GPUs
or screens, after time-based screen blanking has occurred, it is not
possible to unlock the screen. Bisection indicates that this regressed
in commit 209b1ba3, so presumably this is because a refresh rate of 0
is reported while the screen is blanked, leading to the frame clock
pausing forever.

Fixes: 209b1ba3 "clutter/frame-clock: Adapt refresh rate from to frame info"
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1536
Bug-Debian: https://bugs.debian.org/974172
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1601>
2020-11-25 10:14:10 +00:00
Jonas Dreßler
58930e9e1f clutter/actor: Use a variable to check if culling is allowed
Since we now want to check whether culling is force-disabled using a
debug flag in two places, let's factor this out into a separate
variable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00
Jonas Dreßler
1cd386551d clutter/actor: Remove the queue-redraw signal
The "queue-redraw" signal is not used anywhere in Clutter and we now
also removed the vfunc implementation of the stage. So stop emitting it
and remove it, but keep the propagate_queue_redraw infrastructure to
make sure clones still get their redraws queued.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00
Jonas Dreßler
ce4c297cea clutter/actor: Emit the queue-redraw signal right away
Since we now decoupled the "queue-redraw" signal from creating the stage
clip, we can move signal emission into
_clutter_actor_queue_redraw_full() and emit the signal right away when
queueing a redraw on an actor. With that we now no longer have to
accommodate for the stage pending_queue_redraws list changing while
iterating over it.

To ensure we don't emit the signal too often when multiple redraws are
queued on one actor, use the propagated_one_redraw flag to limit the
number of emissions to a single one for every update cycle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00
Jonas Dreßler
9b16eff784 clutter: Move assembling the redraw clip out of "queue-redraw" signal
Putting together the redraw clip of the stage never really fitted nicely
with the "queue-redraw" signal emission, it forces us to emit the
signals in a batch and we also use a weird trick to get the old paint
volume that's already on-screen into the final redraw clip (we call
_clutter_actor_propagate_queue_redraw() on the stage).

So start breaking up this association by making the stage explicitely
request the redraw clip from the actor and removing the
ClutterPaintVolume argument from _clutter_actor_finish_queue_redraw().
This is done by adding a private function
clutter_actor_get_redraw_clip() which returns our old (currently
visible) paint volume and the new paint volume.

This also allows removing the check whether a full stage redraw has been
queued in clutter_actor_real_queue_redraw() and we can now just stop the
signal emission if a propagation happened at least once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1511>
2020-11-24 18:30:19 +00:00
Georges Basile Stavracas Neto
3cf11f77b3 clutter/pick-stack: Move triangle check to else block
Just to improve the legibility of this part of the code. We
go either through box, or triangle, but never both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1599>
2020-11-23 13:34:28 -03:00
Georges Basile Stavracas Neto
d2feaa8d67 clutter/pick-stack: Use graphene_box_t for axis-aligned rectangles
The most common case for Clutter is 2D axis-aligned actors, which
maintain these properties even after projecting to eye coordinates.
In those cases, we can use a simpler hit test by checking against
boxes.

Not only this is simpler, but this maintains an important aspect
of picking that is a requirement for Clutter: watertightness. Even
though the triangles checks do work on x86_64, they do not guarantee
watertightness. This breaks tests on ARM.

Use graphene_box_t to hit-test axis-aligned 2D actors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1599>
2020-11-23 13:34:28 -03:00
Jonas Dreßler
b5a7fe4b23 clutter/actor: Handle clips correctly when building paint volume
clutter_actor_paint() implements a clear preference for custom clips
over clip_to_allocation: If a custom clip is set, clip_to_allocation is
ignored.

Since the paint volume reflects what Clutter is going to paint, we
should handle it the same when putting together our paint volume: So
first handle custom clips, and if one is set, use that. Then handle
clip_to_allocation, and if that's set, use that. And finally, if both
aren't set, union our allocation with the children paint volumes to get
the building volume.

clutter_actor_paint() also doesn't check whether the custom clip is
empty: If that's the case, it will simply not paint anything. Given that
that's allowed by clutter_actor_paint(), the paint volume should also
follow here and return an empty paint volume in case the custom clip is
empty.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1592>
2020-11-23 14:06:13 +00:00
Jonas Dreßler
44563d2932 clutter/actor: Don't union child paint volumes if clip is set
When a custom clip is set for an actor, this actor is not going to allow
any painting outside that clip. That includes the children, which may
also not paint outside that clip.

Now in case clip_to_allocation is set to TRUE, we already already do the
right thing and simply use the allocation as our paint volume, ignoring
the volumes of our children. The same should be done for the custom
clip, so also stop the process of building the paint volume once we see
that a custom clip is set and simply use that clip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1592>
2020-11-23 14:06:13 +00:00
Jonas Dreßler
3843293e40 clutter/text: Use new pango API to compare attribute lists
Use the new API provided by Pango to compare two PangoAttrLists, this
means we can also detect equal lists that were newly created and avoid
the expensive relayout of the ClutterText a lot more often.

Depends on https://gitlab.gnome.org/GNOME/pango/merge_requests/172

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1050>
2020-11-22 14:57:05 +01:00
Daniel van Vugt
f78cfc0c80 clutter/stage-cogl: Don't paint the blue debug region where it's also red
When using CLUTTER_DEBUG_PAINT_DAMAGE_REGION, the blue swap region is
always a superset of the red redraw region. So painting both in full (since
the previous commit) just meant the red region was overdrawn and came out
purple. That doesn't provide enough visual contrast, changes the user
experience unexpectedly and reduces performance.

So just subtract the redraw region from the swap region. This way the
red redraw region is always red, not purple.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1571>
2020-11-20 17:14:26 +00:00
Daniel van Vugt
96a185d8bc clutter/stage-cogl: Colour fb_clip_region in CLUTTER_DEBUG_PAINT_DAMAGE_REGION
Previously when CLUTTER_DEBUG_PAINT_DAMAGE_REGION was set, that would lead
to has_buffer_age==FALSE, which would lead to use_clipped_redraw==FALSE
which would mean swap_region was always empty. And so the blue region of
CLUTTER_DEBUG_PAINT_DAMAGE_REGION was always empty, *and* fb_clip_region
was always the full view rectangle which is not useful for debugging.

Now when CLUTTER_DEBUG_PAINT_DAMAGE_REGION is set, we don't let that
affect use_clipped_redraw, which means fb_clip_region is calculated
realistically.

But that's not enough. Calculating fb_clip_region properly with
CLUTTER_DEBUG_PAINT_DAMAGE_REGION would still lead to colouring artefacts
left on screen from previous frames that don't apply to the current frame.
So to fix that we also paint_stage for the whole screen every time when
using CLUTTER_DEBUG_PAINT_DAMAGE_REGION.

So now you will only ever see red and blue shading that's applicable to
the current frame, and no artefacts from the previous frames.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1535
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1571>
2020-11-20 17:14:26 +00:00
Daniel van Vugt
a0dbf3b84c clutter/stage-cogl: Scale and offset the swap region before debug painting
It was being painted without scaling and offsetting so would only look
right at scale 1.0 and only on the view with origin (0,0). Now we include
the framebuffer scale and view origin it will be painted in the correct
location.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1571>
2020-11-20 17:14:26 +00:00
Robert Mader
f7cef11515 clutter/stage-view: Make get_refresh_rate() public
We'll need it in a follow-up commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1468>
2020-11-19 19:41:40 +01:00
Carlos Garnacho
23ae8b4519 clutter: Drop clutter_input_device_get_device_id()
Move the GObject property to MetaInputDeviceX11, and throw away the
rest. This is no longer public API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
045181f321 clutter/main: Drop usage of clutter_input_device_get_device_id()
Just print the name in those debug logs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
7aa63d6b8b clutter/event: Drop clutter_event_get_device_id()
Drop this odd shortcut, it is now unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
287d9b6b6f clutter/click-action: Move away from device IDs
Store the press device itself, not its ID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Daniel van Vugt
32b68478ed clutter/stage-cogl: Avoid copying fb_clip_region
Because it gets destroyed (unreferenced) immediately after that.
This avoids a deep copy of potentially kilobytes of data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1572>
2020-11-18 19:08:38 +08:00
Carlos Garnacho
34710eabc0 clutter/event: Do not filter out DEVICE_ADDED/REMOVED events
These devices in x11 are "disabled", that doesn't mean we should refrain
from notifying about them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1553
2020-11-07 10:12:49 +01:00
Corentin Noël
25bb5676df clutter/stage: Add documentation and annotations
Increase the documentation coverage and add some missing annotations to be able to
use some methods correctly with the GObject Introspection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1545>
2020-11-04 11:59:58 +02:00
Jonas Dreßler
c88615aac8 clutter/actor: Queue redraw on no-layout parents when unmapping
As explained in https://gitlab.gnome.org/GNOME/mutter/-/issues/1494,
with commit 29caa5bea5 we stopped queueing
a relayout for the parent of the removed actor in
clutter_actor_remove_child_internal(). This relayout was, as opposed to
the relayout in clutter_actor_real_hide()/clutter_actor_real_unmap(),
queued unconditionally without looking at the parents NO_LAYOUT flag.

Now while that relayout in clutter_actor_remove_child_internal() would
do unnecessary work if the parent had the NO_LAYOUT flag set, it did
also queue a redraw of the parent, which is necessary in any case.

So by removing that relayout in clutter_actor_remove_child_internal(),
we stopped queueing redraws for NO_LAYOUT parents when a child gets
removed from the scenegraph. This caused bugs where the texture of the
child would be left visible on the screen even though the child got
destroyed.

To fix this, make sure again that we always queue a redraw on the parent
when unmapping a child.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1494
2020-11-03 22:53:31 +00:00
Jonas Dreßler
b1700c3f7b clutter/actor: Remove two unused functions in private header
Those two functions are nowhere to be found in our code, so remove those
function headers which were probably forgot during another cleanup.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1528
2020-10-26 17:36:49 +00:00
Jonas Dreßler
84dd6b4af5 clutter/stage: Remove redraw_pending and redraw_count
The redraw_pending boolean is used to schedule the first stage update
after starting Clutter. This flag is superfluous because we have the
pending_finish_queue_redraws flag which does the same.

While at it, also remove the redraw_count debug variable, since there
should be better ways to count the number of queued redraws nowadays,
for example Sysprof marks.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1527
2020-10-26 18:26:30 +01:00
Jonas Dreßler
10392359a9 clutter/actor: Make functions to queue relayout/redraw on clones static
We don't call those functions from outside ClutterActor and we also
shouldn't, so remove them from the private header and define them
statically.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1527
2020-10-26 18:26:28 +01:00
Jonas Dreßler
3ea9217be2 clutter/actor: Remove _clutter_actor_queue_redraw_with_clip()
Queueing a redraw with a clip is easy enough and this function is
private anyway, so remove it and call _clutter_actor_queue_redraw_full()
instead in the one function using it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1527
2020-10-26 18:26:26 +01:00
Jonas Dreßler
8b21fb4f96 clutter: Remove ClutterRedrawFlags
ClutterRedrawFlags are a way to give Clutter additional context
about what it needs to redraw. There currently is only one flag defined,
CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION, this flag would clip the redraw to
the actors current allocation.

Since ClutterActor also provides the clip_to_allocation property (which
affects the paint volume of the actor instead of only one redraw), the
additional CLIPPED_TO_ALLOCATION flag seems unnecessary. It's also only
defined to be used privately in Clutter, which it never is, so let's
remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1527
2020-10-26 18:26:24 +01:00
Jonas Dreßler
52e2afa2ec clutter/actor: Don't check handlers when emitting stage-views-changed
Turns out the g_signal_has_handler_pending() call in
update_stage_views() is actually more expensive than comparing the
sorted list (which is usually very short), so remove that and simply
always emit the signal.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1524
2020-10-26 13:45:57 +00:00
Georges Basile Stavracas Neto
da7671b547 clutter/actor: Don't push identity transforms
It is useless, and needlessly increases the matrix stack and
does more multiplications than necessary.

Don't push identity transforms to the pick stack.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 10:19:04 -03:00
Georges Basile Stavracas Neto
ce6f13357a clutter/pick-context: Remove clutter_pick_context_get_framebuffer()
It is not used anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 10:19:04 -03:00
Georges Basile Stavracas Neto
54db1b2fa2 clutter/actor: Remove cached inverse transform
It is not used anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 10:19:04 -03:00
Georges Basile Stavracas Neto
7d25cbe87f Use graphene_ray_t to pick actors
This commit introduces a few important changes in order to
acommodate graphene_ray_t. Most of them are positive changes,
so don't panic :)

The first very visible change is that neither the actor box
nor the clip rectangles are projected before being pushed.
This required changing the parameters of the related functions
at both ClutterPickContext, and ClutterPickStack, to receive
boxes instead of vertices. These rectangles are projected on
demand now, so in the best case (first actor picked) only
one projection happens; and in the worst case, it projects
as much as it does now.

The second important change is that there are no more checks
for axis-alignment anymore. That's because picking now happens
in 3D space, using triangles.

Talking about triangles in 3D space, this is what is used now
for picking. We break down each actor rectangle in 2 triangles,
and check if the projected pick point is inside any one of them,
of if the ray intersects any one of them. The same check happens
for the clip rectangles.

Checking the projected pick point is both an optimization for the
2D case, and a workaround to graphene_ray_t problems with float
precision, which is specially visible on edges such as the top
bar.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 10:19:01 -03:00
Georges Basile Stavracas Neto
620f0ad74b clutter/pick-stack: Store current matrix entry
This is the beginning of the preparations to passing unprojected
rectangles to the clip stack. Store a ref to the current tip of
the matrix entry.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:57:33 -03:00
Georges Basile Stavracas Neto
f411834d42 Introduce ClutterPickStack
ClutterPickStack is a new boxed type that stores the vertices
and clip rectangles. It is meant to be a byproduct of picking,
and takes over most of what ClutterStage currently does.

It introduces a 'seal' system, inspired by MetaKmsUpdate. After
the pick operation is done, and the rectangles are collected,
the pick stack is sealed, and is not allowed to be externally
modified anymore. Internally, it still can invalidate pick
records when an actor is destroyed.

For now, it handles both the clip rectangles, and the matrix
stack, separatedly. Future commits will rearrange this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:56:42 -03:00
Georges Basile Stavracas Neto
0d79a0faf8 clutter/stage: Remove useless cached pick mode reset
It happens a couple of lines above, in _clutter_stage_clear_pick_stack().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
56ed0bf001 clutter: Remove pick mode from context
It is not used anywhere now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
8d47f79b2c clutter/actor: Remove '_paint' suffix from clutter_actor_should_pick_paint
We're not using paint to pick anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
05b6b6a88d clutter/actor: Use pick context in clutter_actor_should_pick_paint()
Pass the ClutterPickContext to clutter_actor_should_pick_paint() and
check the pick mode from it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
a4961ad4a7 clutter/pick-context: Make pick context aware of the pick mode
Pass the pick mode during construction, and add a getter for it. It'll
be used by the next patches to make clutter_actor_should_pick_paint()
not depend on a global context.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
8a709b5766 clutter/stage: Add pick trace
It will help profiling picking times, and compare this future patches
with status quo.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Jonas Dreßler
cc7c7fa015 clutter/actor: Remove the paint signal and keep the paint vfunc
The "paint" signal of ClutterActor has been a pain for everyone involved
long enough now, turns out we actually use it nowhere except tests
anymore (which has been handled in the last commits), so get rid of it
for good before anyone starts using it again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1522
2020-10-23 22:07:01 +02:00
Carlos Garnacho
027abc6ea7 clutter: Drop unused field in ClutterInputDevice struct
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
8d9dc097e4 clutter: Drop clutter_input_device_set_time()
An input device does not have time on itself, events do. This was made
unused so drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
a76a47fbde clutter: Pass timestamp to clutter_input_device_set_actor()
This function emits crossing events, so needs a (most times truthful)
timestamp. Make it explicit instead of fetching it from the device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
90001f09b3 clutter/main: Drop dead code branches
We shouldn't get an input event that has not a device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
6e49ad436d clutter: Drop clutter_input_device_set_stage()
Also drop the stage argument from clutter_input_device_set_coords()
in consequence. No one uses this already.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
a67f676b0d clutter: Drop clutter_input_device_get_[pointer_]stage()
Input devices are not related to the stage in any way. Drop all the
users that relied on it being so.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
af249ddf44 clutter: Do not depend on device stage on ClutterInputMethod
Look it up through other means.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
f99fc2ae9c clutter: Pass stage on to _clutter_input_device_set_actor()
Don't rely on the device stage, so specify the stage in the callers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
6a6894a397 clutter: Specify stage on clutter_input_device_update() function
This is the function performing the picking, tell it explicitly the
stage it should happen on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
6cb1557d99 backends: Move absolute/relative device mapping to native backend
This is a bit scattered around, with the setter/getter in Clutter, and
it only being only directly honored in Wayland (it goes straight through
device properties in X11).

Make this private native API, and out of public ClutterInputDevice API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
b6a020e9ff clutter: Sanitize ClutterInputDevice header
Move some exposed setters to private headers. It makes some sense to
provide those for backends, not as much to the upper layers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Carlos Garnacho
bd4062a196 clutter: Limit number of touch slots available to a virtual touch device
It's not worth letting these devices have an "unlimited" range of touch
slots. Limiting it to 32 is more than enough to map it with real touch
devices nowadays.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Jonas Dreßler
de610a13f1 clutter/actor: Reset allocation when unrealizing actor
Since commit eb9cd3857d we initialize the allocation of ClutterActors to
an UNINITIALIZED ClutterActorBox. We do that to ensure the actor even
emits notify::allocation in case it got a new valid allocation of
0,0,0,0.

Now there's still the case where an actor gets removed from the
scenegraph and added again to a different parent, in this case we still
don't emit notify::allocation right now in case the new allocation
equals the old one. There's two good reasons to do so though:

1) To Clutter, there's no difference between a newly created actor and
an actor which got removed from the scenegraph, it's not consistent to
always notify the allocation property in the former situation, but not
always notify it in the latter situation.

2) When an allocation changes, Clutter notifies the subtree of that
actor about an absolute geometry change (see the call to
transform_changed() in clutter_actor_set_allocation_internal()). Now
when an actor gets reparented, obviously the absolute geometry might
change, so to make sure transform_changed() is always called in that
case we need to make sure an allocation change happens.

So simply reset the allocation property of the actor to an UNINITIALIZED
ClutterActorBox as soon as it gets unrealized.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1498
2020-10-20 18:22:10 +02:00
Jonas Dreßler
76578e5aa0 clutter/actor: Remove absolute_origin_changed flag again
We introduced the absolute_origin_changed flag when preparing for the
removal of ClutterAllocationFlags in commit dc8e5c7f8b. Turns out in the
mean-time commit df4eeff6f2 happened, which renders the whole
absolute_origin_changed flag moot.

That's because we now notify the whole subtree about the absolute origin
change by calling transform_changed() when the allocation of an actor
changes. transform_changed() traverses the subtree and calls
absolute_geometry_changed() on every actor immediately, which renders
the whole propagation of the absolute_origin_changed flag obsolete.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1498
2020-10-20 18:22:10 +02:00
Jonas Dreßler
29caa5bea5 clutter/actor: Don't queue relayouts inside add/remove_child_internal
Since we now moved the queuing of relayouts into the mapping and
unmapping functions, we no longer need to do it when adding or removing
a child, that's because removing a child always unmaps the child, and
adding it to a stage (if it's visible) will map it.

So remove those calls to queue_relayout() since they're no longer
needed.

With the above we no longer queue a relayout in
clutter_actor_add_child_internal(), that means there's one place where
we need to explicitely queue relayouts now: That's when using the
set_child_at_index/above/below() APIs, those are special because they
avoid unmapping and mapping of actors and would now no longer get a
relayout.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
3bca29f303 clutter/actor: Only allocate when actor is mapped, not only visible
In theory there's no big difference between only handling mapped actors
vs only handling visible actors in clutter_actor_allocate(): The
function is called recursively starting with an actor that is attached
to a stage, so it should only be called on mapped actors anyway.

The behavior of skipping hidden actors was introduced as an optimization
with commit 0eab73dc. Since the last commit, we handle
enable_paint_unmapped a bit better and don't do unnecessary work when
mapping or unmapping, so we can now be a bit stricter enforcing our
invariants and only allow mapped actors in clutter_actor_allocate().

We need to exclude toplevel actors from this check since the stage has a
very different mapped state than normal actors, depending on the
mappedness of the x11 window. Also we need to make an exception for
clones (of course...): Those need their source actor to have an
allocation, which means they might try to force-allocate it, and in that
case we shouldn't bail out of clutter_actor_allocate().

Also moving the clutter_actor_queue_relayout() call from
clutter_actor_real_show() to clutter_actor_real_map() seems to fix a bug
where we don't queue redraws/relayouts on children when a parent gets
shown.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
717b857bd8 clutter/actor: Use separate priv pointer in clutter_actor_real_(un)map
We're accessing self->priv quite often in those functions, it makes
sense to use a separate variable for it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
9b50215008 clutter/actor: Handle getting (un-)mapped during painting differently
We currently support only one case where an actor can get mapped or
unmapped during painting, that is using
_clutter_actor_enable_paint_unmapped() (although we could arguably do a
better job explicitely forbidding it in other cases). This function is
called when painting ClutterClone or MetaWindowActors during
screensharing. It temporarily (fake) realizes and maps the actor and all
its children so it can get painted.

Now a problem will appear when we'll start coupling layout and the
mapped state of actors more closely with the next commit: Since
enable_paint_unmapped() is meant to be enabled and disabled during every
clone paint, we also notify the "mapped" property twice on every clone
paint. That means with the next commit we would queue a relayout for the
source actor on every clone paint.

To avoid this unnecessary work, check whether we're being painted while
unmapped using the new unmapped_paint_branch_counter. Then avoid queuing
relayouts or invalidating paint volumes in that case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
cbf3001bc2 clutter/actor: Add private API to get whether we're painting unmapped
Add new private API to ClutterActor, returning TRUE in case the actor is
being painted while unmapped. This is useful for implementations of the
paint() vfunc or for signal handlers of the "notify::mapped" signal.

Use this API in CallyActor to properly detect "notify::mapped" emissions
while painting unmapped, this fixes detecting the case where
painting-unmapped is used for screencasting.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
bf7cfb877c clutter/actor: Introduce counter for painting in an unmapped branch
Just like the existing in_cloned_branch counter, add a property which
tracks whether the actor is part of a subtree that's being painted while
unmapped. This is going to be useful for a few things, for example
changing the clutter_actor_is_in_clone_paint() API to use
enable_paint_unmapped instead of in_clone_paint.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
734a7cc16f clutter/actor: Alway call queue_relayout() when showing actors
clutter_actor_queue_relayout() detects whether a parent has the
NO_LAYOUT flag set by itself and then queues a shallow relayout for us.
There's no need to duplicate that logic when showing actors, so simply
call clutter_actor_queue_relayout() and let that handle it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366
2020-10-20 15:27:43 +00:00
Jonas Dreßler
d2f8a30625 clutter/paint-volume: Use graphene for computing union of paint volumes
Apparently clutter_paint_volume_union() has problems building the union
of two paint volumes in eye coordinates, that's probably because of the
negative coordinates that come into play there.

Circumvent that by making even more use of Graphene and letting it take
care of computing the union. We do that by creating two graphene_box_t's
from the axis-aligned paint volumes and intersecting those boxes, then
setting our vertices to the new min and max points of the resulting box.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1507
2020-10-19 21:38:51 +02:00