Repository navigation
Conversation
Java draws its tray menus on Windows and only maps its own logical fonts there, so the menu showed in Arial and SimSun on Chinese Windows instead of the app's Inter with the system's CJK fallback. On Windows a right click on the tray icon now opens a Ketch window covering the work area of the pointer's screen, with the same menu entries drawn as a KetchContextMenu at the pointer: just above the taskbar, in the app's theme and zoom, with submenus, keyboard navigation and glyphs, closing on a choice, Esc, a click outside or the window losing focus. macOS keeps its native menu and Linux Java's, which fontconfig already maps to the system font. KetchContextMenu opens a KetchMenu at a point, flipping as system menus do, and submenus now keep cascading the way their menu turned instead of opening back over it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Contributor
Test Results 2 229 files + 5 2 257 suites +5 57m 25s ⏱️ + 1m 25s Results for commit 5615733. ± Comparison against base commit be3a16e. This pull request removes 1 and adds 48 tests. Note that renamed tests count towards both. |
This branch has not been deployed
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.
Refs #600: the tray menu half. The zoom half landed in #643.
Problem
On Windows, Java draws tray menus itself and only maps Java's logical fonts (
WFontConfigurationfalls back to sansserif for any other name). So on Chinese Windows the menu renders in Arial plus SimSun, unlike the app (Inter, with the system's CJK fallback), and nothing set through AWT can change that.What changes
TrayMenu.kt) instead of Java'sPopupMenu. It shows the sameMenuEntrymodel (trayMenu(...)) as aKetchContextMenuat the pointer, in the app's theme, accent, density and zoom, with command glyphs and the status lines as a text block.UTILITY(no taskbar or Alt+Tab entry). It covers the work area of the pointer's screen:GraphicsConfiguration.boundsminusToolkit.getScreenInsets, so never the taskbar.compose.layers.typeis read once per process, so a window sized to the root menu would clip its submenus (Speed, Devices → device → Speed, Recent).PopupMenu(anNSMenu), attached before the icon is added, as before.trayMenuFont(zoom)). Java maps its sans-serif to the system font through fontconfig there, so the CJK problem doesn't arise. XEmbed tray proxies also report unreliable pointer positions, and transparent windows need a compositor.KetchContextMenu(position, onDismissRequest, content)opens a KetchMenu at a point, flipping as system menus do.main.kt: the tray now sits insideLocalWindowExceptionHandlerFactory, so a failure in the menu window is reported like one in the main window.Approaches weighed
JPopupMenuTrackPopupMenu)The Compose window is what the issue asks for (the app's font and zoom). The JNA menu is the fallback if this misbehaves on real Windows machines.
Snapshots
Rendered headlessly on macOS (
./gradlew :app:desktop:test -Psnapshots --tests '*TrayMenuSnapshots*') at 2×: the right part of a 1920 dp wide desktop, right-clicked on the tray icon near the taskbar's right end. CJK text here falls back to macOS's PingFang SC; on Windows, Skia falls back through DirectWrite (Microsoft YaHei UI expected).Rows: the menu while downloading; Devices → this PC → Speed, cascading left from the screen edge; Speed at 150 % zoom; Recent in Chinese.
Tests
TrayMenuPlacementTest(desktop): which screen's work area a pointer belongs to across several screens (negative origins, the shared edge, a pointer outside every screen, no screens).KetchContextMenuTest(shared): placement against a work area. Covers a taskbar below, above, left or right; a pointer inside the area; an offset screen; a menu taller than the area; an area too small for margins; RTL. Also checks the cascade direction of context menus and submenus.TrayMenuContentTest(desktop, headless Compose scene of the real tray entries): ↩ runs the first item and closes; arrows reach Devices → PC → Speed → Slow lane; ← goes back without closing; Esc and a click outside close without running anything; a click runs Quit; with the pointer on a taskbar below, the menu ends just above the bottom edge, left of the pointer../gradlew :app:desktop:test :app:shared:jvmTestpass, and app:shared compiles for wasmJs and metadata.Not verified: needs a Windows machine
All of this was built and tested on macOS. Nothing has run on Windows. Please check:
MouseInfo.getPointerInfo()(falling back to the mouse event's screen point) andgetScreenInsetsmatch on HiDPI (125–200 %) and mixed-DPI multi-monitor setups, with the taskbar on each edge, and with an auto-hiding taskbar (insets 0, so the window covers where the taskbar appears).isPopupTriggerorBUTTON3), and the left click still shows the main window.PopupMenufor that, which Windows no longer has, so that path may do nothing.UTILITYwindow stays off the taskbar and Alt+Tab and above the taskbar's flyouts. Clicking a submenu doesn't close the menu.