From 71d69c88ec9668f0c8f5929c9c70907bec7ef34f Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 12 Dec 2023 11:21:27 -0500 Subject: [PATCH] feat(ags): add method to decide x pos of popup windows --- .../config/ags/js/bar/buttons/notif-button.js | 7 +++++- .../ags/js/bar/buttons/quick-settings.js | 7 +++++- devices/wim/config/ags/js/misc/popup.js | 23 +++++++++++++++++++ .../wim/config/ags/js/notifications/main.js | 3 +-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/devices/wim/config/ags/js/bar/buttons/notif-button.js b/devices/wim/config/ags/js/bar/buttons/notif-button.js index 09f72929..de52082e 100644 --- a/devices/wim/config/ags/js/bar/buttons/notif-button.js +++ b/devices/wim/config/ags/js/bar/buttons/notif-button.js @@ -12,7 +12,12 @@ const SPACING = 4; export default () => EventBox({ className: 'toggle-off', - onPrimaryClickRelease: () => App.toggleWindow('notification-center'), + onPrimaryClickRelease: (self) => { + App.getWindow('notification-center') + .setXPos(self.get_allocation(), 'right'); + + App.toggleWindow('notification-center'); + }, connections: [[App, (self, windowName, visible) => { if (windowName === 'notification-center') { diff --git a/devices/wim/config/ags/js/bar/buttons/quick-settings.js b/devices/wim/config/ags/js/bar/buttons/quick-settings.js index a1376eda..a914ad70 100644 --- a/devices/wim/config/ags/js/bar/buttons/quick-settings.js +++ b/devices/wim/config/ags/js/bar/buttons/quick-settings.js @@ -19,7 +19,12 @@ export default () => EventBox({ onHoverLost: () => { /**/ }, - onPrimaryClickRelease: () => App.toggleWindow('quick-settings'), + onPrimaryClickRelease: (self) => { + App.getWindow('notification-center') + .setXPos(self.get_allocation(), 'right'); + + App.toggleWindow('quick-settings'); + }, connections: [[App, (self, windowName, visible) => { if (windowName === 'quick-settings') { diff --git a/devices/wim/config/ags/js/misc/popup.js b/devices/wim/config/ags/js/misc/popup.js index 0f63d214..c7d96815 100644 --- a/devices/wim/config/ags/js/misc/popup.js +++ b/devices/wim/config/ags/js/misc/popup.js @@ -78,6 +78,29 @@ export default ({ }), }); + window.setXPos = ( + alloc, + side = 'right', + ) => { + const width = window.get_display() + .get_monitor_at_point(alloc.x, alloc.y) + .get_geometry().width; + + window.margins = [ + window.margins[0], + + side === 'right' ? + (width - alloc.x - alloc.width) : + window.margins[1], + + window.margins[2], + + side === 'right' ? + window.margins[3] : + (alloc.x - alloc.width), + ]; + }; + // Make getting the original child passed in this // function easier when making more code for the widget window.getChild = () => window.child.children[0].child; diff --git a/devices/wim/config/ags/js/notifications/main.js b/devices/wim/config/ags/js/notifications/main.js index 64e5fc58..29f343fb 100644 --- a/devices/wim/config/ags/js/notifications/main.js +++ b/devices/wim/config/ags/js/notifications/main.js @@ -15,12 +15,11 @@ export const NotifPopups = () => PopupWindow({ const TOP_MARGIN = 6; -const RIGHT_MARGIN = 60; export const NotifCenter = () => PopupWindow({ name: 'notification-center', anchor: ['top', 'right'], - margins: [TOP_MARGIN, RIGHT_MARGIN, 0, 0], + margins: [TOP_MARGIN, 0, 0, 0], child: NotifCenterWidget(), });