CompositorService: improved Hyprland detection so there is no warning on Niri.

This commit is contained in:
LemmyCook 2025-09-12 22:55:13 -04:00
parent b66bb46fc1
commit dd4641eedd

View file

@ -15,6 +15,8 @@ Singleton {
property bool isHyprland: false property bool isHyprland: false
property bool isNiri: false property bool isNiri: false
readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
// Generic workspace and window data // Generic workspace and window data
property ListModel workspaces: ListModel {} property ListModel workspaces: ListModel {}
property var windows: [] property var windows: []
@ -50,42 +52,49 @@ Singleton {
} }
// Hyprland connections // Hyprland connections
Connections { Loader {
target: Hyprland.workspaces active: isHyprland
enabled: isHyprland sourceComponent: Component {
function onValuesChanged() { Item {
try { Connections {
updateHyprlandWorkspaces() target: Hyprland.workspaces
workspaceChanged() enabled: isHyprland
} catch (e) { function onValuesChanged() {
Logger.error("Compositor", "Error in workspaces onValuesChanged:", e) try {
} updateHyprlandWorkspaces()
} workspaceChanged()
} } catch (e) {
Logger.error("Compositor", "Error in workspaces onValuesChanged:", e)
}
}
}
Connections { Connections {
target: Hyprland.toplevels target: Hyprland.toplevels
enabled: isHyprland enabled: isHyprland
function onValuesChanged() { function onValuesChanged() {
try { try {
// Use debounced update to prevent too frequent calls // Use debounced update to prevent too frequent calls
updateTimer.restart() updateTimer.restart()
} catch (e) { } catch (e) {
Logger.error("Compositor", "Error in toplevels onValuesChanged:", e) Logger.error("Compositor", "Error in toplevels onValuesChanged:", e)
} }
} }
} }
Connections { Connections {
target: Hyprland target: Hyprland
enabled: isHyprland enabled: isHyprland
function onRawEvent(event) { function onRawEvent(event) {
try { try {
updateHyprlandWorkspaces() updateHyprlandWorkspaces()
workspaceChanged() workspaceChanged()
updateTimer.restart() updateTimer.restart()
} catch (e) { } catch (e) {
Logger.error("Compositor", "Error in rawEvent:", e) Logger.error("Compositor", "Error in rawEvent:", e)
}
}
}
} }
} }
} }
@ -93,7 +102,7 @@ Singleton {
function detectCompositor() { function detectCompositor() {
try { try {
// Try Hyprland first // Try Hyprland first
if (Hyprland.eventSocketPath) { if (hyprlandSignature && hyprlandSignature.length > 0) {
compositorType = "hyprland" compositorType = "hyprland"
isHyprland = true isHyprland = true
isNiri = false isNiri = false