add screencorners

This commit is contained in:
lucy 2026-05-17 12:44:22 +02:00
commit ddf4c2e654
3 changed files with 185 additions and 1 deletions

View file

@ -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() }
}
}
}
}
}

View file

@ -3,5 +3,5 @@ barHeight=34
font=Maple Mono font=Maple Mono
fontSize=16 fontSize=16
opacity=1 opacity=1
roudning=16 roudning=20
wallpaper=@Variant(\0\0\0\x11\0\0\0)file:///home/lucy/.wall/walkingcastle.png) wallpaper=@Variant(\0\0\0\x11\0\0\0)file:///home/lucy/.wall/walkingcastle.png)

View file

@ -5,10 +5,12 @@ import qs.modules.ipc
import qs.modules.wallpaper import qs.modules.wallpaper
import qs.settings import qs.settings
import qs.modules.notifications import qs.modules.notifications
import qs.modules.corners
ShellRoot { ShellRoot {
Bar {} Bar {}
Ipc {} Ipc {}
Wallpaper {} Wallpaper {}
NotiPopup {} NotiPopup {}
ScreenCorners {}
} }