diff --git a/Settings.ui b/Settings.ui index 1b12929..ca59390 100644 --- a/Settings.ui +++ b/Settings.ui @@ -364,6 +364,11 @@ 0.01 0.10000000000000001 + + 9999 + 25 + 100 + 0.33000000000000002 1 @@ -957,6 +962,34 @@ 0 + + + True + True + 4 + 0 + preview_timeout_adjustment + True + + + 1 + 1 + + + + + True + False + True + Time before showing (ms) + True + 0 + + + 0 + 1 + + diff --git a/prefs.js b/prefs.js index 7986701..a4104a3 100644 --- a/prefs.js +++ b/prefs.js @@ -155,6 +155,16 @@ const Settings = new Lang.Class({ this._builder.get_object('show_window_previews_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-window-previews', + this._builder.get_object('preview_timeout_spinbutton'), + 'sensitive', + Gio.SettingsBindFlags.DEFAULT); + + this._builder.get_object('preview_timeout_spinbutton').set_value(this._settings.get_int('show-window-previews-timeout')); + this._builder.get_object('preview_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('show-window-previews-timeout', widget.get_value()); + })); + this._settings.bind('isolate-workspaces', this._builder.get_object('isolate_workspaces_switch'), 'active', @@ -249,7 +259,7 @@ const Settings = new Lang.Class({ this._builder.get_object('leave_timeout_spinbutton').set_value(this._settings.get_int('leave-timeout')); - this._builder.get_object('leave_timeout_spinbutton').connect('changed', Lang.bind (this, function(widget) { + this._builder.get_object('leave_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { this._settings.set_int('leave-timeout', widget.get_value()); })); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index bfd42db..800b5e7 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -69,6 +69,11 @@ Show window preview Show preview of running window on hover of app icon + + 100 + Icon enter display time + Amount of time after entering icon to wait before displaying window preview if icon is not clicked or mouse has not left. + false Provide workspace isolation diff --git a/taskbar.js b/taskbar.js index cbfc756..7b90164 100644 --- a/taskbar.js +++ b/taskbar.js @@ -1226,14 +1226,37 @@ const taskbarAppIcon = new Lang.Class({ // Creating a new menu manager for window previews as adding it to the // using the secondary menu's menu manager (which uses the "ignoreRelease" // function) caused the extension to crash. - this._menuManagerWindowPreview = new PopupMenu.PopupMenuManager(this); + this.menuManagerWindowPreview = new PopupMenu.PopupMenuManager(this); + + this.windowPreview = new WindowPreview.thumbnailPreviewMenu(this, this._dtpSettings, this.menuManagerWindowPreview); - this.windowPreview = new WindowPreview.thumbnailPreviewMenu(this, this._dtpSettings); this.windowPreview.connect('open-state-changed', Lang.bind(this, function (menu, isPoppedUp) { if (!isPoppedUp) this._onMenuPoppedDown(); })); - this._menuManagerWindowPreview.addMenu(this.windowPreview); + this.menuManagerWindowPreview.addMenu(this.windowPreview); + + // 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 + // in quick succession (for example, clicking the icon as the preview window is opening) + // So, instead I'll issue the grab when the preview menu is actually entered. + // Alternatively, I was able to solve this by waiting a 100ms timeout to ensure the menu was + // still open, but this waiting until the menu is entered seems a bit safer if it doesn't cause other issues + let windowPreviewMenuData = this.menuManagerWindowPreview._menus[this.menuManagerWindowPreview._findMenu(this.windowPreview)]; + this.windowPreview.disconnect(windowPreviewMenuData.openStateChangeId); + windowPreviewMenuData.openStateChangeId = this.windowPreview.connect('open-state-changed', Lang.bind(this.menuManagerWindowPreview, function(menu, open) { + if (open) { + if (this.activeMenu) + this.activeMenu.close(BoxPointer.PopupAnimation.FADE); + + // Mainloop.timeout_add(100, Lang.bind(this, function() { + // if(menu.isOpen) + // this._grabHelper.grab({ actor: menu.actor, focus: menu.sourceActor, onUngrab: Lang.bind(this, this._closeMenu, menu) }); + // })); + } else { + this._grabHelper.ungrab({ actor: menu.actor }); + } + })); this.forcedOverview = false; }, diff --git a/windowPreview.js b/windowPreview.js index 87b34f2..cba438a 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -110,6 +110,13 @@ const thumbnailPreviewMenu = new Lang.Class({ this.shouldOpen = true; this.shouldClose = false; + // This grab is usually called when the menu is opened. However, there seems to be a bug in the + // underlying gnome-shell that causes the window contents to freeze if the grab and ungrab occur + // in quick succession (for example, clicking the icon as the preview window is opening) + // So, instead I'll issue the grab when the preview menu is actually entered. + this._source.menuManagerWindowPreview._grabHelper.grab({ actor: this.actor, focus: this.sourceActor, + onUngrab: Lang.bind(this, this.requestCloseMenu) }); + this.hoverOpen(); }, @@ -123,7 +130,7 @@ const thumbnailPreviewMenu = new Lang.Class({ this.shouldOpen = true; this.shouldClose = false; - this.hoverOpen(); + Mainloop.timeout_add(this._dtpSettings.get_int('show-window-previews-timeout'), Lang.bind(this, this.hoverOpen)); }, _onLeave: function () {