From ddf4c2e654a483acae0437186af7ca28986efcb4 Mon Sep 17 00:00:00 2001 From: lucy Date: Sun, 17 May 2026 12:44:22 +0200 Subject: [PATCH] add screencorners --- modules/corners/ScreenCorners.qml | 182 ++++++++++++++++++++++++++++++ settings/settings.ini | 2 +- shell.qml | 2 + 3 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 modules/corners/ScreenCorners.qml diff --git a/modules/corners/ScreenCorners.qml b/modules/corners/ScreenCorners.qml new file mode 100644 index 0000000..976a2bd --- /dev/null +++ b/modules/corners/ScreenCorners.qml @@ -0,0 +1,182 @@ +pragma ComponentBehavior: Bound +import QtQuick +import Quickshell +import Quickshell.Wayland +import qs +import qs.settings + +Item { + // Top-left corners + Variants { + model: Quickshell.screens + delegate: WlrLayershell { + id: tlWin + required property var modelData + screen: modelData + visible: Config.rounding > 0 + exclusionMode: ExclusionMode.Ignore + layer: WlrLayer.Overlay + anchors { top: true; left: true } + margins.top: Config.barHeight + implicitWidth: Config.rounding + implicitHeight: Config.rounding + color: "transparent" + + Canvas { + id: tlCanvas + anchors.fill: parent + onWidthChanged: requestPaint() + onPaint: { + var ctx = getContext("2d") + var s = width + ctx.clearRect(0, 0, s, s) + var c = Colors.base00 + ctx.fillStyle = Qt.rgba(c.r, c.g, c.b, Config.opacity) + ctx.fillRect(0, 0, s, s) + // Punch out quarter-circle from inner corner (s, s) + ctx.globalCompositeOperation = "destination-out" + ctx.beginPath() + ctx.moveTo(s, s) + ctx.arc(s, s, s, Math.PI, 3 * Math.PI / 2, false) + ctx.closePath() + ctx.fill() + ctx.globalCompositeOperation = "source-over" + } + Connections { + target: Config + function onOpacityChanged() { tlCanvas.requestPaint() } + } + } + } + } + + // Top-right corners + Variants { + model: Quickshell.screens + delegate: WlrLayershell { + id: trWin + required property var modelData + screen: modelData + visible: Config.rounding > 0 + exclusionMode: ExclusionMode.Ignore + layer: WlrLayer.Overlay + anchors { top: true; right: true } + margins.top: Config.barHeight + implicitWidth: Config.rounding + implicitHeight: Config.rounding + color: "transparent" + + Canvas { + id: trCanvas + anchors.fill: parent + onWidthChanged: requestPaint() + onPaint: { + var ctx = getContext("2d") + var s = width + ctx.clearRect(0, 0, s, s) + var c = Colors.base00 + ctx.fillStyle = Qt.rgba(c.r, c.g, c.b, Config.opacity) + ctx.fillRect(0, 0, s, s) + // Punch out quarter-circle from inner corner (0, s) + ctx.globalCompositeOperation = "destination-out" + ctx.beginPath() + ctx.moveTo(0, s) + ctx.arc(0, s, s, -Math.PI / 2, 0, false) + ctx.closePath() + ctx.fill() + ctx.globalCompositeOperation = "source-over" + } + Connections { + target: Config + function onOpacityChanged() { trCanvas.requestPaint() } + } + } + } + } + + // Bottom-left corners + Variants { + model: Quickshell.screens + delegate: WlrLayershell { + id: blWin + required property var modelData + screen: modelData + visible: Config.rounding > 0 + exclusionMode: ExclusionMode.Ignore + layer: WlrLayer.Overlay + anchors { bottom: true; left: true } + implicitWidth: Config.rounding + implicitHeight: Config.rounding + color: "transparent" + + Canvas { + id: blCanvas + anchors.fill: parent + onWidthChanged: requestPaint() + onPaint: { + var ctx = getContext("2d") + var s = width + ctx.clearRect(0, 0, s, s) + var c = Colors.base00 + ctx.fillStyle = Qt.rgba(c.r, c.g, c.b, Config.opacity) + ctx.fillRect(0, 0, s, s) + // Punch out quarter-circle from inner corner (s, 0) + ctx.globalCompositeOperation = "destination-out" + ctx.beginPath() + ctx.moveTo(s, 0) + ctx.arc(s, 0, s, Math.PI / 2, Math.PI, false) + ctx.closePath() + ctx.fill() + ctx.globalCompositeOperation = "source-over" + } + Connections { + target: Config + function onOpacityChanged() { blCanvas.requestPaint() } + } + } + } + } + + // Bottom-right corners + Variants { + model: Quickshell.screens + delegate: WlrLayershell { + id: brWin + required property var modelData + screen: modelData + visible: Config.rounding > 0 + exclusionMode: ExclusionMode.Ignore + layer: WlrLayer.Overlay + anchors { bottom: true; right: true } + implicitWidth: Config.rounding + implicitHeight: Config.rounding + color: "transparent" + + Canvas { + id: brCanvas + anchors.fill: parent + onWidthChanged: requestPaint() + onPaint: { + var ctx = getContext("2d") + var s = width + ctx.clearRect(0, 0, s, s) + var c = Colors.base00 + ctx.fillStyle = Qt.rgba(c.r, c.g, c.b, Config.opacity) + ctx.fillRect(0, 0, s, s) + // Punch out quarter-circle from inner corner (0, 0) + ctx.globalCompositeOperation = "destination-out" + ctx.beginPath() + ctx.moveTo(0, 0) + ctx.arc(0, 0, s, 0, Math.PI / 2, false) + ctx.closePath() + ctx.fill() + ctx.globalCompositeOperation = "source-over" + } + Connections { + target: Config + function onOpacityChanged() { brCanvas.requestPaint() } + } + } + } + } +} diff --git a/settings/settings.ini b/settings/settings.ini index 6670592..c964bbe 100644 --- a/settings/settings.ini +++ b/settings/settings.ini @@ -3,5 +3,5 @@ barHeight=34 font=Maple Mono fontSize=16 opacity=1 -roudning=16 +roudning=20 wallpaper=@Variant(\0\0\0\x11\0\0\0)file:///home/lucy/.wall/walkingcastle.png) diff --git a/shell.qml b/shell.qml index 209b9ef..f758e5a 100644 --- a/shell.qml +++ b/shell.qml @@ -5,10 +5,12 @@ import qs.modules.ipc import qs.modules.wallpaper import qs.settings import qs.modules.notifications +import qs.modules.corners ShellRoot { Bar {} Ipc {} Wallpaper {} NotiPopup {} + ScreenCorners {} }