Toast: proper scaling + brought back assignation to WlrLayer.Overlay so its above all.

This commit is contained in:
LemmyCook 2025-09-01 15:03:30 -04:00
parent 87067f7062
commit 57d912efc8
3 changed files with 18 additions and 10 deletions

View file

@ -163,7 +163,7 @@ Rectangle {
Loader { Loader {
id: trayMenu id: trayMenu
source: "../Extras/TrayMenu.qml" source: "../Extras/TrayMenu.qml"
} }
} }
} }

View file

@ -12,6 +12,7 @@ Variants {
delegate: Loader { delegate: Loader {
required property ShellScreen modelData required property ShellScreen modelData
property real scaling: ScalingService.getScreenScale(modelData) property real scaling: ScalingService.getScreenScale(modelData)
Connections { Connections {
target: ScalingService target: ScalingService
function onScaleChanged(screenName, scale) { function onScaleChanged(screenName, scale) {
@ -34,28 +35,29 @@ Variants {
anchors { anchors {
top: Settings.data.bar.position === "top" top: Settings.data.bar.position === "top"
bottom: Settings.data.bar.position === "bottom" 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 // Set margins based on bar position
margins.top: Settings.data.bar.position === "top" ? (Style.barHeight + Style.marginS) * scaling : 0 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 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 // Transparent background
color: Color.transparent color: Color.transparent
// High layer to appear above other panels // Overlay layer to appear above other panels
//WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
exclusionMode: PanelWindow.ExclusionMode.Ignore exclusionMode: PanelWindow.ExclusionMode.Ignore
NToast { NToast {
id: toast id: toast
scaling: scaling screen: modelData
// Simple positioning - margins already account for bar // Simple positioning - margins already account for bar
targetY: Style.marginS * scaling targetY: Style.marginS * scaling

View file

@ -2,8 +2,10 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Effects import QtQuick.Effects
import Quickshell
import qs.Commons import qs.Commons
import qs.Widgets import qs.Widgets
import qs.Services
Item { Item {
id: root id: root
@ -14,7 +16,8 @@ Item {
property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide
property bool persistent: false // If true, requires manual dismiss 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 // Animation properties
property real targetY: 0 property real targetY: 0
@ -31,6 +34,9 @@ Item {
z: 1000 // High z-index to appear above everything z: 1000 // High z-index to appear above everything
function show() { function show() {
// NToast updates its scaling when showing.
scaling = ScalingService.getScreenScale(screen)
visible = true visible = true
showAnimation.start() showAnimation.start()
if (duration > 0 && !persistent) { if (duration > 0 && !persistent) {