From 23a548e034800be68b7a5ab2b7c4f81582847b39 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sun, 9 Nov 2025 13:50:20 -0500 Subject: [PATCH] BarContent: fix screen assignment --- Modules/MainScreen/AllScreens.qml | 4 +- Modules/MainScreen/BarContentWindow.qml | 82 ++++++++++--------------- Modules/Panels/Tray/TrayMenuPanel.qml | 1 + 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/Modules/MainScreen/AllScreens.qml b/Modules/MainScreen/AllScreens.qml index 7ae5a29c..3211a332 100644 --- a/Modules/MainScreen/AllScreens.qml +++ b/Modules/MainScreen/AllScreens.qml @@ -53,7 +53,9 @@ Variants { } asynchronous: false - sourceComponent: BarContentWindow {} + sourceComponent: BarContentWindow { + screen: modelData + } onLoaded: { Logger.d("Shell", "BarContentWindow created for", modelData?.name) diff --git a/Modules/MainScreen/BarContentWindow.qml b/Modules/MainScreen/BarContentWindow.qml index 9637a410..b83e975c 100644 --- a/Modules/MainScreen/BarContentWindow.qml +++ b/Modules/MainScreen/BarContentWindow.qml @@ -12,61 +12,45 @@ import qs.Modules.Bar * This window contains only the bar widgets (content), while the background * is rendered in MainScreen's unified Shape system. This separation prevents * fullscreen redraws when bar widgets redraw. + * + * This component should be instantiated once per screen by AllScreens.qml */ -Variants { - model: Quickshell.screens +PanelWindow { + id: barWindow - delegate: Loader { - id: barWindowLoader + // Note: screen property is inherited from PanelWindow and should be set by parent + color: Color.transparent // Transparent - background is in MainScreen below - required property ShellScreen modelData + Component.onCompleted: { + Logger.d("BarContentWindow", "Bar content window created for screen:", barWindow.screen?.name) + } - // Only create window if bar should be visible on this screen - active: { - if (!modelData || !modelData.name) - return false - var monitors = Settings.data.bar.monitors || [] - return BarService.isVisible && (monitors.length === 0 || monitors.includes(modelData.name)) - } + // Wayland layer configuration + WlrLayershell.namespace: "noctalia-bar-content-" + (barWindow.screen?.name || "unknown") + WlrLayershell.layer: WlrLayer.Top + WlrLayershell.exclusionMode: ExclusionMode.Ignore // Don't reserve space - BarExclusionZone in MainScreen handles that - sourceComponent: PanelWindow { - id: barWindow - screen: modelData + // Position and size to match bar location + readonly property string barPosition: Settings.data.bar.position || "top" + readonly property bool barIsVertical: barPosition === "left" || barPosition === "right" + readonly property bool barFloating: Settings.data.bar.floating || false + readonly property real barMarginH: barFloating ? Settings.data.bar.marginHorizontal * Style.marginXL : 0 + readonly property real barMarginV: barFloating ? Settings.data.bar.marginVertical * Style.marginXL : 0 - color: Color.transparent // Transparent - background is in MainScreen below + // Anchor to the bar's edge + anchors { + top: barPosition === "top" || barIsVertical + bottom: barPosition === "bottom" || barIsVertical + left: barPosition === "left" || !barIsVertical + right: barPosition === "right" || !barIsVertical + } + // Set to FULL screen dimensions - margins will reduce the actual window size + implicitWidth: (barIsVertical ? (Style.barHeight + 1) : barWindow.screen.width) + barMarginH + implicitHeight: (barIsVertical ? barWindow.screen.height : Style.barHeight) + barMarginV - Component.onCompleted: { - Logger.d("BarContentWindow", "Bar content window created for screen:", screen?.name) - } - - // Wayland layer configuration - WlrLayershell.namespace: "noctalia-bar-content-" + (screen?.name || "unknown") - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.exclusionMode: ExclusionMode.Ignore // Don't reserve space - BarExclusionZone in MainScreen handles that - - // Position and size to match bar location - readonly property string barPosition: Settings.data.bar.position || "top" - readonly property bool barIsVertical: barPosition === "left" || barPosition === "right" - readonly property bool barFloating: Settings.data.bar.floating || false - readonly property real barMarginH: barFloating ? Settings.data.bar.marginHorizontal * Style.marginXL : 0 - readonly property real barMarginV: barFloating ? Settings.data.bar.marginVertical * Style.marginXL : 0 - - // Anchor to the bar's edge - anchors { - top: barPosition === "top" || barIsVertical - bottom: barPosition === "bottom" || barIsVertical - left: barPosition === "left" || !barIsVertical - right: barPosition === "right" || !barIsVertical - } - // Set to FULL screen dimensions - margins will reduce the actual window size - implicitWidth: (barIsVertical ? (Style.barHeight + 1) : screen.width) + barMarginH - implicitHeight: (barIsVertical ? screen.height : Style.barHeight) + barMarginV - - // Bar content - just the widgets, no background - Bar { - anchors.fill: parent - screen: modelData - } - } + // Bar content - just the widgets, no background + Bar { + anchors.fill: parent + screen: barWindow.screen } } diff --git a/Modules/Panels/Tray/TrayMenuPanel.qml b/Modules/Panels/Tray/TrayMenuPanel.qml index fa354fb7..23ed1d74 100644 --- a/Modules/Panels/Tray/TrayMenuPanel.qml +++ b/Modules/Panels/Tray/TrayMenuPanel.qml @@ -135,6 +135,7 @@ SmartPanel { maxWidth = Math.max(maxWidth, requiredWidth) } } catch (e) { + // Silently ignore errors during width calculation } }