mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
spotlight: remove darken bg opt, improve performance
This commit is contained in:
@@ -312,8 +312,6 @@ Singleton {
|
||||
property int overviewColumns: 5
|
||||
property real overviewScale: 0.16
|
||||
|
||||
property bool modalDarkenBackground: true
|
||||
|
||||
property bool lockScreenShowPowerActions: true
|
||||
property bool lockScreenShowSystemIcons: true
|
||||
property bool lockScreenShowTime: true
|
||||
|
||||
@@ -211,8 +211,6 @@ var SPEC = {
|
||||
overviewColumns: { def: 5, persist: false },
|
||||
overviewScale: { def: 0.16, persist: false },
|
||||
|
||||
modalDarkenBackground: { def: true },
|
||||
|
||||
lockScreenShowPowerActions: { def: true },
|
||||
lockScreenShowSystemIcons: { def: true },
|
||||
lockScreenShowTime: { def: true },
|
||||
|
||||
@@ -19,8 +19,6 @@ Item {
|
||||
readonly property real screenWidth: effectiveScreen?.width ?? 1920
|
||||
readonly property real screenHeight: effectiveScreen?.height ?? 1080
|
||||
readonly property real dpr: effectiveScreen ? CompositorService.getScreenScale(effectiveScreen) : 1
|
||||
property bool showBackground: true
|
||||
property real backgroundOpacity: 0.5
|
||||
property string positioning: "center"
|
||||
property point customPosition: Qt.point(0, 0)
|
||||
property bool closeOnEscapeKey: true
|
||||
@@ -46,17 +44,15 @@ Item {
|
||||
property var customKeyboardFocus: null
|
||||
property bool useOverlayLayer: false
|
||||
readonly property alias contentWindow: contentWindow
|
||||
readonly property alias backgroundWindow: backgroundWindow
|
||||
readonly property alias clickCatcher: clickCatcher
|
||||
readonly property bool useHyprlandFocusGrab: CompositorService.useHyprlandFocusGrab
|
||||
|
||||
readonly property bool useSingleWindow: root.useHyprlandFocusGrab
|
||||
readonly property bool useSingleWindow: useHyprlandFocusGrab
|
||||
|
||||
signal opened
|
||||
signal dialogClosed
|
||||
signal backgroundClicked
|
||||
|
||||
property bool animationsEnabled: true
|
||||
readonly property bool useBackgroundWindow: !useSingleWindow
|
||||
|
||||
function open() {
|
||||
ModalManager.openModal(root);
|
||||
@@ -64,20 +60,15 @@ Item {
|
||||
const focusedScreen = CompositorService.getFocusedScreen();
|
||||
if (focusedScreen) {
|
||||
contentWindow.screen = focusedScreen;
|
||||
if (useBackgroundWindow)
|
||||
backgroundWindow.screen = focusedScreen;
|
||||
if (!useSingleWindow)
|
||||
clickCatcher.screen = focusedScreen;
|
||||
}
|
||||
shouldBeVisible = true;
|
||||
contentWindow.visible = false;
|
||||
if (useBackgroundWindow)
|
||||
backgroundWindow.visible = true;
|
||||
Qt.callLater(() => {
|
||||
contentWindow.visible = true;
|
||||
shouldHaveFocus = false;
|
||||
Qt.callLater(() => {
|
||||
shouldHaveFocus = Qt.binding(() => shouldBeVisible);
|
||||
});
|
||||
});
|
||||
if (!useSingleWindow)
|
||||
clickCatcher.visible = true;
|
||||
contentWindow.visible = true;
|
||||
shouldHaveFocus = false;
|
||||
Qt.callLater(() => shouldHaveFocus = Qt.binding(() => shouldBeVisible));
|
||||
}
|
||||
|
||||
function close() {
|
||||
@@ -94,8 +85,8 @@ Item {
|
||||
ModalManager.closeModal(root);
|
||||
closeTimer.stop();
|
||||
contentWindow.visible = false;
|
||||
if (useBackgroundWindow)
|
||||
backgroundWindow.visible = false;
|
||||
if (!useSingleWindow)
|
||||
clickCatcher.visible = false;
|
||||
dialogClosed();
|
||||
Qt.callLater(() => animationsEnabled = true);
|
||||
}
|
||||
@@ -107,9 +98,8 @@ Item {
|
||||
Connections {
|
||||
target: ModalManager
|
||||
function onCloseAllModalsExcept(excludedModal) {
|
||||
if (excludedModal !== root && !allowStacking && shouldBeVisible) {
|
||||
if (excludedModal !== root && !allowStacking && shouldBeVisible)
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +121,8 @@ Item {
|
||||
const newScreen = CompositorService.getFocusedScreen();
|
||||
if (newScreen) {
|
||||
contentWindow.screen = newScreen;
|
||||
if (useBackgroundWindow)
|
||||
backgroundWindow.screen = newScreen;
|
||||
if (!useSingleWindow)
|
||||
clickCatcher.screen = newScreen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,12 +131,12 @@ Item {
|
||||
id: closeTimer
|
||||
interval: animationDuration + 120
|
||||
onTriggered: {
|
||||
if (!shouldBeVisible) {
|
||||
contentWindow.visible = false;
|
||||
if (useBackgroundWindow)
|
||||
backgroundWindow.visible = false;
|
||||
dialogClosed();
|
||||
}
|
||||
if (shouldBeVisible)
|
||||
return;
|
||||
contentWindow.visible = false;
|
||||
if (!useSingleWindow)
|
||||
clickCatcher.visible = false;
|
||||
dialogClosed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,11 +171,11 @@ Item {
|
||||
})(), dpr)
|
||||
|
||||
PanelWindow {
|
||||
id: backgroundWindow
|
||||
id: clickCatcher
|
||||
visible: false
|
||||
color: "transparent"
|
||||
|
||||
WlrLayershell.namespace: root.layerNamespace + ":background"
|
||||
WlrLayershell.namespace: root.layerNamespace + ":clickcatcher"
|
||||
WlrLayershell.layer: WlrLayershell.Top
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
@@ -201,41 +191,16 @@ Item {
|
||||
item: Rectangle {
|
||||
x: root.alignedX
|
||||
y: root.alignedY
|
||||
width: root.shouldBeVisible ? root.alignedWidth : 0
|
||||
height: root.shouldBeVisible ? root.alignedHeight : 0
|
||||
width: root.alignedWidth
|
||||
height: root.alignedHeight
|
||||
}
|
||||
intersection: Intersection.Xor
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: root.useBackgroundWindow && root.closeOnBackgroundClick && root.shouldBeVisible
|
||||
onClicked: mouse => {
|
||||
const clickX = mouse.x;
|
||||
const clickY = mouse.y;
|
||||
const outsideContent = clickX < root.alignedX || clickX > root.alignedX + root.alignedWidth || clickY < root.alignedY || clickY > root.alignedY + root.alignedHeight;
|
||||
|
||||
if (!outsideContent)
|
||||
return;
|
||||
root.backgroundClicked();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: background
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
opacity: root.showBackground && SettingsData.modalDarkenBackground ? (root.shouldBeVisible ? root.backgroundOpacity : 0) : 0
|
||||
visible: root.useBackgroundWindow && root.showBackground && SettingsData.modalDarkenBackground
|
||||
|
||||
Behavior on opacity {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: root.shouldBeVisible ? root.animationEnterCurve : root.animationExitCurve
|
||||
}
|
||||
}
|
||||
enabled: root.closeOnBackgroundClick && root.shouldBeVisible
|
||||
onClicked: root.backgroundClicked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,23 +272,6 @@ Item {
|
||||
onClicked: root.backgroundClicked()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
z: -1
|
||||
color: "black"
|
||||
opacity: root.showBackground && SettingsData.modalDarkenBackground ? (root.shouldBeVisible ? root.backgroundOpacity : 0) : 0
|
||||
visible: root.useSingleWindow && root.showBackground && SettingsData.modalDarkenBackground
|
||||
|
||||
Behavior on opacity {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: root.shouldBeVisible ? root.animationEnterCurve : root.animationExitCurve
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: modalContainer
|
||||
x: root.useSingleWindow ? root.alignedX : shadowBuffer
|
||||
|
||||
@@ -118,14 +118,12 @@ DankModal {
|
||||
function openCentered() {
|
||||
parentBounds = Qt.rect(0, 0, 0, 0);
|
||||
parentScreen = null;
|
||||
backgroundOpacity = 0.5;
|
||||
open();
|
||||
}
|
||||
|
||||
function openFromControlCenter(bounds, targetScreen) {
|
||||
parentBounds = bounds;
|
||||
parentScreen = targetScreen;
|
||||
backgroundOpacity = 0;
|
||||
open();
|
||||
}
|
||||
|
||||
|
||||
@@ -876,21 +876,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
tab: "theme"
|
||||
tags: ["modal", "darken", "background", "overlay"]
|
||||
|
||||
SettingsToggleRow {
|
||||
tab: "theme"
|
||||
tags: ["modal", "darken", "background", "overlay"]
|
||||
settingKey: "modalDarkenBackground"
|
||||
text: I18n.tr("Darken Modal Background")
|
||||
description: I18n.tr("Show darkened overlay behind modal dialogs")
|
||||
checked: SettingsData.modalDarkenBackground
|
||||
onToggled: checked => SettingsData.set("modalDarkenBackground", checked)
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
tab: "theme"
|
||||
tags: ["applications", "portal", "dark", "terminal"]
|
||||
|
||||
@@ -13,7 +13,8 @@ Scope {
|
||||
property string searchActiveScreen: ""
|
||||
property bool isClosing: false
|
||||
property bool releaseKeyboard: false
|
||||
property bool overlayActive: (NiriService.inOverview && !(PopoutService.spotlightModal?.spotlightOpen ?? false)) || searchActive
|
||||
readonly property bool spotlightModalOpen: PopoutService.spotlightModal?.spotlightOpen ?? false
|
||||
property bool overlayActive: (NiriService.inOverview && !spotlightModalOpen) || searchActive
|
||||
|
||||
function showSpotlight(screenName) {
|
||||
isClosing = false;
|
||||
@@ -33,7 +34,7 @@ Scope {
|
||||
hideSpotlight();
|
||||
}
|
||||
|
||||
function completeHide() {
|
||||
function resetState() {
|
||||
searchActive = false;
|
||||
searchActiveScreen = "";
|
||||
isClosing = false;
|
||||
@@ -43,19 +44,15 @@ Scope {
|
||||
Connections {
|
||||
target: NiriService
|
||||
function onInOverviewChanged() {
|
||||
if (!NiriService.inOverview) {
|
||||
if (searchActive) {
|
||||
isClosing = true;
|
||||
return;
|
||||
}
|
||||
searchActive = false;
|
||||
searchActiveScreen = "";
|
||||
isClosing = false;
|
||||
if (NiriService.inOverview) {
|
||||
resetState();
|
||||
return;
|
||||
}
|
||||
searchActive = false;
|
||||
searchActiveScreen = "";
|
||||
isClosing = false;
|
||||
if (!searchActive) {
|
||||
resetState();
|
||||
return;
|
||||
}
|
||||
isClosing = true;
|
||||
}
|
||||
|
||||
function onCurrentOutputChanged() {
|
||||
@@ -65,13 +62,9 @@ Scope {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PopoutService.spotlightModal
|
||||
function onSpotlightOpenChanged() {
|
||||
if (!PopoutService.spotlightModal?.spotlightOpen || !searchActive)
|
||||
return;
|
||||
onSpotlightModalOpenChanged: {
|
||||
if (spotlightModalOpen && searchActive)
|
||||
hideSpotlight();
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
@@ -221,6 +214,7 @@ Scope {
|
||||
layer.textureSize: Qt.size(Math.round(width * overlayWindow.dpr), Math.round(height * overlayWindow.dpr))
|
||||
|
||||
Behavior on scale {
|
||||
id: scaleAnimation
|
||||
NumberAnimation {
|
||||
duration: Theme.expressiveDurations.expressiveDefaultSpatial
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -228,11 +222,17 @@ Scope {
|
||||
onRunningChanged: {
|
||||
if (running || !spotlightContainer.animatingOut)
|
||||
return;
|
||||
niriOverviewScope.completeHide();
|
||||
niriOverviewScope.resetState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAnimatingOutChanged: {
|
||||
if (!animatingOut || scaleAnimation.animation.running)
|
||||
return;
|
||||
Qt.callLater(niriOverviewScope.resetState);
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.expressiveDurations.expressiveDefaultSpatial
|
||||
|
||||
Reference in New Issue
Block a user