From 57d912efc82e81dc56fc5bf41bcf97252c9e8da7 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Mon, 1 Sep 2025 15:03:30 -0400 Subject: [PATCH] Toast: proper scaling + brought back assignation to WlrLayer.Overlay so its above all. --- Modules/Bar/Widgets/Tray.qml | 2 +- Modules/Toast/ToastOverlay.qml | 18 ++++++++++-------- Widgets/NToast.qml | 8 +++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index b44e60e..f29d7b7 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -163,7 +163,7 @@ Rectangle { Loader { id: trayMenu - source: "../Extras/TrayMenu.qml" + source: "../Extras/TrayMenu.qml" } } } diff --git a/Modules/Toast/ToastOverlay.qml b/Modules/Toast/ToastOverlay.qml index db880b5..d86a549 100644 --- a/Modules/Toast/ToastOverlay.qml +++ b/Modules/Toast/ToastOverlay.qml @@ -12,6 +12,7 @@ Variants { delegate: Loader { required property ShellScreen modelData property real scaling: ScalingService.getScreenScale(modelData) + Connections { target: ScalingService function onScaleChanged(screenName, scale) { @@ -34,28 +35,29 @@ Variants { anchors { top: Settings.data.bar.position === "top" bottom: Settings.data.bar.position === "bottom" - left: true - right: true } + // Set a width instead of anchoring left/right so we can click on the side of the toast + implicitWidth: 500 * scaling + + // Small height when hidden, appropriate height when visible + implicitHeight: Math.round(toast.visible ? toast.height + Style.marginM * scaling : 1) + // Set margins based on bar position margins.top: Settings.data.bar.position === "top" ? (Style.barHeight + Style.marginS) * scaling : 0 margins.bottom: Settings.data.bar.position === "bottom" ? (Style.barHeight + Style.marginS) * scaling : 0 - // Small height when hidden, appropriate height when visible - implicitHeight: toast.visible ? toast.height + Style.marginS * scaling : 1 - // Transparent background color: Color.transparent - // High layer to appear above other panels - //WlrLayershell.layer: WlrLayer.Overlay + // Overlay layer to appear above other panels + WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.keyboardFocus: WlrKeyboardFocus.None exclusionMode: PanelWindow.ExclusionMode.Ignore NToast { id: toast - scaling: scaling + screen: modelData // Simple positioning - margins already account for bar targetY: Style.marginS * scaling diff --git a/Widgets/NToast.qml b/Widgets/NToast.qml index c5fbee1..8865c6b 100644 --- a/Widgets/NToast.qml +++ b/Widgets/NToast.qml @@ -2,8 +2,10 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Effects +import Quickshell import qs.Commons import qs.Widgets +import qs.Services Item { id: root @@ -14,7 +16,8 @@ Item { property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide property bool persistent: false // If true, requires manual dismiss - property real scaling: 1.0 // Will be set by parent + required property ShellScreen screen + property real scaling: 1.0 // Animation properties property real targetY: 0 @@ -31,6 +34,9 @@ Item { z: 1000 // High z-index to appear above everything function show() { + // NToast updates its scaling when showing. + scaling = ScalingService.getScreenScale(screen) + visible = true showAnimation.start() if (duration > 0 && !persistent) {