ActiveWindow: add guarding for null title/icon (Hyprland)

CompositorService: turn title, appId and id into strings to perhaps
prevent crashing (Hyprland)
This commit is contained in:
Ly-sec 2025-09-09 14:11:18 +02:00
parent f7b0a28b1e
commit ed9ee65885
2 changed files with 9 additions and 5 deletions

View file

@ -47,14 +47,18 @@ RowLayout {
// Try CompositorService first // Try CompositorService first
const focusedWindow = CompositorService.getFocusedWindow() const focusedWindow = CompositorService.getFocusedWindow()
if (focusedWindow && focusedWindow.appId) { if (focusedWindow && focusedWindow.appId) {
return Icons.iconForAppId(focusedWindow.appId.toLowerCase()) const idValue = focusedWindow.appId
const normalizedId = (typeof idValue === 'string') ? idValue : String(idValue)
return Icons.iconForAppId(normalizedId.toLowerCase())
} }
// Fallback to ToplevelManager // Fallback to ToplevelManager
if (ToplevelManager && ToplevelManager.activeToplevel) { if (ToplevelManager && ToplevelManager.activeToplevel) {
const activeToplevel = ToplevelManager.activeToplevel const activeToplevel = ToplevelManager.activeToplevel
if (activeToplevel.appId) { if (activeToplevel.appId) {
return Icons.iconForAppId(activeToplevel.appId.toLowerCase()) const idValue2 = activeToplevel.appId
const normalizedId2 = (typeof idValue2 === 'string') ? idValue2 : String(idValue2)
return Icons.iconForAppId(normalizedId2.toLowerCase())
} }
} }

View file

@ -192,9 +192,9 @@ Singleton {
} }
windowsList.push({ windowsList.push({
"id": toplevel.address || "", "id": (toplevel.address !== undefined && toplevel.address !== null) ? String(toplevel.address) : "",
"title": toplevel.title || "", "title": (toplevel.title !== undefined && toplevel.title !== null) ? String(toplevel.title) : "",
"appId": appId, "appId": (appId !== undefined && appId !== null) ? String(appId) : "",
"workspaceId": toplevel.workspace?.id || null, "workspaceId": toplevel.workspace?.id || null,
"isFocused": toplevel.activated === true "isFocused": toplevel.activated === true
}) })