Dimmer: new implementation of the screen diming in a separate component.
This commit is contained in:
parent
eb26aa10f7
commit
6f1ae43d62
4 changed files with 96 additions and 2 deletions
76
Modules/Background/Dimmer.qml
Normal file
76
Modules/Background/Dimmer.qml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
|
||||
delegate: Loader {
|
||||
required property ShellScreen modelData
|
||||
|
||||
// Dimmer is only active on the screen where the panel is currently open.
|
||||
active: {
|
||||
if (Settings.isLoaded && Settings.data.general.dimDesktop && modelData !== undefined && PanelService.openedPanel !== null && PanelService.openedPanel.item !== null) {
|
||||
return (PanelService.openedPanel.item.screen === modelData)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
id: panel
|
||||
|
||||
property real customOpacity: 0
|
||||
|
||||
Component.onCompleted: {
|
||||
if (modelData) {
|
||||
Logger.log("Dimmer", "component loaded on", modelData.name)
|
||||
}
|
||||
|
||||
// When a NPanel opens it seems it is initialized with the primary screen for a very brief moment
|
||||
// before the screen actually updates to the proper value. We use a timer to delay the fade in to avoid
|
||||
// a single frame flicker on the main screen when opening a panel on another screen.
|
||||
fadeInTimer.start()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PanelService
|
||||
function onWillClose() {
|
||||
customOpacity = Style.opacityNone
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: fadeInTimer
|
||||
interval: 100
|
||||
onTriggered: customOpacity = Style.opacityHeavy
|
||||
}
|
||||
|
||||
screen: modelData
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
WlrLayershell.namespace: "quickshell-dimmer"
|
||||
|
||||
// mask: Region {}
|
||||
anchors {
|
||||
top: true
|
||||
bottom: true
|
||||
right: true
|
||||
left: true
|
||||
}
|
||||
|
||||
color: Qt.alpha(Color.mShadow, customOpacity)
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationSlow
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,9 @@ Singleton {
|
|||
|
||||
property var registeredPanels: ({})
|
||||
|
||||
signal willOpen
|
||||
signal willClose
|
||||
|
||||
// Register this panel
|
||||
function registerPanel(panel) {
|
||||
registeredPanels[panel.objectName] = panel
|
||||
|
|
@ -38,6 +41,14 @@ Singleton {
|
|||
openedPanel.close()
|
||||
}
|
||||
openedPanel = panel
|
||||
|
||||
// emit signal
|
||||
willOpen()
|
||||
}
|
||||
|
||||
function willClosePanel(panel) {
|
||||
// emit signal
|
||||
willClose()
|
||||
}
|
||||
|
||||
function closedPanel(panel) {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ Loader {
|
|||
scaleValue = originalScale
|
||||
opacityValue = originalOpacity
|
||||
hideTimer.start()
|
||||
PanelService.willClosePanel(root)
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
|
@ -146,6 +147,10 @@ Loader {
|
|||
readonly property bool barIsVisible: (screen !== null) && (Settings.data.bar.monitors.includes(screen.name) || (Settings.data.bar.monitors.length === 0))
|
||||
readonly property real verticalBarWidth: Math.round(Style.barHeight * scaling)
|
||||
|
||||
Component.onCompleted: {
|
||||
Logger.log("NPanel", "Opened", root.objectName)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ScalingService
|
||||
function onScaleChanged(screenName, scale) {
|
||||
|
|
@ -172,6 +177,7 @@ Loader {
|
|||
// No dimming here
|
||||
color: Color.transparent
|
||||
|
||||
WlrLayershell.layer: Settings.data.general.dimDesktop ? WlrLayer.Overlay : WlrLayer.Top
|
||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.namespace: "noctalia-panel"
|
||||
WlrLayershell.keyboardFocus: root.panelKeyboardFocus ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||
|
|
@ -280,14 +286,14 @@ Loader {
|
|||
|
||||
scale: root.scaleValue
|
||||
opacity: root.opacityValue
|
||||
|
||||
x: calculatedX
|
||||
y: calculatedY
|
||||
|
||||
// ---------------------------------------------
|
||||
// ---------------------------------------------
|
||||
// All Style.marginXXX are handled above in the PanelWindow itself.
|
||||
// Does not account for corners are they are negligible and helps keep the code clean.
|
||||
// ---------------------------------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
property int calculatedX: {
|
||||
// Priority to fixed anchoring
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ ShellRoot {
|
|||
Background {}
|
||||
Overview {}
|
||||
ScreenCorners {}
|
||||
Dimmer {}
|
||||
Bar {}
|
||||
Dock {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue