Commit Graph

9290 Commits

Author SHA1 Message Date
Florian Müllner
b4c2901e47 dbusServices/extensions: Check earlier for existing dialog
There is no point in making a D-Bus call if we are going to bail
out anyway.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
3451c5a182 extensionUtils: Slightly optimize current extension lookup
When looking for a directory name that matches the extension UUID,
we can just as well use GLib's dirname()/basename() functions
instead of wrapping the path in a GFile.

We also know that the original path corresponds to a regular file
and not a directory, so rearrange the loop to avoid a lookup that
is guaranteed to fail.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
3289b79433 extensionUtils: Stop using RegExp for stack parsing
We currently use a regular expression to extract the exact file path
from a stack line. That RE is no longer accurate:

 - we assume a line number at the end, but at one point the column
   number was added as well
 - stacks from ES modules use file:// URIs instead of plain paths

Luckily that doesn't matter: We don't want to access any actual
files, so all we need is a path that can be traversed and that
contains the UUID.

We can get that with simple string manipulation, so avoid the regex
overhead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Evan Welsh
c2c4d84fc1 dependencies: Migrate to ES module and organize dependencies
gi modules are always loaded (there is no API for "set version without
loading"), so
we need to break dependencies.js into three sections:

- Required
- Compile-time optional
- Runtime optional

Required dependencies are always imported, compile-time optional
dependencies
are loaded if gnome-shell is compiled with support for them, and for
runtime optional dependencies we catch any errors when attempting to
load them.
If runtime optional dependencies fail to load we log a debug-level
message.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
7a5f1e5c9e layout: Add catch when asynchronously setting up the startup animation
This ensures any errors that occur in this stage of startup are clearly
logged.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
3f12f3a87c scripting: Convert to ES module and migrate tests
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
9a2c3da868 environment: Port environment.js to be an ES module
Removes the init() function in favor of executing all environment
changes when the file is imported.

Additionally ports all unit tests using imports.gi.environment.init() to
use the updated module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
011ac6f83c dependencies: Specify versions of Shell/St
We started to version them last cycle, so docs can be differentiated
between versions. It is not *expected* that two versions show up
on the same system, but then it also doesn't hurt handling it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
e2e3694cbd environment: Split dependencies loading into a new file
Once environment.js is an ES module we need to ensure we can dynamically
specify the version for required GI dependencies such as Clutter.

Moving dependency version setup to dependencies.js ensures gi.require
calls are done before environment.js imports any utilities.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
87d1248dc1 animationUtils: Group together various animation helpers
The environment module is used to initialize the environment, yet it
currently also defines the adjustAnimationTime() function.

Ideally it should not export any utility functions, in particular
once converted to ESM.

The function cannot be moved to the existing Utils module, as that
depends on an initialized environment, and can therefore not be
imported from environment.js, so use that opportunity to group
together several animation helpers in a new animationUtils module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
7eafc248cd lookingGlass: Evaluate command asynchronously
This allows using await in the command (or the header we
add to it), for example when handling Promises or importing
a module dynamically.

The latter will be crucial when porting to ESM.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
85a8a6f46c lookingGlass: Reformat command header
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
c0fbd74d07 jsParse: Make getCompletions() asynchronous
Part of the possible completions involves evaluating the part
of the passed in text that looks like an object, so that we
can query it for properties.

Using a Function or eval() for that means that we can only
complete text that does not use `await`. To get over that
limitation, evaluate the text in an AsyncFunction instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
13e20e47bf jsParse: Replace eval()
The evil() function is considered eval, replace it like we
already did in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Evan Welsh
a66ffcfc74 jsParse: Use JSDoc to document functions
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
561d0d3758 lookingGlass: Handle completions asynchronously
They will actually become asynchronous in a following commit,
prepare for that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
03025d7cff lookingGlass: Handle unprintable object
We currently throw an error when encountering a result that cannot
be represented as string, with the prompt appearing somewhat stuck
(the input cannot be committed).

Showing a lame fallback instead at least avoids that issue. When
the object has a typeof 'object' but is not an instanceof Object,
we are likely dealing with an ES module, and can show a slightly
less lame fallback.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Lukáš Tyrychtr
a5cf08ac55 a11y: Don't create a parent loop for quick settings sliders
Rather than returning the parent container of the slider, which presents
itself as the slider, return the parent of the slider container.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2762>
2023-07-13 18:15:16 +02:00
Carlos Garnacho
04aaa4b67b keyboard: Spawn "tecla" to show keyboard map
This is a modern replacement for gkbd-keyboard-display, stuck in gtk3
and X11 (libxklavier).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2834>
2023-07-11 15:06:19 +02:00
Florian Müllner
d52b1576ac main: Replace custom log function with console
console.log() is implemented with structured logging, and as we
set an appropriate log domain, it's identical to the custom function
bar the custom fields with extension data.

Few people know about those custom fields, and adding them comes
at a cost, as we end up producing and parsing a stacktrace on
every log() call.

It therefore seems appropriate to drop the custom function, and
turn the global log() symbol into a simple convenience alias for
console.log().

If it turns out that people do miss the custom fields, we can add
an alternative to ExtensionUtils.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2830>
2023-07-10 09:59:58 +00:00
Florian Müllner
f07bf7b1b6 main: Remove log compatibility
global.log() hasn't been used since 3.6. It seems extremely unlikely
that any extensions are still using it, not least because `log()` is
more convenient.

Time to move on.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2830>
2023-07-10 09:59:58 +00:00
Florian Müllner
b854c1bdbb extensionSystem: Fix signal disconnection
The ::shutdown signal is on Shell.Global, not Meta.Context 🤦️

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2831>
2023-07-09 22:45:03 +02:00
Evan Welsh
812378a00d dateUtils: Refactor so all utilities use cached local timezone
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:58:35 -07:00
Evan Welsh
8d48dc8c6f environment: Remove toLocaleFormat and add dateUtils for date formatting
`toLocaleFormat` is now `formatDateWithCFormatString` and formatTime and
formatTimeSpan are moved into dateUtils.

Instead of overriding system.clearDateCaches, add a helper in dateUtils.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:58:34 -07:00
Evan Welsh
88eb04a42c dateMenu: Fix lint errors prior to refactor
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:32:50 -07:00
Florian Müllner
e7d290bbfb tests: Stop bundling "perf" tests with gnome-shell
Now that scripts are loaded as external modules, there's no reason
anymore for bundling them with the gnome-shell executable. Just
move the scripts into a dedicated folder in tests/ and run them
from there.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
bf9b9838c2 main: Pass script on CLI instead of via environment
Environment variables aren't the best option to pass parameters
to a process (wouldn't it be "fun" if SHELL_PERF_MODULE appeared
in a regular user session?).

Instead, use a (hidden) --automation-script command line flag to
specify a script file that should be used to drive an automated
session.

As a side effect, the script no longer has to be relative to the
main module itself, so it will be possible to run scripts that
aren't bundled with the shell sources.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
5e93791708 main: Load perf scripts as modules
The perf scripts that can be used to script the gnome-shell UI
for testing are sufficiently separate from the rest of the code
base to allow porting them to ESM modules before the rest of
the code base.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
1f08056977 extensionSystem: Remove "disable" file on shutdown
The file indicates to the systemd shutdown scripts that extensions
should be disabled, so that extensions that crash the shell on
startup cannot lock out the user indefinitely.

For that purpose, we create the file before initializing extensions,
and remove it after 60 seconds. That generally works, because it's
highly unlikely that a session genuinely ends within the first minute.

It's possible though (for example during developments or when running
tests), so also remove the file when shutting down cleanly before
the timeout.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2807>
2023-07-07 11:34:44 +00:00
Florian Müllner
c76861b3c1 extensionUtils: Remove installImporter()
The method is now unused, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2795>
2023-07-06 18:41:29 +00:00
Florian Müllner
972a3b2d44 dbusServices/extensions: Load preferences as module
Now that extensions themselves are imported as modules, do the
same for their preference dialogs.

Extensions must now export a class with a `fillPreferencesWindow()`
method as default.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2795>
2023-07-06 18:41:29 +00:00
Florian Müllner
e8ee845e41 extensionSystem: Load extensions as modules
Continue the move to ESM by loading modules dynamically with
the standard import() expression, rather than by installing a
custom (legacy) importer.

This is a breaking change that affects all extensions, as they
now need to explicitly export the expected symbols.

As we are already breaking all extensions, take that opportunity
and remove support for the individual entry points: Using a
class with enable()/disable() methods has been the recommended
pattern for a long time, it is now the only entry point.

Instead of instantiating the class from an `init()` function,
the class must now be exported as default to be recognized.

Additionally, we no longer install an importer on the extension
object, so extensions that consist of more than one file MUST
import those files as modules now.

There will be a second breaking change for extensions when
gnome-shell's own code is ported to ESM, so most extension
developers will likely want to wait until the port is complete
before starting to port their extensions.

Based on a commit from Evan Welsh.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2795>
2023-07-06 18:41:29 +00:00
Florian Müllner
097c21d140 animations: Stop syncing size manually
The returned slice actors are now set up to fill their parent,
accounting for any difference between loaded- and displayed size,
so we can stop syncing the size manually.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2798>
2023-07-05 10:36:14 +00:00
Florian Müllner
ace8676ad0 windowManager: Add shortcut for toggling quick settings
Ever since the various status menus were combined into a single
aggregate menu, the menu has been an important entry point. Alas,
we never got around to adding a shortcut for it, not least because
there never was a good candidate.

We just freed super+s which works as either "system" or
"(quick) settings", so use that.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2716>
2023-06-21 18:11:05 +00:00
Florian Müllner
e9cabd00fb windowManager: Reindent shortcuts setup
We require all new code to use the non-legacy style. Updating code
on a case-by-case basis works fairly well most of the time, but
here we have a big uniform block, where any addition with a different
style would stick out badly.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2716>
2023-06-21 18:11:05 +00:00
Evan Welsh
0705c7a4eb js: Fix linting errors from line shifts
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2794>
2023-06-21 04:50:33 -07:00
Evan Welsh
1e9b906cbc js: Split gi imports to be on new lines to prepare for ES modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2794>
2023-06-21 04:50:33 -07:00
Florian Müllner
8d562ff71c portalHelper: Port to ESM
The helper app that provides the login dialog for network portals
is another separate process that can be moved to ESM separately.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>
2023-06-21 13:26:42 +02:00
Florian Müllner
612e04165e dbusServices: Port to ESM
We want to replace gjs' custom (and now legacy) imports system
with standard EcmaScript modules: JS developers are already
familiar with them, they have better tooling support and using
standard features over non-standard ones is generally the right
thing to do.

Our D-Bus services are separate from the main process, and thus
can be ported separately (except for the few imports that are
shared with the main process' code base).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>
2023-06-21 13:26:42 +02:00
Sam Hewitt
eacabbf443 panel: Stylesheet updates and minor improvements for panel buttons
- spin out all the panel button styling into a drawing mixin
- clean up the styles generally
- make special cases for the clock and non-flat buttons
- contrast fixes for non-flat buttons, fixes #6768
- new stop icon for the screen recording/cast indicators

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2804>
2023-06-21 10:28:13 +00:00
Florian Müllner
aa11d90693 workspace: Reapply border radius on background changes
The rounded corner effect is applied to the background actor, so
we have to reapply the correct values when the background changes
for the corners to persist.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2801>
2023-06-21 08:49:36 +00:00
Florian Müllner
593f659a73 parentalControlsManager: Don't log error when disabled
We currently special-case the DISABLED error when initializing
filtering, but not on app filter changes.

While it seems reasonable that Malcontent.Manager wouldn't emit
the signal while disabled, that's not actually true: It is emitted
when any user account information tracked by AccountsServices
changes.

Even if the signal were limited to changes of the ParentalControls
extension, it would still get emitted when app filtering *becomes*
disabled.

So regardless of potential improvements in libmalcontent itself,
we should filter out the DISABLED consistently, both when creating
the initial filter and when updating it.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2796>
2023-06-09 16:37:36 +02:00
Андрей Гриценко
ae24b0247e magnifier: Fix cursor offset
Commit c449058d44 changed the pointer clone to use a single
actor. However that broke applying the hotspot translation to the
position, so the magnified cursor is now displayed with a shift.

Undo the change to restore the old behavior.

This reverts commit c449058d44.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2780>
2023-06-07 22:52:27 +02:00
Evan Welsh
8fb8f7f827 init: Move Meta main loop into JavaScript after GJS context is initialized
gjs now has an internal mainloop that it can spin to resolve
module imports. That loop uses the thread default context,
so its possible that other sources, namely from mutter, get
dispatched when iterating the context. If that happens before
mutter is properly initialized, this will lead to a crash.

GjsContext needs to iterate its internal mainloop when initializing
to resolve internal modules, to avoid iterating Meta's mainloop and
triggering events before Meta is ready we will initialize the Shell
global and thus the GjsContext (js_context) before Meta.

Once GjsContext is initialized, we can call meta_context_setup().
Once Meta is setup and started, we'll run init.js which uses GJS'
internal promises API to set a "mainloop hook". The mainloop hook
is run immediately after the module returns so GJS will not attempt
to iterate the main loop again before exiting.

Also adjust the 'headlessStart' test to not wait for the
MetaContext::started signal, as that signal has now already
been emitted when the code is executed.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2781>
2023-06-07 19:23:27 +00:00
Evan Welsh
5d8e860a48 panel: Refactor quick settings loading for asynchronous imports
When the Shell ports to ESM, our inline imports of the network and
bluetooth indicators will no longer be possible, refactor quick settings
to load indicators asynchronously.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2563>
2023-06-07 18:59:43 +00:00
Evan Welsh
7116d91852 animation: Don't get size information until spinner has a parent
get_size() in _syncAnimationSize() can't be called until the actor
has a parent, otherwise we'll get an error for calling
st_get_theme_node() prior to the actor being on a stage.

_syncAnimationSize() is called asynchronously via
textureCache.load_sliced_image() and there is currently no guarantee
the actor will actually be "loaded" prior to calling it.

This becomes a more obvious error/issue when refactoring parts of the
Shell loading to also be asynchronous.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2563>
2023-06-07 18:59:43 +00:00
Florian Müllner
2416e4eec0 scripting: Make helper proxy initialization async
We are about to port the helper proxy to GApplication, which means
that it will establish a display connection before exporting its
D-Bus name. That means that the compositor must be able to respond
to a roundtrip request to avoid locking, so don't block on the proxy
becoming available.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
2023-06-07 11:12:40 +00:00
Florian Müllner
dec26b7da2 backgroundApps: Allow activating apps
Now that we track apps instead of instances, we can make the menu
items activatable, because the corresponding action is no longer
app specific (like activating a particular tab): We can simply
activate the app, which hopefully will bring it to the foreground
again.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2790>
2023-06-06 17:16:32 +00:00
Florian Müllner
6cf0df5fb9 backgroundApps: Track apps instead of instances
The background apps menu currently tracks instances rather than
apps. That matches the behavior of `flatpak ps` and can be useful,
for example when one particular instance runs out of control.

But as we don't include any information that allows to actually
distinguish between instances, multiple instances appear simply
as duplicated app entries.

Given that a menu is too limited for detailed information, stop
representing individual instances, and track apps instead.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2790>
2023-06-06 17:16:32 +00:00
Andy Holmes
32b9109967 overview: Provide public access for search provider registration
Provide a reasonably public way to register and unregister search
providers, without adding too much API.

`Main.overview.searchController` provides access that may be generally
useful, while `SearchController.addProvider()` and
`SearchController.removeProvider()` provide a simple interface for
extensions.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2783>
2023-06-01 15:54:59 -07:00