Delay window previews on hover for #26

This commit is contained in:
jderose9
2017-02-06 18:03:42 -05:00
parent 049935becf
commit e3435275bb
5 changed files with 83 additions and 5 deletions

View File

@@ -364,6 +364,11 @@
<property name="step_increment">0.01</property>
<property name="page_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="preview_timeout_adjustment">
<property name="upper">9999</property>
<property name="step_increment">25</property>
<property name="page_increment">100</property>
</object>
<object class="GtkAdjustment" id="statusicon_padding_adjustment">
<property name="lower">0.33000000000000002</property>
<property name="upper">1</property>
@@ -957,6 +962,34 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="preview_timeout_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">preview_timeout_adjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="preview_timeout_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Time before showing (ms)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>

View File

@@ -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());
}));

View File

@@ -69,6 +69,11 @@
<summary>Show window preview</summary>
<description>Show preview of running window on hover of app icon</description>
</key>
<key type="i" name="show-window-previews-timeout">
<default>100</default>
<summary>Icon enter display time</summary>
<description>Amount of time after entering icon to wait before displaying window preview if icon is not clicked or mouse has not left.</description>
</key>
<key type="b" name="isolate-workspaces">
<default>false</default>
<summary>Provide workspace isolation</summary>

View File

@@ -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;
},

View File

@@ -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 () {