[gnome-shell/wip/carlosg/update-pad-osd-actions] padOsd: Re-query action labels after mode switches
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/update-pad-osd-actions] padOsd: Re-query action labels after mode switches
- Date: Mon, 16 Dec 2019 13:19:13 +0000 (UTC)
commit 6b0983e1f17494054b64cf1077519215c948432e
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Dec 16 12:39:49 2019 +0100
padOsd: Re-query action labels after mode switches
Do this so the pad OSD is able to update dynamically to mode changes,
showing immediately the new actions for the current mode(s).
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/898
js/ui/padOsd.js | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js
index 55b3d0b8c4..6ddb0c71fe 100644
--- a/js/ui/padOsd.js
+++ b/js/ui/padOsd.js
@@ -564,6 +564,14 @@ var PadDiagram = GObject.registerClass({
this.add_actor(label);
}
+ updateLabels(callback) {
+ for (let i = 0; i < this._labels.length; i++) {
+ let [label, action, idx, dir] = this._labels[i];
+ let str = callback(action, idx, dir);
+ label.set_text(str);
+ }
+ }
+
_applyLabel(label, action, idx, dir, str) {
if (str != null) {
label.set_text(str);
@@ -776,17 +784,29 @@ var PadOsd = GObject.registerClass({
global.display.request_pad_osd(pad, editionMode);
}
- _createLabel(type, number, dir) {
+ _getActionText(type, number) {
let str = global.display.get_pad_action_label(this.padDevice, type, number);
- let label = new St.Label({ text: str ? str : _("None") });
+ return str ? str : _("None");
+ }
+
+ _createLabel(type, number, dir) {
+ let label = new St.Label({ text: this._getActionText(type, number) });
this._padDiagram.addLabel(label, type, number, dir);
}
+ _updateActionLabels() {
+ this._padDiagram.updateLabels(this._getActionText.bind(this));
+ }
+
_onCapturedEvent(actor, event) {
+ let isModeSwitch =
+ (event.type() == Clutter.EventType.PAD_BUTTON_PRESS ||
+ event.type() == Clutter.EventType.PAD_BUTTON_RELEASE) &&
+ this.padDevice.get_mode_switch_button_group(event.get_button()) >= 0;
+
if (event.type() == Clutter.EventType.PAD_BUTTON_PRESS &&
event.get_source_device() == this.padDevice) {
this._padDiagram.activateButton(event.get_button());
- let isModeSwitch = this.padDevice.get_mode_switch_button_group(event.get_button()) >= 0;
/* Buttons that switch between modes cannot be edited */
if (this._editionMode && !isModeSwitch)
@@ -795,6 +815,11 @@ var PadOsd = GObject.registerClass({
} else if (event.type() == Clutter.EventType.PAD_BUTTON_RELEASE &&
event.get_source_device() == this.padDevice) {
this._padDiagram.deactivateButton(event.get_button());
+
+ if (isModeSwitch) {
+ this._endActionEdition();
+ this._updateActionLabels();
+ }
return Clutter.EVENT_STOP;
} else if (event.type() == Clutter.EventType.KEY_PRESS &&
(!this._editionMode || event.get_key_symbol() === Clutter.KEY_Escape)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]