Commit Graph

485 Commits

Author SHA1 Message Date
Jonas Ådahl
c1d66af4b9 js: Get monitor manager from backend
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2557>
2022-12-16 22:12:59 +01:00
Florian Müllner
1a9e072ca0 fileUtils: Do not follow symlinks
Extensions should not include symlinks, in particular ones that
point outside the extension directory. However if they do, then
we should only move/remove the link rather than the files it
points to.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2571>
2022-12-15 22:34:26 +00:00
Evan Welsh
56beb6ff2b extensionUtils: Add DISABLING and ENABLING extension states
Extensions can export asynchronous enable() and disable()
functions. To guard against re-entrancy when enabling or
disabling an extension, this commit adds two new states:
ENABLING and DISABLING which are set immediately prior
to calling enable() and disable() respectively.

This commit updates the extensions CLI and Extensions app
with new strings for these states.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2364>
2022-12-01 12:59:32 +00:00
Evan Welsh
b7c097ba79 fileUtils: Refactor collectFromDatadirs to be a generator
This change enables mapping each collected file to a Promise in
asynchronous operations.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2364>
2022-12-01 12:59:32 +00:00
Jonas Ådahl
411360cd1b signalTracker: Clear all signal trackers on shutdown
This avoids a lot of otherwise invalid signal handler invokations if we
would later attempt to terminate the gjs and mutter context.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:09:37 +01:00
Colin Kinloch
50bc2c6529 systemActions: Add poweroff without space
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2523>
2022-11-04 18:14:11 +00:00
Florian Müllner
f266c2ca15 screenshot: Move HAVE_RECORDER check into screencast service
Some gstreamer plugins require a connection to the display server,
so if we end up initializing gstreamer before we are ourselves
fully initialized, we may end up with a locked compositor.

Avoid this by moving the runtime recorder check into the screencast
D-Bus service, so that all gstreamer calls happen out of process.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2519>
2022-11-04 09:51:20 +00:00
Florian Müllner
cff56d4b03 config: Check for correct Gst element
We use filesink, not filesrc ...

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2519>
2022-11-04 09:51:20 +00:00
Carlos Garnacho
ecc3cf8ab1 inputMethod: Manually reset input context state before unfocus
The IBusInputContext currently seems to be a bit sloppy wrt propagating
the current state to engines after those are changed, this results in
engines possibly ending with purpose/hint/etc that do not actually
correspond to the current state.

Ensure this state is cleared on unfocus of our IBusInputContext, so
that the next time the input method receives an input focus, the new
state makes it all the way to the currently active engine.

Fixes situations in the GDM/lock screen password entry that IBus
would miss the PASSWORD hint set on the StEntry, and let passwords
be fed to engines.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5966
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>
2022-10-26 10:00:37 +00:00
Carlos Garnacho
12032dcc50 ibusManager: Make more resilient to completion/engine independent changes
Besides user interaction, there's two users of IBusManager.setEngine():

- The code that toggles all IBus engines off on entries with PASSWORD
  purpose.
- The code that toggles completion support on OSK presence.

These are currently pretty oblivious to each other. Make this
interaction more resilient by making all external IBusManager changes
more cautious about directly changing the engine, and revoke properly
the completion mode if it needs be (e.g. changing to a non-XKB engine).

But another notable change is that ibus-typing-booster is now preferred
always, over PASSWORD purpose hints. This is done to avoid possible
doubled attempts to change the current engine (and ensuing IBusInputContext
confusion).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>
2022-10-26 10:00:37 +00:00
Carlos Garnacho
b2f2266199 keyboard: Synchronize input method state after toggling completion
Make the input method synchronize its state after the engine changes
resulting from completion being toggled.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>
2022-10-26 10:00:37 +00:00
Carlos Garnacho
ff09c4efc1 inputMethod: Cache cursor rectangle
This may need to be synchronized in other places, so keep
the rectangle around.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>
2022-10-26 10:00:37 +00:00
Carlos Garnacho
290dd38a3a ibusManager: Allow passing callbacks after enabling/disabling completion
Since this is an async operation, we may want to let some things happen
after the engine is changed due to completion being enabled/disabled.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>
2022-10-26 10:00:37 +00:00
Carlos Garnacho
76090c14eb inputMethod: Check return value when letting IM handle virtual keys
When propagating keys from the OSK, we usually feed these directly to
the IBusInputContext and let the IM handle the effects of this virtual
key event (which may also include feeding a key event back to us).

But these functions may also return a FALSE value if the key was "let
through" by the IM, which means the ball is in our yard again, and
we are responsible of letting this event get to its destination.

If that happens, just fall through, so the string is committed to
the client as an UTF-8 string, or propagated through keyboard events.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5930
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2508>
2022-10-18 19:31:51 +00:00
Jonas Ådahl
dfcab5a2b1 inputMethod: Also forward TERMINAL input purpose
It was added relatively recently (1.5.24), so check if it exists first.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5958
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2511>
2022-10-14 21:59:21 +02:00
Florian Müllner
17a2726e64 loginManager: Fix canRebootToBootLoaderMenu() result
Since commit a3db909383, the `result` variable holds the
destructured result of the D-Bus call, not the results array
as previously.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2472>
2022-09-06 20:57:49 +00:00
Sebastian Keller
91ce5ca960 signalTracker: Remove SignalTracker after its last signal got untracked
The object the SignalTracker belongs to is stored in a map managed by
the SignalManager which keeps a reference to that object. This map is
never destroyed nor is any entry ever removed. This leads to all objects
that ever had SignalTrackers used on them being kept alive even after
all references outside of the SignalTracker are long gone. This then
also extends to other objects which are leaked indirectly through
reference chains from these objects.

And if some of those objects are GObjects, this will prevent them from
being finalized, leaking further resources. A StWidget for example will
not release its shadow textures.

Fix this by destroying the SignalTracker and removing it from the
SignalManager once the last signal it was tracking has been untracked.

A WeakMap could have been used as well, but we need the Map to be
iterable in some of the following changes.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5807
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5796
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2466>
2022-09-03 15:11:46 +00:00
Sebastian Keller
54ee728aa0 signalTracker: Don't try to create a new SignalTracker for disconnecting
After the next commit, when some classes, such as PopupMenuManager try
to disconnect via a destroy handler, the SignalTracker might have
already been destroyed, so trying to get it from the SignalManager will
cause it to create a new one, which will then try to connect to the
destroy signal of the already destroyed object.

This could for example be triggered by changing backgrounds.

Fix this by not doing anything in disconnectObject if there is no
SignalTracker for that object.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2466>
2022-09-03 15:11:46 +00:00
Sebastian Keller
d57953ad94 Revert "signalTracker: Use WeakMap in SignalManager to avoid leaking objects"
This reverts commit 085102be74.

We need the SignalManager map top be iterable at shutdown for some of
the following changes. A WeakMap is not iterable. This revert changes it
back to a regular Map, which re-introduces the leaks caused by this.
Those will be fixed differently by the two followup commits.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2466>
2022-09-03 15:11:46 +00:00
Florian Müllner
9bda370636 config: Check for new required GnomeBluetooth API
Client.default_adapter_state is a recent API addition, so update
the HAVE_BLUETOOTH check accordingly before depending on it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2444>
2022-09-03 15:05:57 +00:00
Sebastian Keller
085102be74 signalTracker: Use WeakMap in SignalManager to avoid leaking objects
The object the SignalTracker belongs to is stored in a map managed by
the SignalManager which keeps a reference to that object. This map is
never destroyed nor is any entry ever removed. This leads to all objects
that ever had SignalTrackers used on them being kept alive even after
all references outside of the SignalTracker are long gone. This then
also extends to other objects which are leaked indirectly through
reference chains from these objects.

And if some of those objects are GObjects, this will prevent them from
being finalized, leaking further resources. A StWidget for example will
not release its shadow textures.

Fix this by using a WeakMap in SignalManager.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5807
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5796
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2450>
2022-08-29 21:53:58 +00:00
Carlos Garnacho
c0a75faf89 keyboard: Use extended US keyboard for terminal mode
If the input hint is "terminal", use the extended keyboard.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
2022-08-10 17:11:26 +00:00
Carlos Garnacho
b210b2de72 ibusManager: Add OSK completion mode
This mode changes the current IBus engine to ibus-typing-booster
under the rug (i.e. no changes in keyboard status menu) for any
XKB engine selected.

In order to make it useful for the currently selected language,
the typing-booster dictionary is changed to the current XKB
layout language. And since the OSK has its own emoji panel,
typing-boosters own emoji completion is disabled.

These changes only apply as long as the OSK panel is shown,
reverting to the original engine and typing-booster configuration
after it is hidden. This in theory also caters for users that
do have ibus-typing-booster enabled as an input source.

The final effect is text prediction for the language that is
being typed, according to the OSK layout, given that
ibus-typing-booster and the relevant hunspell dictionaries are
used.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
2022-08-10 17:11:26 +00:00
Carlos Garnacho
fce376939f keyboard: Add 'delete' OSK key action
This action will replace CLUTTER_KEY_Backspace emission for
the OSK backspace key. Following the available mockups, implement
different modes of operation:

- Single tap deletes a single character
- Long tap starts deleting characters one by one
- Longer tap switches to word-by-word deletion

This is made possible via the input method surrounding text,
inspecting the string to look the previous char/word position
backwards, and relies on IM focus providing enough context.

Since deleting text and getting surrounding text are both
async operations, we make one happen after the other, until
the button is released.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
2022-08-10 17:11:26 +00:00
Carlos Garnacho
482e62cb75 inputMethod: Add signal/getter for surrounding text updates
We need to keep track of those at places, add a signal and getter
so that this information can be accessed from the OSK.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
2022-08-10 17:11:26 +00:00
Alessandro Bono
b63c6ac0ef cleanup: Use deepUnpack() intead of deep_unpack()
deep_unpack() is just a backwards compability alias for deepUnpack()[1].
The new name makes it more clear that this is not a C function, start to
use it.

[1] 13e662a29d

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2416>
2022-08-10 10:29:24 +00:00
Alessandro Bono
ade4b23796 cleanup: Minimize deep_unpack() usage
deep_unpack()[1] will unpack a variant and its children, but only up to one level.
lookup_value()[2] will directly search for a value with a linear scan.

Performing a deep_unpack() + lookup can be a more expensive operation when we are
looking for just a single value compared to just perform the lookup_value() directly
in C. Avoid the deep_unpack() usage when we perform a single check presence.

[1] https://gjs.guide/guides/glib/gvariant.html#deepunpack
[2] https://docs.gtk.org/glib/method.Variant.lookup_value.html

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2416>
2022-08-10 10:29:24 +00:00
Carlos Garnacho
23bfd08b3c misc: Toggle IBus OSK capability on OSK visibility
Newer versions of IBus (> 1.5.26) have the IBUS_CAP_OSK capability
which can be used to hint the active IM about an OSK driving input as
opposed to a physical keyboard. This may be used by IMs to tweak their
behavior to suit OSKs better.

Add the GNOME Shell side handling for this capability, and toggle it
on whenever the OSK is visible.

Since this is a far too new enum value and we don't want such new
IBus dependency, this change plays fast and loose with JS guarantees,
since a logical OR with an undefined value results in the other operand
unmodified it will work for older versions where the capability does not
exist and thus we want nothing extra enabled.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2415>
2022-08-10 10:14:40 +00:00
Florian Müllner
0c68c33826 loginManager: Return objects instead of multiple booleans
Multiple booleans - both in arguments and return values - are almost
always problematic API, because people have to memorize (or more likely
look up) the meaning of each position.

Instead, return a JS object so each value has a name attached to it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2370>
2022-08-01 20:58:37 +02:00
Florian Müllner
637ee7386e js: Use async D-Bus wrappers
After porting the more complex cases - in particular those that
affect a module's API - we are left with straight-forward D-Bus
method calls that can be moved to promise-based wrappers in one
go.

For consistency, this also switches from Remote to Async where
the call result is ignored.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
2022-08-01 18:51:14 +00:00
Florian Müllner
a3db909383 loginManager: Make API promise-based
The LoginManager abstraction is still mostly callback-based, not
least because the methods are thin wrappers around logind D-Bus
calls.

However as gjs' dbus wrapper now generates promised-based wrappers
as well, we can implement a proper async API just as naturally.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
2022-08-01 18:51:14 +00:00
Florian Müllner
4880364cd2 objectManager: Simplify fetching of remote objects
Instead of maintaining an inhibitor count, fetch objects and
their interfaces asynchronously and wait for all promises to
settle.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
2022-08-01 18:51:14 +00:00
Florian Müllner
97b7dee564 objectManager: Use non-legacy style
There are a couple of places left where we still use the old
indentation style, update them before making code changes.

After that, there are only a couple of non-type-safe comparisons
left of legacy style, so change those as well while we're at it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
2022-08-01 18:51:14 +00:00
Carlos Garnacho
b0187d4261 inputMethod: Update to set_preedit_text() API change
Since IBus does not provide this information right away, we
so far cannot do much about providing a truthful anchor position
for the preedit text. But with the Mutter API in place it will
be up to this object to do so in the future.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2384>
2022-07-19 12:20:28 +00:00
Florian Müllner
415349c852 systemActions: Disable power-off if querying support fails
Treating failure as success is weird. It's also most likely wrong,
as the most likely reason is that gnome-session isn't running.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2372>
2022-07-09 14:01:17 +02:00
Evan Welsh
61eef2fb9b extensionUtils: Add utility for setting the current extension
ES modules do not allow exports to be overriden, in anticipation
of the ESM port add a `setCurrentExtension` utility which will
throw if used in the shell. This is tested using a conditional
import of Main.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2363>
2022-07-06 13:40:44 -04:00
Marco Trevisan (Treviño)
9abf3508fd signalTracker: Use a const variable to hold the tracked object value
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
2022-07-06 18:24:41 +02:00
Marco Trevisan (Treviño)
371da8d394 signalTracker: Correctly guard against invalid GObject.ConnectFlags
We considered any ConnectFlag value major than SWAPPED as invalid, while
it's technically not fully true as we need to ensure that the passed
value is respecting the whole flags mask.
In fact, per se SWAPPED|AFTER (> SWAPPED) is a valid value (even if we
don't support the AFTER value).

But this makes the check more future-proof.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
2022-07-06 18:24:15 +02:00
Marco Trevisan (Treviño)
ad0f11f024 signalTracker: Avoid getting the same owner object proto multiple times
While untracking an object we used to compute it's proto for each signal
we were disconnecting from, while this is not needed when we're just
iterating over all the same owner signals, so let's add few more
functions to compute an object prototype, and repeat the disconnections
in the simplest way we can.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
2022-07-06 18:24:12 +02:00
Marco Trevisan (Treviño)
74720f250e signalTracker: Avoid creating a temporary keys array when clearing
We used to create a temporary array of signal tracker keys and then to
iterate through them in order to untrack the objects, but the Map's can
be iterated directly so let's just use their native forEach.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
2022-07-06 18:24:08 +02:00
Marco Trevisan (Treviño)
68ceed5c28 signalTracker: Avoid doing two maps lookups once they're initialized
Avoid checking if a map contains a value, given that in the case it's
not there, get() will just return an undefined value. And only in such
case we need to set the value.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
2022-07-06 18:24:04 +02:00
Evan Welsh
83c08e17cf dbusServices: Refactor service utilities from fileUtils into dbusUtils
To enable porting services to ECMAScript modules independently of
the shell, split DBus service utility functions into a new file,
dbusUtils.js

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2365>
2022-07-05 03:41:41 -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
oreo639
8e87ff2975 ibusManager: Avoid double fork triggering parent death in ibus
Use DO_NOT_REAP_CHILD to avoid a double-fork internally since ibus-daemon
refuses to start with init as its parent.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2345>
2022-07-02 11:04:43 +00:00
oreo639
be52477610 ibusManager: Pass on envrionment variables to ibus-daemon
Previously only DISPLAY was being passed on to ibus, which results in issues
with missing the WAYLAND_DISPLAY or the DBUS_SESSION_BUS_ADDRESS environemnt
variables for example.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2345>
2022-07-02 11:04:43 +00:00
oreo639
4097f9f836 ibusManager: Don't use GNOME_SETUP_DISPLAY
GNOME_SETUP_DISPLAY is only necessary when using xwayland on demand,
which is only supported on systemd, in which case you should consider
using the user service provided by ibus.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2345>
2022-07-02 11:04:43 +00:00
Florian Müllner
5a9d365f84 config: Check runtime dependencies at runtime
Both bluetooth and screencast support are based on build checks
right now. However in both cases, the dependency is only consumed
at runtime via the typelib, so let's actually check for that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2297>
2022-05-20 12:00:22 +00:00
Florian Müllner
b365eb9936 screenshot: Hide screencast button when recorder is disabled
The screencast D-Bus service that is used for the recordings
is only installed if the necessary gstreamer and pipewire
dependencies are found at build time.

The screencast button cannot work when the service is missing,
so don't show it in the first place.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2285>
2022-04-29 20:22:32 +00:00
Florian Müllner
82d336211a config: Fix misleading comment
HAVE_SOUP2=1 does *not* mean that Soup3 is enabled, it does the
exact opposite as indicated by the variable name.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2285>
2022-04-29 20:22:32 +00:00
Cenk Uluisik
b832324ede introspect: Add WindowsChanged signal
The screencast portal supports recording a single window,
and presents a list of open windows when that option is
selected. To allow updating that list when windows are
opened or closed, add a new "WindowsChanged" signal that
the portal can listen to.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2229>
2022-03-08 16:31:20 +00:00