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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue