Commit 5e030c78 by PLN (Algolia)

fix(tray): the only UI on the rig ignored a left click

GNOME's AppIndicator extension turns button-1 on the tray icon into a
StatusNotifierItem Activate() call, Qt re-emits it as activated(Trigger), and
nothing was connected to it — so the most obvious gesture on the one UI that is
meant to be reachable mid-set did nothing at all. Only button-3 opened anything,
and that menu is drawn by the shell from the exported DBusMenu, not by us.

Qt5 hardcodes ItemIsMenu=false, so the host will never open the menu for us on a
left click; popping it at the cursor is the only route. Middle click too — a
hidden third behaviour mid-set is worse than a redundant one.

popup(), not exec_(): exec_() spins a nested modal event loop, which would stall
the 2s refresh timer and the gearbox reads behind it for as long as the menu
stayed open.
parent 519ad30a
......@@ -42,7 +42,9 @@ from pathlib import Path
from PyQt5.QtWidgets import (
QApplication, QSystemTrayIcon, QMenu, QAction, QActionGroup,
)
from PyQt5.QtGui import QIcon, QPixmap, QPainter, QColor, QFont, QPen, QPainterPath
from PyQt5.QtGui import (
QIcon, QPixmap, QPainter, QColor, QFont, QPen, QPainterPath, QCursor,
)
from PyQt5.QtCore import QTimer, Qt, QProcess, QRect, QRectF
# Shared perf logic (DRY with the web Bridge). The tray lives at the repo root;
......@@ -250,6 +252,18 @@ class PerfTray:
self.menu = QMenu()
self._build_menu()
self.tray.setContextMenu(self.menu)
# A LEFT-click had no handler at all, so the icon looked dead. GNOME's
# AppIndicator extension turns button-1 into a StatusNotifierItem
# Activate() call and Qt re-emits it as activated(Trigger) — with nothing
# connected, the most obvious gesture on the rig's only UI did nothing.
# Only button-3 opened anything, and that menu is drawn by the shell from
# the exported DBusMenu, not by us. PLN, 2026-09-06: "i see the parvagues
# tray icon, but doesnt react when i click or right click?"
# Qt5 hardcodes ItemIsMenu=false, so the host will never open the menu for
# us on a left click; popping it at the cursor is the only way. Middle
# click too — same menu, since a hidden third behaviour mid-set is worse
# than a redundant one.
self.tray.activated.connect(self.on_tray_activated)
self.tray.show()
self.timer = QTimer()
......@@ -257,6 +271,17 @@ class PerfTray:
self.timer.start(REFRESH_MS)
self.refresh()
def on_tray_activated(self, reason):
"""Left/middle click opens the same menu right-click does.
popup() (not exec_()) on purpose: exec_() spins a nested modal event loop,
which would stall the 2s refresh timer and the gearbox reads behind it for
as long as the menu stayed open. aboutToShow still fires either way, so
refresh_sc/refresh_gear label the rows correctly before they are drawn.
"""
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.MiddleClick):
self.menu.popup(QCursor.pos())
def _build_menu(self):
# ── the gearbox: two axes, laid out as two axes ──────────────────────
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment