diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-02-15 14:48:46 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-02-15 14:53:36 +0100 |
commit | d2c693d5f1c66f3fad750f2475dd983dcb92f4c3 (patch) | |
tree | a4bdb9e96df99382c35a0aba5c5d16ce9946fc84 | |
parent | 0f3910a2315f0827cfc696874a4ba02ab79b0541 (diff) | |
download | gnome-shell-wip/carlosg/fix-issue-46.tar.gz |
keyboard: Set 'latched' pseudo-class on latched shift keywip/carlosg/fix-issue-46
This is pseudo-class is added on .shift-key-uppercase whenever the shift
state is latched, a matching selector would be:
.keyboard-key.shift-key-uppercase:latched {}
-rw-r--r-- | js/ui/keyboard.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 33ec36810..2c1587383 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -450,6 +450,13 @@ var Key = new Lang.Class({ setWidth: function (width) { this.keyButton.keyWidth = width; }, + + setLatched: function (latched) { + if (latched) + this.keyButton.add_style_pseudo_class('latched'); + else + this.keyButton.remove_style_pseudo_class('latched'); + }, }); Signals.addSignalMethods(Key.prototype); @@ -749,6 +756,8 @@ var Keyboard = new Lang.Class({ let level = (i >= 1 && levels.length == 3) ? i + 1 : i; let layout = new KeyContainer(); + layout.shiftKeys = []; + this._loadRows(currentLevel, level, levels.length, layout); layers[level] = layout; this.actor.add(layout, { expand: true }); @@ -845,7 +854,10 @@ var Keyboard = new Lang.Class({ if (switchToLevel == 1) { extraButton.connect('long-press', Lang.bind(this, function() { this._latched = true; + this._setCurrentLevelLatched(this._current_page, this._latched); })); + } else if (switchToLevel == 0) { + layout.shiftKeys.push(extraButton); } /* Fixup default keys based on the number of levels/keys */ @@ -868,6 +880,13 @@ var Keyboard = new Lang.Class({ } }, + _setCurrentLevelLatched: function(layout, latched) { + for (let i = 0; layout.shiftKeys[i]; i++) { + let key = layout.shiftKeys[i]; + key.setLatched(latched); + } + }, + _getDefaultKeysForRow: function(row, numRows, level) { let pre, post; @@ -961,6 +980,7 @@ var Keyboard = new Lang.Class({ let layers = this._groups[activeGroupName]; if (this._current_page != null) { + this._setCurrentLevelLatched(this._current_page, false); this._current_page.hide(); } |