From 75e70eb7ae9a815292e4a5172f2292235396b8ef Mon Sep 17 00:00:00 2001 From: gonza Date: Mon, 27 Jul 2020 00:49:31 -0300 Subject: [PATCH] Reset LRU on leave event of appIcon Like Unity, reset the list of windows when leaveing (unfocusing) the app icon; instead of in a random time. --- appIcons.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/appIcons.js b/appIcons.js index 68b05abd8..089a8774a 100644 --- a/appIcons.js +++ b/appIcons.js @@ -53,7 +53,6 @@ const scrollAction = { SWITCH_WORKSPACE: 2 }; -let recentlyClickedAppLoopId = 0; let recentlyClickedApp = null; let recentlyClickedAppWindows = null; let recentlyClickedAppIndex = 0; @@ -184,6 +183,12 @@ class MyAppIcon extends Dash.DashIcon { this.onWindowsChanged(); } + vfunc_leave_event(crossingEvent) { + let ret = super.vfunc_leave_event(crossingEvent); + this._resetRecentlyClickedApp(); + return ret; + } + vfunc_scroll_event(scrollEvent) { let settings = Docking.DockManager.settings; let isEnabled = settings.get_enum('scroll-action') === scrollAction.CYCLE_WINDOWS; @@ -691,20 +696,11 @@ class MyAppIcon extends Dash.DashIcon { } _cycleThroughWindows(reversed) { - // Store for a little amount of time last clicked app and its windows - // since the order changes upon window interaction - let MEMORY_TIME=3000; - let app_windows = this.getInterestingWindows(); if (app_windows.length <1) return - if (recentlyClickedAppLoopId > 0) - GLib.source_remove(recentlyClickedAppLoopId); - recentlyClickedAppLoopId = GLib.timeout_add( - GLib.PRIORITY_DEFAULT, MEMORY_TIME, this._resetRecentlyClickedApp); - // If there isn't already a list of windows for the current app, // or the stored list is outdated, use the current windows list. let monitorIsolation = Docking.DockManager.settings.get_boolean('isolate-monitors'); @@ -731,10 +727,7 @@ class MyAppIcon extends Dash.DashIcon { } _resetRecentlyClickedApp() { - if (recentlyClickedAppLoopId > 0) - GLib.source_remove(recentlyClickedAppLoopId); - recentlyClickedAppLoopId=0; - recentlyClickedApp =null; + recentlyClickedApp = null; recentlyClickedAppWindows = null; recentlyClickedAppIndex = 0; recentlyClickedAppMonitor = -1;