Repository navigation
Put the Windows tray on NotifyIconTray - #1013
Merged
Merged
Conversation
The Windows head drew its own NotifyIcon, built the tracked half of its menu on every open beside fixed items it kept, opened the menu on a left click through NotifyIcon's ShowContextMenu, and registered hot keys against the icon's window. The macOS and Linux heads hand a model to PlatformHeads' tray every tenth of a second, so the menu was two implementations. Now the Windows head's tray is PlatformHeads' NotifyIconTray, which makes the menu from the last model as it opens. The turns every head takes are TrayTurns, which TrayLoop runs for the other two and a WinForms timer runs here, on the message loop the icon's events are raised on. MenuBuilder is only how the menu looks: the font, the directions, the tips and the glyphs, and LeftClickOpensMenu. Hot keys go to the tray's Handle, and balloons are TrayNotificationKind.Warning, as they were. A menu can now be a turn behind the tracker, which the ids make safe: a click is done on the menus it was chosen from. MenuBuilderTest shows the menu through MenuTray, which makes it as NotifyIconTray does with no icon in the notification area, and its images are unchanged. The two tests of rebuilding around kept items go, since there are none now, and MenuOnOpening's own tests in PlatformHeads hold to what is left of that. All seven PlatformHeads pins move to 0.10.0, which has NotifyIconTray's additions and runs build-native's macOS job on macos-15, since GitHub retires macos-14 on November 2.
Co-authored-by: SimonCropp <122666+SimonCropp@users.noreply.github.com>
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.
The Windows tray head drew its own
NotifyIconand built its menu itself: the fixed items kept, the tracked ones built on every open. The macOS and Linux heads hand a model to PlatformHeads' tray every tenth of a second, so the menu was shown by two implementations. This needs PlatformHeads 0.10.0 (SimonCropp/PlatformHeads#10) forLeftClickOpensMenu,NotifyIconTray.HandleandTrayNotificationKind.Warning, so all seven pins move to it. 0.10.0 also moves its reusablebuild-nativeworkflow's macOS job frommacos-14, which GitHub retires on November 2, tomacos-15(SimonCropp/PlatformHeads#11). So the nextbuild-nativerun here builds the Swift libraries on macOS 15.The change.
The tray: the Windows head's tray is now
NotifyIconTray<TrayIcon>, which makes the menu from the last model each time it opens.The turns:
TrayTurns(new, in the core) is the turn every head takes. It applies a model of both halves, and does a click on the menus it was chosen from, which it also answers tips from.TrayLoopruns it for Linux and macOS. On Windows aSystem.Windows.Forms.Timerruns it on the message loop, where the icon's events are raised.MenuBuilderis now only how the menu looks, asNotifyIconOptions:Theme: the menu's font and opening direction;Style: the tips and the submenus' direction;LeftClickOpensMenu.Extensions.Handleand theShowContextMenuaccessor are gone, since PlatformHeads does both now.What stays the same:
tray.Handle;Warning, and the update report isInfoorWarning;The cost: an open menu can be up to a tenth of a second behind the tracker, which the ids make safe. And the menu is built ten times a second while the tray is idle, as on Linux. The tracker's lists are cached, so nothing asks a socket or the disk to build it.
Docs: CLAUDE.md. It also drops a stale mention of a
macos-14CI job; the macOS build is theunixjob'smacos-latestleg.Tests.
MenuBuilderTestshows the menu throughMenuTray, a stand-inITraythat makes it asNotifyIconTraydoes, with the head's real options and turns and no icon in the notification area.Empty,Full,FullGroupedandSnapshotThatWasNotWrittenDropDownpass against their existing images, unchanged.AClickDoesWhatItsItemDoesnow clicks and then takes a turn.A_group_named_after_a_fixed_item_is_removed_with_the_restandTracked_items_are_disposed_by_the_next_openare removed. No item is kept now, andMenuOnOpeningTestsin PlatformHeads covers what's left of that.Locally on Windows, against the published 0.10.0 packages, a Release build had no errors:
Not seen working. I didn't run the tray itself: one was already running on this machine, holding the mutex a second one exits on.