[gnome-shell/wip/carlosg/ibus-osk-capability: 11/11] misc: Toggle IBus OSK capability on OSK visibility
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/ibus-osk-capability: 11/11] misc: Toggle IBus OSK capability on OSK visibility
- Date: Wed, 10 Aug 2022 10:14:51 +0000 (UTC)
commit 23bfd08b3c9b5b10f2afc3b4c01544742caef680
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 9 16:00:33 2022 +0200
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>
js/misc/inputMethod.js | 8 ++++++++
js/ui/keyboard.js | 5 ++++-
2 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js
index 856bf57aec..fba2730bd1 100644
--- a/js/misc/inputMethod.js
+++ b/js/misc/inputMethod.js
@@ -3,6 +3,7 @@
const { Clutter, GLib, Gio, GObject, IBus } = imports.gi;
const Keyboard = imports.ui.status.keyboard;
+const Main = imports.ui.main;
Gio._promisify(IBus.Bus.prototype,
'create_input_context_async', 'create_input_context_async_finish');
@@ -42,6 +43,9 @@ class InputMethod extends Clutter.InputMethod {
_updateCapabilities() {
let caps = IBus.Capabilite.PREEDIT_TEXT | IBus.Capabilite.FOCUS | IBus.Capabilite.SURROUNDING_TEXT;
+ if (Main.keyboard.visible)
+ caps |= IBus.Capabilite.OSK;
+
if (this._context)
this._context.set_capabilities(caps);
}
@@ -72,10 +76,14 @@ class InputMethod extends Clutter.InputMethod {
this._context.connect('forward-key-event', this._onForwardKeyEvent.bind(this));
this._context.connect('destroy', this._clear.bind(this));
+ Main.keyboard.connectObject('visibility-changed', () => this._updateCapabilities());
+
this._updateCapabilities();
}
_clear() {
+ Main.keyboard.disconnectObject(this);
+
if (this._cancellable) {
this._cancellable.cancel();
this._cancellable = null;
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index ac36f3573a..77a6f7d5cc 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1180,8 +1180,10 @@ var Keypad = GObject.registerClass({
}
});
-var KeyboardManager = class KeyBoardManager {
+var KeyboardManager = class extends Signals.EventEmitter {
constructor() {
+ super();
+
this._keyboard = null;
this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA });
this._a11yApplicationsSettings.connect('changed', this._syncEnabled.bind(this));
@@ -1237,6 +1239,7 @@ var KeyboardManager = class KeyBoardManager {
if (enabled && !this._keyboard) {
this._keyboard = new Keyboard();
this._keyboard.connect('visibility-changed', () => {
+ this.emit('visibility-changed');
this._bottomDragAction.enabled = !this._keyboard.visible;
});
} else if (!enabled && this._keyboard) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]