You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
3.2 KiB

From 5bd84b34622a3e5919e979b99d1d4872d355d18d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Mon, 4 Jun 2018 13:48:02 -0400
Subject: [PATCH] system: don't throw an exception if power off disabled
---
js/ui/status/system.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index 68a0b4b5b..2ab38419f 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -40,66 +40,69 @@ var AltSwitcher = new Lang.Class({
this._clickAction.connect('long-press', this._onLongPress.bind(this));
this.actor = new St.Bin();
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('notify::mapped', () => { this._flipped = false; });
},
_sync() {
let childToShow = null;
if (this._standard.visible && this._alternate.visible) {
let [x, y, mods] = global.get_pointer();
let altPressed = (mods & Clutter.ModifierType.MOD1_MASK) != 0;
if (this._flipped)
childToShow = altPressed ? this._standard : this._alternate;
else
childToShow = altPressed ? this._alternate : this._standard;
} else if (this._standard.visible) {
childToShow = this._standard;
} else if (this._alternate.visible) {
childToShow = this._alternate;
}
let childShown = this.actor.get_child();
if (childShown != childToShow) {
if (childShown) {
if (childShown.fake_release)
childShown.fake_release();
childShown.remove_action(this._clickAction);
}
- childToShow.add_action(this._clickAction);
- let hasFocus = this.actor.contains(global.stage.get_key_focus());
- this.actor.set_child(childToShow);
- if (hasFocus)
- childToShow.grab_key_focus();
+ if (childToShow) {
+ childToShow.add_action(this._clickAction);
+
+ let hasFocus = this.actor.contains(global.stage.get_key_focus());
+ this.actor.set_child(childToShow);
+ if (hasFocus)
+ childToShow.grab_key_focus();
+ }
// The actors might respond to hover, so
// sync the pointer to make sure they update.
global.sync_pointer();
}
this.actor.visible = (childToShow != null);
},
_onDestroy() {
if (this._capturedEventId > 0) {
global.stage.disconnect(this._capturedEventId);
this._capturedEventId = 0;
}
},
_onCapturedEvent(actor, event) {
let type = event.type();
if (type == Clutter.EventType.KEY_PRESS || type == Clutter.EventType.KEY_RELEASE) {
let key = event.get_key_symbol();
if (key == Clutter.KEY_Alt_L || key == Clutter.KEY_Alt_R)
this._sync();
}
return Clutter.EVENT_PROPAGATE;
},
_onLongPress(action, actor, state) {
if (state == Clutter.LongPressState.QUERY ||
state == Clutter.LongPressState.CANCEL)
--
2.17.1