Commit Graph

6899 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
4959ae8bc4 clutter/brightness-contrast-effect: Compare float with G_APPROX_VALUE
Nobody should ever compare float for equality. Use G_APPROX_VALUE to
check that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/992

(cherry picked from commit 84ea4ad990)
2020-02-02 17:50:30 +01:00
Georges Basile Stavracas Neto
aea5541ffa clutter/offscreen-effect: Clear offscreen when pre-paint fails
Some ClutterOffscreenEffect subclasses, such as ClutterBrightnessContrastEffect,
early-return FALSE in pre-paint before chaining up. It's an important optimization
that avoids creating or updating the offscreen framebuffer.

However, if an offscreen framebuffer already exists by the time pre-paint fails,
it will be used *without* repaint the actor over it. That causes an old picture
of the actor to be displayed.

Fix that by always clearing the offscreen framebuffer when pre-paint fails.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/810

https://gitlab.gnome.org/GNOME/mutter/merge_requests/992

(cherry picked from commit 64685f4b20)
2020-02-02 17:49:34 +01:00
Georges Basile Stavracas Neto
47fe7ac25b clutter/offscreen-effect: Clear offscreen framebuffer when disabling
When changing the 'enabled' property and disabling the offscreen effect,
it doesn't make sense to preserve the offscreen framebuffer. It's not
drawing, after all.

Furthermore, because ClutterOffscreenEffect only checks if the offscreen
framebuffer exists to decide whether or not to redraw, keeping the fbo
alive is a waste of resources.

Clear the offscreen framebuffer when the effect is disabled or enabled.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/810

https://gitlab.gnome.org/GNOME/mutter/merge_requests/992

(cherry picked from commit bf594e9fb6)
2020-02-02 17:31:46 +01:00
Georges Basile Stavracas Neto
d35d7fb618 clutter/offscreen-effect: Use g_clear_pointer for cleanup
It does the exact same checks, and saves us a few lines of code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/992

(cherry picked from commit 3958e75ed2)
2020-02-02 17:31:46 +01:00
Sebastian Keller
5724310899 clutter/stage: Fix picking of rectangles with negative positions
FLT_MIN is the smallest *positive* number above 0 that can be
represented as floating point number. If this is used to initialize the
maximum x/y coordinates of a rectangle, this will always be used if all
x/y coordinates of the rectangle are negative. This means that picking
at 0,0 will always be a hit for such rectangles.

Since mutter creates such a window for server side decorations on X11,
this window will always be picked at 0,0 preventing clicking/hovering
the activities button in gnome-shell at that coordinate.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/893


(cherry picked from commit 674f52ba74)
2019-12-24 16:52:37 +00:00
Robert Mader
9c372388da clutter/cally-root: Use g_clear_signal_handler and fix a signal leak
This commit was split out from `cleanup: Use g_clear_signal_handler()
where possible` as it fixes an actual signal leak and should therefore
get backported to stable releases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 16:22:14 +01:00
Olivier Fourdan
a112d7a10e clutter/stage-view: Separate offscreen and shadowfb
Previously, we would use a single offscreen framebuffer for both
transformations and when a shadow framebuffer should be used, but that
can be dreadfully slow when using software rendering with a discrete GPU
due to bandwidth limitations.

Keep the offscreen framebuffer for transformations only and add another
intermediate shadow framebuffer used as a copy of the onscreen
framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/917

(cherry picked from commit 2b8b450fe16c21f0f37a1779560c0e5da61a9b89)
2019-11-04 11:08:02 +01:00
Marco Trevisan (Treviño)
bf17e04010 clutter/stage: Actually set key focus to an actor on key focus
As per commit c2d03bf73 we're using a private method to set the actors key
focus and emit key-focus-in signal, but we're using inverted logic here.

So flip the parameter to match the expected result.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/860


(cherry picked from commit 553211dd81)
2019-10-15 18:31:50 +00:00
Marco Trevisan (Treviño)
a22731e2b2 clutter/actor: Save key-focus state and unset it before destruction
When clutter actors with key focus are destroyed we emit ::key-focus-out on
them just after their destruction. This is against our assumption that no
signal should be emitted after "::destroy" (see GNOME/mutter!769 [1]), and
in fact could cause the shell to do actions that we won't ever stop on
destroy callback.

To avoid this to happen, use a private function to set its key-state (so we
can avoid looking for the stage) and emit ::key-focus-in/out events and use
this value in both clutter_actor_has_key_focus(),
clutter_actor_grab_key_focus() and on unmap and destruction to unset the
stage key focus before we emit the ::destroy signal.

As result of this, we can now avoid to unset the key focus on actor
destruction in the stage.

[1] https://gitlab.gnome.org/GNOME/mutter/merge_requests/769

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


(cherry picked from commit c2d03bf73e)
2019-10-15 10:42:55 +00:00
Georges Basile Stavracas Neto
943b069996 clutter/shader-effect: Initialize shader-type properly
The default value of the ClutterShaderEffect:shader-type
property is CLUTTER_FRAGMENT_SHADER. However, because the
struct field is not actually initialized to it, it ends
up assuming the value 0, which is CLUTTER_VERTEX_SHADER.

Properly initialize ClutterShaderEffect's shader_type to
CLUTTER_FRAGMENT_SHADER.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/846
2019-10-11 10:53:33 -03:00
Jonas Ådahl
2c388e2155 clutter/transition: Don't split reference counting with actor
ClutterActor took a reference in its transition 'stopped' handler,
aiming to keep the transition alive during signal emission even if it
was removed during. This is, however, already taken care of by
ClutterTimeline, by always taking a reference during its 'stopped'
signal emission, so no need to add another one.

This also has the bonus of making reference ownership simpler, as well
as avoidance of double free if an actor was destroyed before a
transition has finished.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/828
2019-10-07 18:33:28 +00:00
Jonas Ådahl
6ee006c851 clutter/actor: Mark implicit transitions as remove-on-complete
Implicit transitions had a referenced taken while emitting the
completion signals, but said reference would only be released if it was
had remove-on-complete set to TRUE.

Change this to instead remove the 'is_implicit' state and mark all
implicit transitions as remove-on-complete. This fixes a
ClutterPropertyTransition leak in gnome-shell triggered by e.g. showing
/ hiding menus.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/828
2019-10-07 18:33:28 +00:00
Daniel van Vugt
26b76ee95d clutter/base-types: Clarify docs for point_inside_quadrilateral
The final version of the function was changed to allow points that are
touching the edge of a quadrilateral to be counted as "inside". Update
the function documentation to refect this.

Also clarify that the function is written in such a way that it is
agnostic to clockwise or anticlockwise vertex ordering.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/783
2019-10-03 17:06:28 +00:00
Olivier Fourdan
0a3f25c303 clutter/stage-view: Ignore clipping rectangle for offscreen blit
In `clutter_stage_view_blit_offscreen()`, the given clipping rectangle
is in “view” coordinates whereas we intend to copy the whole actual
framebuffer, meaning that we cannot use the clipping rectangle.

Use the actual framebuffer size, starting at (0, 0) instead.

That fixes the issue with partial repainting with shadow framebuffer
when fractional scaling is enabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/820
2019-10-03 10:12:21 +02:00
Marco Trevisan (Treviño)
105a3f757a clutter/actor: Don't emit property changes after ::destroy
Clutter actors might emit property changes in dispose, while unparenting.
However we assume that the ::destroy signal is the last one we emit for an
actor, and that starting from this moment the object is not valid anymore,
and so we don't expect any signal emission from it.

To avoid this, freeze the object notifications on an actor during its
disposition, just before the ::destroy signal emission.

Update the actor-destroy test to verify this behavior.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/769
2019-10-02 17:59:22 +00:00
Marco Trevisan (Treviño)
f376a318ba clutter/actor: Don't emit the parent-set signal on destruction
Clutter actors unset their parent on dispose, after emitting the ::destroy
signal, however this could cause ::parent-set signal emission. Since we
assume that after the destruction has been completed the actor isn't valid
anymore, and that during the destroy phase we do all the signal / source
disconnections, this might create unwanted behaviors, as in the signal
callbacks we always assume that the actor isn't in disposed yet.

To avoid this, don't emit ::parent-set signal if the actor is being
destroyed.

Update the actor-destroy test to verify this behavior.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/769
2019-10-02 17:59:22 +00:00
Olivier Fourdan
05e1a6c2ca clutter/stage-view: Use cogl_blit_framebuffer() for shadow FB
If there is no transformation, use `cogl_blit_framebuffer()` as a
shortcut in `clutter_stage_view_blit_offscreen()`, that dramatically
improves performance when using a shadow framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/809
2019-09-27 20:47:45 +00:00
Marco Trevisan (Treviño)
c9c53cb55f clutter/actor: Cancel delayed timelines on removal
Delayed clutter timelines might be removed while they are still in the
process of being executed, but if they are not playing yet their delay
timeout won't be stopped, causing them to be executed anyway, leading to a
potential crash.

In fact if something else keeps a reference on the timelines (i.e. gjs), the
dispose vfunc delay cancellation won't take effect, causing the timelines to
be started and added to the master clock.

To avoid this, expose clutter_timeline_cancel_delay() function and call it
if a timeline is not playing but has a delay set.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/815
https://gitlab.gnome.org/GNOME/mutter/merge_requests/805
2019-09-20 16:51:20 +02:00
Marco Trevisan (Treviño)
1e637bd7e1 clutter/timeline: Don't emit ::paused signal on delayed timelines
If a timeline is delayed and we request to stop or pause it, we are emitting
the "::paused" signal on it, however this has never been started, and so
nothing has really be paused.

So, just try to cancel the delay on pause and return if not playing.

No code in mutter or gnome-shell is affected by this, so it is safe to
change.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/805
2019-09-20 16:51:20 +02:00
Marco Trevisan (Treviño)
63a0b702c9 clutter/timeline: Use a function to cancel the delay timeout
Avoid repeating the same code for canceling the delay timeout, using a
function for later uses.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/805
2019-09-20 16:51:20 +02:00
Marco Trevisan (Treviño)
b69d2aa6a0 stage: Compute view perspective when parameters changed
Clutter stage used to compute the initial projection using a fixed z
translation which wasn't matching the one we computed in
calculate_z_translation().
This caused to have a wrong initial projection on startup which was then
correctly recomputed only at the first paint.

However, since this calculation doesn't depend on view, but only on viewport
size, perspective's fovy and z_near we can safely do this at startup and
only when any of those parameters change.

Then we can move the computation out _clutter_stage_maybe_setup_viewport()
since the cogl framebuffer viewport sizes aren't affecting this.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1639
https://gitlab.gnome.org/GNOME/mutter/merge_requests/803
2019-09-20 13:51:33 +02:00
Daniel van Vugt
0b19078b2b clutter/stage-cogl: Use portable formatting for 64-bit integers
On 64-bit systems int64_t is %ld but on 32-bit systems it is %lld.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/778
2019-09-20 11:55:32 +02:00
Daniel van Vugt
7811865e84 clutter/paint-node: Convert safely from pointer to integer
To support 32-bit systems without compiler warnings.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/778
2019-09-20 11:55:25 +02:00
Jonas Dreßler
ab7af2d0c5 clutter/actor: Remove unused private function
`_clutter_actor_get_transition` is almost identical to
`clutter_actor_get_transition` and isn't used anywhere in the code (we
stopped using it with ee00e37b), remove it!

https://gitlab.gnome.org/GNOME/mutter/merge_requests/791
2019-09-12 21:36:02 +00:00
Jonas Dreßler
f92e0bec0b clutter/actor: Fix a wrong comment
According to the definition of ClutterAnimationInfo in
clutter-actor-private.h, `transitions` is the third variable of the
struct, not the first one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/791
2019-09-12 21:36:02 +00:00
Olivier Fourdan
2f072af02b clutter/input-pointer-a11y: Restore pointer a11y on resume
When suspending, the devices are removed and the virtual device
associated with the corresponding core pointer is disposed.

Add the pointer accessibility virtual device to the core pointer
on resume to restore pointer accessibility on resume if enabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/761
2019-09-02 17:27:17 +00:00
Daniel van Vugt
14c706e51b clutter: Introduce geometric picking
Currently, Clutter does picking by drawing with Cogl and reading
the pixel that's beneath the given point. Since Cogl has a journal
that records drawing operations, and has optimizations to read a
single pixel from a list of rectangle, it would be expected that
we would hit this fast path and not flush the journal while picking.

However, that's not the case: dithering, clipping with scissors, etc,
can all flush the journal, issuing commands to the GPU and making
picking slow. On NVidia-based systems, this glReadPixels() call is
extremely costly.

Introduce geometric picking, and avoid using the Cogl journal entirely.
Do this by introducing a stack of actors in ClutterStage. This stack
is cached, but for now, don't use the cache as much as possible.

The picking routines are still tied to painting.

When projecting the actor vertexes, do it manually and take the modelview
matrix of the framebuffer into account as well.

CPU usage on an Intel i7-7700, tested with two different GPUs/drivers:

  |         |     Intel | Nvidia |
  | ------: | --------: | -----: |
  | Moving the mouse:            |
  | Before  |       10% |    10% |
  | After   |        6% |     6% |
  | Moving a window:             |
  | Before  |       23% |    81% |
  | After   |       19% |    40% |

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/154,
        https://gitlab.gnome.org/GNOME/mutter/issues/691

Helps significantly with: https://gitlab.gnome.org/GNOME/mutter/issues/283,
                          https://gitlab.gnome.org/GNOME/mutter/issues/590,
                          https://gitlab.gnome.org/GNOME/mutter/issues/700

v2: Fix code style issues
    Simplify quadrilateral checks
    Remove the 0.5f hack
    Differentiate axis-aligned rectangles

https://gitlab.gnome.org/GNOME/mutter/merge_requests/189
2019-09-02 16:41:13 +00:00
Daniel van Vugt
a70823dd1c clutter/point: Add ClutterPoint quarilateral testing API
Add a function to check whether a point is inside a quadrilateral
by checking the cross product of vectors with the quadrilateral
points, and the point being checked.

If the passed quadrilateral is zero-sized, no point is ever reported
to be inside it.

This will be used by the next commit when comparing the transformed
actor vertices.

[feaneron: add a commit message and remove unecessary code]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/189
2019-09-02 16:41:13 +00:00
Jonas Ådahl
97140ab634 Revert "clutter/stage-cogl: Remove pending_swaps counter"
This reverts commit f57ce7254d.

It causes crashes, https://gitlab.gnome.org/GNOME/mutter/issues/735, and
changes various expectations relied upon by the renderer code, and being
close to release, it's safer to revert now and reconsider how to remove
the pending swap counter at a later point.
2019-08-27 20:16:01 +03:00
Jonas Dreßler
a51437ee2b clutter/input-pointer-a11y: Include success boolean in stop signals
Add a boolean parameter to the signal to inform the handler whether the
timeout completed successfully or not. This allows the shell to
gracefully end the pie timer animation and show a success animation when
the click happens.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/745
2019-08-27 07:36:57 +00:00
Olivier Fourdan
b8dcd5f842 clutter/main: Ignore synthetic events for accessibility
When a dwell click causes the pointer to move to another surface, a
synthetic event is generated which triggers another dwell click.

Make sure we ignore those to avoid dwell clicking twice in a raw.

Suggested-by: Carlos Garnacho <carlosg@gnome.org>
https://gitlab.gnome.org/GNOME/mutter/merge_requests/747
2019-08-24 12:43:20 +03:00
Olivier Fourdan
14e02635ff clutter/input-pointer-a11y: Trigger dwell detection in a timeout
Restarting the dwell click immediately would result in a contant
animation showing.

Start dwell detection in its own timeout handler, which has the nice
effect of not constantly showing a dwell animation and also making sure
that the dwell click timeout is started when pointer movement stops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/747
2019-08-24 12:43:20 +03:00
Jonas Dreßler
9b3b5badfb clutter/input-pointer-a11y: Fix dwell timeout start after moving pointer
Sometimes the dwell timeout doesn't start again after quickly moving the
pointer. That happens if `should_stop_dwell` returns TRUE for the last
motion event we receive: It will stop the current timeout, but not start
a new one until we receive another event where the moved distance is
smaller than the threshold.

To fix this, always call `should_start_dwell` and `start_dwell_timeout`
instead of using an else-block, this makes sure we start a new dwell
timeout still during the same motion event that stopped the old one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/746
2019-08-24 09:25:14 +00:00
Jonas Dreßler
47c1558287 clutter/input-pointer-a11y: Remove unneeded character
https://gitlab.gnome.org/GNOME/mutter/merge_requests/746
2019-08-24 09:25:14 +00:00
Carlos Garnacho
cc7e843c44 tests: Move clutter-test-utils.[ch] to src/tests
And add the necessary glue so those initialize a X11 clutter backend.
This should get Clutter tests that are dependent on windowing to work
again, thus they were enabled back again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
cfb8f18cef clutter: Move tests to src/tests
Clutter doesn't hold anymore backend implementations, move tests where
we have one that we may assign.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
8b03d9ecc3 clutter: Move evdev input to src/backends/native
The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendNative, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
ea54ce7d96 clutter: Drop functions to get XVisualInfo
We don't need nor use visuals anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
cb31e3e12a clutter: Drop unused function to translate to screen coordinates
We don't have anything like GdkInputMode that we'd like to honor, this
can just be dropped.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
ad72fa46b0 clutter: Move X11 input to src/backends/x11
The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendX11, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
fa4580de53 clutter: Temporarily comment out clutter tests
It will be enabled back in later commits. We're set for quite a ride
here.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
5e343e2c16 clutter: Remove support for foreign stages
We have no use for this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
ef93bb6471 clutter: Remove event retrieval toggle
This is x11-specific API that was added back when clutter was out
of tree. Just remove it and directly do what we want.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
d6aaef9954 clutter: Drop _() define
It's an unused no-op, we can do without it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
2ca351366e clutter/cally: Remove needless per-backend code in cally
We can poke the X11 stage to translate to root coordinates, or just assume
the compositor will cover the root window area and avoid per-backend behavior
here.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
f54bf022bd clutter: Remove ClutterEventExtender interface
Just move those methods to ClutterDeviceManager, since the two available
ones want to implement it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00
Carlos Garnacho
e56df455ae clutter: Drop ClutterEventTranslator interface
We don't need that much complexity when we have a fixed set of
translators, and only one of them wants a given event.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00
Carlos Garnacho
54101b1948 clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterDeviceManager
https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00
Carlos Garnacho
829d9c863c clutter: Move scattered x11 keymap code into ClutterKeymapX11
https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00
Carlos Garnacho
f304fa4869 Drop xinput2 version checks
We always request XInput >= 2.3 and fail otherwise, we don't need to
check for lower versions for touch events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00