From c53dd6fadea3db6e8fa43dc66d2c5cb0944514c6 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Mon, 29 Sep 2025 15:04:13 -0400 Subject: [PATCH] Compositor: fix getFocusedWindowTitle. Since active workspace has been implemented. + autoformatting --- Modules/Bar/Widgets/Taskbar.qml | 9 +++--- Modules/Launcher/Launcher.qml | 29 +++++++++++-------- .../Launcher/Plugins/ApplicationsPlugin.qml | 12 +++++--- Services/CompositorService.qml | 12 ++++---- Services/HyprlandService.qml | 4 +-- Services/NiriService.qml | 20 ++++++------- 6 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index 8cfd8564..d37100dd 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -12,7 +12,7 @@ Rectangle { id: root property ShellScreen screen property real scaling: 1.0 - + // Widget properties passed from Bar.qml for per-instance settings property string widgetId: "" property string section: "" @@ -22,7 +22,7 @@ Rectangle { readonly property bool isVerticalBar: Settings.data.bar.position === "left" || Settings.data.bar.position === "right" readonly property bool compact: (Settings.data.bar.density === "compact") readonly property real itemSize: compact ? Style.capsuleHeight * 0.9 * scaling : Style.capsuleHeight * 0.8 * scaling - + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { if (section && sectionWidgetIndex >= 0) { @@ -62,9 +62,8 @@ Rectangle { delegate: Item { id: taskbarItem required property var modelData - - visible: (!widgetSettings.onlySameOutput || modelData.output == screen.name) - && (!widgetSettings.onlyActiveWorkspaces || CompositorService.getActiveWorkspaces().map(ws => ws.id).includes(modelData.workspaceId)) + + visible: (!widgetSettings.onlySameOutput || modelData.output == screen.name) && (!widgetSettings.onlyActiveWorkspaces || CompositorService.getActiveWorkspaces().map(ws => ws.id).includes(modelData.workspaceId)) Layout.preferredWidth: root.itemSize Layout.preferredHeight: root.itemSize diff --git a/Modules/Launcher/Launcher.qml b/Modules/Launcher/Launcher.qml index 5b705bd4..e79bee6b 100644 --- a/Modules/Launcher/Launcher.qml +++ b/Modules/Launcher/Launcher.qml @@ -302,7 +302,9 @@ NPanel { positionViewAtIndex(currentIndex, ListView.Contain) } } - onModelChanged: {} + onModelChanged: { + + } delegate: Rectangle { id: entry @@ -313,11 +315,14 @@ NPanel { // Pin helpers function togglePin(appId) { - if (!appId) return + if (!appId) + return let arr = (Settings.data.dock.pinnedApps || []).slice() const idx = arr.indexOf(appId) - if (idx >= 0) arr.splice(idx, 1) - else arr.push(appId) + if (idx >= 0) + arr.splice(idx, 1) + else + arr.push(appId) Settings.data.dock.pinnedApps = arr } @@ -506,13 +511,13 @@ NPanel { z: -1 hoverEnabled: true cursorShape: Qt.PointingHandCursor - onClicked: (mouse) => { - if (mouse.button === Qt.LeftButton) { - selectedIndex = index - ui.activate() - mouse.accepted = true - } - } + onClicked: mouse => { + if (mouse.button === Qt.LeftButton) { + selectedIndex = index + ui.activate() + mouse.accepted = true + } + } acceptedButtons: Qt.LeftButton } } @@ -537,4 +542,4 @@ NPanel { } } } -} \ No newline at end of file +} diff --git a/Modules/Launcher/Plugins/ApplicationsPlugin.qml b/Modules/Launcher/Plugins/ApplicationsPlugin.qml index 4cbd7f1a..84df4450 100644 --- a/Modules/Launcher/Plugins/ApplicationsPlugin.qml +++ b/Modules/Launcher/Plugins/ApplicationsPlugin.qml @@ -76,7 +76,8 @@ Item { // Favorites first const aFav = favoriteApps.includes(getAppKey(a)) const bFav = favoriteApps.includes(getAppKey(b)) - if (aFav !== bFav) return aFav ? -1 : 1 + if (aFav !== bFav) + return aFav ? -1 : 1 const ua = getUsageCount(a) const ub = getUsageCount(b) if (ub !== ua) @@ -87,7 +88,8 @@ Item { sorted = entries.slice().sort((a, b) => { const aFav = favoriteApps.includes(getAppKey(a)) const bFav = favoriteApps.includes(getAppKey(b)) - if (aFav !== bFav) return aFav ? -1 : 1 + if (aFav !== bFav) + return aFav ? -1 : 1 return (a.name || "").toLowerCase().localeCompare((b.name || "").toLowerCase()) }) } @@ -108,8 +110,10 @@ Item { const nonFav = [] for (const r of fuzzyResults) { const app = r.obj - if (favoriteApps.includes(getAppKey(app))) fav.push(r) - else nonFav.push(r) + if (favoriteApps.includes(getAppKey(app))) + fav.push(r) + else + nonFav.push(r) } return fav.concat(nonFav).map(result => createResultEntry(result.obj)) } else { diff --git a/Services/CompositorService.qml b/Services/CompositorService.qml index c2380fda..b5cd62d2 100644 --- a/Services/CompositorService.qml +++ b/Services/CompositorService.qml @@ -117,12 +117,12 @@ Singleton { // Emit signal to notify listeners that workspace list has been updated workspacesChanged() } - + function syncWindows() { windows.clear() const ws = backend.windows for (var i = 0; i < ws.length; i++) { - windows.append(ws[i]) + windows.append(ws[i]) } // Emit signal to notify listeners that workspace list has been updated windowListChanged() @@ -131,7 +131,7 @@ Singleton { // Get window title for focused window function getFocusedWindowTitle() { if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.count) { - return windows[focusedWindowIndex].title || "" + return windows.get(focusedWindowIndex).title || "" } return "" } @@ -155,7 +155,7 @@ Singleton { } return null } - + // Get active workspaces function getActiveWorkspaces() { const activeWorkspaces = [] @@ -167,7 +167,7 @@ Singleton { } return activeWorkspaces } - + // Set focused window function focusWindow(windowId) { if (backend && backend.focusWindow) { @@ -184,7 +184,7 @@ Singleton { } return null } - + // Close window function closeWindow(windowId) { if (backend && backend.closeWindow) { diff --git a/Services/HyprlandService.qml b/Services/HyprlandService.qml index 6c26dba6..1cd43f1e 100644 --- a/Services/HyprlandService.qml +++ b/Services/HyprlandService.qml @@ -277,7 +277,7 @@ Item { Logger.error("HyprlandService", "Failed to switch workspace:", e) } } - + function focusWindow(windowId) { try { Hyprland.dispatch(`focuswindow ${windowId}`) @@ -285,7 +285,7 @@ Item { Logger.error("HyprlandService", "Failed to switch window:", e) } } - + function closeWindow(windowId) { try { Hyprland.dispatch(`killwindow ${windowId}`) diff --git a/Services/NiriService.qml b/Services/NiriService.qml index c298dbc2..3fe4af7a 100644 --- a/Services/NiriService.qml +++ b/Services/NiriService.qml @@ -101,7 +101,7 @@ Item { break } } - + windowsList.push({ "id": win.id, "title": win.title || "", @@ -170,7 +170,7 @@ Item { try { const windowData = eventData.window const existingIndex = windows.findIndex(w => w.id === windowData.id) - + var output = null for (var i = 0; i < workspaces.count; i++) { if (workspaces.get(i).id === windowData.workspace_id) { @@ -251,17 +251,17 @@ Item { break } } - + windowsList.push({ "id": win.id, "title": win.title || "", "appId": win.app_id || "", "workspaceId": win.workspace_id || null, "isFocused": win.is_focused === true, - "output": output, + "output": output }) } - + windowsList.sort((a, b) => a.id - b.id) windows = windowsList windowListChanged() @@ -284,18 +284,18 @@ Item { function handleWindowFocusChanged(eventData) { try { const focusedId = eventData.id - + if (windows[focusedWindowIndex]) { windows[focusedWindowIndex].isFocused = false } if (focusedId) { const newIndex = windows.findIndex(w => w.id === focusedId) - + if (newIndex >= 0) { windows[newIndex].isFocused = true } - + focusedWindowIndex = newIndex >= 0 ? newIndex : -1 } else { focusedWindowIndex = -1 @@ -315,7 +315,7 @@ Item { Logger.error("NiriService", "Failed to switch workspace:", e) } } - + function focusWindow(windowId) { try { Quickshell.execDetached(["niri", "msg", "action", "focus-window", "--id", windowId.toString()]) @@ -323,7 +323,7 @@ Item { Logger.error("NiriService", "Failed to switch window:", e) } } - + function closeWindow(windowId) { try { Quickshell.execDetached(["niri", "msg", "action", "close-window", "--id", windowId.toString()])