search
This commit is contained in:
1 parent
10ffe765b0
commit
d42e24be81
10 files changed
+332
-376
No files matched your search
@@ -1,4 +1,3 @@
|
||||
|
||||
<img src="logo.jpg" width="200" />
|
||||
|
||||
# Skygqts
|
||||
@@ -12,8 +11,8 @@ It ships three apps:
|
||||
- **app-carousel** — a full-screen launcher carousel. Apps sit in a row; the
|
||||
one in the middle is selected. Configure it with a JSON file.
|
||||
- **workspace-manager** — a workspace overview. A carousel of workspace cards
|
||||
(with a live list of their windows), a bar for renaming the current
|
||||
workspace, and a 3D "window loop" for picking a window.
|
||||
(with a live list of their windows), a vim-style search for windows by
|
||||
title and app, and a 3D "window loop" for picking a window.
|
||||
- **workspace-badge** — a small box in each bottom corner of every
|
||||
monitor showing the active workspace's name and color. Click one to rename
|
||||
the workspace or pick a color.
|
||||
@@ -92,7 +91,7 @@ qs -n -p ./workspace-badge
|
||||
| `skygqts workspace-manager toggle` | Toggles the workspace carousel (also closes it) |
|
||||
| `skygqts workspace-manager goto` | Opens the workspace carousel |
|
||||
| `skygqts workspace-manager windows` | Opens the window loop for the focused workspace |
|
||||
| `skygqts workspace-manager rename` | Opens the carousel with the name field focused |
|
||||
| `skygqts workspace-manager search` | Opens the carousel with the window search open |
|
||||
| `skygqts workspace-badge` | Shows the workspace badge on every monitor |
|
||||
| `skygqts workspace-badge --daemon` | Same, but detached from the terminal |
|
||||
| `skygqts workspace-badge edit` | Opens the badge editor on the focused monitor |
|
||||
@@ -110,7 +109,7 @@ Then bind them in your compositor, e.g.:
|
||||
# Hyprland
|
||||
bind = SUPER, TAB, exec, skygqts workspace-manager toggle
|
||||
bind = SUPER, G, exec, skygqts workspace-manager windows
|
||||
bind = SUPER, N, exec, skygqts workspace-manager rename
|
||||
bind = SUPER, SLASH, exec, skygqts workspace-manager search
|
||||
```
|
||||
|
||||
The same calls are available over Quickshell IPC if you prefer not to use the
|
||||
@@ -120,7 +119,7 @@ CLI:
|
||||
qs ipc -p ./workspace-manager call workspace toggle
|
||||
qs ipc -p ./workspace-manager call workspace goTo
|
||||
qs ipc -p ./workspace-manager call workspace openWindowSelection
|
||||
qs ipc -p ./workspace-manager call workspace openWorkspaceRename
|
||||
qs ipc -p ./workspace-manager call workspace openSearch
|
||||
|
||||
qs ipc -p ./workspace-badge call badge edit
|
||||
|
||||
@@ -231,8 +230,8 @@ skygqts workspace-manager --config ~/.config/skygqts/workspace-manager.json
|
||||
|
||||
It detects your compositor from the environment (`niri` or `hyprland`) and
|
||||
shows one column of workspace cards per monitor, each card listing the
|
||||
workspace's windows. From there you can focus a workspace, rename it, or open
|
||||
a window loop.
|
||||
workspace's windows. From there you can focus a workspace, open a window
|
||||
loop, or search windows by title and app.
|
||||
|
||||
### Config
|
||||
|
||||
@@ -241,13 +240,14 @@ default below, and the file is watched for changes. See
|
||||
`workspace-manager.example.json`.
|
||||
|
||||
| Field | Type | Default | Meaning |
|
||||
| ------------------- | ------ | ----------------------------------------- | ------------------------------- |
|
||||
| `keys.rename` | string | `"Ctrl+N"` | Key that focuses the name field |
|
||||
| ------------------- | ------ | ------------------------------------------------------ | ------------------------------ |
|
||||
| `keys.windows` | string | `"Tab"` | Key that opens the window loop |
|
||||
| `hints.show` | bool | `true` | Show the small key hints |
|
||||
| `hints.rename` | string | `"{key}: to switch here"` | Hint text |
|
||||
| `hints.windows` | string | `"{key}: to see windows"` | Hint text |
|
||||
| `hints.exitWindows` | string | `"{key} or Esc: to exit window carousel"` | Hint text |
|
||||
| `hints.search` | string | `"/: to search windows, n / N: next / previous match"` | Hint text |
|
||||
|
||||
The search keys (`/`, `n`, `N`) are fixed, like in vim.
|
||||
|
||||
In any hint, `{key}` is replaced by the matching key. Keys are written as
|
||||
modifiers plus one key, joined by `+`. Recognised modifiers are `Ctrl`
|
||||
@@ -259,21 +259,30 @@ a digit, `F1`–`F12`, `Space`, or `Tab` (for example `Ctrl+N`, `Super+Space`).
|
||||
**Carousel**
|
||||
|
||||
| Key | Action |
|
||||
| ------------------------------ | -------------------------------------------- |
|
||||
| ---------------------------- | -------------------------------------------- |
|
||||
| Up / Down | Previous / next workspace on this monitor |
|
||||
| Left / Right | Previous / next monitor |
|
||||
| Enter | Focus the selected workspace |
|
||||
| Escape | Close without switching |
|
||||
| `keys.rename` (default Ctrl+N) | Focus the name field |
|
||||
| `keys.windows` (default Tab) | Open the window loop |
|
||||
| `/` | Search windows |
|
||||
| `n` / `N` | Next / previous match of the last search |
|
||||
| Scroll | Vertical = workspaces, horizontal = monitors |
|
||||
|
||||
**Renaming**
|
||||
**Search**
|
||||
|
||||
`/` opens a search bar, in the carousel or the window loop. As you type, the
|
||||
view jumps to the first window after the current one whose title or app
|
||||
(niri `app_id`, Hyprland `class`) contains the text, opening the window loop
|
||||
on its workspace. A lowercase search ignores case; any capital letter makes
|
||||
it match case exactly (like vim's `smartcase`). The search wraps round:
|
||||
monitors left to right, workspaces top to bottom, windows in loop order.
|
||||
|
||||
| Key | Action |
|
||||
| ------ | ---------------------- |
|
||||
| Enter | Apply the new name |
|
||||
| Escape | Leave without renaming |
|
||||
| ----------------------- | -------------------------------------- |
|
||||
| Enter | Keep the match; Enter again focuses it |
|
||||
| Escape | Go back to where the search started |
|
||||
| Backspace (empty field) | Same as Escape |
|
||||
|
||||
**Window loop**
|
||||
|
||||
@@ -284,6 +293,7 @@ a digit, `F1`–`F12`, `Space`, or `Tab` (for example `Ctrl+N`, `Super+Space`).
|
||||
| Up / Down | Previous / next workspace and show its windows |
|
||||
| Escape | Fold back to the carousel (closes entirely if opened via `windows`) |
|
||||
| `keys.windows` (default Tab) | Fold back to the carousel |
|
||||
| `/`, `n` / `N` | Search windows, as in the carousel |
|
||||
|
||||
`Tab` and `Shift+Tab` also step windows, unless `keys.windows` is `Tab` (the
|
||||
default), in which case `Tab` folds the loop back instead.
|
||||
@@ -353,7 +363,7 @@ loop.
|
||||
|
||||
```
|
||||
app-carousel/ # launcher: shell.qml, config, theme, cards
|
||||
workspace-manager/ # overview: carousel, rename bar, window loop, compositor bridge
|
||||
workspace-manager/ # overview: carousel, window search, window loop, compositor bridge
|
||||
workspace-badge/ # corner badge: name, color, rename and color editor
|
||||
skygqts.nu # the `skygqts` CLI (Nushell)
|
||||
package.nix # package definition
|
||||
|
||||
+4
-4
@@ -37,7 +37,7 @@ def "main workspace-manager" [
|
||||
}
|
||||
}
|
||||
|
||||
# Toggle the rename bar. Also closes the carousel.
|
||||
# Toggle the workspace carousel. Also closes it.
|
||||
def "main workspace-manager toggle" [] {
|
||||
ws-ipc "toggle"
|
||||
}
|
||||
@@ -52,9 +52,9 @@ def "main workspace-manager windows" [] {
|
||||
ws-ipc "openWindowSelection"
|
||||
}
|
||||
|
||||
# Open the workspace carousel with the name field focused
|
||||
def "main workspace-manager rename" [] {
|
||||
ws-ipc "openWorkspaceRename"
|
||||
# Open the workspace carousel with the window search bar open
|
||||
def "main workspace-manager search" [] {
|
||||
ws-ipc "openSearch"
|
||||
}
|
||||
|
||||
const BADGE_PATH = $REPO_ROOT | path join "workspace-badge"
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"keys": {
|
||||
"rename": "Ctrl+N",
|
||||
"windows": "Ctrl+G"
|
||||
},
|
||||
"hints": {
|
||||
"show": true,
|
||||
"rename": "{key}: to switch here",
|
||||
"windows": "{key}: to see windows",
|
||||
"exitWindows": "{key} or Esc: to exit window carousel"
|
||||
"exitWindows": "{key} or Esc: to exit window carousel",
|
||||
"search": "/: to search windows, n / N: next / previous match"
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,6 @@ Item {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Name of the focused workspace, empty when it has none.
|
||||
property string currentName: ""
|
||||
// Id of the focused workspace, -1 when unknown. Only Hyprland needs it.
|
||||
property int currentId: -1
|
||||
|
||||
// Monitors left to right, each with its workspaces in order.
|
||||
// A nested list of parsed JSON, so this stays an untyped array.
|
||||
@@ -305,8 +301,7 @@ Item {
|
||||
function buildMonitors(parsed): void {
|
||||
const list = Array.isArray(parsed) ? parsed : [];
|
||||
const groups = {};
|
||||
let focusedId = -1;
|
||||
let focusedName = "";
|
||||
let anyFocused = false;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const ws = list[i];
|
||||
@@ -331,10 +326,8 @@ Item {
|
||||
focused: focused
|
||||
});
|
||||
|
||||
if (focused) {
|
||||
focusedId = id;
|
||||
focusedName = name;
|
||||
}
|
||||
if (focused)
|
||||
anyFocused = true;
|
||||
}
|
||||
|
||||
const names = Object.keys(groups);
|
||||
@@ -360,14 +353,8 @@ Item {
|
||||
});
|
||||
}
|
||||
|
||||
if (focusedId < 0) {
|
||||
if (!anyFocused)
|
||||
console.warn("workspace-manager: no focused workspace reported");
|
||||
root.currentId = -1;
|
||||
root.currentName = "";
|
||||
} else {
|
||||
root.currentId = focusedId;
|
||||
root.currentName = focusedName;
|
||||
}
|
||||
root.monitors = built;
|
||||
root.refreshed();
|
||||
}
|
||||
@@ -464,60 +451,6 @@ Item {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function apply(name: string): void {
|
||||
const trimmed = name.trim();
|
||||
if (root.kind === "niri") {
|
||||
action.command = trimmed.length > 0 ? ["niri", "msg", "action", "set-workspace-name", trimmed] : ["niri", "msg", "action", "unset-workspace-name"];
|
||||
} else if (root.kind === "hyprland") {
|
||||
if (root.currentId < 0)
|
||||
return;
|
||||
const id = String(root.currentId);
|
||||
// Hyprland has no "clear name", so fall back to the numeric id.
|
||||
action.command = ["hyprctl", "dispatch", "renameworkspace", id, trimmed.length > 0 ? trimmed : id];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
action.running = false;
|
||||
action.running = true;
|
||||
root.currentName = trimmed;
|
||||
}
|
||||
|
||||
// Rename a workspace by index (niri) or id (Hyprland).
|
||||
// Used from the carousel to rename the selected workspace.
|
||||
function renameWorkspace(wsId: int, wsIdx: int, name: string): void {
|
||||
const trimmed = name.trim();
|
||||
if (root.kind === "niri") {
|
||||
// niri's --workspace flag accepts an index (number) or name (string).
|
||||
if (trimmed.length > 0)
|
||||
action.command = ["niri", "msg", "action", "set-workspace-name", "--workspace", String(wsIdx), trimmed];
|
||||
else
|
||||
action.command = ["niri", "msg", "action", "unset-workspace-name", String(wsIdx)];
|
||||
} else if (root.kind === "hyprland") {
|
||||
if (wsId < 0)
|
||||
return;
|
||||
const id = String(wsId);
|
||||
action.command = ["hyprctl", "dispatch", "renameworkspace", id, trimmed.length > 0 ? trimmed : id];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
action.running = false;
|
||||
action.running = true;
|
||||
// Update the name locally so the carousel reflects it immediately.
|
||||
if (root.currentId === wsId)
|
||||
root.currentName = trimmed;
|
||||
const mons = root.monitors;
|
||||
for (let i = 0; i < mons.length; i++) {
|
||||
const wsList = mons[i].workspaces ?? [];
|
||||
for (let j = 0; j < wsList.length; j++) {
|
||||
if (wsList[j].id === wsId) {
|
||||
wsList[j].name = trimmed;
|
||||
// reassign to trigger QML re-evaluation
|
||||
root.monitors = root.monitors.slice();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Niri indexes count on the focused monitor only, so focus that monitor
|
||||
// first, then the index. Hyprland switches by workspace id in one command.
|
||||
|
||||
@@ -11,16 +11,15 @@ Item {
|
||||
readonly property string configPath: Quickshell.env("SKYG_WORKSPACE_MANAGER") ?? ""
|
||||
|
||||
// Keys written as modifiers plus one key, like "Ctrl+N".
|
||||
property string renameKey
|
||||
property string windowsKey
|
||||
|
||||
property bool showHints
|
||||
// "{key}" in a hint is replaced by its key.
|
||||
property string renameHint
|
||||
property string windowsHint
|
||||
property string exitWindowsHint
|
||||
// The search keys (/, n, N) are fixed, like in vim.
|
||||
property string searchHint
|
||||
|
||||
readonly property string renameHintText: root.fillKey(root.renameHint, root.renameKey)
|
||||
readonly property string windowsHintText: root.fillKey(root.windowsHint, root.windowsKey)
|
||||
readonly property string exitWindowsHintText: root.fillKey(root.exitWindowsHint, root.windowsKey)
|
||||
|
||||
@@ -67,12 +66,13 @@ Item {
|
||||
function load(parsed): void {
|
||||
const keys = parsed.keys ?? {};
|
||||
const hints = parsed.hints ?? {};
|
||||
root.renameKey = root.keyOr(keys.rename, "Ctrl+N", "keys.rename");
|
||||
|
||||
root.windowsKey = root.keyOr(keys.windows, "Tab", "keys.windows");
|
||||
root.showHints = root.boolOr(hints.show, true, "hints.show");
|
||||
root.renameHint = root.textOr(hints.rename, "{key}: to switch here", "hints.rename");
|
||||
|
||||
root.windowsHint = root.textOr(hints.windows, "{key}: to see windows", "hints.windows");
|
||||
root.exitWindowsHint = root.textOr(hints.exitWindows, "{key} or Esc: to exit window carousel", "hints.exitWindows");
|
||||
root.searchHint = root.textOr(hints.search, "/: to search windows, n / N: next / previous match", "hints.search");
|
||||
}
|
||||
|
||||
// ── keys ────────────────────────────────────────────────────────────
|
||||
|
||||
+264
-84
@@ -9,8 +9,8 @@ PanelWindow {
|
||||
required property Compositor compositor
|
||||
required property Theme theme
|
||||
required property Config config
|
||||
// Focus the name field as soon as the carousel has its data.
|
||||
required property bool renameOnOpen
|
||||
// Open the search bar as soon as the carousel has its data.
|
||||
required property bool searchOnOpen
|
||||
// Open the window loop on the focused workspace as soon as the carousel
|
||||
// has its data. Escape then closes everything.
|
||||
required property bool openWindowsOnOpen
|
||||
@@ -42,8 +42,20 @@ PanelWindow {
|
||||
property bool seedPending: false
|
||||
property bool animate: false
|
||||
|
||||
// Whether the name field (rename mode) currently has focus.
|
||||
property bool nameFieldActive: false
|
||||
// The search bar is open and taking typed text.
|
||||
property bool searchActive: false
|
||||
// Last accepted search, used by n and N.
|
||||
property string searchQuery: ""
|
||||
// Matches for the text in the search bar, and which one is shown.
|
||||
// matchIndex is -1 when none is shown.
|
||||
property int matchCount: 0
|
||||
property int matchIndex: -1
|
||||
// Where the view was when the search bar opened. Escape goes back here.
|
||||
property int originMonitor: 0
|
||||
property list<int> originIndices: []
|
||||
// -1 when the window loop was closed.
|
||||
property int originWindowIndex: -1
|
||||
property bool originCanCollapse: true
|
||||
|
||||
// The window loop is open on top of the selected workspace.
|
||||
property bool windowsOpen: false
|
||||
@@ -105,7 +117,6 @@ PanelWindow {
|
||||
copy.push(0);
|
||||
copy[root.monitorIndex] = next;
|
||||
root.workspaceIndices = copy;
|
||||
root.syncNameField();
|
||||
}
|
||||
|
||||
function moveMonitor(delta: int): void {
|
||||
@@ -117,7 +128,6 @@ PanelWindow {
|
||||
if (next < 0 || next >= count)
|
||||
return;
|
||||
root.monitorIndex = next;
|
||||
root.syncNameField();
|
||||
}
|
||||
|
||||
function activateAt(monitorAt: int, workspaceAt: int): void {
|
||||
@@ -140,8 +150,7 @@ PanelWindow {
|
||||
root.activateAt(root.monitorIndex, root.workspaceIndexAt(root.monitorIndex));
|
||||
}
|
||||
|
||||
// ── rename bar helpers ──────────────────────────────────────────────
|
||||
|
||||
// A workspace from parsed JSON, so this stays untyped.
|
||||
function selectedWorkspace(): var {
|
||||
const mons = root.compositor.monitors ?? [];
|
||||
if (root.monitorIndex < 0 || root.monitorIndex >= mons.length)
|
||||
@@ -153,23 +162,6 @@ PanelWindow {
|
||||
return wsList[idx];
|
||||
}
|
||||
|
||||
function syncNameField(): void {
|
||||
const ws = root.selectedWorkspace();
|
||||
nameInput.text = ws ? ws.name : "";
|
||||
}
|
||||
|
||||
function enterRename(): void {
|
||||
root.nameFieldActive = true;
|
||||
root.syncNameField();
|
||||
nameInput.forceActiveFocus();
|
||||
nameInput.selectAll();
|
||||
}
|
||||
|
||||
function leaveRename(): void {
|
||||
root.nameFieldActive = false;
|
||||
nameInput.focus = false;
|
||||
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||
}
|
||||
|
||||
// ── window loop helpers ─────────────────────────────────────────────
|
||||
|
||||
@@ -215,22 +207,201 @@ PanelWindow {
|
||||
root.requestBack();
|
||||
}
|
||||
|
||||
function isToggleRenameKey(event): bool {
|
||||
return root.config.matches(event, root.config.renameKey);
|
||||
// ── search ──────────────────────────────────────────────────────────
|
||||
|
||||
function noCtrlOrAlt(event): bool {
|
||||
return !(event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier));
|
||||
}
|
||||
|
||||
function applyRename(): void {
|
||||
const ws = root.selectedWorkspace();
|
||||
if (ws)
|
||||
root.compositor.renameWorkspace(ws.id, ws.idx, nameInput.text);
|
||||
root.leaveRename();
|
||||
function isSearchKey(event): bool {
|
||||
return event.text === "/" && root.noCtrlOrAlt(event);
|
||||
}
|
||||
|
||||
// n goes forward (1), N goes back (-1), anything else is 0.
|
||||
function nextMatchDirection(event): int {
|
||||
if (event.key !== Qt.Key_N || !root.noCtrlOrAlt(event))
|
||||
return 0;
|
||||
return (event.modifiers & Qt.ShiftModifier) ? -1 : 1;
|
||||
}
|
||||
|
||||
// Selected window in the loop, or -1 when the loop is closed.
|
||||
function currentWindowIndex(): int {
|
||||
return root.windowsOpen ? windowLoop.selectedIndex : -1;
|
||||
}
|
||||
|
||||
// Order: monitor, then workspace, then window. A closed loop (-1)
|
||||
// comes before every window of its workspace.
|
||||
function comparePositions(monitorA: int, workspaceA: int, windowA: int, monitorB: int, workspaceB: int, windowB: int): int {
|
||||
if (monitorA !== monitorB)
|
||||
return monitorA - monitorB;
|
||||
if (workspaceA !== workspaceB)
|
||||
return workspaceA - workspaceB;
|
||||
return windowA - windowB;
|
||||
}
|
||||
|
||||
// Like vim's smartcase: any capital letter makes the search match case.
|
||||
// The window is parsed JSON, so it stays untyped.
|
||||
function windowMatches(w, query: string): bool {
|
||||
const exact = query !== query.toLowerCase();
|
||||
const fold = text => exact ? text : text.toLowerCase();
|
||||
const wanted = fold(query);
|
||||
return fold(w.title ?? "").includes(wanted) || fold(w.app ?? "").includes(wanted);
|
||||
}
|
||||
|
||||
// Every window whose title or app matches, in carousel order, as
|
||||
// { monitor, workspace, window } list positions.
|
||||
function findMatches(query: string): var {
|
||||
const found = [];
|
||||
if (query.length === 0)
|
||||
return found;
|
||||
const mons = root.compositor.monitors ?? [];
|
||||
for (let i = 0; i < mons.length; i++) {
|
||||
const wsList = mons[i].workspaces ?? [];
|
||||
for (let j = 0; j < wsList.length; j++) {
|
||||
const wins = wsList[j].windows ?? [];
|
||||
for (let k = 0; k < wins.length; k++) {
|
||||
if (root.windowMatches(wins[k], query))
|
||||
found.push({
|
||||
monitor: i,
|
||||
workspace: j,
|
||||
window: k
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// The first match after the given place (direction 1) or the last one
|
||||
// before it (direction -1), wrapping round. -1 when there is none.
|
||||
function pickMatch(matches, monitorAt: int, workspaceAt: int, windowAt: int, direction: int): int {
|
||||
if (matches.length === 0)
|
||||
return -1;
|
||||
if (direction > 0) {
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
const m = matches[i];
|
||||
if (root.comparePositions(m.monitor, m.workspace, m.window, monitorAt, workspaceAt, windowAt) > 0)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
for (let i = matches.length - 1; i >= 0; i--) {
|
||||
const m = matches[i];
|
||||
if (root.comparePositions(m.monitor, m.workspace, m.window, monitorAt, workspaceAt, windowAt) < 0)
|
||||
return i;
|
||||
}
|
||||
return matches.length - 1;
|
||||
}
|
||||
|
||||
// Move the view to a workspace, and to one of its windows unless
|
||||
// windowAt is -1, which closes the loop.
|
||||
function showPosition(monitorAt: int, workspaceAt: int, windowAt: int): void {
|
||||
const mons = root.compositor.monitors ?? [];
|
||||
if (monitorAt < 0 || monitorAt >= mons.length)
|
||||
return;
|
||||
const wsList = mons[monitorAt].workspaces ?? [];
|
||||
if (workspaceAt < 0 || workspaceAt >= wsList.length)
|
||||
return;
|
||||
const ws = wsList[workspaceAt];
|
||||
const forward = root.comparePositions(monitorAt, workspaceAt, windowAt, root.monitorIndex, root.workspaceIndexAt(root.monitorIndex), root.currentWindowIndex()) >= 0;
|
||||
|
||||
root.animate = true;
|
||||
root.monitorIndex = monitorAt;
|
||||
const copy = root.workspaceIndices.slice();
|
||||
while (copy.length <= monitorAt)
|
||||
copy.push(0);
|
||||
copy[monitorAt] = workspaceAt;
|
||||
root.workspaceIndices = copy;
|
||||
|
||||
if (windowAt < 0) {
|
||||
if (root.windowsOpen)
|
||||
root.collapseWindows();
|
||||
return;
|
||||
}
|
||||
if (!root.windowsOpen) {
|
||||
root.expandWindows(true);
|
||||
} else if (root.loopWorkspaceId !== ws.id) {
|
||||
windowLoop.holdLeaving();
|
||||
root.loopWorkspaceId = ws.id;
|
||||
windowLoop.switchIn(forward ? 1 : -1);
|
||||
}
|
||||
windowLoop.selectIndex(windowAt);
|
||||
}
|
||||
|
||||
function restoreOrigin(): void {
|
||||
const indices = Array.from(root.originIndices);
|
||||
const workspaceAt = root.originMonitor < indices.length ? indices[root.originMonitor] : 0;
|
||||
root.showPosition(root.originMonitor, workspaceAt, root.originWindowIndex);
|
||||
root.workspaceIndices = indices;
|
||||
root.canCollapse = root.originCanCollapse;
|
||||
}
|
||||
|
||||
function enterSearch(): void {
|
||||
root.originMonitor = root.monitorIndex;
|
||||
root.originIndices = root.workspaceIndices.slice();
|
||||
root.originWindowIndex = root.currentWindowIndex();
|
||||
root.originCanCollapse = root.canCollapse;
|
||||
root.matchCount = 0;
|
||||
root.matchIndex = -1;
|
||||
// Clear before turning on, so the cleared text does not search.
|
||||
searchInput.text = "";
|
||||
root.searchActive = true;
|
||||
searchInput.forceActiveFocus();
|
||||
}
|
||||
|
||||
function leaveSearch(): void {
|
||||
root.searchActive = false;
|
||||
searchInput.focus = false;
|
||||
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||
}
|
||||
|
||||
// Called as the search text changes. Jumps to the first match after
|
||||
// where the search started, or back there when nothing matches.
|
||||
function updateSearch(query: string): void {
|
||||
const matches = root.findMatches(query);
|
||||
root.matchCount = matches.length;
|
||||
const indices = Array.from(root.originIndices);
|
||||
const workspaceAt = root.originMonitor < indices.length ? indices[root.originMonitor] : 0;
|
||||
const index = root.pickMatch(matches, root.originMonitor, workspaceAt, root.originWindowIndex, 1);
|
||||
root.matchIndex = index;
|
||||
if (index < 0) {
|
||||
root.restoreOrigin();
|
||||
return;
|
||||
}
|
||||
const m = matches[index];
|
||||
root.showPosition(m.monitor, m.workspace, m.window);
|
||||
}
|
||||
|
||||
// Enter: keep the shown match and remember the text for n and N.
|
||||
function acceptSearch(): void {
|
||||
if (searchInput.text.length > 0)
|
||||
root.searchQuery = searchInput.text;
|
||||
root.leaveSearch();
|
||||
}
|
||||
|
||||
// Escape: go back to where the search started.
|
||||
function cancelSearch(): void {
|
||||
root.restoreOrigin();
|
||||
root.leaveSearch();
|
||||
}
|
||||
|
||||
function jumpToMatch(direction: int): void {
|
||||
const matches = root.findMatches(root.searchQuery);
|
||||
const index = root.pickMatch(matches, root.monitorIndex, root.workspaceIndexAt(root.monitorIndex), root.currentWindowIndex(), direction);
|
||||
root.matchCount = matches.length;
|
||||
root.matchIndex = index;
|
||||
if (index < 0)
|
||||
return;
|
||||
const m = matches[index];
|
||||
root.showPosition(m.monitor, m.workspace, m.window);
|
||||
}
|
||||
|
||||
// ── visibility handling ─────────────────────────────────────────────
|
||||
|
||||
onVisibleChanged: {
|
||||
root.animate = false;
|
||||
root.nameFieldActive = false;
|
||||
root.searchActive = false;
|
||||
searchInput.focus = false;
|
||||
root.windowsOpen = false;
|
||||
if (!root.visible) {
|
||||
root.seedPending = false;
|
||||
@@ -251,11 +422,10 @@ PanelWindow {
|
||||
return;
|
||||
root.seedPending = false;
|
||||
root.seedSelection();
|
||||
root.syncNameField();
|
||||
if (root.openWindowsOnOpen)
|
||||
root.expandWindows(false);
|
||||
if (root.renameOnOpen)
|
||||
root.enterRename();
|
||||
if (root.searchOnOpen)
|
||||
root.enterSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,8 +439,8 @@ PanelWindow {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (root.nameFieldActive)
|
||||
root.leaveRename();
|
||||
if (root.searchActive)
|
||||
root.cancelSearch();
|
||||
else if (root.windowsOpen)
|
||||
root.leaveWindows();
|
||||
else
|
||||
@@ -279,16 +449,25 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// ── rename bar (always visible at the top) ──────────────────────────
|
||||
// ── search bar (shown while searching) ──────────────────────────────
|
||||
|
||||
Item {
|
||||
id: renameBar
|
||||
id: searchBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: root.theme.renameBarTop
|
||||
anchors.topMargin: root.theme.searchBarTop
|
||||
width: root.theme.barWidth
|
||||
height: root.theme.barHeight
|
||||
z: 10
|
||||
opacity: root.searchActive ? 1 : 0
|
||||
// Shown at once when opened, so the field can take focus.
|
||||
visible: root.searchActive || searchBar.opacity > 0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: root.theme.hintFadeDuration
|
||||
}
|
||||
}
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
@@ -321,17 +500,18 @@ PanelWindow {
|
||||
}
|
||||
|
||||
Text {
|
||||
id: label
|
||||
id: prompt
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "Workspace Name: "
|
||||
text: "/"
|
||||
color: root.theme.labelColor
|
||||
font.pixelSize: root.theme.fontSize
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Item {
|
||||
id: field
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3
|
||||
width: parent.width - prompt.width - matchText.width - root.theme.logoSize - root.theme.barSpacing * 3
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
|
||||
Glass {
|
||||
@@ -339,12 +519,12 @@ PanelWindow {
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius / 2
|
||||
tint: root.theme.fieldBg
|
||||
selected: nameInput.activeFocus
|
||||
selected: searchInput.activeFocus
|
||||
shadow: false
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: nameInput
|
||||
id: searchInput
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: root.theme.fieldPadding
|
||||
anchors.rightMargin: root.theme.fieldPadding
|
||||
@@ -357,61 +537,55 @@ PanelWindow {
|
||||
clip: true
|
||||
focus: false
|
||||
|
||||
onAccepted: root.applyRename()
|
||||
onTextChanged: {
|
||||
if (root.searchActive)
|
||||
root.updateSearch(searchInput.text);
|
||||
}
|
||||
onAccepted: root.acceptSearch()
|
||||
|
||||
// Escape from rename field returns to carousel.
|
||||
Keys.onEscapePressed: event => {
|
||||
root.leaveRename();
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
// The rename key toggles back to carousel.
|
||||
Keys.onShortcutOverride: event => {
|
||||
if (root.isToggleRenameKey(event))
|
||||
root.cancelSearch();
|
||||
event.accepted = true;
|
||||
}
|
||||
// Backspace on an empty search closes it, like in vim.
|
||||
Keys.onPressed: event => {
|
||||
if (root.isToggleRenameKey(event)) {
|
||||
root.leaveRename();
|
||||
if (event.key === Qt.Key_Backspace && searchInput.text.length === 0) {
|
||||
root.cancelSearch();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
event.accepted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: okButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: root.theme.buttonWidth
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
radius: root.theme.cornerRadius / 2
|
||||
color: okArea.pressed ? Qt.darker(root.theme.buttonBg, 1.2) : root.theme.buttonBg
|
||||
|
||||
// "2/5" while there are matches, "no match" when none.
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "OK"
|
||||
color: root.theme.buttonText
|
||||
id: matchText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: root.matchCount > 0 ? root.theme.labelColor : root.theme.fieldBorder
|
||||
font.pixelSize: root.theme.fontSize
|
||||
font.bold: true
|
||||
text: {
|
||||
if (searchInput.text.length === 0)
|
||||
return "";
|
||||
if (root.matchCount === 0)
|
||||
return "no match";
|
||||
return (root.matchIndex + 1) + "/" + root.matchCount;
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: okArea
|
||||
anchors.fill: parent
|
||||
onClicked: root.applyRename()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Where the search bar opens, while it is closed.
|
||||
KeyHint {
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.bottom
|
||||
anchors.topMargin: root.theme.hintGap
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: root.theme.searchBarTop
|
||||
z: 10
|
||||
theme: root.theme
|
||||
hint: root.config.renameHintText
|
||||
shown: root.config.showHints && !root.nameFieldActive
|
||||
}
|
||||
hint: root.config.searchHint
|
||||
shown: root.config.showHints && !root.searchActive
|
||||
}
|
||||
|
||||
// ── carousel ────────────────────────────────────────────────────────
|
||||
@@ -422,9 +596,15 @@ PanelWindow {
|
||||
focus: root.visible
|
||||
|
||||
Keys.onPressed: event => {
|
||||
// The rename key toggles to rename mode.
|
||||
if (root.isToggleRenameKey(event)) {
|
||||
root.enterRename();
|
||||
// / opens the search bar, n and N go to the next or previous match.
|
||||
if (root.isSearchKey(event)) {
|
||||
root.enterSearch();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
const direction = root.nextMatchDirection(event);
|
||||
if (direction !== 0) {
|
||||
root.jumpToMatch(direction);
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
@@ -612,7 +792,7 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// Monitor name, above the rename bar.
|
||||
// Monitor name, above the search bar.
|
||||
Item {
|
||||
id: monitorName
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
required property bool shellOpen
|
||||
required property Compositor compositor
|
||||
required property Theme theme
|
||||
|
||||
signal requestClose
|
||||
signal requestGoto
|
||||
|
||||
visible: root.shellOpen
|
||||
color: "transparent"
|
||||
|
||||
implicitWidth: root.theme.barWidth
|
||||
implicitHeight: root.theme.barHeight
|
||||
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.namespace: "quickshell:workspace-manager"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
|
||||
// No anchors: the layer surface is then centered on the screen.
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!root.visible)
|
||||
return;
|
||||
root.compositor.refresh();
|
||||
nameField.text = root.compositor.currentName;
|
||||
Qt.callLater(() => {
|
||||
nameField.forceActiveFocus();
|
||||
nameField.selectAll();
|
||||
});
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.compositor
|
||||
|
||||
function onRefreshed(): void {
|
||||
if (root.visible) {
|
||||
nameField.text = root.compositor.currentName;
|
||||
nameField.selectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function accept(): void {
|
||||
root.compositor.apply(nameField.text);
|
||||
root.requestClose();
|
||||
}
|
||||
|
||||
function isGotoKey(event): bool {
|
||||
const mods = event.modifiers;
|
||||
const ctrl = (mods & Qt.ControlModifier) && !(mods & Qt.AltModifier) && !(mods & Qt.MetaModifier);
|
||||
return event.key === Qt.Key_G && ctrl;
|
||||
}
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius
|
||||
tint: root.theme.barBg
|
||||
selected: false
|
||||
// The window is only as big as the bar, so a shadow would be cut off.
|
||||
shadow: false
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
anchors.margins: root.theme.barPadding
|
||||
spacing: root.theme.barSpacing
|
||||
|
||||
Image {
|
||||
width: root.theme.logoSize
|
||||
height: root.theme.logoSize
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: root.compositor.logoSource
|
||||
visible: root.compositor.logoSource !== ""
|
||||
sourceSize.width: root.theme.logoSize * 2
|
||||
sourceSize.height: root.theme.logoSize * 2
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
// Raster source, so filter the downscale.
|
||||
mipmap: true
|
||||
}
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "Workspace Name: "
|
||||
color: root.theme.labelColor
|
||||
font.pixelSize: root.theme.fontSize
|
||||
}
|
||||
|
||||
Item {
|
||||
id: field
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius / 2
|
||||
tint: root.theme.fieldBg
|
||||
selected: nameField.activeFocus
|
||||
shadow: false
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: nameField
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: root.theme.fieldPadding
|
||||
anchors.rightMargin: root.theme.fieldPadding
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: root.theme.fontSize
|
||||
selectByMouse: true
|
||||
selectionColor: root.theme.fieldBorder
|
||||
selectedTextColor: root.theme.buttonText
|
||||
clip: true
|
||||
focus: root.visible
|
||||
|
||||
onAccepted: root.accept()
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
root.requestClose();
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
// Ctrl+G opens the carousel. A plain G still types into the name.
|
||||
// Other keys must be rejected, or the field would swallow them.
|
||||
Keys.onShortcutOverride: event => {
|
||||
if (root.isGotoKey(event))
|
||||
event.accepted = true;
|
||||
}
|
||||
Keys.onPressed: event => {
|
||||
if (!root.isGotoKey(event)) {
|
||||
event.accepted = false;
|
||||
return;
|
||||
}
|
||||
root.requestGoto();
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: okButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: root.theme.buttonWidth
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
radius: root.theme.cornerRadius / 2
|
||||
color: okArea.pressed ? Qt.darker(root.theme.buttonBg, 1.2) : root.theme.buttonBg
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "OK"
|
||||
color: root.theme.buttonText
|
||||
font.pixelSize: root.theme.fontSize
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: okArea
|
||||
anchors.fill: parent
|
||||
onClicked: root.accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ QtObject {
|
||||
readonly property real fieldPadding: 14
|
||||
readonly property real logoSize: 36
|
||||
readonly property real fontSize: 24
|
||||
readonly property real buttonWidth: 86
|
||||
|
||||
|
||||
// Fullscreen dim behind the workspace carousel.
|
||||
readonly property color backdrop: "#0d0b0e14"
|
||||
@@ -47,12 +47,12 @@ QtObject {
|
||||
readonly property real cardRadius: 16
|
||||
readonly property real monitorLabelSize: 18
|
||||
// Distance from the top of the screen to each monitor's name,
|
||||
// which sits above the rename bar.
|
||||
// which sits above the search bar.
|
||||
readonly property real monitorLabelTop: 20
|
||||
readonly property real monitorNameSize: 22
|
||||
readonly property real monitorNamePadding: 25
|
||||
// Distance from the top of the screen to the rename bar.
|
||||
readonly property real renameBarTop: 76
|
||||
// Distance from the top of the screen to the search bar.
|
||||
readonly property real searchBarTop: 76
|
||||
|
||||
// Each monitor is a column of its workspaces. One step between
|
||||
// monitors (sideways), and one step between workspaces (down).
|
||||
@@ -76,7 +76,7 @@ QtObject {
|
||||
readonly property real windowRowSpacing: 6
|
||||
readonly property int maxWindowRows: 3
|
||||
|
||||
// Key hints. They sit under the rename bar, the selected workspace and
|
||||
// Key hints. They sit under the search bar, the selected workspace and
|
||||
// the front window, this far below each.
|
||||
readonly property real hintSize: 12
|
||||
readonly property real hintGap: 8
|
||||
|
||||
@@ -190,6 +190,18 @@ Item {
|
||||
root.turn = root.targetStep;
|
||||
}
|
||||
|
||||
// Turn to the window at this list index, the short way round.
|
||||
function selectIndex(index: int): void {
|
||||
if (root.count === 0 || index < 0 || index >= root.count)
|
||||
return;
|
||||
let delta = index - root.selectedIndex;
|
||||
if (delta > root.count / 2)
|
||||
delta -= root.count;
|
||||
else if (delta < -root.count / 2)
|
||||
delta += root.count;
|
||||
root.step(delta);
|
||||
}
|
||||
|
||||
function activateAt(index: int): void {
|
||||
const list = root.windows;
|
||||
if (index < 0 || index >= list.length)
|
||||
|
||||
@@ -6,8 +6,8 @@ ShellRoot {
|
||||
id: shell
|
||||
|
||||
property bool open: false
|
||||
// Focus the name field once the carousel opens.
|
||||
property bool renameOnOpen: false
|
||||
// Open the search bar once the carousel opens.
|
||||
property bool searchOnOpen: false
|
||||
// Open the window loop on the focused workspace once the carousel opens.
|
||||
property bool openWindowsOnOpen: false
|
||||
|
||||
@@ -35,15 +35,15 @@ ShellRoot {
|
||||
shell.open = false;
|
||||
}
|
||||
|
||||
function openWith(rename: bool, windows: bool): void {
|
||||
shell.renameOnOpen = rename;
|
||||
function openWith(search: bool, windows: bool): void {
|
||||
shell.searchOnOpen = search;
|
||||
shell.openWindowsOnOpen = windows;
|
||||
// Already open, so there is no fresh open to wait for.
|
||||
if (shell.open) {
|
||||
if (windows)
|
||||
gotoView.expandWindows(false);
|
||||
if (rename)
|
||||
gotoView.enterRename();
|
||||
if (search)
|
||||
gotoView.enterSearch();
|
||||
return;
|
||||
}
|
||||
shell.open = true;
|
||||
@@ -67,7 +67,7 @@ ShellRoot {
|
||||
shell.openWith(false, true);
|
||||
}
|
||||
|
||||
function openWorkspaceRename(): void {
|
||||
function openSearch(): void {
|
||||
shell.openWith(true, false);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ ShellRoot {
|
||||
compositor: compositor
|
||||
theme: theme
|
||||
config: config
|
||||
renameOnOpen: shell.renameOnOpen
|
||||
searchOnOpen: shell.searchOnOpen
|
||||
openWindowsOnOpen: shell.openWindowsOnOpen
|
||||
onRequestClose: shell.closeAll()
|
||||
onRequestBack: shell.closeAll()
|
||||
|
||||
Reference in new issue
Block a user