diff --git a/monitor.js b/monitor.js
index acb5e00..173943e 100644
--- a/monitor.js
+++ b/monitor.js
@@ -69,9 +69,13 @@ export class MonitorNavigator {
return;
}
+ const activeWorkspace = this.settings.isCurrentWorkspaceOnlyEnabled()
+ ? global.workspace_manager.get_active_workspace()
+ : null;
+ const inWorkspace = win => !activeWorkspace || win.get_workspace() === activeWorkspace;
const windows = global.get_window_actors().map(actor => actor.meta_window);
- const windowsOnCurrent = windows.filter(win => win.get_monitor() === currentMonitor);
- const windowsOnTarget = windows.filter(win => win.get_monitor() === targetMonitor);
+ const windowsOnCurrent = windows.filter(win => win.get_monitor() === currentMonitor && inWorkspace(win));
+ const windowsOnTarget = windows.filter(win => win.get_monitor() === targetMonitor && inWorkspace(win));
for (const win of windowsOnCurrent) {
win.move_to_monitor(targetMonitor);
@@ -92,7 +96,10 @@ export class MonitorNavigator {
}
_focusMostRecentWindowOnMonitor(monitorIndex) {
- const recentWindows = global.display.get_tab_list(0, null);
+ const workspace = this.settings.isCurrentWorkspaceOnlyEnabled()
+ ? global.workspace_manager.get_active_workspace()
+ : null;
+ const recentWindows = global.display.get_tab_list(0, workspace);
for (const win of recentWindows) {
if (!win.minimized && !win.skip_taskbar && win.get_monitor() === monitorIndex) {
win.activate(global.get_current_time());
diff --git a/prefs.js b/prefs.js
index 87d1edc..772e28a 100644
--- a/prefs.js
+++ b/prefs.js
@@ -166,6 +166,23 @@ class PreferencesSettings {
focusGroup.add(changeFocus);
+ const currentWorkspaceOnlySwitch = new Gtk.Switch({
+ active: this.schema.get_boolean('current-workspace-only'),
+ valign: Gtk.Align.CENTER
+ });
+ const currentWorkspaceOnlyRow = new Adw.ActionRow({
+ title: _('Restrict actions to the current workspace'),
+ subtitle: _('When enabled, swap and focus updates only consider windows on the active workspace')
+ });
+ currentWorkspaceOnlyRow.add_suffix(currentWorkspaceOnlySwitch);
+ currentWorkspaceOnlyRow.activatable_widget = currentWorkspaceOnlySwitch;
+
+ currentWorkspaceOnlySwitch.connect('notify::active', () => {
+ this.schema.set_boolean('current-workspace-only', currentWorkspaceOnlySwitch.active);
+ });
+
+ focusGroup.add(currentWorkspaceOnlyRow);
+
this.page.add(cursorGroup);
this.page.add(focusGroup);
}
diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled
index f7df1be..745810d 100644
Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ
diff --git a/schemas/org.gnome.shell.extensions.binu.gschema.xml b/schemas/org.gnome.shell.extensions.binu.gschema.xml
index 85047f8..5e435f8 100644
--- a/schemas/org.gnome.shell.extensions.binu.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.binu.gschema.xml
@@ -82,6 +82,12 @@
Update the focus to the window on the navigated monitor
+
+ true
+ Restrict actions to the current workspace
+ When enabled, swap and focus actions only consider windows on the currently active workspace.
+
+
diff --git a/utils.js b/utils.js
index 3efea79..89a6677 100644
--- a/utils.js
+++ b/utils.js
@@ -92,6 +92,11 @@ export class Preferences{
return this._settings.get_boolean('update-focus');
}
+ isCurrentWorkspaceOnlyEnabled() {
+ // Restrict swap/focus actions to the active workspace
+ return this._settings.get_boolean('current-workspace-only');
+ }
+
getAnimationDuration() {
return this._settings.get_int('animate-cursor-duration');
}