google / mozc

Mozc - a Japanese Input Method Editor designed for multi-platform
Other
2.4k stars 348 forks source link

Conform Per-Monitor DPI v2 protocol in Windows #831

Open yukawa opened 11 months ago

yukawa commented 11 months ago

Description

Currently Mozc binaries fall into System DPI Awareness category in Windows.

We'd like to make them run under Per-Monitor v2 Awareness mode.

Version or commit-id

af209061632ba7dcc64b63bd06eb988974375508

Environment

Additional Context

src/gui/tool/mozc_tool.exe.manifest

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/gui/tool/mozc_tool.exe.manifest#L25-L27 Needs PerMonitorV2 declaration.

      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>

Also, it'd be safer to switch to Qt 6.6 or later version, which contains https://github.com/qt/qtbase/commit/5e0d9a077d28802988182319ae257e9102f0344e.


src/renderer/win32/mozc_renderer.exe.manifest

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/renderer/win32/mozc_renderer.exe.manifest#L25-L27 Needs PerMonitorV2 declaration.

      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>

src/renderer/win32/indicator_window.cc

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/renderer/win32/indicator_window.cc#L96-L100 We can no longer assume this is a runtime constant.

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/renderer/win32/indicator_window.cc#L115-L119 We also need to handle WM_DPICHANGED.


src/renderer/win32/candidate_window.h

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/renderer/win32/candidate_window.h#L77-L88 We also need to handle WM_DPICHANGED.


src/renderer/win32/candidate_window.cc

https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/renderer/win32/candidate_window.cc#L234-L265 scale_factor_x and scale_factor_y are no longer the runtime constants. We need to re-calculate these values every time WM_DPICHANGED is received.


src/win32/tip/tip_lang_bar_menu.cc

LoadIconFromResource should use GetSystemMetricsForDpi with primary display's DPI no matter which display is used to show the application, because the IME mode icon is shown only on the primary display. https://github.com/google/mozc/blob/af209061632ba7dcc64b63bd06eb988974375508/src/win32/tip/tip_lang_bar_menu.cc#L105-L119