From b540b77f917f1494c5c2fc45d16cb4b6e3a3e32c Mon Sep 17 00:00:00 2001 From: Tarik02 Date: Mon, 30 Apr 2018 10:56:16 +0300 Subject: [PATCH 1/2] Feature: "Cycle + Minimize" windows --- Settings.ui | 4 ++++ appIcons.js | 31 +++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Settings.ui b/Settings.ui index 2b164a8b8..1cfdd2f47 100644 --- a/Settings.ui +++ b/Settings.ui @@ -82,6 +82,7 @@ Minimize window Launch new instance Cycle through windows + Cycle + Minimize Minimize or overview Show window previews Minimize or show previews @@ -154,6 +155,7 @@ Minimize window Launch new instance Cycle through windows + Cycle + Minimize Minimize or overview Show window previews Minimize or show previews @@ -226,6 +228,7 @@ Minimize window Launch new instance Cycle through windows + Cycle + Minimize Minimize or overview Show window previews Minimize or show previews @@ -1586,6 +1589,7 @@ Minimize Launch new instance Cycle through windows + Cycle + Minimize Minimize or overview Show window previews Minimize or show previews diff --git a/appIcons.js b/appIcons.js index ef9c6e110..66e560d28 100644 --- a/appIcons.js +++ b/appIcons.js @@ -43,10 +43,11 @@ const clickAction = { MINIMIZE: 1, LAUNCH: 2, CYCLE_WINDOWS: 3, - MINIMIZE_OR_OVERVIEW: 4, - PREVIEWS: 5, - MINIMIZE_OR_PREVIEWS: 6, - QUIT: 7 + CYCLE_MINIMIZE: 4, + MINIMIZE_OR_OVERVIEW: 5, + PREVIEWS: 6, + MINIMIZE_OR_PREVIEWS: 7, + QUIT: 8 }; const scrollAction = { @@ -459,6 +460,13 @@ var MyAppIcon = new Lang.Class({ this.app.activate(); break; + case clickAction.CYCLE_MINIMIZE: + if (!Main.overview._shown) + this._cycleThroughWindows(false, true); + else + this.app.activate(); + break; + case clickAction.LAUNCH: this.launchNewWindow(); break; @@ -688,7 +696,7 @@ var MyAppIcon = new Lang.Class({ windows[i].delete(global.get_current_time()); }, - _cycleThroughWindows: function(reversed) { + _cycleThroughWindows: function(reversed, minimize) { // Store for a little amount of time last clicked app and its windows // since the order changes upon window interaction let MEMORY_TIME=3000; @@ -712,7 +720,7 @@ var MyAppIcon = new Lang.Class({ recentlyClickedApp = this.app; recentlyClickedAppWindows = app_windows; recentlyClickedAppMonitor = this.monitorIndex; - recentlyClickedAppIndex = 0; + recentlyClickedAppIndex = reserved ? 0 : -1; } if (reversed) { @@ -721,10 +729,17 @@ var MyAppIcon = new Lang.Class({ } else { recentlyClickedAppIndex++; } + let index = recentlyClickedAppIndex % recentlyClickedAppWindows.length; - let window = recentlyClickedAppWindows[index]; - Main.activateWindow(window); + if (minimize && recentlyClickedAppIndex !== 0 && index === 0) { + recentlyClickedAppWindows.forEach(function (w) { w.minimize(); }); + recentlyClickedAppIndex = -1; + } else { + let window = recentlyClickedAppWindows[index]; + + Main.activateWindow(window); + } }, _resetRecentlyClickedApp: function() { From 951b8e30525468b15e46cc37f217b7697d6c4dd6 Mon Sep 17 00:00:00 2001 From: Tarik02 Date: Mon, 30 Apr 2018 11:25:32 +0300 Subject: [PATCH 2/2] Fixed a little bug --- appIcons.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appIcons.js b/appIcons.js index 66e560d28..4e59fc1bd 100644 --- a/appIcons.js +++ b/appIcons.js @@ -461,9 +461,15 @@ var MyAppIcon = new Lang.Class({ break; case clickAction.CYCLE_MINIMIZE: - if (!Main.overview._shown) + if (!Main.overview._shown) { + if (this.app != focusedApp) { + recentlyClickedApp = this.app; + recentlyClickedAppWindows = windows; + recentlyClickedAppMonitor = this.monitorIndex; + recentlyClickedAppIndex = -1; + } this._cycleThroughWindows(false, true); - else + } else this.app.activate(); break;