qts
This commit is contained in:
1 parent
44d0491183
commit
8426b53251
7 files changed
+269
-100
No files matched your search
+3
-1
@@ -5,6 +5,8 @@
|
||||
quickshell,
|
||||
nushell,
|
||||
curl,
|
||||
grim,
|
||||
wl-clipboard,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
@@ -33,7 +35,7 @@ stdenvNoCC.mkDerivation {
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${lib.getExe nushell} $out/bin/skygqts \
|
||||
--add-flags "$out/share/skygqts/skygqts.nu" \
|
||||
--prefix PATH : ${lib.makeBinPath [ quickshell curl ]}
|
||||
--prefix PATH : ${lib.makeBinPath [ quickshell curl grim wl-clipboard ]}
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Item {
|
||||
// Id of the focused workspace, -1 when unknown. Only Hyprland needs it.
|
||||
property int currentId: -1
|
||||
|
||||
// Monitors top to bottom, each with its workspaces left to right.
|
||||
// Monitors left to right, each with its workspaces in order.
|
||||
// A nested list of parsed JSON, so this stays an untyped array.
|
||||
property var monitors: []
|
||||
|
||||
@@ -42,16 +42,27 @@ Item {
|
||||
// Raw workspace JSON saved between the workspaces and windows query stages.
|
||||
property var workspaceData: []
|
||||
// Normalized windows, left to right, with { title, app, id, key, focused,
|
||||
// preview }. id is the workspace id. key is the niri window id or the
|
||||
// Hyprland address. preview is a screenshot file on niri, "" otherwise.
|
||||
// captureId, preview }. id is the workspace id. key is the niri window id
|
||||
// or the Hyprland address. captureId is what the snapshot tool needs: the
|
||||
// niri window id, or the Hyprland stableId. preview is the snapshot file,
|
||||
// "" when snapshots are off.
|
||||
property var windowList: []
|
||||
|
||||
// Take niri screenshots for window previews. Each one also replaces the
|
||||
// clipboard, and niri has no way to turn that off.
|
||||
required property bool niriScreenshots
|
||||
// Bumped after each niri screenshot so preview images load again.
|
||||
// Live Hyprland previews.
|
||||
required property bool livePreviews
|
||||
// Still snapshots for previews, per compositor. See Theme.qml.
|
||||
required property bool snapshotPreviewsHyprland
|
||||
required property bool snapshotPreviewsNiri
|
||||
readonly property bool snapshotPreviews: {
|
||||
if (root.kind === "niri")
|
||||
return root.snapshotPreviewsNiri;
|
||||
if (root.kind === "hyprland")
|
||||
return root.snapshotPreviewsHyprland;
|
||||
return false;
|
||||
}
|
||||
// Bumped after each snapshot so preview images load again.
|
||||
property int previewVersion: 0
|
||||
// niri window ids still waiting for a screenshot.
|
||||
// Window keys still waiting for a snapshot.
|
||||
property list<string> shotQueue: []
|
||||
|
||||
readonly property string previewDir: {
|
||||
@@ -226,12 +237,13 @@ Item {
|
||||
const windows = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const w = list[i];
|
||||
let title, app, id, key, focused, sortA, sortB;
|
||||
let title, app, id, key, captureId, focused, sortA, sortB;
|
||||
if (root.kind === "niri") {
|
||||
title = root.asString(w.title);
|
||||
app = root.asString(w.app_id);
|
||||
id = root.asNumber(w.workspace_id, -1);
|
||||
key = root.asString(w.id);
|
||||
captureId = key;
|
||||
focused = w.is_focused === true;
|
||||
// Tiled windows sort by column then row. Floating ones have
|
||||
// no position and go last.
|
||||
@@ -246,6 +258,7 @@ Item {
|
||||
app = root.asString(w.class);
|
||||
id = root.asNumber(w.workspace?.id, -1);
|
||||
key = root.asString(w.address);
|
||||
captureId = root.asString(w.stableId);
|
||||
focused = root.asNumber(w.focusHistoryID, -1) === 0;
|
||||
const at = Array.isArray(w.at) ? w.at : [0, 0];
|
||||
sortA = root.asNumber(at[0], 0);
|
||||
@@ -258,20 +271,21 @@ Item {
|
||||
app: app,
|
||||
id: id,
|
||||
key: key,
|
||||
captureId: captureId,
|
||||
focused: focused,
|
||||
sortA: sortA,
|
||||
sortB: sortB
|
||||
});
|
||||
}
|
||||
windows.sort((a, b) => a.sortA !== b.sortA ? a.sortA - b.sortA : a.sortB - b.sortB);
|
||||
const withPreview = root.kind === "niri" && root.niriScreenshots;
|
||||
root.windowList = windows.map(w => ({
|
||||
title: w.title,
|
||||
app: w.app,
|
||||
id: w.id,
|
||||
key: w.key,
|
||||
captureId: w.captureId,
|
||||
focused: w.focused,
|
||||
preview: withPreview ? root.previewPath(w.key) : ""
|
||||
preview: root.snapshotPreviews && w.captureId.length > 0 ? root.previewPath(w.key) : ""
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -367,7 +381,7 @@ Item {
|
||||
|
||||
// Live capture handle for a Hyprland window, null when there is none.
|
||||
function toplevelFor(key: string): Toplevel {
|
||||
if (root.kind !== "hyprland")
|
||||
if (root.kind !== "hyprland" || !root.livePreviews)
|
||||
return null;
|
||||
const wanted = key.toLowerCase().replace(/^0x/, "");
|
||||
const list = Hyprland.toplevels.values;
|
||||
@@ -378,9 +392,9 @@ Item {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Screenshot these niri windows one at a time.
|
||||
// Snapshot these windows one at a time.
|
||||
function takeScreenshots(keys: list<string>): void {
|
||||
if (root.kind !== "niri" || !root.niriScreenshots)
|
||||
if (!root.snapshotPreviews)
|
||||
return;
|
||||
root.shotQueue = keys;
|
||||
if (!shotProc.running)
|
||||
@@ -389,13 +403,26 @@ Item {
|
||||
|
||||
function nextScreenshot(): void {
|
||||
if (root.shotQueue.length === 0) {
|
||||
// niri may still be writing the last file, so look again shortly.
|
||||
// The last file may still be settling, so look again shortly.
|
||||
shotSettle.restart();
|
||||
return;
|
||||
}
|
||||
const key = root.shotQueue[0];
|
||||
root.shotQueue = root.shotQueue.slice(1);
|
||||
shotProc.command = ["niri", "msg", "action", "screenshot-window", "--id", key, "--write-to-disk", "true", "--path", root.previewPath(key)];
|
||||
const w = root.windowList.find(item => item.key === key);
|
||||
if (!w || w.captureId.length === 0) {
|
||||
root.nextScreenshot();
|
||||
return;
|
||||
}
|
||||
const path = root.previewPath(key);
|
||||
if (root.kind === "niri") {
|
||||
// niri only shows its "Screenshot captured" notice when it saves a
|
||||
// file, so skip the file and copy the image from the clipboard.
|
||||
// The id and path are passed as $1 and $2, not pasted into the script.
|
||||
shotProc.command = ["sh", "-c", "niri msg action screenshot-window --id \"$1\" --write-to-disk false && wl-paste --type image/png > \"$2\"", "sh", w.captureId, path];
|
||||
} else {
|
||||
shotProc.command = ["grim", "-T", w.captureId, path];
|
||||
}
|
||||
shotProc.running = true;
|
||||
}
|
||||
|
||||
@@ -419,12 +446,12 @@ Item {
|
||||
const rightKnown = right.known === true;
|
||||
if (leftKnown !== rightKnown)
|
||||
return leftKnown ? -1 : 1;
|
||||
const yDelta = root.asNumber(left.y, 0) - root.asNumber(right.y, 0);
|
||||
if (yDelta !== 0)
|
||||
return yDelta;
|
||||
const xDelta = root.asNumber(left.x, 0) - root.asNumber(right.x, 0);
|
||||
if (xDelta !== 0)
|
||||
return xDelta;
|
||||
const yDelta = root.asNumber(left.y, 0) - root.asNumber(right.y, 0);
|
||||
if (yDelta !== 0)
|
||||
return yDelta;
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a > b)
|
||||
|
||||
+129
-62
@@ -185,6 +185,18 @@ PanelWindow {
|
||||
windowLoop.seed();
|
||||
}
|
||||
|
||||
// Up/Down while the loop is open: move to the next workspace on this
|
||||
// monitor and show its windows.
|
||||
function switchWindows(delta: int): void {
|
||||
const before = root.selectedWorkspace();
|
||||
root.moveWorkspace(delta);
|
||||
const ws = root.selectedWorkspace();
|
||||
if (!ws || ws === before)
|
||||
return;
|
||||
root.loopWorkspaceId = ws.id;
|
||||
windowLoop.switchIn(delta);
|
||||
}
|
||||
|
||||
function collapseWindows(): void {
|
||||
root.animate = true;
|
||||
root.windowsOpen = false;
|
||||
@@ -277,7 +289,7 @@ PanelWindow {
|
||||
id: renameBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 40
|
||||
anchors.topMargin: root.theme.renameBarTop
|
||||
width: root.theme.barWidth
|
||||
height: root.theme.barHeight
|
||||
z: 10
|
||||
@@ -430,7 +442,10 @@ PanelWindow {
|
||||
root.leaveWindows();
|
||||
break;
|
||||
case Qt.Key_Up:
|
||||
root.switchWindows(-1);
|
||||
break;
|
||||
case Qt.Key_Down:
|
||||
root.switchWindows(1);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -440,16 +455,16 @@ PanelWindow {
|
||||
}
|
||||
|
||||
switch (event.key) {
|
||||
case Qt.Key_Left:
|
||||
case Qt.Key_Up:
|
||||
root.moveWorkspace(-1);
|
||||
break;
|
||||
case Qt.Key_Right:
|
||||
case Qt.Key_Down:
|
||||
root.moveWorkspace(1);
|
||||
break;
|
||||
case Qt.Key_Up:
|
||||
case Qt.Key_Left:
|
||||
root.moveMonitor(-1);
|
||||
break;
|
||||
case Qt.Key_Down:
|
||||
case Qt.Key_Right:
|
||||
root.moveMonitor(1);
|
||||
break;
|
||||
case Qt.Key_Return:
|
||||
@@ -471,14 +486,23 @@ PanelWindow {
|
||||
property real accX: 0
|
||||
property real accY: 0
|
||||
|
||||
function stepWorkspace(delta: int): void {
|
||||
root.moveWorkspace(delta);
|
||||
swipeHandler.accX = 0;
|
||||
// Vertical swipes move between workspaces, both in the carousel
|
||||
// and in the loop. Horizontal ones move between monitors, or
|
||||
// turn the loop while it is open.
|
||||
function stepVertical(delta: int): void {
|
||||
if (root.windowsOpen)
|
||||
root.switchWindows(delta);
|
||||
else
|
||||
root.moveWorkspace(delta);
|
||||
swipeHandler.accY = 0;
|
||||
}
|
||||
|
||||
function stepMonitor(delta: int): void {
|
||||
root.moveMonitor(delta);
|
||||
swipeHandler.accY = 0;
|
||||
function stepHorizontal(delta: int): void {
|
||||
if (root.windowsOpen)
|
||||
windowLoop.step(delta);
|
||||
else
|
||||
root.moveMonitor(delta);
|
||||
swipeHandler.accX = 0;
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
@@ -486,30 +510,18 @@ PanelWindow {
|
||||
const ang = event.angleDelta;
|
||||
const dx = px.x !== 0 ? px.x : ang.x;
|
||||
const dy = px.y !== 0 ? px.y : ang.y;
|
||||
// The loop turns with either direction.
|
||||
if (root.windowsOpen) {
|
||||
swipeHandler.accX += Math.abs(dx) >= Math.abs(dy) ? dx : dy;
|
||||
if (swipeHandler.accX <= -root.theme.swipeThreshold) {
|
||||
windowLoop.step(1);
|
||||
swipeHandler.accX = 0;
|
||||
} else if (swipeHandler.accX >= root.theme.swipeThreshold) {
|
||||
windowLoop.step(-1);
|
||||
swipeHandler.accX = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Math.abs(dy) >= Math.abs(dx)) {
|
||||
swipeHandler.accY += dy;
|
||||
if (swipeHandler.accY <= -root.theme.swipeThreshold)
|
||||
swipeHandler.stepMonitor(1);
|
||||
swipeHandler.stepVertical(1);
|
||||
else if (swipeHandler.accY >= root.theme.swipeThreshold)
|
||||
swipeHandler.stepMonitor(-1);
|
||||
swipeHandler.stepVertical(-1);
|
||||
} else {
|
||||
swipeHandler.accX += dx;
|
||||
if (swipeHandler.accX <= -root.theme.swipeThreshold)
|
||||
swipeHandler.stepWorkspace(1);
|
||||
swipeHandler.stepHorizontal(1);
|
||||
else if (swipeHandler.accX >= root.theme.swipeThreshold)
|
||||
swipeHandler.stepWorkspace(-1);
|
||||
swipeHandler.stepHorizontal(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,31 +529,40 @@ PanelWindow {
|
||||
Repeater {
|
||||
model: root.compositor.monitors
|
||||
|
||||
// One column per monitor, with its workspaces top to bottom.
|
||||
Item {
|
||||
id: row
|
||||
id: column
|
||||
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
readonly property int rowIndex: index
|
||||
readonly property int selectedWs: root.workspaceIndexAt(rowIndex)
|
||||
readonly property int columnIndex: index
|
||||
readonly property int selectedWs: root.workspaceIndexAt(columnIndex)
|
||||
readonly property var workspaces: modelData.workspaces ?? []
|
||||
readonly property bool isCurrentRow: row.rowIndex === root.monitorIndex
|
||||
// Other rows move up or down, out of the loop's way.
|
||||
readonly property real spreadY: root.windowsOpen ? Math.sign(row.rowIndex - root.monitorIndex) * root.theme.loopSpreadY : 0
|
||||
readonly property bool isCurrentColumn: column.columnIndex === root.monitorIndex
|
||||
// Other columns turn to face the middle while the loop is open.
|
||||
readonly property real tiltY: root.windowsOpen && !column.isCurrentColumn ? -Math.sign(column.columnIndex - root.monitorIndex) * root.theme.loopTiltY : 0
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: root.theme.cardHeight
|
||||
z: row.isCurrentRow ? 1 : 0
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: root.theme.cardWidth
|
||||
z: column.isCurrentColumn ? 1 : 0
|
||||
opacity: {
|
||||
const fade = 1 - Math.min(Math.abs(row.rowIndex - root.monitorIndex) * root.theme.carouselRowFadeStep, root.theme.carouselRowMaxFade);
|
||||
return root.windowsOpen && !row.isCurrentRow ? fade * root.theme.loopHiddenFade : fade;
|
||||
const fade = 1 - Math.min(Math.abs(column.columnIndex - root.monitorIndex) * root.theme.carouselMonitorFadeStep, root.theme.carouselMonitorMaxFade);
|
||||
return root.windowsOpen && !column.isCurrentColumn ? fade * root.theme.loopHiddenFade : fade;
|
||||
}
|
||||
// While the loop is open, the nearest column on each side sits
|
||||
// just past the loop's edge. Further columns keep the normal step.
|
||||
anchors.horizontalCenterOffset: {
|
||||
const steps = column.columnIndex - root.monitorIndex;
|
||||
if (!root.windowsOpen || steps === 0)
|
||||
return steps * root.theme.carouselStepX;
|
||||
const nearest = windowLoop.reachX + root.theme.cardWidth / 2 + root.theme.loopEdgeGap;
|
||||
return Math.sign(steps) * (nearest + (Math.abs(steps) - 1) * root.theme.carouselStepX);
|
||||
}
|
||||
anchors.verticalCenterOffset: (row.rowIndex - root.monitorIndex) * root.theme.carouselStepY + row.spreadY
|
||||
|
||||
Behavior on anchors.verticalCenterOffset {
|
||||
Behavior on anchors.horizontalCenterOffset {
|
||||
enabled: root.animate
|
||||
NumberAnimation {
|
||||
duration: root.theme.carouselDuration
|
||||
@@ -555,29 +576,53 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
width: root.theme.cardWidth * 2
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.top
|
||||
anchors.bottomMargin: root.theme.monitorLabelGap
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideMiddle
|
||||
color: root.theme.labelColor
|
||||
font.pixelSize: root.theme.monitorLabelSize
|
||||
text: row.modelData.name.length > 0 ? row.modelData.name : "screen"
|
||||
// The loop covers this label, so hide it while open.
|
||||
opacity: root.windowsOpen && row.isCurrentRow ? 0 : 1
|
||||
transform: Rotation {
|
||||
origin.x: column.width / 2
|
||||
origin.y: column.height / 2
|
||||
axis {
|
||||
x: 0
|
||||
y: 1
|
||||
z: 0
|
||||
}
|
||||
angle: column.tiltY
|
||||
|
||||
Behavior on opacity {
|
||||
Behavior on angle {
|
||||
enabled: root.animate
|
||||
NumberAnimation {
|
||||
duration: root.theme.carouselDuration
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Monitor name, above the rename bar.
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: root.theme.monitorLabelTop
|
||||
z: 2
|
||||
width: Math.min(nameText.implicitWidth + root.theme.monitorNamePadding * 10, column.width)
|
||||
height: nameText.implicitHeight + root.theme.monitorNamePadding
|
||||
radius: height / 4
|
||||
color: root.theme.barBg
|
||||
border.width: column.isCurrentColumn ? 2 : 1
|
||||
border.color: column.isCurrentColumn ? root.theme.fieldBorder : root.theme.barBorder
|
||||
|
||||
Text {
|
||||
id: nameText
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - root.theme.monitorNamePadding * 2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideMiddle
|
||||
color: column.isCurrentColumn ? root.theme.textColor : root.theme.labelColor
|
||||
font.pixelSize: root.theme.monitorNameSize
|
||||
font.bold: true
|
||||
text: column.modelData.name.length > 0 ? column.modelData.name : "screen"
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: row.workspaces
|
||||
model: column.workspaces
|
||||
|
||||
WorkspaceCard {
|
||||
id: card
|
||||
@@ -585,25 +630,28 @@ PanelWindow {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
readonly property int distance: Math.abs(index - row.selectedWs)
|
||||
readonly property int distance: Math.abs(index - column.selectedWs)
|
||||
// This card turns into the window loop.
|
||||
readonly property bool opensLoop: root.windowsOpen && card.selected
|
||||
// Cards next to the loop move sideways out of its way.
|
||||
readonly property real spreadX: root.windowsOpen && row.isCurrentRow ? Math.sign(index - row.selectedWs) * root.theme.loopSpreadX : 0
|
||||
// Cards above and below the loop move out of its way.
|
||||
readonly property real spreadY: root.windowsOpen && column.isCurrentColumn ? Math.sign(index - column.selectedWs) * root.theme.loopSpreadY : 0
|
||||
// They also lean back: the top edge away above the
|
||||
// loop, the bottom edge away below it.
|
||||
readonly property real tiltX: root.windowsOpen && column.isCurrentColumn ? -Math.sign(index - column.selectedWs) * root.theme.loopTiltX : 0
|
||||
readonly property real baseOpacity: 1 - Math.min(card.distance * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
readonly property real baseScale: 1 - Math.min(card.distance * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
theme: root.theme
|
||||
workspaceName: modelData.name
|
||||
workspaceIndex: modelData.idx
|
||||
selected: row.rowIndex === root.monitorIndex && index === row.selectedWs
|
||||
selected: column.isCurrentColumn && index === column.selectedWs
|
||||
current: modelData.focused === true
|
||||
animateMoves: root.animate
|
||||
windows: modelData.windows ?? []
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.horizontalCenterOffset: (index - row.selectedWs) * root.theme.carouselStepX + card.spreadX
|
||||
anchors.verticalCenterOffset: (index - column.selectedWs) * root.theme.carouselStepY + card.spreadY
|
||||
opacity: {
|
||||
if (card.opensLoop)
|
||||
return 0;
|
||||
@@ -613,7 +661,26 @@ PanelWindow {
|
||||
z: card.selected ? 1 : 0
|
||||
enabled: !root.windowsOpen
|
||||
|
||||
onActivated: root.activateAt(row.rowIndex, index)
|
||||
transform: Rotation {
|
||||
origin.x: card.width / 2
|
||||
origin.y: card.height / 2
|
||||
axis {
|
||||
x: 1
|
||||
y: 0
|
||||
z: 0
|
||||
}
|
||||
angle: card.tiltX
|
||||
|
||||
Behavior on angle {
|
||||
enabled: root.animate
|
||||
NumberAnimation {
|
||||
duration: root.theme.carouselDuration
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onActivated: root.activateAt(column.columnIndex, index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-15
@@ -31,18 +31,24 @@ QtObject {
|
||||
readonly property real cardSpacing: 36
|
||||
readonly property real cardRadius: 16
|
||||
readonly property real monitorLabelSize: 18
|
||||
readonly property real monitorLabelGap: 12
|
||||
// Distance from the top of the screen to each monitor's name,
|
||||
// which sits above the rename 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
|
||||
|
||||
// One step across a monitor's workspaces, and one step between monitors.
|
||||
// The gap above a card leaves room for that monitor's name.
|
||||
readonly property real carouselStepX: cardWidth + cardSpacing
|
||||
readonly property real carouselStepY: cardHeight + 180
|
||||
// Each monitor is a column of its workspaces. One step between
|
||||
// monitors (sideways), and one step between workspaces (down).
|
||||
readonly property real carouselStepX: cardWidth + 120
|
||||
readonly property real carouselStepY: cardHeight + cardSpacing
|
||||
readonly property real carouselFadeStep: 0.35
|
||||
readonly property real carouselMaxFade: 0.85
|
||||
readonly property real carouselScaleStep: 0.08
|
||||
readonly property real carouselMaxScaleReduction: 0.3
|
||||
readonly property real carouselRowFadeStep: 0.4
|
||||
readonly property real carouselRowMaxFade: 0.72
|
||||
readonly property real carouselMonitorFadeStep: 0.4
|
||||
readonly property real carouselMonitorMaxFade: 0.72
|
||||
readonly property int carouselDuration: 220
|
||||
|
||||
// A swipe must cross this many pixels (or angleDelta units) before the
|
||||
@@ -57,16 +63,25 @@ QtObject {
|
||||
|
||||
// ── window loop (Ctrl+B) ────────────────────────────────────────────
|
||||
|
||||
// Off by default: every niri preview screenshot also replaces the
|
||||
// clipboard. Hyprland previews are live and never touch it.
|
||||
readonly property bool niriScreenshots: false
|
||||
// Live previews on Hyprland.
|
||||
readonly property bool livePreviews: true
|
||||
// Still snapshots taken when the loop opens. On Hyprland they back up the
|
||||
// live previews and use grim. On niri they use niri's own screenshot,
|
||||
// which also replaces the clipboard, and need wl-paste.
|
||||
readonly property bool snapshotPreviewsHyprland: true
|
||||
readonly property bool snapshotPreviewsNiri: true
|
||||
|
||||
// How far the other workspace cards move out while the loop is open:
|
||||
// sideways in the selected row, up or down for the other rows.
|
||||
readonly property real loopSpreadX: 420
|
||||
readonly property real loopSpreadY: 260
|
||||
// While the loop is open, other monitors sit this far past its edge,
|
||||
// and workspaces above and below move out by loopSpreadY.
|
||||
readonly property real loopEdgeGap: 40
|
||||
readonly property real loopSpreadY: 60
|
||||
// Extra fade on those cards while the loop is open.
|
||||
readonly property real loopHiddenFade: 0.35
|
||||
readonly property real loopHiddenFade: 0.75
|
||||
// Tilt in degrees while the loop is open, so the other cards look part
|
||||
// of the same 3D scene. Workspaces above and below lean back as if on a
|
||||
// drum; other monitors turn to face the middle.
|
||||
readonly property real loopTiltX: 35
|
||||
readonly property real loopTiltY: 30
|
||||
// Size the loop grows from as it appears.
|
||||
readonly property real loopStartScale: 0.6
|
||||
readonly property int loopExpandDuration: 280
|
||||
@@ -104,4 +119,9 @@ QtObject {
|
||||
readonly property real loopBackShade: 0.55
|
||||
|
||||
readonly property int loopTurnDuration: 320
|
||||
|
||||
// When Up/Down switch workspaces inside the loop, the new windows slide
|
||||
// in from this far away and fade up.
|
||||
readonly property real loopSwitchOffset: 160
|
||||
readonly property int loopSwitchDuration: 260
|
||||
}
|
||||
@@ -32,12 +32,32 @@ Item {
|
||||
return Math.max(root.theme.loopMinRadius, Math.min(natural, widest));
|
||||
}
|
||||
|
||||
// About how far the loop reaches sideways from its center, card edges
|
||||
// included. Sampled over the front half so it stays still while turning.
|
||||
readonly property real reachX: {
|
||||
const half = root.theme.loopCardWidth / 2;
|
||||
if (root.count <= 1)
|
||||
return half;
|
||||
const focal = root.theme.loopFocalLength;
|
||||
let widest = half;
|
||||
for (let i = 1; i <= 16; i++) {
|
||||
const angle = i / 16 * Math.PI / 2;
|
||||
const depthScale = focal / (focal + root.radius * (1 - Math.cos(angle)));
|
||||
const edge = (root.radius * Math.sin(angle) + half * Math.cos(angle)) * depthScale;
|
||||
widest = Math.max(widest, edge);
|
||||
}
|
||||
return widest;
|
||||
}
|
||||
|
||||
// Selected step. It is not wrapped, so the loop can keep turning the
|
||||
// same way. Use selectedIndex for the position in the window list.
|
||||
property int targetStep: 0
|
||||
// Follows targetStep smoothly and drives every card position.
|
||||
property real turn: 0
|
||||
property bool animate: false
|
||||
// Offset and fade of the loop while it slides in after a workspace switch.
|
||||
property real slideY: 0
|
||||
property real switchFade: 1
|
||||
|
||||
readonly property int selectedIndex: root.wrapIndex(root.targetStep)
|
||||
|
||||
@@ -65,6 +85,24 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
ParallelAnimation {
|
||||
id: switchAnim
|
||||
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "slideY"
|
||||
to: 0
|
||||
duration: root.theme.loopSwitchDuration
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "switchFade"
|
||||
to: 1
|
||||
duration: root.theme.loopSwitchDuration
|
||||
}
|
||||
}
|
||||
|
||||
function wrapIndex(step: int): int {
|
||||
if (root.count === 0)
|
||||
return 0;
|
||||
@@ -96,6 +134,16 @@ Item {
|
||||
root.compositor.takeScreenshots(list.map(w => w.key));
|
||||
}
|
||||
|
||||
// Show another workspace. The new windows slide in from below when
|
||||
// direction is positive, from above when negative.
|
||||
function switchIn(direction: int): void {
|
||||
switchAnim.stop();
|
||||
root.slideY = direction * root.theme.loopSwitchOffset;
|
||||
root.switchFade = 0;
|
||||
root.seed();
|
||||
switchAnim.start();
|
||||
}
|
||||
|
||||
function step(delta: int): void {
|
||||
if (root.count === 0)
|
||||
return;
|
||||
@@ -118,6 +166,8 @@ Item {
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: root.slideY
|
||||
opacity: root.switchFade
|
||||
visible: root.count === 0
|
||||
color: root.theme.labelColor
|
||||
font.pixelSize: root.theme.loopEmptySize
|
||||
@@ -129,7 +179,8 @@ Item {
|
||||
Item {
|
||||
id: stage
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: root.theme.loopBackLift / 2
|
||||
anchors.verticalCenterOffset: root.theme.loopBackLift / 2 + root.slideY
|
||||
opacity: root.switchFade
|
||||
|
||||
Repeater {
|
||||
model: root.windows
|
||||
|
||||
@@ -27,7 +27,7 @@ Rectangle {
|
||||
border.color: root.selected ? root.theme.fieldBorder : root.theme.barBorder
|
||||
clip: true
|
||||
|
||||
Behavior on anchors.horizontalCenterOffset {
|
||||
Behavior on anchors.verticalCenterOffset {
|
||||
enabled: root.animateMoves
|
||||
NumberAnimation {
|
||||
duration: root.theme.carouselDuration
|
||||
|
||||
@@ -13,7 +13,9 @@ ShellRoot {
|
||||
|
||||
Compositor {
|
||||
id: compositor
|
||||
niriScreenshots: theme.niriScreenshots
|
||||
livePreviews: theme.livePreviews
|
||||
snapshotPreviewsHyprland: theme.snapshotPreviewsHyprland
|
||||
snapshotPreviewsNiri: theme.snapshotPreviewsNiri
|
||||
}
|
||||
|
||||
Theme {
|
||||
|
||||
Reference in new issue
Block a user