Don't dim ScreenCorners

NPanel: add dimOverlay
This commit is contained in:
Ly-sec 2025-08-31 10:34:01 +02:00
parent 1e52e7ca40
commit 7b63b6900d
2 changed files with 76 additions and 16 deletions

View file

@ -44,11 +44,11 @@ Loader {
margins {
top: ((modelData && Settings.data.bar.monitors.includes(modelData.name))
|| (Settings.data.bar.monitors.length === 0))
&& Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top"
&& Settings.data.bar.backgroundOpacity > 0 ? Math.floor(Style.barHeight * scaling) : 0
bottom: ((modelData && Settings.data.bar.monitors.includes(modelData.name))
|| (Settings.data.bar.monitors.length === 0))
&& Settings.data.bar.position === "bottom" ? Math.floor(Style.barHeight * scaling) : 0
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom"
&& Settings.data.bar.backgroundOpacity > 0 ? Math.floor(Style.barHeight * scaling) : 0
}
// Source we want to show only as a ring

View file

@ -41,6 +41,21 @@ Loader {
readonly property real barHeight: Style.barHeight * scaling
readonly property bool barAtBottom: Settings.data.bar.position === "bottom"
// Helper function to check if bar is enabled on this screen
function isBarEnabled(screen) {
if (!screen || !screen.name)
return false
return Settings.data.bar.monitors.includes(screen.name) || (Settings.data.bar.monitors.length === 0)
}
// Helper function to get effective bar height (accounting for opacity)
function getEffectiveBarHeight(screen) {
if (!isBarEnabled(screen))
return 0
// If bar opacity is 0, treat it as if bar is not there for dimming purposes
return Settings.data.bar.backgroundOpacity > 0 ? barHeight : 0
}
signal opened
signal closed
@ -132,27 +147,19 @@ Loader {
visible: true
// Dim desktop if required
color: (root.active && !root.isClosing && Settings.data.general.dimDesktop) ? Color.applyOpacity(
Color.mShadow,
"BB") : Color.transparent
// Dim desktop if required - but exclude corners if screen corners are enabled
color: Color.transparent
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "noctalia-panel"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
Behavior on color {
ColorAnimation {
duration: Style.animationNormal
}
}
anchors.top: true
anchors.left: true
anchors.right: true
anchors.bottom: true
margins.top: !barAtBottom ? barHeight : 0
margins.bottom: barAtBottom ? barHeight : 0
margins.top: !barAtBottom ? getEffectiveBarHeight(screen) : 0
margins.bottom: barAtBottom ? getEffectiveBarHeight(screen) : 0
// Close any panel with Esc without requiring focus
Shortcut {
@ -168,6 +175,59 @@ Loader {
onClicked: root.close()
}
// Dim overlay that excludes corners when screen corners are enabled
Item {
id: dimOverlay
anchors.fill: parent
visible: root.active && !root.isClosing && Settings.data.general.dimDesktop
opacity: visible ? 1.0 : 0.0
// Helper function to check if screen corners are enabled
function isScreenCornersEnabled() {
return Settings.data.general.showScreenCorners
}
// Helper function to get corner radius
function getCornerRadius() {
return 20 // Same as ScreenCorners innerRadius
}
// Helper function to get border width
function getBorderWidth() {
return Style.borderM
}
// Full screen dim when screen corners are disabled
Rectangle {
id: fullScreenDim
visible: dimOverlay.visible && !dimOverlay.isScreenCornersEnabled()
anchors.fill: parent
color: Color.applyOpacity(Color.mShadow, "BB")
}
// Masked dim when screen corners are enabled
Item {
id: maskedDim
visible: dimOverlay.visible && dimOverlay.isScreenCornersEnabled()
anchors.fill: parent
// Only dim the center area, leaving the entire border undimmed
Rectangle {
id: centerDim
anchors.margins: dimOverlay.getCornerRadius() + dimOverlay.getBorderWidth()
anchors.fill: parent
color: Color.applyOpacity(Color.mShadow, "BB")
}
}
// Behavior for dim overlay visibility
Behavior on opacity {
NumberAnimation {
duration: Style.animationNormal
}
}
}
Rectangle {
id: panelBackground
color: panelBackgroundColor