keyboard: Handle extended keyboards through TERMINAL input purpose
Drop the channeling of this specific signal from the InputMethod, and update the OSK Keyboard object to using the purpose hint to find out whether a extended keymap is necessary. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>
This commit is contained in:
parent
173d70dc70
commit
35bfb4501d
@ -21,7 +21,6 @@ const HAVE_REQUIRE_SURROUNDING_TEXT = GObject.signal_lookup('require-surrounding
|
|||||||
export const InputMethod = GObject.registerClass({
|
export const InputMethod = GObject.registerClass({
|
||||||
Signals: {
|
Signals: {
|
||||||
'surrounding-text-set': {},
|
'surrounding-text-set': {},
|
||||||
'terminal-mode-changed': {},
|
|
||||||
},
|
},
|
||||||
}, class InputMethod extends Clutter.InputMethod {
|
}, class InputMethod extends Clutter.InputMethod {
|
||||||
_init() {
|
_init() {
|
||||||
@ -34,7 +33,6 @@ export const InputMethod = GObject.registerClass({
|
|||||||
this._preeditAnchor = 0;
|
this._preeditAnchor = 0;
|
||||||
this._preeditVisible = false;
|
this._preeditVisible = false;
|
||||||
this._hidePanelId = 0;
|
this._hidePanelId = 0;
|
||||||
this.terminalMode = false;
|
|
||||||
this._ibus = IBus.Bus.new_async();
|
this._ibus = IBus.Bus.new_async();
|
||||||
this._ibus.connect('connected', this._onConnected.bind(this));
|
this._ibus.connect('connected', this._onConnected.bind(this));
|
||||||
this._ibus.connect('disconnected', this._clear.bind(this));
|
this._ibus.connect('disconnected', this._clear.bind(this));
|
||||||
@ -229,7 +227,6 @@ export const InputMethod = GObject.registerClass({
|
|||||||
this._surroundingTextCursor = null;
|
this._surroundingTextCursor = null;
|
||||||
this._surroundingTextAnchor = null;
|
this._surroundingTextAnchor = null;
|
||||||
this._preeditStr = null;
|
this._preeditStr = null;
|
||||||
this._setTerminalMode(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_set_cursor_location(rect) {
|
vfunc_set_cursor_location(rect) {
|
||||||
@ -302,21 +299,11 @@ export const InputMethod = GObject.registerClass({
|
|||||||
IBus.InputPurpose.TERMINAL)
|
IBus.InputPurpose.TERMINAL)
|
||||||
ibusPurpose = IBus.InputPurpose.TERMINAL;
|
ibusPurpose = IBus.InputPurpose.TERMINAL;
|
||||||
|
|
||||||
this._setTerminalMode(
|
|
||||||
purpose === Clutter.InputContentPurpose.TERMINAL);
|
|
||||||
|
|
||||||
this._purpose = ibusPurpose;
|
this._purpose = ibusPurpose;
|
||||||
if (this._context)
|
if (this._context)
|
||||||
this._context.set_content_type(this._purpose, this._hints);
|
this._context.set_content_type(this._purpose, this._hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setTerminalMode(terminalMode) {
|
|
||||||
if (this.terminalMode !== terminalMode) {
|
|
||||||
this.terminalMode = terminalMode;
|
|
||||||
this.emit('terminal-mode-changed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vfunc_filter_key_event(event) {
|
vfunc_filter_key_event(event) {
|
||||||
if (!this._context)
|
if (!this._context)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1413,10 +1413,6 @@ export const Keyboard = GObject.registerClass({
|
|||||||
|
|
||||||
this._updateKeys();
|
this._updateKeys();
|
||||||
|
|
||||||
Main.inputMethod.connectObject(
|
|
||||||
'terminal-mode-changed', this._onTerminalModeChanged.bind(this),
|
|
||||||
this);
|
|
||||||
|
|
||||||
this._keyboardController.connectObject(
|
this._keyboardController.connectObject(
|
||||||
'active-group', this._onGroupChanged.bind(this),
|
'active-group', this._onGroupChanged.bind(this),
|
||||||
'groups-changed', this._onKeyboardGroupsChanged.bind(this),
|
'groups-changed', this._onKeyboardGroupsChanged.bind(this),
|
||||||
@ -1493,7 +1489,12 @@ export const Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ensureKeys() {
|
_ensureKeys() {
|
||||||
const group = this._keyboardController.getCurrentGroup();
|
let group;
|
||||||
|
if (this._purpose === Clutter.InputContentPurpose.TERMINAL)
|
||||||
|
group = 'us-extended';
|
||||||
|
else
|
||||||
|
group = this._keyboardController.getCurrentGroup();
|
||||||
|
|
||||||
if (!this._groups[group])
|
if (!this._groups[group])
|
||||||
this._groups[group] = this._createLayersForGroup(group);
|
this._groups[group] = this._createLayersForGroup(group);
|
||||||
}
|
}
|
||||||
@ -1617,7 +1618,7 @@ export const Keyboard = GObject.registerClass({
|
|||||||
if (enabled &&
|
if (enabled &&
|
||||||
(!Main.inputMethod.currentFocus ||
|
(!Main.inputMethod.currentFocus ||
|
||||||
Main.inputMethod.hasPreedit() ||
|
Main.inputMethod.hasPreedit() ||
|
||||||
Main.inputMethod.terminalMode)) {
|
this._purpose === Clutter.InputContentPurpose.TERMINAL)) {
|
||||||
this._keyboardController.keyvalPress(Clutter.KEY_BackSpace);
|
this._keyboardController.keyvalPress(Clutter.KEY_BackSpace);
|
||||||
this._backspacePressed = true;
|
this._backspacePressed = true;
|
||||||
return;
|
return;
|
||||||
@ -1803,10 +1804,6 @@ export const Keyboard = GObject.registerClass({
|
|||||||
this._updateKeys();
|
this._updateKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onTerminalModeChanged() {
|
|
||||||
this._updateKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
_onKeyboardGroupsChanged() {
|
_onKeyboardGroupsChanged() {
|
||||||
let nonGroupActors = [this._emojiSelection, this._keypad];
|
let nonGroupActors = [this._emojiSelection, this._keypad];
|
||||||
this._aspectContainer.get_children().filter(c => !nonGroupActors.includes(c)).forEach(c => {
|
this._aspectContainer.get_children().filter(c => !nonGroupActors.includes(c)).forEach(c => {
|
||||||
@ -2220,9 +2217,6 @@ class KeyboardController extends Signals.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentGroup() {
|
getCurrentGroup() {
|
||||||
if (Main.inputMethod.terminalMode)
|
|
||||||
return 'us-extended';
|
|
||||||
|
|
||||||
// Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
|
// Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
|
||||||
if (this._currentSource.id === 'hangul') {
|
if (this._currentSource.id === 'hangul') {
|
||||||
const inputSourceManager = InputSourceManager.getInputSourceManager();
|
const inputSourceManager = InputSourceManager.getInputSourceManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user