shortcuts: add special workspace cycle (#1158)
* [CI] chore: update flake * [CI] chore: update flake * [CI] chore: update flake * [CI] chore: update flake * shortcuts: special workspace cycle IPC, reopen last * Moved implementation into Hypr service --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
5b2e1a6231
commit
2e22a21def
1 changed files with 54 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ Singleton {
|
|||
readonly property alias devices: extras.devices
|
||||
|
||||
property bool hadKeyboard
|
||||
property string lastSpecialWorkspace: ""
|
||||
|
||||
signal configReloaded
|
||||
|
||||
|
|
@ -41,6 +42,39 @@ Singleton {
|
|||
Hyprland.dispatch(request);
|
||||
}
|
||||
|
||||
function cycleSpecialWorkspace(direction: string): void {
|
||||
const openSpecials = workspaces.values.filter(w => w.name.startsWith("special:") && w.lastIpcObject.windows > 0);
|
||||
|
||||
if (openSpecials.length === 0)
|
||||
return;
|
||||
|
||||
const activeSpecial = focusedMonitor.lastIpcObject.specialWorkspace.name ?? "";
|
||||
|
||||
if (!activeSpecial) {
|
||||
if (lastSpecialWorkspace) {
|
||||
const workspace = workspaces.values.find(w => w.name === lastSpecialWorkspace);
|
||||
if (workspace && workspace.lastIpcObject.windows > 0) {
|
||||
dispatch(`workspace ${lastSpecialWorkspace}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
dispatch(`workspace ${openSpecials[0].name}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const currentIndex = openSpecials.findIndex(w => w.name === activeSpecial);
|
||||
let nextIndex = 0;
|
||||
|
||||
if (currentIndex !== -1) {
|
||||
if (direction === "next")
|
||||
nextIndex = (currentIndex + 1) % openSpecials.length;
|
||||
else
|
||||
nextIndex = (currentIndex - 1 + openSpecials.length) % openSpecials.length;
|
||||
}
|
||||
|
||||
dispatch(`workspace ${openSpecials[nextIndex].name}`);
|
||||
}
|
||||
|
||||
function monitorFor(screen: ShellScreen): HyprlandMonitor {
|
||||
return Hyprland.monitorFor(screen);
|
||||
}
|
||||
|
|
@ -105,6 +139,18 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.focusedMonitor
|
||||
|
||||
function onLastIpcObjectChanged(): void {
|
||||
const specialName = root.focusedMonitor.lastIpcObject.specialWorkspace.name;
|
||||
|
||||
if (specialName && specialName.startsWith("special:")) {
|
||||
root.lastSpecialWorkspace = specialName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: kbLayoutFile
|
||||
|
||||
|
|
@ -144,6 +190,14 @@ Singleton {
|
|||
function refreshDevices(): void {
|
||||
extras.refreshDevices();
|
||||
}
|
||||
|
||||
function cycleSpecialWorkspace(direction: string): void {
|
||||
root.cycleSpecialWorkspace(direction);
|
||||
}
|
||||
|
||||
function listSpecialWorkspaces(): string {
|
||||
return root.workspaces.values.filter(w => w.name.startsWith("special:") && w.lastIpcObject.windows > 0).map(w => w.name).join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
CustomShortcut {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue