Switch overview workspaces after keyboard focus is released

Closing the overview handed focus back to the previous window after the
workspace switch, pulling back to the old workspace whenever it was occupied.
Release focus first, then switch. Window clicks go to their workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-12 16:03:56 +01:00
1 parent aecee213f8
commit 178041edf9
2 files changed
+16 -14

No files matched your search

+16 -4
View File
@@ -14,7 +14,7 @@ import "../services/AppMatching.js" as Matching
// Workspace overview (SUPER+Tab): a drawer out of the bar with one live // Workspace overview (SUPER+Tab): a drawer out of the bar with one live
// thumbnail per workspace (bar.workspaces.count of them), drawn over that // thumbnail per workspace (bar.workspaces.count of them), drawn over that
// monitor's wallpaper. Click a workspace or window to go there, drag a window // monitor's wallpaper. Click a workspace (or a window on it) to go there, drag a window
// onto another workspace to move it, middle-click a window to close it. // onto another workspace to move it, middle-click a window to close it.
// Arrows/1–9 pick a workspace, Enter goes there, Esc closes. // Arrows/1–9 pick a workspace, Enter goes there, Esc closes.
// qmllint disable uncreatable-type // qmllint disable uncreatable-type
@@ -86,9 +86,22 @@ PanelWindow {
const entry = Matching.match(win.appId, win.initialClass, ApplicationsService.entries, ConfigService.ready ? ConfigService.data.dock.appOverrides : ({})); const entry = Matching.match(win.appId, win.initialClass, ApplicationsService.entries, ConfigService.ready ? ConfigService.data.dock.appOverrides : ({}));
return entry ? ApplicationsService.icon(entry) : Quickshell.iconPath(String(win.appId || "").toLowerCase(), "application-x-executable"); return entry ? ApplicationsService.icon(entry) : Quickshell.iconPath(String(win.appId || "").toLowerCase(), "application-x-executable");
} }
// Closing hands keyboard focus back, and Hyprland then refocuses the
// previous window, pulling back to its workspace if the switch came first.
// So release focus, then switch once that has gone through.
property int pendingWorkspace: 0
function go(index) { function go(index) {
pendingWorkspace = index + 1;
ShellState.overviewOpen = false; ShellState.overviewOpen = false;
HyprlandService.focusWorkspace(index + 1); switchDelay.restart();
}
Timer {
id: switchDelay
interval: 100
onTriggered: {
HyprlandService.focusWorkspace(root.pendingWorkspace);
root.pendingWorkspace = 0;
}
} }
function select(index) { function select(index) {
if (index >= 0 && index < layout.count) if (index >= 0 && index < layout.count)
@@ -372,8 +385,7 @@ PanelWindow {
HyprlandService.closeWindow(tile.win.address); HyprlandService.closeWindow(tile.win.address);
return; return;
} }
ShellState.overviewOpen = false; root.go(slot.index);
HyprlandService.revealWindow(tile.win.address, slot.workspaceId);
} }
} }
} }
-10
View File
@@ -61,16 +61,6 @@ Singleton {
return false; return false;
return true; return true;
} }
// Goes to a window wherever it is. Activation requests (focusWindow) are
// ignored for windows on other workspaces unless misc:focus_on_activate is set.
function revealWindow(address, workspace) {
if (!/^(0x)?[0-9a-f]+$/i.test(address))
return false;
if (Number.isInteger(workspace) && workspace > 0)
focusWorkspace(workspace);
Hyprland.dispatch("hl.dsp.focus({ window = 'address:" + (address.startsWith("0x") ? address : "0x" + address) + "' })");
return true;
}
function focusWorkspace(id) { function focusWorkspace(id) {
if (!Number.isInteger(id) || id < 1) if (!Number.isInteger(id) || id < 1)
return false; return false;