Removing unecessary wrapper in ScreenCorners.qml

This commit is contained in:
quadbyte 2025-08-10 12:04:34 -04:00
parent 61abcddeeb
commit 975cb6018f
2 changed files with 119 additions and 117 deletions

View file

@ -6,12 +6,16 @@ import qs.Services
import qs.Widgets import qs.Widgets
NLoader { NLoader {
id: cornerLoader
isLoaded: Settings.data.general.showScreenCorners isLoaded: Settings.data.general.showScreenCorners
panel: Component {
ShellRoot { panel: Variants {
model: Quickshell.screens
PanelWindow {
id: root id: root
required property ShellScreen modelData
// Visible ring color // Visible ring color
property color ringColor: Colors.backgroundPrimary property color ringColor: Colors.backgroundPrimary
// The amount subtracted from full size for the inner cutout // The amount subtracted from full size for the inner cutout
@ -20,11 +24,12 @@ NLoader {
// Rounded radius for the inner cutout // Rounded radius for the inner cutout
property int innerRadius: 20 property int innerRadius: 20
Variants { color: "transparent"
model: Quickshell.screens screen: modelData
WlrLayershell.exclusionMode: ExclusionMode.Ignore
PanelWindow { WlrLayershell.namespace: "quickshell-corner"
required property ShellScreen modelData // Do not take keyboard focus and make the surface click-through
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors { anchors {
top: true top: true
@ -32,20 +37,15 @@ NLoader {
left: true left: true
right: true right: true
} }
margins { margins {
top: Math.round(Style.barHeight * Scaling.scale(screen)) top: Math.round(Style.barHeight * Scaling.scale(screen))
} }
color: "transparent"
screen: modelData
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "quickshell-corner"
// Do not take keyboard focus and make the surface click-through
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
mask: Region {}
// Source we want to show only as a ring // Source we want to show only as a ring
Rectangle { Rectangle {
id: overlaySource id: overlaySource
anchors.fill: parent anchors.fill: parent
color: root.ringColor color: root.ringColor
} }
@ -53,6 +53,7 @@ NLoader {
// Texture for overlaySource // Texture for overlaySource
ShaderEffectSource { ShaderEffectSource {
id: overlayTexture id: overlayTexture
anchors.fill: parent anchors.fill: parent
sourceItem: overlaySource sourceItem: overlaySource
hideSource: true hideSource: true
@ -63,6 +64,7 @@ NLoader {
// Mask via Canvas: paint opaque white, then punch rounded inner hole // Mask via Canvas: paint opaque white, then punch rounded inner hole
Canvas { Canvas {
id: maskSource id: maskSource
anchors.fill: parent anchors.fill: parent
antialiasing: true antialiasing: true
renderTarget: Canvas.FramebufferObject renderTarget: Canvas.FramebufferObject
@ -74,15 +76,12 @@ NLoader {
ctx.globalCompositeOperation = "source-over" ctx.globalCompositeOperation = "source-over"
ctx.fillStyle = "#ffffffff" ctx.fillStyle = "#ffffffff"
ctx.fillRect(0, 0, width, height) ctx.fillRect(0, 0, width, height)
// Punch hole using destination-out with rounded rect path // Punch hole using destination-out with rounded rect path
const x = Math.round(root.borderWidth / 2) const x = Math.round(root.borderWidth / 2)
const y = Math.round(root.borderWidth / 2) const y = Math.round(root.borderWidth / 2)
const w = Math.max(0, width - root.borderWidth) const w = Math.max(0, width - root.borderWidth)
const h = Math.max(0, height - root.borderWidth) const h = Math.max(0, height - root.borderWidth)
const r = Math.max(0, Math.min(root.innerRadius, const r = Math.max(0, Math.min(root.innerRadius, Math.min(w, h) / 2))
Math.min(w, h) / 2))
ctx.globalCompositeOperation = "destination-out" ctx.globalCompositeOperation = "destination-out"
ctx.fillStyle = "#ffffffff" ctx.fillStyle = "#ffffffff"
ctx.beginPath() ctx.beginPath()
@ -105,19 +104,23 @@ NLoader {
// Repaint mask when properties change // Repaint mask when properties change
Connections { Connections {
target: root
function onBorderWidthChanged() { function onBorderWidthChanged() {
maskSource.requestPaint() maskSource.requestPaint()
} }
function onRingColorChanged() {/* no-op for mask */ }
function onRingColorChanged() {}
function onInnerRadiusChanged() { function onInnerRadiusChanged() {
maskSource.requestPaint() maskSource.requestPaint()
} }
target: root
} }
// Texture for maskSource; hides the original // Texture for maskSource; hides the original
ShaderEffectSource { ShaderEffectSource {
id: maskTexture id: maskTexture
anchors.fill: parent anchors.fill: parent
sourceItem: maskSource sourceItem: maskSource
hideSource: true hideSource: true
@ -133,8 +136,8 @@ NLoader {
maskSource: maskTexture maskSource: maskTexture
maskInverted: false maskInverted: false
} }
}
} mask: Region {}
} }
} }
} }

View file

@ -1,4 +1,3 @@
// Disable reload popup // Disable reload popup
//@ pragma Env QS_NO_RELOAD_POPUP=1 //@ pragma Env QS_NO_RELOAD_POPUP=1
import QtQuick import QtQuick