mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
pass screen to modals
This commit is contained in:
@@ -15,9 +15,9 @@ Item {
|
|||||||
property real modalWidth: 400
|
property real modalWidth: 400
|
||||||
property real modalHeight: 300
|
property real modalHeight: 300
|
||||||
property var targetScreen
|
property var targetScreen
|
||||||
readonly property var effectiveScreen: targetScreen || contentWindow.screen
|
readonly property var effectiveScreen: contentWindow.screen ?? targetScreen
|
||||||
readonly property real screenWidth: effectiveScreen?.width
|
readonly property real screenWidth: effectiveScreen?.width ?? 1920
|
||||||
readonly property real screenHeight: effectiveScreen?.height
|
readonly property real screenHeight: effectiveScreen?.height ?? 1080
|
||||||
readonly property real dpr: effectiveScreen ? CompositorService.getScreenScale(effectiveScreen) : 1
|
readonly property real dpr: effectiveScreen ? CompositorService.getScreenScale(effectiveScreen) : 1
|
||||||
property bool showBackground: true
|
property bool showBackground: true
|
||||||
property real backgroundOpacity: 0.5
|
property real backgroundOpacity: 0.5
|
||||||
@@ -58,6 +58,12 @@ Item {
|
|||||||
function open() {
|
function open() {
|
||||||
ModalManager.openModal(root);
|
ModalManager.openModal(root);
|
||||||
closeTimer.stop();
|
closeTimer.stop();
|
||||||
|
const focusedScreen = CompositorService.getFocusedScreen();
|
||||||
|
if (focusedScreen) {
|
||||||
|
contentWindow.screen = focusedScreen;
|
||||||
|
if (useBackgroundWindow)
|
||||||
|
backgroundWindow.screen = focusedScreen;
|
||||||
|
}
|
||||||
shouldBeVisible = true;
|
shouldBeVisible = true;
|
||||||
contentWindow.visible = false;
|
contentWindow.visible = false;
|
||||||
if (useBackgroundWindow)
|
if (useBackgroundWindow)
|
||||||
@@ -102,6 +108,30 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Quickshell
|
||||||
|
function onScreensChanged() {
|
||||||
|
if (!contentWindow.screen)
|
||||||
|
return;
|
||||||
|
const currentScreenName = contentWindow.screen.name;
|
||||||
|
let screenStillExists = false;
|
||||||
|
for (let i = 0; i < Quickshell.screens.length; i++) {
|
||||||
|
if (Quickshell.screens[i].name === currentScreenName) {
|
||||||
|
screenStillExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (screenStillExists)
|
||||||
|
return;
|
||||||
|
const newScreen = CompositorService.getFocusedScreen();
|
||||||
|
if (newScreen) {
|
||||||
|
contentWindow.screen = newScreen;
|
||||||
|
if (useBackgroundWindow)
|
||||||
|
backgroundWindow.screen = newScreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: closeTimer
|
id: closeTimer
|
||||||
interval: animationDuration + 120
|
interval: animationDuration + 120
|
||||||
|
|||||||
@@ -64,6 +64,28 @@ Singleton {
|
|||||||
return screen?.devicePixelRatio || 1;
|
return screen?.devicePixelRatio || 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFocusedScreen() {
|
||||||
|
let screenName = "";
|
||||||
|
if (isHyprland && Hyprland.focusedWorkspace?.monitor)
|
||||||
|
screenName = Hyprland.focusedWorkspace.monitor.name;
|
||||||
|
else if (isNiri && NiriService.currentOutput)
|
||||||
|
screenName = NiriService.currentOutput;
|
||||||
|
else if (isSway) {
|
||||||
|
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||||
|
screenName = focusedWs?.monitor?.name || "";
|
||||||
|
} else if (isDwl && DwlService.activeOutput)
|
||||||
|
screenName = DwlService.activeOutput;
|
||||||
|
|
||||||
|
if (!screenName)
|
||||||
|
return Quickshell.screens.length > 0 ? Quickshell.screens[0] : null;
|
||||||
|
|
||||||
|
for (let i = 0; i < Quickshell.screens.length; i++) {
|
||||||
|
if (Quickshell.screens[i].name === screenName)
|
||||||
|
return Quickshell.screens[i];
|
||||||
|
}
|
||||||
|
return Quickshell.screens.length > 0 ? Quickshell.screens[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: sortDebounceTimer
|
id: sortDebounceTimer
|
||||||
interval: 100
|
interval: 100
|
||||||
|
|||||||
Reference in New Issue
Block a user