mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Cancel timers rather than using flags
Previously using flags in the event handlers to decide whether they should handle the timeout event, rather than just cancelling the timeout.
This commit is contained in:
@@ -305,7 +305,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="label" translatable="yes">If set too low, the window preview of running applications may seem to close too quickly when trying to enter the popup. If set too high, the taskbar may feel slow to highlight applications.</property>
|
||||
<property name="label" translatable="yes">If set too low, the window preview of running applications may seem to close too quickly when trying to enter the popup. If set too high, the preview may linger too long when moving to an adjacent icon.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="max_width_chars">40</property>
|
||||
<property name="xalign">0</property>
|
||||
|
||||
@@ -1368,7 +1368,6 @@ const taskbarAppIcon = new Lang.Class({
|
||||
|
||||
this.emit('menu-state-changed', true);
|
||||
|
||||
this.windowPreview.shouldOpen = false;
|
||||
this.windowPreview.close();
|
||||
|
||||
this.actor.set_hover(true);
|
||||
@@ -1413,7 +1412,6 @@ const taskbarAppIcon = new Lang.Class({
|
||||
},
|
||||
|
||||
activate: function(button) {
|
||||
this.windowPreview.shouldOpen = false;
|
||||
this.windowPreview.requestCloseMenu();
|
||||
|
||||
let event = Clutter.get_current_event();
|
||||
|
||||
@@ -56,8 +56,6 @@ const thumbnailPreviewMenu = new Lang.Class({
|
||||
|
||||
this._source = source;
|
||||
this._app = this._source.app;
|
||||
this.shouldOpen = true;
|
||||
this.shouldClose = false;
|
||||
|
||||
this.actor.add_style_class_name('app-well-menu');
|
||||
this.actor.set_style("max-width: " + (Main.layoutManager.primaryMonitor.width - 22) + "px;");
|
||||
@@ -107,8 +105,7 @@ const thumbnailPreviewMenu = new Lang.Class({
|
||||
},
|
||||
|
||||
_onMenuEnter: function () {
|
||||
this.shouldOpen = true;
|
||||
this.shouldClose = false;
|
||||
this.cancelClose();
|
||||
|
||||
// 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
|
||||
@@ -121,35 +118,51 @@ const thumbnailPreviewMenu = new Lang.Class({
|
||||
},
|
||||
|
||||
_onMenuLeave: function () {
|
||||
this.shouldOpen = false;
|
||||
this.shouldClose = true;
|
||||
Mainloop.timeout_add(Taskbar.DASH_ITEM_HOVER_TIMEOUT, Lang.bind(this, this.hoverClose));
|
||||
this.cancelOpen();
|
||||
this.cancelClose();
|
||||
|
||||
this._hoverCloseTimeoutId = Mainloop.timeout_add(Taskbar.DASH_ITEM_HOVER_TIMEOUT, Lang.bind(this, this.hoverClose));
|
||||
},
|
||||
|
||||
_onEnter: function () {
|
||||
this.shouldOpen = true;
|
||||
this.shouldClose = false;
|
||||
this.cancelOpen();
|
||||
this.cancelClose();
|
||||
|
||||
Mainloop.timeout_add(this._dtpSettings.get_int('show-window-previews-timeout'), Lang.bind(this, this.hoverOpen));
|
||||
this._hoverOpenTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('show-window-previews-timeout'), Lang.bind(this, this.hoverOpen));
|
||||
},
|
||||
|
||||
_onLeave: function () {
|
||||
this.shouldClose = true;
|
||||
this.shouldOpen = false;
|
||||
this.cancelOpen();
|
||||
this.cancelClose();
|
||||
|
||||
Mainloop.timeout_add(this._dtpSettings.get_int('leave-timeout'), Lang.bind(this, this.hoverClose));
|
||||
this._hoverCloseTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('leave-timeout'), Lang.bind(this, this.hoverClose));
|
||||
},
|
||||
|
||||
cancelOpen: function () {
|
||||
if(this._hoverOpenTimeoutId) {
|
||||
Mainloop.source_remove(this._hoverOpenTimeoutId);
|
||||
log("cancelled open");
|
||||
this._hoverOpenTimeoutId = null;
|
||||
}
|
||||
},
|
||||
|
||||
cancelClose: function () {
|
||||
if(this._hoverCloseTimeoutId) {
|
||||
Mainloop.source_remove(this._hoverCloseTimeoutId);
|
||||
log("cancelled close");
|
||||
this._hoverCloseTimeoutId = null;
|
||||
}
|
||||
},
|
||||
|
||||
hoverOpen: function () {
|
||||
if (this.shouldOpen && !this.isOpen && this._dtpSettings.get_boolean("show-window-previews")) {
|
||||
this._hoverOpenTimeoutId = null;
|
||||
if (!this.isOpen && this._dtpSettings.get_boolean("show-window-previews"))
|
||||
this.popup();
|
||||
}
|
||||
},
|
||||
|
||||
hoverClose: function () {
|
||||
if (this.shouldClose) {
|
||||
this.close(~0);
|
||||
}
|
||||
this._hoverCloseTimeoutId = null;
|
||||
this.close(~0);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
@@ -173,6 +186,8 @@ const thumbnailPreviewMenu = new Lang.Class({
|
||||
},
|
||||
|
||||
close: function(animate) {
|
||||
this.cancelOpen();
|
||||
|
||||
if (this.isOpen)
|
||||
this.emit('open-state-changed', false);
|
||||
if (this._activeMenuItem)
|
||||
|
||||
Reference in New Issue
Block a user