Commit Graph

97 Commits

Author SHA1 Message Date
Carlos Garnacho
876765dbe1 boxPointer: Do not mute key events while showing
We want to mute things like pointers hovering the BoxPointer while
it does open. However keyboard events should still be handled
promptly.

Since Clutter.grab() will involve different actors being grabbed
and focused, this will have some more presence, e.g. when navigating
panel menus. We want to be able to navigate outside a menu while it
is still being shown.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2045>
2022-01-29 01:16:29 +01:00
Florian Müllner
0fd205ce54 boxpointer: Fix positioning with non-widget sources
Commit 16d371873 lifted the requirement for source actors to be
widgets, then got it wrong :rolling_eyes:

The content box is expected to be in actor coordinates, so the
allocation must be translated to (0, 0).

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4593

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1969>
2021-09-01 20:22:58 +00:00
Florian Müllner
6f7df32b0e boxpointer: Fix coordinate
Eeeks. Spotted by coverity in CID 351259.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1950>
2021-08-13 15:16:54 +02:00
Florian Müllner
16d3718735 boxpointer: Handle non-widget source actors
There is no convincing reason why source actors must be widgets,
so lift that restriction.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1903>
2021-06-29 22:47:50 +02:00
Florian Müllner
54a71944ba boxpointer: Disable unredirection while visible
Some popovers like the ibus candidate popover may be requested while
showing an unredirected fullscreen window. Disable unredirection
while the popover is visible so that it can actually be shown.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1900>
2021-06-28 12:07:12 +02:00
Daniel García Moreno
71d37bffdf util: Remove shell_util_get_transformed_allocation
This helper function could be replaced with the new
clutter_actor_get_transformed_extents, that does the same.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1386

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1380
2020-07-29 18:09:53 +02:00
Jonas Dreßler
9b99b67fea Remove ClutterAllocationFlags
Those flags were removed from Clutter since they're pretty much unused,
so remove them here, too.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1245
2020-05-20 15:12:03 +02:00
Jonas Dreßler
63a0e521fd boxpointer: Call set_allocation before allocating child
It's important to update the allocation of the parent before allocating
its children, it's an assumption we make in a lot of places.

This broke resource scale calculation for boxpointers and their
children when multiple monitors with different scales are used and the
primary monitor is not positioned at x=0, y=0.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1615
2020-04-27 19:53:20 +02:00
Daniel van Vugt
c773c8c162 Revert "js/ui: Use Clutter.OffscreenRedirect.ON_IDLE"
This reverts commit c0c027c608. Because for
some reason animating external opacity and position is still incurring
internal repaints, which disables offscreening and makes fading of
overlapping actors look wrong. `ON_IDLE` should be fixed in mutter before
it is used (in boxpointer at least) again.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2270
2020-02-26 11:54:54 +08:00
Daniel van Vugt
c0c027c608 js/ui: Use Clutter.OffscreenRedirect.ON_IDLE
To bypass offscreening in cases where continuous animation is happening.
Offscreening is slower in such cases so this reduces the render time of
animations within offscreenable actors.

On an i7-7700 this reduces the render time of boxpointers for example by
25-30%.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1025
2020-02-21 12:19:15 +00:00
Florian Müllner
e44adb92cf cleanup: Avoid unnecessary parentheses
Extra parentheses usually add noise rather than clarity, so avoid
them.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
ebf77748a8 cleanup: Require "dangling" commas
Since ES5, trailing commas in arrays and object literals are valid.
We generally haven't used them so far, but they are actually a good
idea, as they make additions and removals in diffs much cleaner.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
67ea424525 cleanup: Avoid unnecessary braces
Our coding style has always been to avoid braces when all blocks
are single-lines.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
1e203f4631 cleanup: Replace deprecated lower/raise calls
Those methods have been deprecated for a long time, so
move to the drop-in replacement.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
2019-11-06 09:42:57 +01:00
Marco Trevisan (Treviño)
55b57421dc cleanup: Replace signal connections with virtual functions
Inheriting from actors allows to use virtual functions instead of signal
connections for multiple cases, so just use them when possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
2019-10-16 15:26:13 +00:00
Florian Müllner
efed695eca cleanup: Don't add linebreak before operators
When breaking overly long conditions into multiple lines, the operator
should end the previous line instead of starting the new one.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Florian Müllner
0846238f69 js: Use implicit animations for animatable properties
We now have everything in place to replace Tweener for all animatable
properties with implicit animations, which has the following benefits:

 - they run entirely in C, while Tweener requires context switches
   to JS each frame

 - they are more reliable, as Tweener only detects when an animation
   is overwritten with another Tween, while Clutter considers any
   property change

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/22
2019-08-06 23:54:29 +02:00
Florian Müllner
476816732f cleanup: Use milliseconds for animation times
The different units - seconds for Tweener and milliseconds for
timeouts - are not a big issue currently, as there is little
overlap. However this will change when we start using Clutter's
own animation framework (which uses milliseconds as well), in
particular where constants are shared between modules.

In order to prepare for the transition, define all animation times
as milliseconds and adjust them when passing them to Tweener.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/663
2019-08-05 21:55:20 +00:00
Florian Müllner
e357559582 cleanup: Mark globals used from other modules as exported
eslint cannot figure out that those symbols are used from other modules
via imports, so they trigger unused-variable errors. To fix, explicitly
mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
11b116cb9d cleanup: Remove some unhelpful unused variables in destructuring
We aren't using them, and they don't add much in terms of clarity,
so drop them to fix a couple of eslint errors.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
6ed5bc2f6c cleanup: Use consistent switch indentation
We are currently inconsistent on whether case labels share the same
indentation level as the corresponding switch statement or not. gjs
goes with the default of no additional indentation, so go along with
that.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
7ac35c644e style: Fix stray/missing spaces
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
29b04fcbf2 style: Fix stray/missing semi-colons
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
0b08ee54bb cleanup: Clean up unused imports
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:10 +02:00
Marco Trevisan (Treviño)
76dc77f617 boxpointer: Remove deprecated show/hide methods
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576
2019-06-17 14:22:42 +02:00
Marco Trevisan (Treviño)
cb4c0d32c0 boxpointer: Trigger a relayout when setting position
Since the repositioning is now done during allocation, we can just queue
a relayout when setting the boxpointer positioning via the source actor.

As per this _relayout() and _updateFlip now needs to be called during allocation
only and with an allocation box set.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576
2019-06-17 14:22:40 +02:00
Marco Trevisan (Treviño)
3d4ba028c4 boxpointer: Don't trigger a relayout when updating arrow side
Changing the arrow side might need to reposition the boxpointer, however
if this happens during allocation, we don't need to trigger a new relayout since
we'd set the new allocation once _updateFlip's _reposition call is terminated,
otherwise if the position has changed, changing the boxpointer coordinates
will trigger a relayout anyways.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576
2019-06-17 14:22:19 +02:00
Marco Trevisan (Treviño)
5481c1899f boxpointer: Don't set actor position during allocation
As per commit 044572cb60 boxpointer uses its own coordinates to position itself.
However this would lead to warning when mutter-clutter is compiled with debug
options as we'd might try to set the box coordinates during the allocation
cycle.

So, when calling _reposition during allocation, instead of setting the actor's
coordinates we just pass the allocation box and we adjust its origin, in order
to set it properly in the vfunc.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1382
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576
2019-06-17 14:22:18 +02:00
Marco Trevisan (Treviño)
2fd120162f boxpointer: Unset the sourceActor on destruction
A boxpointer sourceActor could be destroyed before the boxpointer itself.
In such case, unset the sourceActor reference, connecting to 'destroy' signal.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1295
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576
2019-06-17 12:39:26 +02:00
Marco Trevisan (Treviño)
1be933bc49 boxpointer: Don't use boxpointer actor, as it's now an actor itself
Remove this.actor = actor, since the class is now an actor itself.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/487
2019-04-17 21:32:18 +00:00
Marco Trevisan (Treviño)
244a329ee7 boxpointer: Compute source allocation and work area just once
Compute the source actor workarea and allocation when repositioning and keep it
cached so that we've not to calculating it again in _calculateArrowSide.

Since _calculateArrowSide only is called inside _updateFlip that is always
called just after reposition, we can be sure that the computed values are still
correct.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435
2019-04-11 19:38:17 +00:00
Marco Trevisan (Treviño)
044572cb60 boxpointer: Use X/Y actor positioning instead of an anchor point
Currently all the widgets using BoxPointer and so popup actors are always drawn
at screen origin and then shifted at paint time in the proper position.

This doesn't work when using resource scale, since the widgets need to know
in which monitor they currently are in order to use properly scaled resources.

So, basically revert commit 22c22e0d7 and go back using the actual actor
coordinates for positioning and the actor translation for animating it, as the
relayouting issues of the past seem to be gone now.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1008
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435
2019-04-11 19:38:17 +00:00
Marco Trevisan (Treviño)
4892a87dfe boxpointer: Compute arrowStride using sourceActor monitor as reference
I suppose this was also the goal of commit 96e14dc, but because it was checking
the value of the always-undefined this.sourceActor, it really never worked as
expected.

So, now since we assume that this._sourceActor is always defined just use it
as reference to compute the monitor menu position.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1029
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435
2019-04-11 19:38:17 +00:00
Andrea Azzarone
2f3f3fbcdb boxpointer: Calculate position using workarea
Take the workarea into consideration when calculating the position and the size
of box pointer and of its arrow.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1102
2019-03-22 12:31:48 +00:00
Florian Müllner
fd50b9a45e cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 07:39:20 +01:00
Florian Müllner
a1534dab02 cleanup: Clean up unused imports
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 05:05:07 +01:00
Florian Müllner
e68dfed1f7 cleanup: Port GObject classes to JS6 classes
GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Georges Basile Stavracas Neto
3fa19e58ac
boxPointer: Stop using Shell.GenericContainer
An easy removal too.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
2018-10-08 22:43:01 -03:00
Georges Basile Stavracas Neto
f460f2748d
boxPointer: Add compatibility API
Because we're late in the cycle, and don't know how many
extensions actually rely on this API, this commit adds
back the BoxPointer.show() and .hide() functions, with
warning messages to notify consumers that this is going
to be removed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
2018-10-08 22:43:01 -03:00
Georges Basile Stavracas Neto
8b215b2446
boxPointer: Rename show/hide to open/close
Pretty much like dd4709bb2, BoxPointer's show() and hide()
functions will clash with Clutter.Actor's ones.

In addition to that, on a conceptual level, the current API
is not great, because calling boxPointer.hide() won't result
in boxPointer.actor.visible == false.

For these reasons, rename show() and hide() to open() and
close(). A compatibility layer will be added in a following
commit, warning about the usage of show() and hide().

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
2018-10-08 22:42:53 -03:00
Daniel van Vugt
f77b3da74f js/ui: Choose some actors to cache on the GPU
Flag some actors that are good candidates for caching in texture memory
(what Clutter calls "offscreen redirect"), thereby mostly eliminating
their repaint overhead.

This isn't exactly groundbreaking, it's how you're meant to use
OpenGL in the first place. But the difficulty is in the design of
Clutter which has some peculiarities making universal caching
inefficient at the moment:

 * Repainting an offscreen actor is measurably slower than repainting
   the same actor if it was uncached. But only by less than 100%,
   so if an actor can avoid changing every frame then caching is usually
   more efficient over that timeframe.

 * The cached painting from a container typically includes its children,
   so you can't cache containers whose children are usually animating at
   full frame rate. That results in a performance loss.
     This could be remedied in future by Clutter explicitly separating a
   container's background painting from its child painting and always
   caching the background (as StWidget tries to in some cases already).

So this commit selects just a few areas where caching has been verified
to be beneficial, and many use cases now see their CPU usage halved:

One small window active...... 10% -> 7% (-30%)
...under a panel menu........ 23% -> 9% (-61%)
One maximized window active.. 12% -> 9% (-25%)
...under a panel menu........ 23% -> 11% (-52%)
...under a shell dialog...... 22% -> 12% (-45%)
...in activities overview.... 32% -> 17% (-47%)
(on an i7-7700)

Also a couple of bugs are fixed by this:

https://bugzilla.gnome.org/show_bug.cgi?id=792634
https://bugzilla.gnome.org/show_bug.cgi?id=792633
2018-08-27 14:16:59 +00:00
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Jonas Ådahl
96e14dcbe7 boxpointer: If available, use source actor for constraining
If a source actor is set, use that for determining the arrow side (i.e.
whether the BoxPointer widget should expand in a certain direction).
This is better because it ensures that the popup is displayed on the
same monitor as the widget it originates from.

Without this, entering text with a vertically aligned input method
close to the bottom of a monitor would expand the BoxPointer downwards
on the monitor beneath it, instead of upwards, which is what one would
expect.

https://bugzilla.gnome.org/show_bug.cgi?id=786886
2017-09-04 16:28:58 +08:00
Florian Müllner
033277b68f Define externally accessible contants with 'var' instead of 'const'
Just as we did with classes, define other constants that are (or
may be) used from other modules with 'var' to cut down on warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Tarun Kumar Joshi
cbceac4c8a boxpointer: Add condition checks for -arrow-rise:0px
This is done for properly drawing popup menu when arrow rise is 0 (in
case of background menu).

Normally, the menu with arrow rise set to 0 is drawn properly having
all four corners rounded. But when the source(click/arrowOrigin) is
near screen's edges, one of the corners (depending on source's position
and arrow alignment) is drawn right angled.

This happens because the rounded corners are skipped and right angled
arrow is drawn when arrow origin is close to the edges.(That's why when
arrow-rise is 0, it forms right angled corner).

So, a few condition checks are made to ensure that right angled corner
is not drawn.

https://bugzilla.gnome.org/show_bug.cgi?id=699608
2014-01-15 18:28:31 +01:00
Florian Müllner
deb2f30b37 js: Use EVENT_PROPAGATE/EVENT_STOP constants in event handlers
Just as SOURCE_CONTINUE/SOURCE_REMOVE in source functions, these
constants increase code clarity over plain true/false.

https://bugzilla.gnome.org/show_bug.cgi?id=719567
2013-12-16 18:27:19 +01:00
Jasper St. Pierre
d77fc01580 boxpointer: Don't hide when we're already hidden
You would think we would already do something like this, but apparently
lots of code was calling hide() without checking if the box pointer was
already visible, causing it to queue a full tween. The biggest win was
with ibusCandidatePopup.js, which called hide() on every DBus message.

This increases the performance for me to enter the overview by a tiny
bit. The remaining time is spent updating the frequent apps / all apps
display.

https://bugzilla.gnome.org/show_bug.cgi?id=712727
2013-11-19 23:23:25 -05:00