Skip to content

Commit 491873a

Browse files
yukawahiroyuki-komatsu
authored andcommitted
Fix window locations under Per-Monitor DPI in Windows
This is a minimum change to place candidate windows around the cursor location even under Per-Monitor DPI mode in Windows. Note that there are still known issues that 'mozc_render' continues using the initial DPI. Watch #831 for such remaining issues. Closes #832. PiperOrigin-RevId: 575633393
1 parent d155a14 commit 491873a

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

Diff for: src/renderer/win32/candidate_window.cc

+4
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ void CandidateWindow::OnDestroy() {
291291
::PostQuitMessage(0);
292292
}
293293

294+
void CandidateWindow::OnDpiChanged(UINT dpiX, UINT dpiY, RECT *rect) {
295+
metrics_changed_ = true;
296+
}
297+
294298
BOOL CandidateWindow::OnEraseBkgnd(CDCHandle dc) {
295299
// We do not have to erase background
296300
// because all pixels in client area will be drawn in the DoPaint method.

Diff for: src/renderer/win32/candidate_window.h

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class CandidateWindow : public ATL::CWindowImpl<CandidateWindow, ATL::CWindow,
7777
BEGIN_MSG_MAP_EX(CandidateWindow)
7878
MSG_WM_CREATE(OnCreate)
7979
MSG_WM_DESTROY(OnDestroy)
80+
MSG_WM_DPICHANGED(OnDpiChanged)
8081
MSG_WM_ERASEBKGND(OnEraseBkgnd)
8182
MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
8283
MSG_WM_LBUTTONDOWN(OnLButtonDown)
@@ -93,6 +94,7 @@ class CandidateWindow : public ATL::CWindowImpl<CandidateWindow, ATL::CWindow,
9394
~CandidateWindow();
9495
LRESULT OnCreate(LPCREATESTRUCT create_struct);
9596
void OnDestroy();
97+
void OnDpiChanged(UINT dpiX, UINT dpiY, RECT *rect);
9698
BOOL OnEraseBkgnd(WTL::CDCHandle dc);
9799
void OnGetMinMaxInfo(MINMAXINFO *min_max_info);
98100
void OnLButtonDown(UINT nFlags, CPoint point);

Diff for: src/renderer/win32/infolist_window.cc

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ void InfolistWindow::OnDestroy() {
104104
::PostQuitMessage(0);
105105
}
106106

107+
void InfolistWindow::OnDpiChanged(UINT dpiX, UINT dpiY, RECT *rect) {
108+
metrics_changed_ = true;
109+
}
110+
107111
BOOL InfolistWindow::OnEraseBkgnd(CDCHandle dc) {
108112
// We do not have to erase background
109113
// because all pixels in client area will be drawn in the DoPaint method.

Diff for: src/renderer/win32/infolist_window.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class InfolistWindow : public ATL::CWindowImpl<InfolistWindow, ATL::CWindow,
7070

7171
BEGIN_MSG_MAP_EX(InfolistWindow)
7272
MSG_WM_DESTROY(OnDestroy)
73+
MSG_WM_DPICHANGED(OnDpiChanged)
7374
MSG_WM_ERASEBKGND(OnEraseBkgnd)
7475
MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
7576
MSG_WM_SETTINGCHANGE(OnSettingChange)
@@ -83,6 +84,7 @@ class InfolistWindow : public ATL::CWindowImpl<InfolistWindow, ATL::CWindow,
8384
InfolistWindow &operator=(const InfolistWindow &) = delete;
8485
~InfolistWindow();
8586
void OnDestroy();
87+
void OnDpiChanged(UINT dpiX, UINT dpiY, RECT *rect);
8688
BOOL OnEraseBkgnd(WTL::CDCHandle dc);
8789
void OnGetMinMaxInfo(MINMAXINFO *min_max_info);
8890
void OnPaint(WTL::CDCHandle dc);

Diff for: src/renderer/win32/mozc_renderer.exe.manifest

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
2525
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
2626
<dpiAware>true</dpiAware>
27+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
28+
PerMonitorV2
29+
</dpiAwareness>
2730
</asmv3:windowsSettings>
2831
</asmv3:application>
2932
</assembly>

0 commit comments

Comments
 (0)