From 9938be93a19ae3eb09ec7704d800991eb7fc0f12 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Thu, 28 May 2020 08:26:52 +1000 Subject: Bug [#2171]. Check for DPI change in WM_DPICHANGED_AFTERPARENT instead of every paint. --- win32/ScintillaWin.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 28b6e950c..f2f6976f5 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -99,6 +99,9 @@ #ifndef WM_DPICHANGED #define WM_DPICHANGED 0x02E0 #endif +#ifndef WM_DPICHANGED_AFTERPARENT +#define WM_DPICHANGED_AFTERPARENT 0x02E3 +#endif #ifndef UNICODE_NOCHAR #define UNICODE_NOCHAR 0xFFFF @@ -376,8 +379,6 @@ class ScintillaWin : Sci::Position TargetAsUTF8(char *text) const; Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const; - void CheckDpiChanged(); - bool PaintDC(HDC hdc); sptr_t WndPaint(); @@ -901,14 +902,6 @@ Sci::Position ScintillaWin::EncodedFromUTF8(const char *utf8, char *encoded) con } } -void ScintillaWin::CheckDpiChanged() { - const UINT dpiNow = DpiForWindow(wMain.GetID()); - if (dpi != dpiNow) { - dpi = dpiNow; - InvalidateStyleData(); - } -} - bool ScintillaWin::PaintDC(HDC hdc) { if (technology == SC_TECHNOLOGY_DEFAULT) { AutoSurface surfaceWindow(hdc, this); @@ -939,7 +932,6 @@ bool ScintillaWin::PaintDC(HDC hdc) { } sptr_t ScintillaWin::WndPaint() { - CheckDpiChanged(); //ElapsedPeriod ep; // Redirect assertions to debug output and save current state @@ -1965,6 +1957,15 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam InvalidateStyleRedraw(); break; + case WM_DPICHANGED_AFTERPARENT: { + const UINT dpiNow = DpiForWindow(wMain.GetID()); + if (dpi != dpiNow) { + dpi = dpiNow; + InvalidateStyleRedraw(); + } + } + break; + case WM_CONTEXTMENU: return ShowContextMenu(iMessage, wParam, lParam); -- cgit v1.2.3