Taskbar: Filter by same output and active workspaces.

This commit is contained in:
Leopold Luley
2025-09-29 11:01:14 +02:00
parent 49961882dd
commit e6b0be77e7
4 changed files with 133 additions and 17 deletions
+53 -6
View File
@@ -14,7 +14,7 @@ Singleton {
// Generic workspace and window data
property ListModel workspaces: ListModel {}
property var windows: []
property ListModel windows: ListModel {}
property int focusedWindowIndex: -1
// Generic events
@@ -82,10 +82,17 @@ Singleton {
workspaceChanged()
})
backend.activeWindowChanged.connect(activeWindowChanged)
backend.activeWindowChanged.connect(() => {
// Sync active window when it changes
// TODO: Avoid re-syncing all windows
syncWindows()
// Forward the signal
activeWindowChanged()
})
backend.windowListChanged.connect(() => {
// Sync windows when they change
windows = backend.windows
syncWindows()
// Forward the signal
windowListChanged()
})
@@ -97,7 +104,7 @@ Singleton {
// Initial sync
syncWorkspaces()
windows = backend.windows
syncWindows()
focusedWindowIndex = backend.focusedWindowIndex
}
@@ -110,10 +117,20 @@ 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])
}
// Emit signal to notify listeners that workspace list has been updated
windowListChanged()
}
// Get window title for focused window
function getFocusedWindowTitle() {
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) {
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.count) {
return windows[focusedWindowIndex].title || ""
}
return ""
@@ -138,14 +155,44 @@ Singleton {
}
return null
}
// Get active workspaces
function getActiveWorkspaces() {
const activeWorkspaces = []
for (var i = 0; i < workspaces.count; i++) {
const ws = workspaces.get(i)
if (ws.isActive) {
activeWorkspaces.push(ws)
}
}
return activeWorkspaces
}
// Set focused window
function focusWindow(windowId) {
if (backend && backend.focusWindow) {
backend.focusWindow(windowId)
} else {
Logger.warn("Compositor", "No backend available for window focus")
}
}
// Get focused window
function getFocusedWindow() {
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) {
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.count) {
return windows[focusedWindowIndex]
}
return null
}
// Close window
function closeWindow(windowId) {
if (backend && backend.closeWindow) {
backend.closeWindow(windowId)
} else {
Logger.warn("Compositor", "No backend available for window closing")
}
}
// Session management
function logout() {