From 0b4c525cf34c627df81288a376b5b627e3fda6d9 Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Mon, 25 Sep 2023 12:30:32 -0400
Subject: [PATCH] fix(ags): make revealers work on first try

---
 config/ags/js/date.js                 |  1 +
 config/ags/js/misc/popup.js           | 45 ++++++++++-----------------
 config/ags/js/notifications/center.js |  1 +
 config/ags/js/overview/main.js        |  1 +
 config/ags/js/powermenu.js            |  1 +
 config/ags/js/quick-settings/main.js  |  1 +
 6 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/config/ags/js/date.js b/config/ags/js/date.js
index 1b623e9f..263b9b96 100644
--- a/config/ags/js/date.js
+++ b/config/ags/js/date.js
@@ -71,6 +71,7 @@ const CalendarWidget = () => Box({
 export const Calendar = Window({
   name: 'calendar',
   layer: 'overlay',
+  popup: true,
   anchor: 'top right',
   margin: [ 8, 182, 0, 0],
   child: PopUp({
diff --git a/config/ags/js/misc/popup.js b/config/ags/js/misc/popup.js
index aeca01fe..60a19d39 100644
--- a/config/ags/js/misc/popup.js
+++ b/config/ags/js/misc/popup.js
@@ -1,31 +1,20 @@
-const { Revealer } = ags.Widget;
-const { closeWindow, openWindow } = ags.App;
+const { Revealer, Box } = ags.Widget;
+const { openWindow } = ags.App;
 
-export const PopUp = ({name, child, transition = 'slide_down', ...params}) => Revealer({
-  ...params,
-  // FIXME: popups don't work with revealers
-  setup: () => {
-    setTimeout(() => {
-      closeWindow(name);
-    }, 100);
+export const PopUp = ({name, child, transition = 'slide_down', ...params}) => Box({
+  style: 'min-height:1px; min-width:1px',
+  child: Revealer({
+    ...params,
+    transition,
+    transitionDuration: 500,
+    connections: [[ags.App, (revealer, currentName, visible) => {
+      if (currentName === name) {
+        revealer.reveal_child = visible;
 
-    // my eyes hurt
-    if (name == 'overview') {
-      setTimeout(() => {
-        openWindow(name);
-        closeWindow(name);
-      }, 700);
-    }
-  },
-  transition,
-  transitionDuration: 500,
-  connections: [[ags.App, (revealer, currentName, visible) => {
-    if (currentName === name) {
-      revealer.reveal_child = visible;
-
-      if (visible && name !== 'overview')
-        openWindow('closer');
-    }
-  }]],
-  child: child,
+        if (visible && name !== 'overview')
+          openWindow('closer');
+      }
+    }]],
+    child: child,
+  }),
 });
diff --git a/config/ags/js/notifications/center.js b/config/ags/js/notifications/center.js
index 9e09d80a..3ee07080 100644
--- a/config/ags/js/notifications/center.js
+++ b/config/ags/js/notifications/center.js
@@ -136,6 +136,7 @@ export const NotificationCenter = Window({
   name: 'notification-center',
   layer: 'overlay',
   anchor: 'top right',
+  popup: true,
   margin: [ 8, 60, 0, 0 ],
   child: PopUp({
     name: 'notification-center',
diff --git a/config/ags/js/overview/main.js b/config/ags/js/overview/main.js
index 882f8222..b998afe0 100644
--- a/config/ags/js/overview/main.js
+++ b/config/ags/js/overview/main.js
@@ -8,6 +8,7 @@ import { updateClients } from './clients.js';
 export default Window({
   name: 'overview',
   layer: 'overlay',
+  popup: true,
 
   child: PopUp({
     name: 'overview',
diff --git a/config/ags/js/powermenu.js b/config/ags/js/powermenu.js
index 5a2b0411..381a9273 100644
--- a/config/ags/js/powermenu.js
+++ b/config/ags/js/powermenu.js
@@ -37,6 +37,7 @@ const PowermenuWidget = CenterBox({
 
 export const Powermenu = Window({
   name: 'powermenu',
+  popup: true,
   layer: 'overlay',
   child: PopUp({
     name: 'powermenu',
diff --git a/config/ags/js/quick-settings/main.js b/config/ags/js/quick-settings/main.js
index 1b7c5068..40dc13b4 100644
--- a/config/ags/js/quick-settings/main.js
+++ b/config/ags/js/quick-settings/main.js
@@ -71,6 +71,7 @@ export const QuickSettings = Window({
   name: 'quick-settings',
   layer: 'overlay',
   anchor: 'top right',
+  popup: true,
   margin: [ 8, 5, 0, ],
   child: PopUp({
     name: 'quick-settings',