Skip to content

Commit

Permalink
fix application group sometimes not raised
Browse files Browse the repository at this point in the history
  • Loading branch information
nclarius committed May 25, 2022
1 parent 7a0d5da commit 7d25455
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.bbcode
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[h2]v1.2[/h2]
[list]\n[*] fix application group sometimes not raised
[/list]

[h2]v1.1[/h2]
[list]\n[*] fix some special windows not opening correctly
[*] refactoring
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.2
- fix application group sometimes not raised

## v1.1
- fix some special windows not opening correctly
- refactoring
Expand Down
8 changes: 4 additions & 4 deletions README.bbcode
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Extension for KDE's window manager to automatically raise all other visible windows of the same application together when activating one of them.
Automatically raises all other visible windows of the same application together when activating one of them, effectively creating application groups to task-switch between.

This creates an application-centric task switching workflow as known from environments such as GNOME or MacOS, where an application’s windows are treated as a group, and task switching can take place at two levels: one mode for switching applications and one mode for switching between windows of an application.
[b]Please make sure to install the most recent version (v1.2) and to not use Discover for installation.[/b] For more information on installation, setup and usage as well as any requests, please visit [url=https://github.com/nclarius/kwin-application-switcher]the GitHub page[/url].

Raising all windows collectively whenever the application is entered means that all windows belonging to the application are available at the front, and closing or minimizing a window will keep focus on the same application, as the window switched to will be the most recently active one of that application provided that there is any, rather than the most recently active window overall which may belong to a different application.
This extension gives rise to an application-centric task switching workflow as known from environments such as GNOME or MacOS, where an application’s windows are treated as a group, and task switching can take place at two levels: one mode for switching applications and one mode for switching between windows of an application.

[b]Please make sure to install the most recent version (v1.1) and to not use Discover for installation.[/b] For more information on installation, setup and usage as well as any requests, please visit [url=https://github.com/nclarius/kwin-application-switcher]the GitHub page[/url].
Raising all windows collectively whenever the application is entered means that all windows belonging to the application are available at the front, and closing or minimizing a window will keep focus on the same application, as the window switched to will be the most recently active one of that application provided that there is any, rather than the most recently active window overall which may belong to a different application.

© 2022 Natalie Clarius ‹[email protected]

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

[latest release](https://github.com/nclarius/kwin-application-switcher/releases/latest) | [view in KDE store](https://store.kde.org/p/1805105)

Extension for KDE's window manager to automatically raise all other visible windows of the same application together when activating one of them.
Extension for KDE's window manager to automatically raise all other visible windows of the same application together when activating one of them, effectively creating application groups to task-switch between.

This creates an application-centric task switching workflow as known from environments such as GNOME or MacOS, where an application’s windows are treated as a group, and task switching can take place at two levels: one mode for switching applications and one mode for switching between windows of an application.
This gives rise an application-centric task switching workflow as known from environments such as GNOME or MacOS, where an application’s windows are treated as a group, and task switching can take place at two levels: one mode for switching applications and one mode for switching between windows of an application.

Raising all windows collectively whenever the application is entered means that all windows belonging to the application are available at the front, and closing or minimizing a window will keep focus on the same application, as the window switched to will be the most recently active one of that application provided that there is any, rather than the most recently active window overall which may belong to a different application.

Seen in the screencast: Switching from Konsole back to Dolphin also brings the other Dolphin window in front of the Konsole windows - unlike with the default behavior, where the right Konsole window, being the second most recently active one, would remain on top of the center Dolphin window.
Seen in the screencast: Switching from Konsole back to Dolphin also brings the other Dolphin window in front of the Konsole windows, and gives focus to it when the other Dolphin window is minimized - whereas without the script, the right Konsole window, being the second most recently active one, would remain on top of the center Dolphin window and be switched to when the most recently active Dolphin window is minimized.

![screenshot](.img/screenshot.gif)

Expand All @@ -20,7 +20,7 @@ Seen in the screencast: Switching from Konsole back to Dolphin also brings the o

### Installation via graphical interface

**Please make sure to select the most recent version (v1.1)** in the installation process.
**Please make sure to select the most recent version (v1.2)** in the installation process.

A [bug](https://bugs.kde.org/show_bug.cgi?id=453521) in Discover causes a wrong version to be installed, so using the installation module in System Settings instead is recommended.

Expand Down
Binary file not shown.
28 changes: 15 additions & 13 deletions contents/code/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ setPrevActiveApp(workspace.activeClient);
// set previously active application for recently activated window
function setPrevActiveApp(current) {
if (!current) return;
prevActiveApp = String(current.resourceClass);
prevActiveApp = getApp(current);
}

// get previously active application
Expand All @@ -75,17 +75,17 @@ function updateAppGroups(current) {
if (!current) return;
let app = getApp(current);
if (!appGroups[app]) appGroups[app] = [];
appGroups[app] = appGroups[app].filter(window => window);
appGroups[app] = appGroups[app].filter(window => window != current);
appGroups[app] = appGroups[app].filter(window => window &&
window != current);
appGroups[app].push(current);
debug("updating app group", appGroups[app].map(window => window.caption));
}

// return other visible windows of same application as given window
function getAppGroup(current) {
if (!current) return;
let appGroup = appGroups[getApp(current)].filter(window =>
window && !window.minimized &&
let appGroup = appGroups[getApp(current)].filter(window => window &&
!window.minimized &&
(window.desktop == current.desktop ||
window.onAllDesktops || current.onAllDesktops));
debug("getting app group", appGroup.map(window => window.caption));
Expand All @@ -101,12 +101,13 @@ function getAppGroup(current) {
var autoActivated = [];

function addAutoActivated(current) {
autoActivated = autoActivated.filter(window => window && window != current);
autoActivated = autoActivated.filter(window => window &&
window != current);
autoActivated.push(current);
}

function delAutoActivated(current) {
autoActivated = autoActivated.filter(window => window && window != current);
function clearAutoActivated() {
autoActivated = [];
}

///////////////////////
Expand All @@ -116,31 +117,32 @@ function delAutoActivated(current) {
// when client is activated, auto-raise other windows of the same applicaiton
workspace.clientActivated.connect(active => {
if (!active) return;
debug("");
debug("---------");
debug("activated", active.caption);
debug("app", getApp(active));
// abort if application is ignored
if (ignoredApps.includes(getApp(active))) {
debug("ignored");
return;
}
// abort if current activation was due to auto-raise
if (autoActivated.includes(active)) {
delAutoActivated(active);
debug("auto-raised");
return;
}

updateAppGroups(active);

// if application was switched
debug("previous app", getPrevActiveApp());
if (getApp(active) != getPrevActiveApp()) {
debug("app switched");
clearAutoActivated();
// auto-raise other windows of same application
for (let window of getAppGroup(active)) {
debug("auto-raising", window.caption);
addAutoActivated(window);
workspace.activeClient = window;
}
setPrevActiveApp(active);
}

setPrevActiveApp(active);
});
4 changes: 2 additions & 2 deletions metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

[Desktop Entry]
Name=Application Switcher
Comment=Collectively raise all windows of the same application when switching tasks
Comment=Collectively raises all windows of the same application when switching tasks
Icon=preferences-system-windows

X-KDE-PluginInfo-Name=applicationswitcher
X-KDE-PluginInfo-Version=1.1
X-KDE-PluginInfo-Version=1.2
X-KDE-PluginInfo-Author=Natalie Clarius
X-KDE-PluginInfo-Email[email protected]
X-KDE-PluginInfo-License=GPLv3.0
Expand Down
Empty file removed test.txt
Empty file.

0 comments on commit 7d25455

Please sign in to comment.