Commit Graph

36 Commits

Author SHA1 Message Date
Ting-Wei Lan
e08a4acd06 ibusManager: Fix the panel after porting to Promises
Commit 764527c8c9 not only ports this file
to Promises but also changes the behavior of _initPanelService method.
Instead of always calling _updateReadiness when _panelService is ready,
it only calls it when get_global_engine_async succeeds.

The only callers of _updateReadiness are _initEngines and
_initPanelService. Assume that _initEngines completes first. Its
_updateReadiness call keeps _ready as false and it is expected for
_initPanelService to change it to true. However, since
get_global_engine_async fails because there is no active engine,
_initPanelService never calls _updateReadiness. Therefore, all setEngine
calls do nothing because _ready is false, and the input method panel
never shows. Users are unable to use any input method even if they can
see that ibus-daemon is already running.

Fix the issue by changing it back to the old behavior.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1235
2020-05-03 23:26:39 +08: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
13f3f75303 ibusManager: Simplify code a bit
ibus_bus_request_name_async_finish() will throw an error on failure,
so we can move the error handling there instead of checking for the
return value, which saves one level of indentation.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1122
2020-03-24 08:27:27 +01:00
Alynx Zhou
94f6976ddd ibusManager: fix ibus launch error because of wrong method name
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1080
2020-03-11 09:30:15 +00:00
Carlos Garnacho
1a0ec782b5 ibusManager: Ensure to spawn --xim on non-wayland sessions
This (mistakenly) now only depends on signals triggered on Wayland
sessions. Hardcoding the XIM support on X11 sessions will make input
in some clients work again.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1690
2020-03-06 18:57:23 +00:00
Carlos Garnacho
3c4a5a67e2 ibusManager: Use setup X11 display for ibus-x11
(re)spawning ibus to get ibus-x11 will be part atm of Xwayland
initialization process. For it to be set up before the client
it needs using the GNOME_SETUP_DISPLAY.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/836
2020-02-29 18:58:47 +01: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
682bd7e97c cleanup: Don't shadow variables
Having variables that share the same name in overlapping scopes is
confusing and error-prone, and is best avoided.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Marco Trevisan (Treviño)
6a6d66486d ibusManager: Cancel the preload engines timeout on clear
This is created when preloading but never cancelled if ibus disappears

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/743
2019-10-02 18:19:53 +02:00
Marco Trevisan (Treviño)
1cc766d636 ibusManager, inputMethod: Cancel async ibus calls chain on disconnect
The shell tries to spawn the ibus daemon on startup if unavailable, however
as per commit 8adfc5b1 we also force restarting it once the X11 server is
available.
Unfortunately this could cause a race if we disconnect while we were already
connected to an ibus daemon, but still in the process of going through the
various nested calls.
In fact the ::disconnect callback didn't stop any further async ibus call
that, even if failing, would have eventually triggered the emission of a
'ready' signal and to the Keyboard's callback, leading under X11 to a full
grab owned by ibus daemon.

In order to avoid this and keep control of the calls order, use in both
IbusManager and InputMethod a cancellable that is setup before connecting to
the bus, and that is cancelled on disconnection.
Then handle the finish() calls properly, using try/catch to validate the
returned value, taking in account the potential error and just not
proceeding in case of cancellation.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1712
2019-10-02 18:19:53 +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
Florian Müllner
4bfee3a8ca ibusManager: Wrap line before dot
When chaining function calls, our coding style asks for the dot to
start the new line, not end the preceding one.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/710
2019-09-11 20:59:31 +00:00
Carlos Garnacho
8adfc5b106 windowManager: Handle starting/stopping of X11 services
We now do 2 things along Xwayland startup/shutdown:
- Start or stop the gnome-session-x11-services target, that will
  pull all X11 related services that the session might depend on.
- As we start ibus-daemon manually, trigger a restart in order to
  toggle the XIM daemon on and off along with Xwayland presence.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/680
2019-09-05 07:42:46 +00:00
Carlos Garnacho
8be95b5785 ibusManager: Add call to restart the ibus daemon
We may need to restart it with different arguments, so make it
possible to do that. Also, avoid to just restart it on _clear(),
this is now most likely through our --replace call than it is
through ibus-daemon eg. dying, avoids some noise in logs as
there is already an ongoing ibus-daemon.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/680
2019-09-05 07:42:46 +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
0d035a4e53 cleanup: Prefer template strings
Template strings are much nicer than string concatenation, so use
them where possible; this excludes translatable strings and any
strings containing '/' (until we can depend on gettext >= 0.20[0]).

[0] https://savannah.gnu.org/bugs/?50920

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612
2019-07-05 11:32:31 +00:00
Florian Müllner
e95f3febd6 ibusManager: Use Map to store engines
This is a clear case of key->value mapping, so using the corresponding
data type makes sense.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612
2019-07-05 11:32:31 +00:00
Florian Müllner
14d7897a93 style: Stop using braces for single-line arrow functions
Braces are optional for single-line arrow functions, but there's a
subtle difference:
Without braces, the expression is implicitly used as return value; with
braces, the function returns nothing unless there's an explicit return.

We currently reflect that in our style by only omitting braces when the
function is expected to have a return value, but that's not very obvious,
not an important differentiation to make, and not easy to express in an
automatic rule.

So just omit braces consistently as mandated by gjs' coding style.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
f250643385 style: Use space after catch
We are currently inconsistent with whether or not to put a space
after catch clauses. While the predominant style is to omit it,
that's inconsistent with the style we use for any other statement.
There's not really a good reason to stick with it, so switch to
the style gjs/eslint default to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02: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
bacfdbbb03 cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can
replace our custom Lang.Class framework with the new syntax. Any
classes that inherit from GObject will need special treatment,
so limit the port to regular javascript classes for now.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
74bb9e6249 ibusManager: Don't pass undefined callback to ibus
Since commit 551e827841, we don't always pass a callback parameter.
However passing it on as undefined to ibus doesn't work, as gjs doesn't
accept that as a valid callback value and throw an error. As a result,
we can end up with no layout selected in the keyboard menu and an "empty"
indicator. Fix this by explicitly passing null if no callback has been
provided.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/293
2018-11-17 12:15:46 +00:00
Carlos Garnacho
11fb91f60f keyboard: Listen to IbusPanelService::focus-in/out to track focus changes
In X11 there's no input panel state requests, so restore the previous behavior
that focused entries would always toggle the OSK on there.
2018-09-25 23:49:42 +00:00
Carlos Garnacho
fc5ab44704 keyboard: Implement standalone FocusTracker
And stop using FocusCaretTracker for caret position purposes. This
new object uses 1) the text-input protocol in wayland and 2) Info
from IBusPanelService for X11 (which is meant to work for XIM too).

This drops the usage of AtspiEventListener for OSK purposes, which
is best to avoid.
2018-07-11 18:32:32 +02: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
Carlos Garnacho
083d11a032 misc: Make IBus a mandatory dependency
IBus was initially made optional as gnome-shell depended on too
recent API. This API is now old enough and gnome-shell is committing
further to IBus by implementing a ClutterInputMethod through it.
Let's just make IBus a mandatory dependency, instead of making code
paths trickier to cater for situations where it's missing.
2018-02-05 17:46:57 +01: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
Florian Müllner
f33560f014 ibusManager: Fix a warning
Don't try to access a non-existent engine - it probably makes sense to
use Map() instead of a plain object to track engines in the future, but
for now just add an additional check to shut up a warning.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-13 17:23:54 +02:00
Philip Chimento
f7752ac699 ibusManager: Use const correctly
Per ES6, a variable declared const should only be valid inside its lexical
scope. Previously, GJS would accept this code, but that will change in the
SpiderMonkey JS engine in the next release of GJS.

https://bugzilla.gnome.org/show_bug.cgi?id=778425
2017-02-10 13:19:08 -08:00
Takao Fujiwara
d8ca374a06 ibusManager: Disable IBus input sources on password entries
Input method preedit text needs to be disabled on password entries
for security and usability reasons.
IBus 1.5.7 provides the signal set-content-type so that panel UIs can
handle these special purpose input entries:
https://github.com/ibus/ibus/commit/6ca5ddb302c9

Unfortunately IBus versions older than 1.5.10 have a bug which causes
spurious set-content-type emissions when switching input focus that
temporarily lose purpose and hints defeating its intended semantics
and confusing users. We thus don't use it in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=730628
2015-01-12 16:13:45 +01:00
Takao Fujiwara
e467a734a1 ibusManager: Preload all ibus input sources in user configuration
Normally users switch xkb input sources and ibus input sources.
But currently the first input source only is running. It's also good
to preload all ibus engines in the logging session so that users switch
input sources quickly without the launching time of input sources.

The following is the ibus change:
https://github.com/ibus/ibus/commit/cff35929a9

https://bugzilla.gnome.org/show_bug.cgi?id=695428
2014-11-12 21:07:19 +01:00
Rui Matos
8589bfb62e Implement input source switching
Instead of calling out to gnome-settings-daemon we'll just implement
the switching logic ourselves and use mutter APIs that allow this
functionality to work both in X sessions and when we're a Wayland
compositor.

Switching IBus engines is done transparently as well just like g-s-d
used to do.

https://bugzilla.gnome.org/show_bug.cgi?id=736435
2014-09-11 19:14:46 +02:00
Rui Matos
6a36a68f32 ibusManager: Spawn ibus-daemon
gnome-settings-daemon doesn't this for us anymore. Note that
ibus-daemon isn't DBus activatable but just spawning it is fine
because it does its own single instance management. The library
notifies us when it shows up and goes away through the connected and
disconnected signals.

https://bugzilla.gnome.org/show_bug.cgi?id=736435
2014-09-11 19:14:46 +02:00
Rui Matos
58aabfcf5b status/keyboard: Move IBusManager into its own file
This also makes it a singleton for easier access from multiple places.

https://bugzilla.gnome.org/show_bug.cgi?id=736435
2014-09-11 19:14:45 +02:00