Repository navigation
Conversation
WHAT: * Dynamically resolve and query GetDpiForWindow on the target composition or IME window with fallback to GetDeviceCaps(LOGPIXELSY) and 96 DPI. * Scale candidate and tooltip font height dynamically based on monitor DPI (-MulDiv(candFontSize, dpi, 72)). * Cache current DPI per candidate/message window and update font only when monitor DPI changes or when font settings are modified. * Replace shared font_ and updateFont_ member variables with independent window font updates. * Use static_cast and reinterpret_cast instead of C-style casts. WHY: * Fixes #960. Currently PIMETextService creates a single font at startup based on system primary DC DPI. On Windows 10/11 multi-monitor systems with mixed DPI scaling (e.g., 100% and 150%/200%), candidate and message windows rendered with incorrect font sizing and blurry text when moved between monitors. Generated with assistance from Antigravity.
|
Code review(沒有裝機實測,手邊沒有能編譯的環境,但有雙螢幕混合 DPI 的機器,之後有簽章的 build 可以幫測)。兩點: 1. HFONT 會隨每次候選視窗開關漏掉一個 GDI handle。 2. 分支的 libIME2 submodule 指到舊的 commit。 其他部分( (由 Claude Code (Claude Fable 5.1) 協助審閱) |
Resolves #960
Summary of Changes
GetDpiForWindowvia dynamic resolution fromuser32.dllon the composition or IME window, falling back to device caps (LOGPIXELSY) and 96 DPI.-MulDiv(candFontSize_, dpi, 72)instead of using a static font created at startup.currentCandDpi_andcurrentMsgDpi_independently, updating and applying font scaling only when moving across monitors with differing DPI or when font settings (candFontSize_,candFontName_) are updated.font_andupdateFont_flag fromTextService, allowingImeWindow::setFontto manage font handle lifetime cleanly without risk of double-free or use-after-free.static_castandreinterpret_cast.Verification
PIMETextService.vcxprojlocally with 0 errors.Generated with assistance from Antigravity.