From 55de36c354d3fc9efcadec72895b0918d74abfe6 Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Wed, 23 Jul 2025 21:57:21 -0300 Subject: [PATCH] :sparkles: chore: make tray item activate on primary button click and open menu on secondary click --- ags/widget/bar/Tray.tsx | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ags/widget/bar/Tray.tsx b/ags/widget/bar/Tray.tsx index 631b45b..ecd88a4 100644 --- a/ags/widget/bar/Tray.tsx +++ b/ags/widget/bar/Tray.tsx @@ -1,10 +1,10 @@ import { createBinding, createComputed, For, With } from "ags"; import { Gdk, Gtk } from "ags/gtk4"; +import { variableToBoolean } from "../../scripts/utils"; +import GObject from "gi://GObject?version=2.0"; import AstalTray from "gi://AstalTray" import Gio from "gi://Gio?version=2.0"; -import { variableToBoolean } from "../../scripts/utils"; -import GObject from "gi://GObject?version=2.0"; const astalTray = AstalTray.get_default(); @@ -22,7 +22,6 @@ export const Tray = () => { return {(item: AstalTray.TrayItem) => - { {([actionGroup, menuModel]: [Gio.ActionGroup, Gio.MenuModel]) => { const popover = popoverFromModel(menuModel, actionGroup); - return { + return { const conns: Map = new Map(); const gestureClick = Gtk.GestureClick.new(); + gestureClick.set_button(0); self.add_controller(gestureClick); @@ -43,13 +44,20 @@ export const Tray = () => { if(gesture.get_current_button() === Gdk.BUTTON_PRIMARY) { item.activate(x, y); return; - } else if(gesture.get_current_button() === Gdk.BUTTON_SECONDARY) { + } + + if(gesture.get_current_button() === Gdk.BUTTON_SECONDARY) { item.about_to_show(); + self.set_popover(popover); + const conn = self.popover!.connect("closed", (ppover) => { + self.set_popover(null); + ppover.disconnect(conn); + }); + self.popup(); } })) }}> - }}