Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346281: [Windows] RenderScale doesn't update to HiDPI changes #1668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions modules/javafx.graphics/src/main/native-glass/win/GlassWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this value come from some windows header?

#endif

#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down