Commit Graph

134 Commits

Author SHA1 Message Date
Jonas Dreßler
7bf8f40c84 magnifier: Update zoom region right after enabling the magnifier
We want the zoom region to always be where the mouse cursor is, so make
sure to update it initially, too.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2234>
2022-03-13 00:12:18 +00:00
Jonas Dreßler
f13a6145fd magnifier: Properly hide the second (real) cursor
The magnifier uses a PointerWatcher (which is based on a simple timeout
source) to update the zoom region based on the current mouse cursor
position 60 times a second. When updating the zoom region, it would also
hide mutters cursor using meta_cursor_tracker_set_pointer_visible().

Since a few months, mutter has decoupled the handling of input events
from the monitor refresh rate though, which means it's no longer
guaranteed that the cursor changes only 60 times a second (on higher
refresh rate monitors it actually never was). This means mutter might
show the cursor more often than 60 times a second, while we hide it only
60 times a second, leading to a flickering second cursor.

To fix this, implement the cursor-hiding by listening to
MetaCursorTrackers visibility-changed signal, and immediately hiding the
cursor again when it's shown.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2234>
2022-03-13 00:12:18 +00:00
Florian Müllner
26235bbe54 js: Use (dis)connectObject()
Start using the new methods to simplify signal cleanup. For now,
focus on replacing existing cleanups; in most cases this means
signals connected in the constructor and disconnected on destroy,
but also other cases with a similarly defined lifetime (say: from
show to hide).

This doesn't change signal connections that only exist for a short
time (say: once), handlers that are connected on-demand (say: the
first time a particular method is called), or connections that
aren't tracked (read: disconnected) at all.

We will eventually replace the latter with connectObject() as
well - especially from actor subclasses - but the changeset is
already big enough as-is :-)

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1953>
2022-03-04 14:14:37 +00:00
Florian Müllner
2b45a01517 cleanup: Use new indentation style for object literals
We have made good progress on object literals as well, although there
are still a lot that use the old style, given how ubiquitous object
literals are.

But the needed reindentation isn't overly intrusive, as changes are
limited to the object literals themselves (i.e. they don't affect
surrounding code).

And given that object literals account for quite a bit of the remaining
differences between regular and legacy rules, doing the transition now
is still worthwhile.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2200>
2022-02-23 12:23:52 +00:00
Florian Müllner
ac9fbe92e5 cleanup: Use new indentation style for arrays
We've made some progress on transitioning to the modern indentation
style, and for arrays the legacy style is now rare enough to make
a bulk transition feasible.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2200>
2022-02-23 12:23:52 +00:00
Sebastian Keller
34bf17ad27 magnifier: Remove call to dropped Clutter::get_default_frame_rate()
Clutter::get_default_frame_rate() has been removed in mutter!2002, but
it is still being used here. Given that this was basically hardcoded to
60 in mutter with the only way of changing this being an obscure
environment variable, just use that value here directly. This avoids a
crash when starting gnome-shell with the magnifier enabled.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4761
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2025>
2021-11-16 23:34:38 +00:00
Sebastian Keller
34b6cd0bea magnifier: Disable desaturation effect when not in use
The desaturation effect was always enabled, regardless of the specified
factor. This was causing the magnifier to always hit offscreen
rendering, even when not necessary. Additionally offscreen rendering is
currently also causing glitches in MetaWindowGroup which this helps to
avoid in some cases.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1678
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2026>
2021-11-08 15:39:34 +00:00
Daniel van Vugt
af03314f20 magnifier: Avoid painting a desktop that's fully occluded by its clone
This significantly reduces the render time for fullscreen zoom mode.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3305
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1899>
2021-08-18 14:12:34 +00:00
Florian Müllner
8f42053b5f magnifier: Small cleanup
Use an early return instead of a big if() block to cut down on
indentation.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1932>
2021-07-31 17:18:08 +00:00
Florian Müllner
77b175e763 magnifier: Remove unused return value
Before the introduction of PointerWatcher, the method was used as
a timeout handler. That hasn't been the case since 2012, so drop
the return value.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1932>
2021-07-31 17:18:08 +00:00
Florian Müllner
1ea4d72fe5 magnifier: Don't query pointer unless necessary
The PointerWatcher passes the current pointer position to every watch,
so we don't have to query the pointer again scrollToMousePos() is used
as watch callback.

While that should be the only use, be conservative and still query the
pointer when called without arguments.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1932>
2021-07-31 17:18:08 +00:00
Lee
006d206f98 Magnifier: Filter caret tracking in gnome magnifier
Add a check to filter out caret tracking events that result in a caret
location of 0,0.

Fixes #4177

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1823>
2021-06-28 21:28:10 +00:00
Carlos Garnacho
c449058d44 magnifier: Remove needless actor
For the pointer clone, we actually have 2 actors (one that contains
the sprite, another that moves around). These can just be the same.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1902>
2021-06-28 20:53:57 +02:00
Carlos Garnacho
3df4b5ec7c magnifier: Add method to enable/disable crosshairs
These do some some signals connection and monitor layout tracking
that we forget to disconnect when the magnifier is disconnected.
This causes warnings if enabling the magnifier, disabling it,
switching to another tty, and back. (Presumably also happens for
monitor hotplugs).

This signal should just stay connected as long as it's needed,
so add a setEnabled() method on the CrossHairs actor that we
can hook on the magnifier.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1902>
2021-06-28 20:53:36 +02:00
Carlos Garnacho
a363f1343a magnifier: Unset variable holding GSource ID
Otherwise we try to remove the no longer existing GSource
later on.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1902>
2021-06-28 19:54:07 +02:00
Jonas Ådahl
08fb067d24 js: Get idle monitor from backend
Its ownership has moved from dangeling to owned by the backend, which
has reflected the API is accessible by. Adapt to this change.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1838>
2021-05-18 13:42:52 +00:00
Florian Müllner
cb8b19939d magnifier: Stop exposing D-Bus interface
Screen magnification is the compositor's business, not that of "random"
unprivileged tools. And for cases where a more specialised behavior is
wanted, an extension likely does a better job than a consumer of the
D-Bus API.

In addition to that, exporting the interface has been broken for an
unknown time, because the object that holds the implementation isn't
referenced and thus ends up being garbage collected, whoops.

And last but not least, this gets rid of the last public D-Bus name
that isn't clearly in the system namespace (org.gnome.Shell,
org.gnome.Mutter, org.gtk).

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1523>
2020-12-06 06:18:07 +01:00
Florian Müllner
8a47f1c667 cleanup: Remove empty leading/trailing lines in blocks
gjs added a new rule to its eslint ruleset that forbids "block padding",
so make sure we conform to that rule before syncing up the configuration.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1498
2020-11-16 18:04:23 +00:00
Carlos Garnacho
a9a54ba2a3 magnifier: Avoid cursor visibility changes on startup
When initializing the shell, we create the magnifier, and (normally)
let it disabled. This still toggles cursor visibility on, which is
not right since there's other considerations to take during
initialization.

Only do this after actual changes to the magnifier state, so
initialization is left unperturbed.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1486
2020-10-28 20:59:07 +01:00
Georges Basile Stavracas Neto
0717f76362 Replace anchor point by translation and pivot point
Anchor point is deprecated and will eventually be removed from
Mutter's Clutter. Replace them by a combination of pivot point
and translation.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1334
2020-06-26 21:03:57 +00:00
Florian Müllner
153b7d525d cleanup: Don't linebreak before closing parentheses
Otherwise recent versions of eslint want "dangling" commas,
which is at least ugly considering that most functions don't
allow adding arguments at leasure.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1177
2020-04-28 09:04:49 +00:00
Jonas Dreßler
3848513cf4 magnifier: Use inhibit-unfocus API to keep wayland focus while hidden
Since commit mutter/a2a8f0cda we force the focus surface of the
meta-wayland-pointer to NULL while the pointer is hidden. This
introduced an issue with the magnifier, where we use
`set_pointer_visible` to hide the real cursor and show our own cursor at
the correct position: Because the meta-wayland-pointer is still used to
communicate with Wayland clients, the UI of the windows will not respond
to mouse movement anymore as soon as the real cursor is hidden.

To fix this, use the newly added clutter_seat_inhibit_unfocus() API to
temporarily disable unsetting the focus-surface while the magnifier is
hiding the system cursor.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/993
2020-02-24 10:31:08 +00:00
Jonas Dreßler
725c72e020 magnifier: Use own showSystemCursor() instead of set_pointer_visible()
We already have our own function to show the system cursor, use it!

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/993
2020-02-24 10:31:08 +00:00
Carlos Garnacho
e16def0c43 magnifier: Make magnification factor changes animatable
So we can seamlessly change between them through eg. keybindings.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
83d083f189 magnifier: Implement pointer motion tracking differently
The use of the core idle monitor means that focus change events
are also delayed by keyboard interaction. Since the magnifier is
already in the business of pointer tracking, it's easy enough to
fire the pointer rest timeout from here, so focus changes are
accumulated and delayed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
b1ea4f6c35 magnifier: Animate focus/caret position changes
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
60c540e93a magnifier: Add support for animating "scroll" on focus changes
This is nice in that it provides a hint of the relative position of
the new focus area, as opposed to a sudden jump.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
f3b56e0eb1 magnifier: Transform a11y events' coordinates by scale factor
We get those events in logical coordinates, which we have to transform
into actual pixels.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
c8d02be14a magnifier: Ignore repeated a11y events
We may get several a11y events setting the caret on the same
coordinates it previously was. Make focus tracking ignore those,
as we're jumping to the same coordinates again during eg. mouse
operation.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
42b50051ac magnifier: Sanity check coordinates in scrollContentsTo
We may receive a11y events with bogus coordinates (eg. x/y = minint),
so ensure the coordinates are sane before scrolling there.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
bda18888c0 magnifier: Clip all crosshair lines at even distances
If the crosshair is clipped so it doesn't cover the pointer cursor,
the clip rectangle is skewed towards the bottom/right. This was
made so to accomodate the default pointer, but the unevenness stays
on other pointer cursors, and it makes the crosshair look odd on
short crosshair length.

Make all lines clip to an even distance from the center instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
c150fe95b9 magnifier: Apply color inversion to crosshairs/pointer
It is somewhat unexpected that crosshair color and pointer cursor colors
remain the same across changes in color inversion settings, and may lead
to contrast issues. Apply the effect on the common container, so it
applies to these all.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
8b4b9d396b magnifier: Apply scale factor to crosshair length
On hidpi displays the length is double as advertised, make it match
the advertised length.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
2020-02-07 18:18:25 +01:00
Carlos Garnacho
5c570460cf magnifier: Use core idletime monitor
As it's getting the idletime monitor for the seat pointer, boils
down to about the same thing. We are moving away from per-device
idletime monitors though.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/978
2020-02-05 16:17:30 +00:00
Carlos Garnacho
9aca26916c magnifier: Adapt to idle monitors API change
It takes Clutter input devices now, not device IDs.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/760
2020-01-30 17:49:08 +00:00
Robert Mader
0795d8df5f magnifier: Adapt to painting and picking API change
This was left out in 988a0e7314

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/891
2019-12-07 13:08:28 +00:00
Florian Müllner
a32c4f30d1 style: Allow lonely ifs where appropriate
We now have a lint rule to disallow lonely ifs, however there are
cases where the "lonely" part mirrors code from the preceding if
clause. Opt out of the lint rule in those cases.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/818
2019-11-11 23:51:17 +00:00
Florian Müllner
61210fdae1 cleanup: Use JSDoc for documentation comments
It's a better fit than gtk-doc, and eslint can validate that they
are complete and use correct syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +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
07cc84f632 cleanup: Only omit braces for single-line blocks
Braces can be avoided when a block consists of a single statement,
but readability suffers when the statement spans more than a single
line.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
c860409da5 cleanup: Use object shorthand where possible
ES6 allows to omit property names where they match the name of the
assigned variable, which makes code less redunant and thus cleaner.
We will soon enforce that in our eslint rules, so make sure we use
the shorthand wherever possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
9eaa0089d0 cleanup: Fix missing/stray spaces
Those are wrong according to our style guidelines, but the previous
eslint ruleset didn't catch them.

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
Florian Müllner
f2bd39b20c js: Use generic actor properties to align StBin children
StBin's fill/align properties are now no-ops; get back the intended
child allocation by setting the corresponding x/y-align on the child.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/803
2019-11-04 21:27:56 +01:00
Marco Trevisan (Treviño)
c4c5c4fd5c cleanup: Use inheritance for Actor classes instead of composition
Remove the `this.actor = ...` and `this.actor._delegate = this` patterns in most
of classes, by inheriting all the actor container classes.

Uses interfaces when needed for making sure that multiple classes will implement
some required methods or to avoid redefining the same code multiple times.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
2019-10-16 15:26:13 +00:00
Florian Müllner
8d6820c4df magnifier: Do not modify function argument
The intention of the code is clearly to operate on a copy, but that's
not how the Object constructor works. While it doesn't matter in
practice that we modify the passed-in object parameter, it's still
a good idea to fix the code.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Florian Müllner
2546445884 magnifier: Simplify some code
We don't need nested if blocks to set or unset the crosshairs'
clip size.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Florian Müllner
2fc4987c73 cleanup: Stop using Mainloop module
It is deprecated in favor of the regular GLib functions.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/718
2019-09-12 19:09:24 +02:00