diff --git a/modules/overview/OverviewWindow.qml b/modules/overview/OverviewWindow.qml index 17c40b4..e19ae71 100644 --- a/modules/overview/OverviewWindow.qml +++ b/modules/overview/OverviewWindow.qml @@ -78,7 +78,7 @@ Item { // Window const isFullscreen = (windowData?.fullscreen ?? 0) > 0; if (isFullscreen || thisWsId === undefined) return true; - return !HyprlandData.windowList.some(w => w.workspace?.id === thisWsId && (w.fullscreen ?? 0) > 0); + return !HyprlandData.fullscreenWorkspaces[thisWsId]; } clip: true @@ -122,7 +122,7 @@ Item { // Window width: root.cropToFill ? Math.max(parent.width, parent.height * srcAspect) : Math.min(parent.width, parent.height * srcAspect) height: root.cropToFill ? Math.max(parent.height, parent.width / srcAspect) : Math.min(parent.height, parent.width / srcAspect) captureSource: shouldCapturePreview ? root.toplevel : null - live: livePreviewEnabled + live: livePreviewEnabled && shouldCapturePreview layer.enabled: root.windowRounding > 0 layer.smooth: true layer.effect: MultiEffect { diff --git a/services/HyprlandData.qml b/services/HyprlandData.qml index ac8595b..fdf167f 100644 --- a/services/HyprlandData.qml +++ b/services/HyprlandData.qml @@ -14,12 +14,10 @@ Singleton { id: root property var windowList: [] property var windowByAddress: ({}) - property var workspaces: [] - property var workspaceById: ({}) + property var fullscreenWorkspaces: ({}) property var monitors: [] property bool pendingWindowsUpdate: false property bool pendingMonitorsUpdate: false - property bool pendingWorkspacesUpdate: false function updateWindowList() { getClients.running = true; } @@ -28,18 +26,16 @@ Singleton { getMonitors.running = true; } - function updateWorkspaces() { - getWorkspaces.running = true; - } - function updateAll() { - scheduleUpdates(true, true, true); + scheduleUpdates(true, true); } - function scheduleUpdates(windows, monitors, workspaces) { + function scheduleUpdates(windows, monitors) { + if (!GlobalStates.overviewOpen) + return; + pendingWindowsUpdate = pendingWindowsUpdate || !!windows; pendingMonitorsUpdate = pendingMonitorsUpdate || !!monitors; - pendingWorkspacesUpdate = pendingWorkspacesUpdate || !!workspaces; const debounceMs = Math.max(0, Config.options.hacks.hyprlandEventDebounceMs); if (debounceMs === 0) { @@ -59,10 +55,6 @@ Singleton { pendingMonitorsUpdate = false; updateMonitors(); } - if (pendingWorkspacesUpdate) { - pendingWorkspacesUpdate = false; - getWorkspaces.running = true; - } } function biggestWindowForWorkspace(workspaceId) { @@ -75,34 +67,42 @@ Singleton { } Component.onCompleted: { - scheduleUpdates(true, true, true); - flushPendingUpdates(); + if (GlobalStates.overviewOpen) { + root.updateAll(); + root.flushPendingUpdates(); + } + } + + Connections { + target: GlobalStates + + function onOverviewOpenChanged() { + if (GlobalStates.overviewOpen) { + root.updateAll(); + root.flushPendingUpdates(); + } else { + eventDebounceTimer.stop(); + root.pendingWindowsUpdate = false; + root.pendingMonitorsUpdate = false; + } + } } Connections { target: Hyprland function onRawEvent(event) { - const eventName = `${event?.name ?? event?.event ?? event?.type ?? ""}`; - if (["openlayer", "closelayer", "screencast"].includes(eventName)) + if (!GlobalStates.overviewOpen) return; + const eventName = `${event?.name ?? event?.event ?? event?.type ?? ""}`; if (eventName === "openwindow" || eventName === "closewindow" || eventName === "movewindow" || eventName === "movewindowv2" || eventName === "windowtitle") { - scheduleUpdates(true, false, true); + root.scheduleUpdates(true, false); return; } - if (eventName === "workspace" || eventName === "workspacev2" || eventName === "focusedmon" || eventName === "focusedmonv2" || eventName === "activewindow" || eventName === "activewindowv2") { - scheduleUpdates(false, false, true); - return; - } - - if (eventName.startsWith("monitor") || eventName === "configreloaded") { - scheduleUpdates(true, true, true); - return; - } - - scheduleUpdates(true, true, true); + if (eventName.startsWith("monitor") || eventName === "configreloaded") + root.scheduleUpdates(true, true); } } @@ -119,13 +119,20 @@ Singleton { stdout: StdioCollector { id: clientsCollector onStreamFinished: { + if (!GlobalStates.overviewOpen) + return; + root.windowList = JSON.parse(clientsCollector.text); let tempWinByAddress = {}; + let tempFullscreenWorkspaces = {}; for (var i = 0; i < root.windowList.length; ++i) { var win = root.windowList[i]; tempWinByAddress[win.address] = win; + if ((win.fullscreen ?? 0) > 0 && win.workspace?.id !== undefined) + tempFullscreenWorkspaces[win.workspace.id] = true; } root.windowByAddress = tempWinByAddress; + root.fullscreenWorkspaces = tempFullscreenWorkspaces; } } } @@ -136,24 +143,8 @@ Singleton { stdout: StdioCollector { id: monitorsCollector onStreamFinished: { - root.monitors = JSON.parse(monitorsCollector.text); - } - } - } - - Process { - id: getWorkspaces - command: ["hyprctl", "workspaces", "-j"] - stdout: StdioCollector { - id: workspacesCollector - onStreamFinished: { - root.workspaces = JSON.parse(workspacesCollector.text); - let tempWorkspaceById = {}; - for (var i = 0; i < root.workspaces.length; ++i) { - var ws = root.workspaces[i]; - tempWorkspaceById[ws.id] = ws; - } - root.workspaceById = tempWorkspaceById; + if (GlobalStates.overviewOpen) + root.monitors = JSON.parse(monitorsCollector.text); } } } diff --git a/shell.qml b/shell.qml index bc954e1..7cb123a 100644 --- a/shell.qml +++ b/shell.qml @@ -1,4 +1,3 @@ -//@ pragma UseQApplication //@ pragma Env QT_QUICK_CONTROLS_STYLE=Basic //@ pragma ShellId overzicht