From c595727b9440734b5626a467781d2bbeec486fac Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 12 Dec 2025 15:37:39 -0500 Subject: [PATCH] osd: optimize surface damage fixes #994 --- CHANGELOG.MD | 1 + quickshell/Modules/Toast.qml | 26 +++++++++++++++++++------- quickshell/Widgets/DankOSD.qml | 15 +++++++++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d5f71582..28f89bf1 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -3,3 +3,4 @@ - Added clipboard and clipboard history integration - Added swipe to dismiss notification popups and from center - Added paste from clipboard history view - requires wtype +- Optimize surface damage of OSD & Toast diff --git a/quickshell/Modules/Toast.qml b/quickshell/Modules/Toast.qml index bbead194..03b0e288 100644 --- a/quickshell/Modules/Toast.qml +++ b/quickshell/Modules/Toast.qml @@ -16,6 +16,10 @@ PanelWindow { property real frozenWidth: 0 readonly property string copiedText: I18n.tr("Copied!") + readonly property real dpr: modelData ? CompositorService.getScreenScale(modelData) : 1 + readonly property real shadowBuffer: 5 + readonly property real toastY: Theme.barHeight - 4 + (SettingsData.barConfigs[0]?.spacing ?? 4) + 2 + Connections { target: ToastService function onToastVisibleChanged() { @@ -23,7 +27,6 @@ PanelWindow { shouldBeVisible = true; visible = true; } else { - // Freeze the width before starting exit animation frozenWidth = toast.width; shouldBeVisible = false; closeTimer.restart(); @@ -48,13 +51,22 @@ PanelWindow { WlrLayershell.keyboardFocus: WlrKeyboardFocus.None color: "transparent" + readonly property real toastWidth: shouldBeVisible ? Math.min(900, messageText.implicitWidth + statusIcon.width + Theme.spacingM + (ToastService.hasDetails ? (expandButton.width + closeButton.width + 4) : (ToastService.currentLevel === ToastService.levelError ? closeButton.width + Theme.spacingS : 0)) + Theme.spacingL * 2 + Theme.spacingM * 2) : frozenWidth + readonly property real toastHeight: toastContent.height + Theme.spacingL * 2 + anchors { top: true left: true - right: true - bottom: true } + WlrLayershell.margins { + left: Math.max(0, Theme.snap((modelData?.width ?? 1920) / 2 - toastWidth / 2 - shadowBuffer, dpr)) + top: Math.max(0, Theme.snap(toastY - shadowBuffer, dpr)) + } + + implicitWidth: toastWidth + (shadowBuffer * 2) + implicitHeight: toastHeight + (shadowBuffer * 2) + Rectangle { id: toast @@ -67,10 +79,10 @@ PanelWindow { } } - width: shouldBeVisible ? Math.min(900, messageText.implicitWidth + statusIcon.width + Theme.spacingM + (ToastService.hasDetails ? (expandButton.width + closeButton.width + 4) : (ToastService.currentLevel === ToastService.levelError ? closeButton.width + Theme.spacingS : 0)) + Theme.spacingL * 2 + Theme.spacingM * 2) : frozenWidth - height: toastContent.height + Theme.spacingL * 2 - anchors.horizontalCenter: parent.horizontalCenter - y: Theme.barHeight - 4 + (SettingsData.barConfigs[0]?.spacing ?? 4) + 2 + x: shadowBuffer + y: shadowBuffer + width: root.toastWidth + height: root.toastHeight color: { switch (ToastService.currentLevel) { case ToastService.levelError: diff --git a/quickshell/Widgets/DankOSD.qml b/quickshell/Widgets/DankOSD.qml index 30411375..153b1b23 100644 --- a/quickshell/Widgets/DankOSD.qml +++ b/quickshell/Widgets/DankOSD.qml @@ -74,6 +74,7 @@ PanelWindow { readonly property real dpr: CompositorService.getScreenScale(screen) readonly property real screenWidth: screen.width readonly property real screenHeight: screen.height + readonly property real shadowBuffer: 5 readonly property real alignedWidth: Theme.px(osdWidth, dpr) readonly property real alignedHeight: Theme.px(osdHeight, dpr) @@ -172,10 +173,16 @@ PanelWindow { anchors { top: true left: true - right: true - bottom: true } + WlrLayershell.margins { + left: Math.max(0, Theme.snap(alignedX - shadowBuffer, dpr)) + top: Math.max(0, Theme.snap(alignedY - shadowBuffer, dpr)) + } + + implicitWidth: alignedWidth + (shadowBuffer * 2) + implicitHeight: alignedHeight + (shadowBuffer * 2) + Timer { id: hideTimer @@ -203,8 +210,8 @@ PanelWindow { Item { id: osdContainer - x: alignedX - y: alignedY + x: shadowBuffer + y: shadowBuffer width: alignedWidth height: alignedHeight opacity: shouldBeVisible ? 1 : 0