Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: "Cycle + Minimize" windows #731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<item translatable="yes">Minimize window</item>
<item translatable="yes">Launch new instance</item>
<item translatable="yes">Cycle through windows</item>
<item translatable="yes">Cycle + Minimize</item>
<item translatable="yes">Minimize or overview</item>
<item translatable="yes">Show window previews</item>
<item translatable="yes">Minimize or show previews</item>
Expand Down Expand Up @@ -154,6 +155,7 @@
<item translatable="yes">Minimize window</item>
<item translatable="yes">Launch new instance</item>
<item translatable="yes">Cycle through windows</item>
<item translatable="yes">Cycle + Minimize</item>
<item translatable="yes">Minimize or overview</item>
<item translatable="yes">Show window previews</item>
<item translatable="yes">Minimize or show previews</item>
Expand Down Expand Up @@ -226,6 +228,7 @@
<item translatable="yes">Minimize window</item>
<item translatable="yes">Launch new instance</item>
<item translatable="yes">Cycle through windows</item>
<item translatable="yes">Cycle + Minimize</item>
<item translatable="yes">Minimize or overview</item>
<item translatable="yes">Show window previews</item>
<item translatable="yes">Minimize or show previews</item>
Expand Down Expand Up @@ -1586,6 +1589,7 @@
<item translatable="yes">Minimize</item>
<item translatable="yes">Launch new instance</item>
<item translatable="yes">Cycle through windows</item>
<item translatable="yes">Cycle + Minimize</item>
<item translatable="yes">Minimize or overview</item>
<item translatable="yes">Show window previews</item>
<item translatable="yes">Minimize or show previews</item>
Expand Down
37 changes: 29 additions & 8 deletions appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -459,6 +460,19 @@ var MyAppIcon = new Lang.Class({
this.app.activate();
break;

case clickAction.CYCLE_MINIMIZE:
if (!Main.overview._shown) {
if (this.app != focusedApp) {
recentlyClickedApp = this.app;
recentlyClickedAppWindows = windows;
recentlyClickedAppMonitor = this.monitorIndex;
recentlyClickedAppIndex = -1;
}
this._cycleThroughWindows(false, true);
} else
this.app.activate();
break;

case clickAction.LAUNCH:
this.launchNewWindow();
break;
Expand Down Expand Up @@ -688,7 +702,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;
Expand All @@ -712,7 +726,7 @@ var MyAppIcon = new Lang.Class({
recentlyClickedApp = this.app;
recentlyClickedAppWindows = app_windows;
recentlyClickedAppMonitor = this.monitorIndex;
recentlyClickedAppIndex = 0;
recentlyClickedAppIndex = reserved ? 0 : -1;
}

if (reversed) {
Expand All @@ -721,10 +735,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() {
Expand Down