From 3d984cebbd79dee4dc949dabc855649db8e8378c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 14 Jul 2024 10:18:24 +0545 Subject: [PATCH] fix --- config/ags/modules/bar.ts | 7 ++- .../misc/cickinsidepopupwindow (copy 1).ts | 45 +++++++++++++++++++ config/ags/modules/sideleft/applauncher.ts | 6 +-- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 config/ags/modules/misc/cickinsidepopupwindow (copy 1).ts diff --git a/config/ags/modules/bar.ts b/config/ags/modules/bar.ts index 9a81fc03..4c4f37bc 100644 --- a/config/ags/modules/bar.ts +++ b/config/ags/modules/bar.ts @@ -429,7 +429,12 @@ function TaskBar() { return Widget.Box({ class_name: "tray", spacing: 5, - children: hyprland.bind("clients").as(Clients) + setup: (self) => { + self.hook(hyprland, () => { + self.children = Clients(hyprland.clients); + self.visible = self.children.length > 0; + }); + } }); } diff --git a/config/ags/modules/misc/cickinsidepopupwindow (copy 1).ts b/config/ags/modules/misc/cickinsidepopupwindow (copy 1).ts new file mode 100644 index 00000000..15baa4fa --- /dev/null +++ b/config/ags/modules/misc/cickinsidepopupwindow (copy 1).ts @@ -0,0 +1,45 @@ +import App from "resource:///com/github/Aylur/ags/app.js"; +import Widget from "resource:///com/github/Aylur/ags/widget.js"; +import { WindowProps, Window } from "types/widgets/window"; +import Gtk from "gi://Gtk?version=3.0"; + +type _WindowProps = WindowProps> | undefined[]; + +type Type = { + name: string; + child: any; + showClassName?: string; + hideClassName?: string; +}; + +export default ({ + name, + child, + showClassName = "", + hideClassName = "", + ...props +}: T & Omit<_WindowProps, keyof Type>) => { + return Widget.Window({ + name, + visible: false, + type: Gtk.WindowType.POPUP, + layer: "overlay", + resizable: true, + ...props, + setup: (self) => { + self.keybind("Escape", () => App.closeWindow(name)); + self.on("button-press-event", () => App.closeWindow(name)); // Close on mouse click + + if (showClassName !== "" && hideClassName !== "") { + self.hook(App, (self, currentName, visible) => { + if (currentName === name) { + self.toggleClassName(hideClassName, !visible); + } + }); + + self.class_name = `${showClassName} ${hideClassName}`; + } + }, + child: child + }); +}; diff --git a/config/ags/modules/sideleft/applauncher.ts b/config/ags/modules/sideleft/applauncher.ts index 0fe6511d..9e0577d7 100644 --- a/config/ags/modules/sideleft/applauncher.ts +++ b/config/ags/modules/sideleft/applauncher.ts @@ -3,10 +3,10 @@ const encoder = new TextEncoder(); const decoder = new TextDecoder(); const Gio = imports.gi.Gio; const GLib = imports.gi.GLib; -const WINDOW_NAME = "applauncher"; import Box from "types/widgets/box"; import { Application } from "types/service/applications"; import Gtk from "gi://Gtk?version=3.0"; +import { WINDOW_NAME } from "modules/sideleft/main"; const LAUNCH_COUNT_FILE = Gio.File.new_for_path( GLib.build_filenamev([GLib.get_home_dir(), ".cache", "launch_counts.json"]) @@ -75,7 +75,7 @@ function AppItem(app: Application): Box { button.connect("clicked", () => { clickCount++; - if (clickCount === 1) { + if (clickCount === 2) { incrementLaunchCount(app.name); App.closeWindow(WINDOW_NAME); app.launch(); @@ -122,7 +122,7 @@ export const Applauncher = () => { on_accept: () => { const results = applications.filter((item) => item.visible); if (results[0]) { - App.toggleWindow(WINDOW_NAME); + App.closeWindow(WINDOW_NAME); results[0].attribute.app.launch(); } },