[gnome-shell/wip/carlosg/ibus-osk-capability: 110/110] misc: Toggle IBus OSK capability on OSK visibility
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/ibus-osk-capability: 110/110] misc: Toggle IBus OSK capability on OSK visibility
- Date: Tue, 9 Aug 2022 21:42:31 +0000 (UTC)
commit 48331df1eb4273dbc36fceaa1fb0afedf2395967
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.
js/misc/inputMethod.js | 9 +++++++++
js/ui/keyboard.js | 5 ++++-
2 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js
index 856bf57aec..17674dee16 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,15 @@ class InputMethod extends Clutter.InputMethod {
this._context.connect('forward-key-event', this._onForwardKeyEvent.bind(this));
this._context.connect('destroy', this._clear.bind(this));
+ this._keyboardVisibilityId =
+ Main.keyboard.connect('visibility-changed', () => this._updateCapabilities());
+
this._updateCapabilities();
}
_clear() {
+ Main.keyboard.disconnect(this._keyboardVisibilityId);
+
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]