Compositor: fix getFocusedWindowTitle. Since active workspace has been implemented.

+ autoformatting
This commit is contained in:
ItsLemmy
2025-09-29 15:04:13 -04:00
parent bb24b6904d
commit c53dd6fade
6 changed files with 47 additions and 39 deletions
+4 -5
View File
@@ -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
+17 -12
View File
@@ -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 {
}
}
}
}
}
@@ -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 {
+6 -6
View File
@@ -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) {
+2 -2
View File
@@ -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}`)
+10 -10
View File
@@ -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()])