diff --git a/windowPreview.js b/windowPreview.js index 97e79d4..05a4e01 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -85,10 +85,18 @@ const thumbnailPreviewMenu = new Lang.Class({ this._previewBox = new thumbnailPreviewList(this._app, this._dtpSettings); this.addMenuItem(this._previewBox); + + this._peekMode = false; + this._peekModeEnterTimeoutId = 0; + this._ENTER_PEEK_MODE_TIMEOUT = 500; + this._peekedWindow = null; + this._peekModeSavedWorkspaces = null; }, requestCloseMenu: function() { // The "~0" argument makes the animation display. + if(this._previewBox._peekMode) + this._previewBox._disablePeekMode(); this.close(~0); }, @@ -108,20 +116,32 @@ const thumbnailPreviewMenu = new Lang.Class({ _onMenuEnter: function () { this.cancelClose(); + //log("onMenuEnter preview menu"); this.hoverOpen(); }, - _onMenuLeave: function () { + _onMenuLeave: function (actor, event) { this.cancelOpen(); this.cancelClose(); + log("onMenuLeave preview menu"); this._hoverCloseTimeoutId = Mainloop.timeout_add(Taskbar.DASH_ITEM_HOVER_TIMEOUT, Lang.bind(this, this.hoverClose)); + + if(actor != event.get_source()) + return; + if(this._peekMode) + this._disablePeekMode(); + if(this._peekModeEnterTimeoutId) { + Mainloop.source_remove(this._peekModeEnterTimeoutId); + this._peekModeEnterTimeoutId = null; + } }, _onEnter: function () { this.cancelOpen(); this.cancelClose(); + //log("onEnter preview menu"); this._hoverOpenTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('show-window-previews-timeout'), Lang.bind(this, this.hoverOpen)); }, @@ -129,6 +149,7 @@ const thumbnailPreviewMenu = new Lang.Class({ _onLeave: function () { this.cancelOpen(); this.cancelClose(); + //log("onLeave preview menu"); // grabHelper.grab() is usually called when the menu is opened. However, there seems to be a bug in the // underlying gnome-shell that causes all window contents to freeze if the grab and ungrab occur @@ -200,9 +221,62 @@ const thumbnailPreviewMenu = new Lang.Class({ })); } - this.isOpen = false; - } + if(this._peekMode) + this._disablePeekMode(); + this.isOpen = false; + }, + + _disablePeekMode: function() { + //TODO: Restore windows' old state + this._peekedWindow.get_compositor_private().hide(); + this._peekedWindow = null; + + this._peekModeSavedWorkspaces.forEach(function(workspace) { + workspace.forEach(function(window) { + window.get_compositor_private().show(); + }); + }); + this._peekModeSavedWorkspaces = null; + + this._peekMode = false; + log("Disabled peek mode"); + }, + + _setPeekedWindow: function(newPeekedWindow) { + //Hide currently peeked window and show the new one + if(this._peekedWindow) + this._peekedWindow.get_compositor_private().hide(); + this._peekedWindow = newPeekedWindow; + this._peekedWindow.get_compositor_private().show(); + }, + + _enterPeekMode: function(thumbnail) { + this._peekMode = true; + if(this._peekModeEnterTimeoutId) { + Mainloop.source_remove(this._peekModeEnterTimeoutId); + this._peekModeEnterTimeoutId = null; + } + log("Entered peek mode", thumbnail); + //TODO: Save the state and Hide all windows + this._peekModeSavedWorkspaces = []; + + for ( let wks=0; wks windowB.get_stable_sequence(); } - });