fix(tray): populate Linux right-click menu via setContextMenu#2856
Open
BlueManCZ wants to merge 2 commits intogitify-app:mainfrom
Open
fix(tray): populate Linux right-click menu via setContextMenu#2856BlueManCZ wants to merge 2 commits intogitify-app:mainfrom
BlueManCZ wants to merge 2 commits intogitify-app:mainfrom
Conversation
On Linux, trays go through libappindicator / StatusNotifierItem (D-Bus). Electron only emits 'right-click' on that path when no context menu is set, so the popUpContextMenu call inside our JS handler showed an empty menu (or nothing) depending on the desktop environment. Hand the menu to the host indicator instead so it renders natively on right-click. Keep the existing right-click + popUpContextMenu path on macOS / Windows — setContextMenu intercepts left-click on macOS and would break the menubar window toggle. Refs gitify-app#1612, gitify-app#2096. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Some Linux tray providers (e.g. KStatusNotifier-backed indicators on GNOME) require a double-click on the icon to trigger the primary action. A "Toggle Gitify" menu item gives users a guaranteed single-click path to show or hide the popup regardless of the provider's activation behavior. Static label keeps the menu cheap on Linux — no need to rebuild and re-call setContextMenu on visibility changes for a Show/Hide label flip to propagate over D-Bus. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member
|
Can you help me better understand the |
Contributor
Author
|
It's just Show/Hide for the Gitify window. Applications usually have this in tray menu, I thought Gitify may have this as well. |
Member
Gotcha Is this a common context menu in each Linux app? What would the experience be like if this was left out? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Right-clicking the tray icon on Linux opened an empty menu (or nothing at all on some DEs) because the existing
right-click→popUpContextMenuhandler doesn't reach libappindicator / StatusNotifierItem (D-Bus). On that path, Electron only emits theright-clickevent when no context menu is set —setContextMenuinstead hands the menu to the host indicator so it renders natively on right-click.Left-click behavior is unchanged on every platform — menubar's own click handler still toggles the popup. Note that some tray providers (e.g. KStatusNotifier-backed indicators on GNOME) require a double-click to trigger the icon's primary action by design; that's a property of the provider, not something this PR alters either way.
The macOS / Windows code path is intentionally untouched:
setContextMenuintercepts left-click on macOS and would break the menubar window toggle, so those platforms keep the existingright-click+popUpContextMenuhandler.This mirrors the approach we took in zoidsh/meru#498.
Toggle Gitify menu entry
Adds a
Toggle Gitifyitem at the top of the right-click menu that hides the popup if it's visible and shows it otherwise. This gives users a guaranteed single-click path to the popup even on tray providers where icon activation needs a double-click. Static label (rather than dynamic Show/Hide) keeps things simple on Linux — no need to rebuild and re-callsetContextMenufor label changes to propagate over D-Bus.Test plan
popUpContextMenu; left-click still toggles popup; Toggle Gitify works.pnpm testpasses (5 new tests acrossstartup.test.tsandmenu.test.ts).May close #1612, #2096 — both threads include the empty/unresponsive right-click menu reported here.
🤖 Generated with Claude Code