diff --git a/modules/javafx.graphics/src/main/native-glass/win/GlassWindow.cpp b/modules/javafx.graphics/src/main/native-glass/win/GlassWindow.cpp index f1dd1f2d5c1..70b5e77608e 100644 --- a/modules/javafx.graphics/src/main/native-glass/win/GlassWindow.cpp +++ b/modules/javafx.graphics/src/main/native-glass/win/GlassWindow.cpp @@ -209,6 +209,10 @@ LRESULT CALLBACK GlassWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam) return ::CallNextHookEx(GlassWindow::sm_hCBTFilter, nCode, wParam, lParam); } +#ifndef USER_DEFAULT_SCREEN_DPI +#define USER_DEFAULT_SCREEN_DPI 96 +#endif + #ifndef WM_DPICHANGED #define WM_DPICHANGED 0x02E0 #endif @@ -360,6 +364,10 @@ LRESULT GlassWindow::WindowProc(UINT msg, WPARAM wParam, LPARAM lParam) } HandleViewSizeEvent(GetHWND(), msg, wParam, lParam); break; + case WM_DPICHANGED: + HandleDPIEvent(wParam, lParam); + GlassScreen::HandleDisplayChange(); + break; case WM_MOVING: m_winChangingReason = WasMoved; break; @@ -742,6 +750,15 @@ void GlassWindow::HandleSizeEvent(int type, RECT *pRect) CheckAndClearException(env); } +void GlassWindow::HandleDPIEvent(WPARAM wParam, LPARAM lParam) +{ + JNIEnv* env = GetEnv(); + float scale = (float) LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; + + env->CallVoidMethod(m_grefThis, midNotifyScaleChanged, scale, scale, scale, scale); + CheckAndClearException(env); +} + void GlassWindow::HandleActivateEvent(jint event) { const bool active = event != com_sun_glass_events_WindowEvent_FOCUS_LOST;