From 3ff1be9fe127a51092b1f5b97d65af7fff75041d Mon Sep 17 00:00:00 2001 From: rpm-build Date: Mon, 13 Nov 2017 14:17:18 -0500 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 2a8ca47..37d140a 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', Lang.bind(this, this._onLongPress)); this.actor = new St.Bin(); this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); this.actor.connect('notify::mapped', () => { this._flipped = false; }); }, _sync: function() { 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: function() { if (this._capturedEventId > 0) { global.stage.disconnect(this._capturedEventId); this._capturedEventId = 0; } }, _onCapturedEvent: function(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: function(action, actor, state) { if (state == Clutter.LongPressState.QUERY || state == Clutter.LongPressState.CANCEL) -- 2.14.3