From 9cadfed0e4e541b8a65f4083800da6bf25c965da Mon Sep 17 00:00:00 2001
From: Aylur <k.demeter@protonmail.com>
Date: Thu, 23 Jan 2025 17:58:38 +0100
Subject: update popover example

---
 examples/gtk3/js/applauncher/widget/Applauncher.tsx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'examples/gtk3/js/applauncher/widget/Applauncher.tsx')

diff --git a/examples/gtk3/js/applauncher/widget/Applauncher.tsx b/examples/gtk3/js/applauncher/widget/Applauncher.tsx
index c7bac68..8206250 100644
--- a/examples/gtk3/js/applauncher/widget/Applauncher.tsx
+++ b/examples/gtk3/js/applauncher/widget/Applauncher.tsx
@@ -35,6 +35,7 @@ function AppButton({ app }: { app: Apps.Application }) {
 export default function Applauncher() {
     const { CENTER } = Gtk.Align
     const apps = new Apps.Apps()
+    const width = Variable(1000)
 
     const text = Variable("")
     const list = text(text => apps.fuzzy_query(text).slice(0, MAX_ITEMS))
@@ -49,13 +50,16 @@ export default function Applauncher() {
         exclusivity={Astal.Exclusivity.IGNORE}
         keymode={Astal.Keymode.ON_DEMAND}
         application={App}
-        onShow={() => text.set("")}
+        onShow={(self) => {
+            text.set("")
+            width.set(self.get_current_monitor().workarea.width)
+        }}
         onKeyPressEvent={function (self, event: Gdk.Event) {
             if (event.get_keyval()[1] === Gdk.KEY_Escape)
                 self.hide()
         }}>
         <box>
-            <eventbox widthRequest={4000} expand onClick={hide} />
+            <eventbox widthRequest={width(w => w / 2)} expand onClick={hide} />
             <box hexpand={false} vertical>
                 <eventbox heightRequest={100} onClick={hide} />
                 <box widthRequest={500} className="Applauncher" vertical>
@@ -81,7 +85,7 @@ export default function Applauncher() {
                 </box>
                 <eventbox expand onClick={hide} />
             </box>
-            <eventbox widthRequest={4000} expand onClick={hide} />
+            <eventbox widthRequest={width(w => w / 2)} expand onClick={hide} />
         </box>
     </window>
 }
-- 
cgit v1.2.3

