From eb025901c8e826a30a0353dca0e304c06e67d014 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 21 Sep 2009 13:44:42 -0400 Subject: [PATCH] [AppSwitcher] Implement pointer selection --- js/ui/altTab.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/js/ui/altTab.js b/js/ui/altTab.js index 9818d0a3e..333937c78 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -20,6 +20,8 @@ const POPUP_GRID_SPACING = 8; const POPUP_ICON_SIZE = 48; const POPUP_NUM_COLUMNS = 5; +const POPUP_POINTER_SELECTION_THRESHOLD = 3; + function AltTabPopup() { this._init(); } @@ -59,6 +61,8 @@ AltTabPopup.prototype = { appIcon.connect('menu-popped-up', Lang.bind(this, this._menuPoppedUp)); appIcon.connect('menu-popped-down', Lang.bind(this, this._menuPoppedDown)); + appIcon.actor.connect('enter-event', Lang.bind(this, this._iconEntered)); + // FIXME? appIcon.actor.border = 2; @@ -87,6 +91,10 @@ AltTabPopup.prototype = { this._keyPressEventId = global.stage.connect('key-press-event', Lang.bind(this, this._keyPressEvent)); this._keyReleaseEventId = global.stage.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent)); + this._motionEventId = this.actor.connect('motion-event', Lang.bind(this, this._mouseMoved)); + this._mouseActive = false; + this._mouseMovement = 0; + // Contruct the AppIcons, sort by time, add to the popup let icons = []; for (let i = 0; i < apps.length; i++) @@ -156,6 +164,29 @@ AltTabPopup.prototype = { this._highlightWindow(window); }, + _mouseMoved : function(actor, event) { + if (++this._mouseMovement < POPUP_POINTER_SELECTION_THRESHOLD) + return; + + this.actor.disconnect(this._motionEventId); + this._mouseActive = true; + + actor = event.get_source(); + while (actor) { + if (actor._delegate instanceof AppIcon.AppIcon) { + this._iconEntered(actor, event); + return; + } + actor = actor.get_parent(); + } + }, + + _iconEntered : function(actor, event) { + let index = this._icons.indexOf(actor._delegate); + if (this._mouseActive) + this._updateSelection(index - this._selected); + }, + destroy : function() { this.actor.destroy(); },