From 1bd4eeb736770dea40726f304abc94691d5ababf Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 5 Aug 2025 18:08:13 -0400 Subject: [PATCH] make screen to popouts for positioning data --- Modules/AppDrawer/AppDrawerPopout.qml | 12 ++++++++---- Modules/CentcomCenter/CentcomPopout.qml | 18 ++++++++++-------- Modules/ControlCenter/ControlCenterPopout.qml | 8 +++++--- Modules/ProcessList/ProcessListPopout.qml | 17 +++++++++++------ Modules/TopBar/Battery.qml | 7 +++++-- Modules/TopBar/BatteryPopout.qml | 17 +++++++++++------ Modules/TopBar/Clock.qml | 7 +++++-- Modules/TopBar/CpuMonitor.qml | 7 +++++-- Modules/TopBar/LauncherButton.qml | 7 +++++-- Modules/TopBar/Media.qml | 7 +++++-- Modules/TopBar/NotificationCenterButton.qml | 7 +++++-- Modules/TopBar/RamMonitor.qml | 7 +++++-- Modules/TopBar/TopBar.qml | 9 +++++++++ Modules/TopBar/Weather.qml | 7 +++++-- 14 files changed, 94 insertions(+), 43 deletions(-) diff --git a/Modules/AppDrawer/AppDrawerPopout.qml b/Modules/AppDrawer/AppDrawerPopout.qml index a0b40ca8..ad4e4a4b 100644 --- a/Modules/AppDrawer/AppDrawerPopout.qml +++ b/Modules/AppDrawer/AppDrawerPopout.qml @@ -17,7 +17,8 @@ PanelWindow { property real triggerX: Theme.spacingL property real triggerY: Theme.barHeight + Theme.spacingXS property real triggerWidth: 40 - property string triggerSection: "left" // "left", "center", "right" + property string triggerSection: "left" + property var triggerScreen: null function show() { appDrawerPopout.isVisible = true; @@ -35,11 +36,12 @@ PanelWindow { show(); } - function setTriggerPosition(x, y, width, section) { + function setTriggerPosition(x, y, width, section, screen) { triggerX = x; triggerY = y; triggerWidth = width; triggerSection = section; + triggerScreen = screen; } WlrLayershell.layer: WlrLayershell.Overlay @@ -48,6 +50,7 @@ PanelWindow { WlrLayershell.namespace: "quickshell-launcher" visible: isVisible color: "transparent" + screen: triggerScreen || Screen anchors { top: true @@ -83,10 +86,11 @@ PanelWindow { readonly property real popupWidth: 520 readonly property real popupHeight: 600 - readonly property real screenWidth: Screen.width - readonly property real screenHeight: Screen.height + readonly property real screenWidth: appDrawerPopout.screen ? appDrawerPopout.screen.width : Screen.width + readonly property real screenHeight: appDrawerPopout.screen ? appDrawerPopout.screen.height : Screen.height readonly property real calculatedX: { var centerX = appDrawerPopout.triggerX + (appDrawerPopout.triggerWidth / 2) - (popupWidth / 2); + if (centerX >= Theme.spacingM && centerX + popupWidth <= screenWidth - Theme.spacingM) return centerX; diff --git a/Modules/CentcomCenter/CentcomPopout.qml b/Modules/CentcomCenter/CentcomPopout.qml index 95e36a24..c92f7be4 100644 --- a/Modules/CentcomCenter/CentcomPopout.qml +++ b/Modules/CentcomCenter/CentcomPopout.qml @@ -19,15 +19,18 @@ PanelWindow { property real triggerY: Theme.barHeight + 4 property real triggerWidth: 80 property string triggerSection: "center" + property var triggerScreen: null - function setTriggerPosition(x, y, width, section) { + function setTriggerPosition(x, y, width, section, screen) { triggerX = x; triggerY = y; triggerWidth = width; triggerSection = section; + triggerScreen = screen; } visible: internalVisible + screen: triggerScreen || Screen onCalendarVisibleChanged: { if (calendarVisible) { internalVisible = true; @@ -61,7 +64,7 @@ PanelWindow { Rectangle { id: mainContainer - readonly property real targetWidth: Math.min(Screen.width * 0.9, 600) + readonly property real targetWidth: Math.min((root.screen ? root.screen.width : Screen.width) * 0.9, 600) function calculateWidth() { let baseWidth = 320; @@ -89,15 +92,14 @@ PanelWindow { } readonly property real calculatedX: { - // For center widgets, always center the popup on screen + var screenWidth = root.screen ? root.screen.width : Screen.width; if (root.triggerSection === "center") { - return (Screen.width - targetWidth) / 2; + return (screenWidth - targetWidth) / 2; } - // For non-center widgets, use the original logic var centerX = root.triggerX + (root.triggerWidth / 2) - (targetWidth / 2); - if (centerX >= Theme.spacingM && centerX + targetWidth <= Screen.width - Theme.spacingM) { + if (centerX >= Theme.spacingM && centerX + targetWidth <= screenWidth - Theme.spacingM) { return centerX; } @@ -105,8 +107,8 @@ PanelWindow { return Theme.spacingM; } - if (centerX + targetWidth > Screen.width - Theme.spacingM) { - return Screen.width - targetWidth - Theme.spacingM; + if (centerX + targetWidth > screenWidth - Theme.spacingM) { + return screenWidth - targetWidth - Theme.spacingM; } return centerX; diff --git a/Modules/ControlCenter/ControlCenterPopout.qml b/Modules/ControlCenter/ControlCenterPopout.qml index 9658c47e..5d0c6774 100644 --- a/Modules/ControlCenter/ControlCenterPopout.qml +++ b/Modules/ControlCenter/ControlCenterPopout.qml @@ -15,13 +15,15 @@ PanelWindow { id: root property bool controlCenterVisible: false - property string currentTab: "network" // "network", "audio", "bluetooth", "display" + property string currentTab: "network" property bool powerOptionsExpanded: false + property var triggerScreen: null signal powerActionRequested(string action, string title, string message) signal lockRequested() visible: controlCenterVisible + screen: triggerScreen || Screen onVisibleChanged: { NetworkService.autoRefreshEnabled = visible && NetworkService.wifiEnabled; if (!visible && BluetoothService.adapter && BluetoothService.adapter.discovering) @@ -48,14 +50,14 @@ PanelWindow { Loader { id: contentLoader - readonly property real targetWidth: Math.min(600, Screen.width - Theme.spacingL * 2) + readonly property real targetWidth: Math.min(600, (root.screen ? root.screen.width : Screen.width) - Theme.spacingL * 2) asynchronous: true active: controlCenterVisible width: targetWidth height: root.powerOptionsExpanded ? 570 : 500 y: Theme.barHeight + Theme.spacingXS - x: Math.max(Theme.spacingL, Screen.width - targetWidth - Theme.spacingL) + x: Math.max(Theme.spacingL, (root.screen ? root.screen.width : Screen.width) - targetWidth - Theme.spacingL) opacity: controlCenterVisible ? 1 : 0 scale: controlCenterVisible ? 1 : 0.9 diff --git a/Modules/ProcessList/ProcessListPopout.qml b/Modules/ProcessList/ProcessListPopout.qml index b8aadbf0..8d0239a5 100644 --- a/Modules/ProcessList/ProcessListPopout.qml +++ b/Modules/ProcessList/ProcessListPopout.qml @@ -20,12 +20,14 @@ PanelWindow { property real triggerY: Theme.barHeight + Theme.spacingXS property real triggerWidth: 55 property string triggerSection: "right" + property var triggerScreen: null - function setTriggerPosition(x, y, width, section) { + function setTriggerPosition(x, y, width, section, screen) { triggerX = x; triggerY = y; triggerWidth = width; triggerSection = section; + triggerScreen = screen; } function hide() { @@ -47,6 +49,7 @@ PanelWindow { } visible: isVisible + screen: triggerScreen || Screen implicitWidth: 600 implicitHeight: 600 WlrLayershell.layer: WlrLayershell.Overlay @@ -78,12 +81,14 @@ PanelWindow { Loader { id: contentLoader - readonly property real targetWidth: Math.min(600, Screen.width - Theme.spacingL * 2) - readonly property real targetHeight: Math.min(600, Screen.height - Theme.barHeight - Theme.spacingS * 2) + readonly property real screenWidth: processListPopout.screen ? processListPopout.screen.width : Screen.width + readonly property real screenHeight: processListPopout.screen ? processListPopout.screen.height : Screen.height + readonly property real targetWidth: Math.min(600, screenWidth - Theme.spacingL * 2) + readonly property real targetHeight: Math.min(600, screenHeight - Theme.barHeight - Theme.spacingS * 2) readonly property real calculatedX: { var centerX = processListPopout.triggerX + (processListPopout.triggerWidth / 2) - (targetWidth / 2); - if (centerX >= Theme.spacingM && centerX + targetWidth <= Screen.width - Theme.spacingM) { + if (centerX >= Theme.spacingM && centerX + targetWidth <= screenWidth - Theme.spacingM) { return centerX; } @@ -91,8 +96,8 @@ PanelWindow { return Theme.spacingM; } - if (centerX + targetWidth > Screen.width - Theme.spacingM) { - return Screen.width - targetWidth - Theme.spacingM; + if (centerX + targetWidth > screenWidth - Theme.spacingM) { + return screenWidth - targetWidth - Theme.spacingM; } return centerX; diff --git a/Modules/TopBar/Battery.qml b/Modules/TopBar/Battery.qml index 551680f8..20e37e33 100644 --- a/Modules/TopBar/Battery.qml +++ b/Modules/TopBar/Battery.qml @@ -10,6 +10,7 @@ Rectangle { property bool batteryPopupVisible: false property string section: "right" property var popupTarget: null + property var parentScreen: null signal toggleBatteryPopup() @@ -96,8 +97,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } toggleBatteryPopup(); } diff --git a/Modules/TopBar/BatteryPopout.qml b/Modules/TopBar/BatteryPopout.qml index b3d45ce8..d225c573 100644 --- a/Modules/TopBar/BatteryPopout.qml +++ b/Modules/TopBar/BatteryPopout.qml @@ -16,12 +16,14 @@ PanelWindow { property real triggerY: Theme.barHeight + Theme.spacingS property real triggerWidth: 70 property string triggerSection: "right" + property var triggerScreen: null - function setTriggerPosition(x, y, width, section) { + function setTriggerPosition(x, y, width, section, screen) { triggerX = x; triggerY = y; triggerWidth = width; triggerSection = section; + triggerScreen = screen; } function isActiveProfile(profile) { @@ -43,6 +45,7 @@ PanelWindow { } visible: batteryPopupVisible + screen: triggerScreen || Screen implicitWidth: 400 implicitHeight: 300 WlrLayershell.layer: WlrLayershell.Overlay @@ -70,12 +73,14 @@ PanelWindow { Loader { id: contentLoader - readonly property real targetWidth: Math.min(380, Screen.width - Theme.spacingL * 2) - readonly property real targetHeight: Math.min(450, Screen.height - Theme.barHeight - Theme.spacingS * 2) + readonly property real screenWidth: root.screen ? root.screen.width : Screen.width + readonly property real screenHeight: root.screen ? root.screen.height : Screen.height + readonly property real targetWidth: Math.min(380, screenWidth - Theme.spacingL * 2) + readonly property real targetHeight: Math.min(450, screenHeight - Theme.barHeight - Theme.spacingS * 2) readonly property real calculatedX: { var centerX = root.triggerX + (root.triggerWidth / 2) - (targetWidth / 2); - if (centerX >= Theme.spacingM && centerX + targetWidth <= Screen.width - Theme.spacingM) { + if (centerX >= Theme.spacingM && centerX + targetWidth <= screenWidth - Theme.spacingM) { return centerX; } @@ -83,8 +88,8 @@ PanelWindow { return Theme.spacingM; } - if (centerX + targetWidth > Screen.width - Theme.spacingM) { - return Screen.width - targetWidth - Theme.spacingM; + if (centerX + targetWidth > screenWidth - Theme.spacingM) { + return screenWidth - targetWidth - Theme.spacingM; } return centerX; diff --git a/Modules/TopBar/Clock.qml b/Modules/TopBar/Clock.qml index bd86c5e3..cf3f2de3 100644 --- a/Modules/TopBar/Clock.qml +++ b/Modules/TopBar/Clock.qml @@ -10,6 +10,7 @@ Rectangle { property bool compactMode: false property string section: "center" property var popupTarget: null + property var parentScreen: null signal clockClicked() @@ -71,8 +72,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } root.clockClicked(); } diff --git a/Modules/TopBar/CpuMonitor.qml b/Modules/TopBar/CpuMonitor.qml index 55fa3a23..8405c9d5 100644 --- a/Modules/TopBar/CpuMonitor.qml +++ b/Modules/TopBar/CpuMonitor.qml @@ -12,6 +12,7 @@ Rectangle { property var toggleProcessList property string section: "right" property var popupTarget: null + property var parentScreen: null width: 55 height: 30 @@ -36,8 +37,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } SysMonitorService.setSortBy("cpu"); if (root.toggleProcessList) diff --git a/Modules/TopBar/LauncherButton.qml b/Modules/TopBar/LauncherButton.qml index e1f03fe5..6601724a 100644 --- a/Modules/TopBar/LauncherButton.qml +++ b/Modules/TopBar/LauncherButton.qml @@ -9,6 +9,7 @@ Rectangle { property bool isActive: false property string section: "left" // Which section this button is in property var popupTarget: null // Reference to the popup to position + property var parentScreen: null // The screen this button is on signal clicked() @@ -47,8 +48,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } root.clicked(); } diff --git a/Modules/TopBar/Media.qml b/Modules/TopBar/Media.qml index 13788e87..94613927 100644 --- a/Modules/TopBar/Media.qml +++ b/Modules/TopBar/Media.qml @@ -15,6 +15,7 @@ Rectangle { readonly property int compactContentWidth: Math.min(120, baseContentWidth) property string section: "center" property var popupTarget: null + property var parentScreen: null signal clicked() @@ -132,8 +133,10 @@ Rectangle { onClicked: { if (root.popupTarget && root.popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - root.popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, root.width, root.section); + var currentScreen = root.parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + root.popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, root.width, root.section, currentScreen); } root.clicked(); } diff --git a/Modules/TopBar/NotificationCenterButton.qml b/Modules/TopBar/NotificationCenterButton.qml index d71e7a02..a29991bd 100644 --- a/Modules/TopBar/NotificationCenterButton.qml +++ b/Modules/TopBar/NotificationCenterButton.qml @@ -9,6 +9,7 @@ Rectangle { property bool isActive: false property string section: "right" property var popupTarget: null + property var parentScreen: null signal clicked() @@ -48,8 +49,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } root.clicked(); } diff --git a/Modules/TopBar/RamMonitor.qml b/Modules/TopBar/RamMonitor.qml index 045d0230..8aa76dc2 100644 --- a/Modules/TopBar/RamMonitor.qml +++ b/Modules/TopBar/RamMonitor.qml @@ -12,6 +12,7 @@ Rectangle { property var toggleProcessList property string section: "right" property var popupTarget: null + property var parentScreen: null width: 55 height: 30 @@ -36,8 +37,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } SysMonitorService.setSortBy("memory"); if (root.toggleProcessList) diff --git a/Modules/TopBar/TopBar.qml b/Modules/TopBar/TopBar.qml index ae004d97..2ef95e90 100644 --- a/Modules/TopBar/TopBar.qml +++ b/Modules/TopBar/TopBar.qml @@ -447,6 +447,7 @@ PanelWindow { return "left"; // default fallback } popupTarget: appDrawerPopout + parentScreen: root.screen onClicked: { if (appDrawerPopout) appDrawerPopout.toggle(); @@ -486,6 +487,7 @@ PanelWindow { return "center"; } popupTarget: centcomPopout + parentScreen: root.screen onClockClicked: { centcomPopout.calendarVisible = !centcomPopout.calendarVisible; } @@ -505,6 +507,7 @@ PanelWindow { return "center"; } popupTarget: centcomPopout + parentScreen: root.screen onClicked: { centcomPopout.calendarVisible = !centcomPopout.calendarVisible; } @@ -523,6 +526,7 @@ PanelWindow { return "center"; } popupTarget: centcomPopout + parentScreen: root.screen onClicked: { centcomPopout.calendarVisible = !centcomPopout.calendarVisible; } @@ -604,6 +608,7 @@ PanelWindow { return "right"; } popupTarget: processListPopout + parentScreen: root.screen toggleProcessList: () => { return processListPopout.toggle(); } @@ -617,6 +622,7 @@ PanelWindow { return "right"; } popupTarget: processListPopout + parentScreen: root.screen toggleProcessList: () => { return processListPopout.toggle(); } @@ -639,6 +645,7 @@ PanelWindow { return "right"; } popupTarget: notificationCenter + parentScreen: root.screen onClicked: { notificationCenter.notificationHistoryVisible = !notificationCenter.notificationHistoryVisible; } @@ -658,6 +665,7 @@ PanelWindow { return "right"; } popupTarget: batteryPopout + parentScreen: root.screen onToggleBatteryPopup: { batteryPopout.batteryPopupVisible = !batteryPopout.batteryPopupVisible; } @@ -671,6 +679,7 @@ PanelWindow { ControlCenterButton { isActive: controlCenterPopout.controlCenterVisible onClicked: { + controlCenterPopout.triggerScreen = root.screen; controlCenterPopout.controlCenterVisible = !controlCenterPopout.controlCenterVisible; if (controlCenterPopout.controlCenterVisible) { if (NetworkService.wifiEnabled) diff --git a/Modules/TopBar/Weather.qml b/Modules/TopBar/Weather.qml index b302ddb0..f3c1d3af 100644 --- a/Modules/TopBar/Weather.qml +++ b/Modules/TopBar/Weather.qml @@ -8,6 +8,7 @@ Rectangle { property string section: "center" property var popupTarget: null + property var parentScreen: null signal clicked() @@ -55,8 +56,10 @@ Rectangle { onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0); - var screenRelativeX = globalPos.x >= Screen.width ? globalPos.x % Screen.width : globalPos.x; - popupTarget.setTriggerPosition(screenRelativeX, Theme.barHeight + Theme.spacingXS, width, section); + var currentScreen = parentScreen || Screen; + var screenX = currentScreen.x || 0; + var relativeX = globalPos.x - screenX; + popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen); } root.clicked(); }