Commit Graph

104 Commits

Author SHA1 Message Date
Alessandro Bono
7bd98f3f5f environment: Set time zero when animations are disabled
In commit ee09c5c853 we chose to pick
the minimum value in order to preserve 0 instead of replacing it with
1. While returning 0 unconditionally when animations are disabled
seems the more logic thing to do, we were unsure about possible side
effects. Do the change now. Since we are early in the development cycle
we should be able to deal with side effects (if any) on time for the
next release.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2528>
2022-11-04 14:14:34 +01:00
Alessandro Bono
ee09c5c853 environment: Preserve time 0 when animations are disabled
There are cases where the animation time is set to 0 on purpose
in order to not animate. When animations are disabled via
/org/gnome/desktop/interface/enable-animations those animation
times are increased from 0 to 1. This makes the "Caps lock is on."
message appear unconditionally in the lockscreen for a brief moment.

Select the minimum between the two values. So that an animation time
0 is preserved instead of being replaced by 1.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2471>
2022-10-14 22:32:31 +00:00
Milan Crha
5c935af7d3 build: Port to gcr4
The gcr4 is going to replace gcr3. As only base functions are used,
the port to gcr4 is trivial.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2386>
2022-08-02 16:13:54 +00:00
Evan Welsh
4257fc9522 environment: Remove inline import of extensionUtils
The logging function cannot be asynchronous, so move the override
into main.js where ExtensionUtils can be imported at the top level.
Importing ExtensionUtils in environment.js at the top level is not
possible because it would import Main prematurely.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2363>
2022-07-06 13:40:44 -04:00
Evan Welsh
a88e59c1a8 Adopt EventEmitter class instead of injecting Signal methods
Introduce a new class, EventEmitter, which implements signal
handling for pure JavaScript classes. EventEmitter still
utilizes GJS' addSignalMethods internally.

EventEmitter allows static typechecking to understand the
structure of event-emitting JS classes and makes creating
child classes simpler.

The name 'EventEmitter' mirrors a common name for this pattern
in Node and in JS libraries.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2043>
2022-07-04 18:30:49 -04:00
Simon McVittie
7f4f328a7f Specify API versions for all public GIR APIs, except GLib
If one of these libraries breaks its GIR API in future, then upgrading
packages unrelated to gnome-shell might pull in the newer version,
causing gnome-shell to crash when it gets a newer GIR API that is
incompatible with its expectations. For example, this seems to be
happening in Debian testing at the moment, when GNOME Shell 41.4
imports GWeather and can get version 4.0 instead of the version 3.0 that
it expected.

Adding explicit API versions at the time the newer version is released
is too late, because that will still let the newer version of the GIR API
break pre-existing GNOME Shell packages. Prevent similar crashes in
future by making the desired versions explicit.

This is done for all third-party libraries except GLib, similar to the
common practice in Python code; if GLib breaks API, then that will be
a disruptive change to the whole GLib/GObject ecosystem, regardless.

Gvc, Meta, Shell, Shew, St are not included because they're private
(only exist in a non-default search path entry).

Clutter and Cogl *are* included, because we need to import the fork of
them that comes with Meta, as opposed to their deprecated standalone
versions.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug-Debian: https://bugs.debian.org/1008926
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2261>
2022-04-04 17:55:25 +01:00
Florian Müllner
fc4f9f61fa signalTracker: Explicitly register destroyable types
We currently assume that any '::destroy' signal on a GObject type
has the semantics of the ClutterActor/GtkWidget signal, and should
therefore result in all signals being disconnected.

But we already have a case where the assumption doesn't hold: ShellWM
uses '::destroy' for the closing animation of windows, and the ShellWM
object itself remains very valid after the emission.

So rather than making assumptions about '::destroy', check objects
against a list of destroyable types that are explicitly registered
as such.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2226>
2022-03-06 00:10:03 +00:00
Florian Müllner
f45ccc9143 signalTracker: Provide monkey-patching for (dis)connectObject()
The module exports a `addObjectSignalMethods()` method that extends
the provided prototype with `connectObject()` and `disconnectObject()`
methods.

In its simplest form, `connectObject()` looks like the regular
`connect()` method, except for an additional parameter:

```js
    this._button.connectObject('clicked',
        () => this._onButtonClicked(), this);
```

The additional object can be used to disconnect all handlers on the
instance that were connected with that object, similar to
`g_signal_handlers_disconnect_by_data()` (which cannot be used
from introspection).

For objects that are subclasses of Clutter.Actor, that will happen
automatically when the actor is destroyed, similar to
`g_signal_connect_object()`.

Finally, `connectObject()` allows to conveniently connect multiple
signals at once, similar to `g_object_connect()`:

```js
    this._toggleButton.connect(
        'clicked', () => this._onClicked(),
        'notify::checked', () => this._onChecked(), this);
```

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
5442266f28 js: Simplify promisify() calls
If the finish function isn't specified, promisify will now try
to use the async name without '_async'/'_begin' suffix (if any)
and '_finish' appended.

Everything except IBus uses a variation of that pattern, so there's
quite a bit of boilerplate we get to remove…

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>
2022-02-11 16:24:01 +00:00
Florian Müllner
928f3288e9 js: Stop using Gio._LocalFilePrototype
gjs now supports overriding interface methods, so promisify()
works on Gio.File itself, not just the LocalFilePrototype cludge.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>
2022-02-11 16:24:01 +00:00
Bastien Nocera
4a480a78af status/bluetooth: Port to new GListModel API
The GtkTreeView API was removed, and replaced with a GListModel API.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4748
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2055>
2022-02-08 23:16:46 +00:00
Florian Müllner
ab52ce4591 dateMenu: Port to GWeather 4.0
Besides dropping its GTK dependency (which doesn't affect us),
GWeather 4.0 replaces its own timezone type with GTimeZone.

It's easy enough to adjust to that, so port over to the new
version.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2083>
2022-01-05 04:07:25 +01:00
Florian Müllner
f07a40d5ee environment: Require libgweather 3.0
GWeather did a major version bump on its main branch, so it is
now possible that multiple versions are installed in parallel,
and we should explicitly pick the one we are using.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2083>
2022-01-05 03:39:57 +01:00
Georges Basile Stavracas Neto
795312b8d5 environment: Require gnome-desktop 3.0
Pretty much the exact same case of 9ce6756235.

libgnome-desktop saw a major version bump, and we have to
stick with 3.0 for a while.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2030>
2021-11-11 16:20:39 -03:00
Georges Basile Stavracas Neto
9ce6756235 environment: Require GnomeBluetooth 1.0
libgnome-bluetooth will start to offer a 2.0 library version
depending on GTK4. Given that GNOME Shell already depends on
GTK3, it cannot use this next version of gnome-bluetooth. And
since GJS will automatically try and use the latest version
available of any library, Shell must specify it wants 1.0
explicitly.

Add a required GnomeBluetooth version number when importing it
for the status indicator.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2015>
2021-11-11 19:13:40 +00:00
Florian Müllner
cc5cc0d653 environment: Apply autoReverse/repeatCount to all transitions
Like the old Tweener API, ease() allows to transition multiple
properties at once. If autoReverse or repeatCount are specified,
they should apply to all transitions, but right now we only set
them for the first one.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2007>
2021-10-21 19:52:33 +02:00
Florian Müllner
ef70364e81 cleanup: Replace non-standard ByteArray module
gjs landed support for TextDecoder/TextEncoder. Use those instead
of gjs' own ByteArray module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1946>
2021-09-01 14:49:30 +00:00
Florian Müllner
1d607cf18f build: Add soup2 option
!1940 added support for soup 3, including a fallback to soup 2.4
where the newer version isn't available.

Unfortunately it missed that libgweather has a hidden soup dependency,
and now gnome-shell fails to start if a weather location has been set
up and soup 3 is available.

We don't have a good way to detect that case, so hide the soup 3 support
behind a build option. Distributors are expected to switch it at the
same time as libgweather.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1966>
2021-09-01 12:26:15 +02:00
Florian Müllner
d562c70f4e environment: Fallback to Soup 2.4
We cannot assume yet that Soup3 is available everywhere. Until that
is the case, allow falling back to Soup 2.4 by imitating the bits
of the Soup3 API we use with monkey-patching.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Florian Müllner
ae90b50dc7 extensionDownloader: Port to Soup3
After 13 years, Soup will release a new, API-incompatible
version[0]. This is a good thing, make sure we support it.

[0] https://blog.tingping.se/2021/02/23/future-of-libsoup.html

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Abderrahim Kitouni
c90bde464a js: Require Soup 2.4
Soup 3.0 is a thing now

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1720>
2021-02-26 12:28:21 +00:00
Florian Müllner
40e22eb524 cleanup: Use optional chaining and ?? operator
Those operators have been supported since gjs switched to mozjs78
last cycle. While not ground-breaking, using it makes for a nice
cleanup here and there.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1517>
2020-12-02 15:10:29 +00:00
Andre Moreira Magalhaes
cc9f66d784 environment: Handle @content for property transitions
When using `Actor.ease_property` if the property starts with '@' and the
duration of the transition is zero (which may happen if the actor is not
mapped even if a non-zero duration was passed to `ease_property`), the
impl will try getting the actual target object where the property should
be set.

This works fine for most cases but it currently throws an error when
passing '@content.*' properties. Fix this by handling '@content' as
a property of `actor.content` (used by MetaBackgroundActor when
showing the overview).

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1461
2020-10-07 20:49:09 -03:00
Florian Müllner
cf1d09b482 environment: Mark transitions as "work"
global.run_at_leisure() is used from automated scripts to schedule
a callback when the shell is idle. However since we moved away from
Tweener, animations are no longer taken into account; fix this by
marking transitions as "work" if the convenience ease() functions
are used.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1396
2020-08-12 15:43:38 +00:00
Georges Basile Stavracas Neto
8154728d09 environment: Add Math.clamp
The good old clamp function, now part of the Math family.
Clamp is happy after so many years of loneliness.

This is a strict implementation of the draft ECMAScript
proposal.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1295
2020-06-03 12:55:53 -03:00
Florian Müllner
e20cf1ac78 environment: Replace monkey-patched method with Symbol.iterator
This allows using the actor itself as iterator:

  for (let child of container)
      doStuff(child);

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1269
2020-05-19 21:33:31 +02:00
Florian Müllner
8d4e650a95 environment: Monkey-patch iterate_children() generator
This is a small convenience method for using ClutterActor's iterator API
with javascript's built-in iterator protocol, for example as:

  for (let child of container.iterate_children())
      doStuff(child);

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1268
2020-05-19 21:07:20 +02:00
Andy Holmes
3dc4f01113
JS: migrate from the global window to globalThis
As of mozjs68 (gjs-1.64) `globalThis` is recommended over `window` and
it makes more sense in this context anyways. Migrate the few instances
of `window` we use and adjust the eslint configuration.

`window` will continue to resolve to `globalThis`, so this won't affect
extensions or other downstream users.

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

closes #2322
2020-04-26 19:07:02 -07:00
Jonas Ådahl
b3b91f1699 js: Drop tweener.js
We're using clutter's animation framework now, so lets drop the old
tweener support layer.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1200
2020-04-15 13:25:14 +00:00
Florian Müllner
764527c8c9 js: Promisify async operations
Promises make asynchronous operations easier to manage, in particular
when used through the async/await syntax that allows for asynchronous
code to closely resemble synchronous one.

gjs has included a Gio._promisify() helper for a while now, which
monkey-patches methods that follow GIO's async pattern to return a
Promise when called without a callback argument.

Use that to get rid of all those GAsyncReadyCallbacks!

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1126
2020-03-31 05:43:40 +00:00
Florian Müllner
78997cb7eb environment: Hook up touch_file to GFile prototype
We don't usually extend introspected types with our own API, but in
this case it's too tempting to make the helper functions usable with
Gio._promisify() ...

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432
2020-03-25 20:03:01 +00:00
Florian Müllner
0dd171a7c8 environment: Fix date conversion
This is a regression from commit 06b690ff21:

GLib.DateTime.new() expects the full four-digit year, so passing
the abbreviated year from Date() will result in a bogus datetime.

Today is *not* Saturday March 2nd, 120 ...

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1061
2020-03-02 13:54:23 +01:00
Florian Müllner
06b690ff21 environment: reduce calls to g_time_zone_new_local()
Creating a new GTimeZone for the local timezone can be quite expensive if
done repeatedly. It requires an open(), mmap(), and parsing of
/etc/localtime.

This patch was provided by Florian, and I've tested it as far back as
3.28.4 to ensure that we are really reducing the number of open() calls
on the compositor thread.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1051

Signed-off-by: Christian Hergert <chergert@redhat.com>
2020-02-27 13:48:26 -08:00
Florian Müllner
2bb8e1be9b environment: Handle reversed transition with 0 duration
If a transition is reversed, the final property values will be the
same as before the transition. However this currently only works
correctly when we actually use a transition; to fix this with a
duration of 0, simply skip the set() call when the transition is
reversed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1042
2020-02-25 18:08:47 +00:00
Florian Müllner
9dc85d76d9 environment: Remove unused ease parameter
In an earlier iteration of the ease patch set, animatable properties
and easing parameters were different arguments.

This wasn't the case in the final version, so remove the left-overs.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/917
2020-01-06 13:17:59 +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
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
ac1f896107 environment: Reimplement Date.toLocaleFormat() override
Now that we no longer go through GTimeVal to convert from Date to
GDateTime, there is no more reason for using a C helper function.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/807
2019-11-06 20:19:57 +00:00
Florian Müllner
3913fa5044 environment: Stop adding child_set() to layout managers
We no longer use any layout managers that use custom child properties
instead of the generic Clutter.Actor properties, so this override
is completely unused.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
2019-11-06 09:42:57 +01:00
Florian Müllner
32185c17d0 environment: Stop monkey-patching Clutter.TableLayout
It's not used for anything anymore, and may well end up being removed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
2019-11-06 09:42:57 +01:00
Marco Trevisan (Treviño)
91707f4f82 environment: Use gjs smart GObject GTypeName computation
Make gjs to compute the GType name for registered GObject-derived
classes using the file basename and the first directory name, so that we
can avoid name clashing, and ensure that no extension will break the
shell by registering a name that is already used (by the shell or by any
other extension).

This requires gjs commit 02568304 [1] that will be part of release 3.35.2,
so bump the required version as gjs does post-release version bumps.

[1] https://gitlab.gnome.org/GNOME/gjs/merge_requests/337

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/790
2019-10-29 18:38:35 +00:00
Georges Basile Stavracas Neto
f2466caef3 environment: Parse repeat-count and auto-reverse
Those are two useful ClutterTimeline properties and
will be needed for wiggling the search entry when
failing the password.

Add support for passing repeat-count and auto-reverse
to ClutterActor.ease and ClutterActor.ease_property.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/768
2019-10-18 11:25:45 +00:00
Florian Müllner
38ad1d7c13 environment: Only disable unredirection of ongoing transitions
When a transition is set up with a delay, it may be removed before it
actually started. We won't get a ::stopped signal in that case, with
the result that we currently end up with a mismatched unredirection
disabling.

Address this by only disable unredirection once the transition has
actually started.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1788
2019-10-14 10:47:36 +02:00
Florian Müllner
b6754d7db7 environment: Try harder to find a transition
When easing, we need the transition of one of the involved properties
to connect our callbacks. Currently we simply get the transition for
the first property, however as Clutter optimizes the case where a
property doesn't actually change, that transition may be NULL even
though we still animate other properties.

So instead of only looking at the transition of the first property,
try to find a transition for any of the involved properties.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1572
2019-09-20 16:40:46 +00:00
Jonas Ådahl
57ed68541a environment: Disable fullscreen unredirect during all transitions
When there is a transition, it's likely that we are animating some part
of the desktop, and in such situations we don't want to unredirect
fullscreen windows.

This fixes unwanted unredirection when e.g. hiding a modal dialog by
re-enabling the unredirection after the animation has finished, instead
of when it starts.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/721
2019-09-13 16:10:17 +00:00
Florian Müllner
0888a9bffd environment: Skip property animations while hidden
For implicit animations, Clutter will skip any transitions while
an actor is unmapped, and just set the property directly. Do the
same in our ease_property() convencience method.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/708
2019-09-10 14:41:26 +00:00
Marco Trevisan (Treviño)
826ac95726 environment: Don't use actor if an ease callback destroys it
An actor ease callback could destroy the actor, in such case we should do not
touch the actor anymore.

So, before calling the callback, reset restore the easing state and don't
perform any further action with it.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1507
2019-08-09 21:00:22 +00:00
Florian Müllner
8ac2086ed1 environment: Add convenience method for adjustment transitions
By now, Tweener is used exclusively to animate changes to the
StAdjustment:value property. But not for long, as now that we
implement the same transition API as Clutter.Actor, we can
re-use the existing convenience method for property transitions
for adjustment changes as well.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/669
2019-08-07 18:40:49 +02:00