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>
This commit is contained in:
parent
8874f2c248
commit
c0a75faf89
@ -13,6 +13,7 @@ var HIDE_PANEL_TIME = 50;
|
|||||||
var InputMethod = GObject.registerClass({
|
var 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() {
|
||||||
@ -25,6 +26,7 @@ var 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));
|
||||||
@ -208,6 +210,7 @@ var InputMethod = GObject.registerClass({
|
|||||||
this._surroundingText = null;
|
this._surroundingText = null;
|
||||||
this._surroundingTextCursor = null;
|
this._surroundingTextCursor = null;
|
||||||
this._preeditStr = null;
|
this._preeditStr = null;
|
||||||
|
this._setTerminalMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_set_cursor_location(rect) {
|
vfunc_set_cursor_location(rect) {
|
||||||
@ -271,11 +274,21 @@ var InputMethod = GObject.registerClass({
|
|||||||
else if (purpose == Clutter.InputContentPurpose.PASSWORD)
|
else if (purpose == Clutter.InputContentPurpose.PASSWORD)
|
||||||
ibusPurpose = IBus.InputPurpose.PASSWORD;
|
ibusPurpose = IBus.InputPurpose.PASSWORD;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -1416,6 +1416,9 @@ var Keyboard = GObject.registerClass({
|
|||||||
// keyboard on RTL locales.
|
// keyboard on RTL locales.
|
||||||
this.text_direction = Clutter.TextDirection.LTR;
|
this.text_direction = Clutter.TextDirection.LTR;
|
||||||
|
|
||||||
|
Main.inputMethod.connect(
|
||||||
|
'terminal-mode-changed', this._onTerminalModeChanged.bind(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),
|
||||||
@ -1610,7 +1613,9 @@ var Keyboard = GObject.registerClass({
|
|||||||
this._deleteEnabled = enabled;
|
this._deleteEnabled = enabled;
|
||||||
this._timesDeleted = 0;
|
this._timesDeleted = 0;
|
||||||
|
|
||||||
if (!Main.inputMethod.currentFocus || Main.inputMethod.hasPreedit()) {
|
if (!Main.inputMethod.currentFocus ||
|
||||||
|
Main.inputMethod.hasPreedit() ||
|
||||||
|
Main.inputMethod.terminalMode) {
|
||||||
/* If there is no IM focus or are in the middle of preedit,
|
/* If there is no IM focus or are in the middle of preedit,
|
||||||
* fallback to keypresses */
|
* fallback to keypresses */
|
||||||
if (enabled)
|
if (enabled)
|
||||||
@ -1791,11 +1796,19 @@ var Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onGroupChanged() {
|
_updateKeys() {
|
||||||
this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
|
this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
|
||||||
this._setActiveLayer(0);
|
this._setActiveLayer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onGroupChanged() {
|
||||||
|
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 => {
|
||||||
@ -2206,6 +2219,8 @@ var KeyboardController = class extends Signals.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentGroup() {
|
getCurrentGroup() {
|
||||||
|
if (Main.inputMethod.terminalMode)
|
||||||
|
return 'us-extended';
|
||||||
return this._currentSource.xkbId;
|
return this._currentSource.xkbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user