Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions synodic_client/application/screen/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
class TrayScreen:
"""Tray screen for the application."""

_MENU_POPUP_DELAY_MS = 100

def __init__(
self,
app: QApplication,
Expand All @@ -57,6 +55,9 @@ def __init__(
self.tray.activated.connect(self._on_tray_activated)

self._build_menu()
# setContextMenu delegates positioning to the OS tray API, which
# correctly avoids the taskbar. Do not manually handle the Context
# activation reason — that causes duplicate popups or z-order issues.
self.tray.setContextMenu(self._menu)

# At early Windows login the notification area may not be ready.
Expand Down Expand Up @@ -150,13 +151,6 @@ def _on_tray_activated(self, reason: QSystemTrayIcon.ActivationReason) -> None:
logger.debug('Tray activated: reason=%s', reason.name)
if reason == QSystemTrayIcon.ActivationReason.DoubleClick:
self._show_window()
elif reason == QSystemTrayIcon.ActivationReason.Context:
QTimer.singleShot(self._MENU_POPUP_DELAY_MS, self._show_tray_menu)

def _show_tray_menu(self) -> None:
"""Show the tray context menu at the current cursor position."""
geo = self.tray.geometry()
self._menu.popup(geo.center())

def _show_window(self) -> None:
"""Show, raise, and focus the main window."""
Expand Down
Loading