diff --git a/extension.js b/extension.js index 47e113b..8b910a9 100644 --- a/extension.js +++ b/extension.js @@ -290,7 +290,7 @@ class MonitorWidget extends PanelMenu.Button { return box; } - _manageEventAction(action) { + _manageEventAction(action, signalName) { if (action === 'open-popup') this.menu.open(true); else if (action === 'close-popup') @@ -299,6 +299,8 @@ class MonitorWidget extends PanelMenu.Button { this.menu.toggle(); else if (action == 'delete') this.dbus.deleteItem(this, this.group); + else if (action === 'signal') + this.dbus.emitSignal(signalName, this.fullname); return Clutter.EVENT_PROPAGATE; } @@ -310,10 +312,12 @@ class MonitorWidget extends PanelMenu.Button { _doClickCallback() { let right = ''; let nbClicks = ''; + if (this.button == 3) right = 'Right'; if (this.nbClicks > 1) nbClicks = 'Dbl'; + let signalName = 'on' + right + nbClicks + 'Click'; let action = 'signal'; @@ -324,10 +328,8 @@ class MonitorWidget extends PanelMenu.Button { case 'onRightDblClick': action = this.onRightDblClick; break; } - if (action === 'signal') - this.dbus.emitSignal(signalName, this.fullname); - else - this._manageEventAction(action); + this._manageEventAction(action, signalName); + this.nbClicks = 0; this.button = -1; @@ -349,34 +351,22 @@ class MonitorWidget extends PanelMenu.Button { } _onEnter(/*actor, event*/) { - if (this.onEnter === 'signal') - this.dbus.emitSignal('onEnter', this.fullname); - else - return this._manageEventAction(this.onEnter); - - return Clutter.EVENT_PROPAGATE; + return this._manageEventAction(this.onEnter, 'onEnter'); } _onLeave(/*actor, event*/) { - if (this.onLeave === 'signal') - this.dbus.emitSignal('onLeave', this.fullname); - else - return this._manageEventAction(this.onLeave); - - return Clutter.EVENT_PROPAGATE; + return this._manageEventAction(this.onLeave, 'onLeave'); } _onScroll(actor, event) { - if (this.onScroll === 'signal') { - let direction = event.get_scroll_direction (); - if (direction == Clutter.ScrollDirection.UP) - this.dbus.emitSignal('onScrollUp', this.fullname); - else if (direction == Clutter.ScrollDirection.DOWN) - this.dbus.emitSignal('onScrollDown', this.fullname); - } else - return this._manageEventAction(this.onScroll); + let signalName = ''; + let direction = event.get_scroll_direction (); + if (direction == Clutter.ScrollDirection.UP) + signalName = 'onScrollUp'; + else if (direction == Clutter.ScrollDirection.DOWN) + signalName = 'onScrollDown'; - return Clutter.EVENT_PROPAGATE; + return this._manageEventAction(this.onScroll, signalName); } update(item) {