From 78183fb45b61cf744fdc1950ec1f84cb921d1d0e Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 19 Feb 2018 10:18:55 +0000 Subject: [PATCH] Don't use FLTK's way to support HighDPI screens when the app has set a DPI awareness through a manifest - cont'd. It's also necessary to prevent FLTK from rescaling windows moved between screens with different DPI's. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12678 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_win32.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 93ea280be..3a5447de7 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -87,6 +87,10 @@ void fl_cleanup_dc_list(void); # include #endif +#ifdef FLTK_HIDPI_SUPPORT + typedef HRESULT(WINAPI * SetProcessDpiAwareness_type)(int); + static SetProcessDpiAwareness_type fl_SetProcessDpiAwareness = NULL; +#endif extern bool fl_clipboard_notify_empty(void); extern void fl_trigger_clipboard_notify(int source); @@ -519,14 +523,14 @@ void Fl_WinAPI_Screen_Driver::open_display_platform() { beenHereDoneThat = 1; #ifdef FLTK_HIDPI_SUPPORT - typedef HRESULT(WINAPI * SetProcessDpiAwareness_type)(int); HMODULE hMod = LoadLibrary("Shcore.DLL"); if (hMod) { - SetProcessDpiAwareness_type fl_SetProcessDpiAwareness = (SetProcessDpiAwareness_type)GetProcAddress(hMod, "SetProcessDpiAwareness"); + fl_SetProcessDpiAwareness = (SetProcessDpiAwareness_type)GetProcAddress(hMod, "SetProcessDpiAwareness"); const int PROCESS_PER_MONITOR_DPI_AWARE = 2; if (fl_SetProcessDpiAwareness) { HRESULT hr = fl_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); if (hr == S_OK) init_screen_scale_factors(); + else fl_SetProcessDpiAwareness = NULL; } } #endif // FLTK_HIDPI_SUPPORT @@ -1178,7 +1182,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar #ifdef FLTK_HIDPI_SUPPORT case WM_DPICHANGED: { // 0x02E0 - if (!Fl_WinAPI_Window_Driver::data_for_resize_window_between_screens_.busy) { + if (fl_SetProcessDpiAwareness && !Fl_WinAPI_Window_Driver::data_for_resize_window_between_screens_.busy) { RECT r; float f = HIWORD(wParam) / 96.; GetClientRect(hWnd, &r);