From 368390536b41ed51159e7ab0c031abf7ba5eea22 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 1 Nov 2015 19:07:33 +0100 Subject: [PATCH 1/2] Fix bug preventing switching from Z_top to Z_normal on Windows (Reported by Epihaius) --- panda/src/windisplay/winGraphicsWindow.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 0146f2f89c..5018fb8a4a 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1272,7 +1272,7 @@ adjust_z_order(WindowProperties::ZOrder last_z_order, // have focus now, don't move it to the top; it will get moved // the next time we get focus. ) { - order = HWND_TOP; + order = HWND_NOTOPMOST; do_change = true; } break; From d8fedc1bc0dfb1e41cc760306c4a327b298239ef Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 1 Nov 2015 20:01:39 +0100 Subject: [PATCH 2/2] Call SetProcessDPIAware() to fix issues caused by DPI virtualization in Windows 8.1 --- panda/src/windisplay/config_windisplay.cxx | 6 ++++++ panda/src/windisplay/config_windisplay.h | 1 + panda/src/windisplay/winGraphicsPipe.cxx | 17 +++++++++++++++++ panda/src/windisplay/winGraphicsPipe.h | 4 ++++ 4 files changed, 28 insertions(+) diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index fe1919a6c9..e0bda2979e 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -65,6 +65,12 @@ ConfigVariableBool request_dxdisplay_information "you have a specific need for this information and don't mind " "having a slow start-up.")); +ConfigVariableBool dpi_aware +("dpi-aware", true, + PRC_DESC("The default behavior is for Panda3D to disable DPI-virtualization " + "that is introduced in Windows 8.1. Set this to false if you are " + "experiencing problems with this setting.")); + ConfigVariableBool swapbuffer_framelock ("swapbuffer-framelock", false, PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards")); diff --git a/panda/src/windisplay/config_windisplay.h b/panda/src/windisplay/config_windisplay.h index ac0e1b1df9..f3f7cb1ea4 100644 --- a/panda/src/windisplay/config_windisplay.h +++ b/panda/src/windisplay/config_windisplay.h @@ -30,6 +30,7 @@ extern ConfigVariableBool ime_composition_w; extern ConfigVariableBool ime_aware; extern ConfigVariableBool ime_hide; extern ConfigVariableBool request_dxdisplay_information; +extern ConfigVariableBool dpi_aware; extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock; diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 3776e8dbc5..eb56ec2f10 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -686,16 +686,30 @@ WinGraphicsPipe() { // these fns arent defined on win95, so get dynamic ptrs to them // to avoid ugly DLL loader failures on w95 _pfnTrackMouseEvent = NULL; + _pfnSetProcessDPIAware = NULL; _hUser32 = (HINSTANCE)LoadLibrary("user32.dll"); if (_hUser32 != NULL) { _pfnTrackMouseEvent = (PFN_TRACKMOUSEEVENT)GetProcAddress(_hUser32, "TrackMouseEvent"); + + if (dpi_aware) { + _pfnSetProcessDPIAware = + (PFN_SETPROCESSDPIAWARE)GetProcAddress(_hUser32, "SetProcessDPIAware"); + + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "Calling SetProcessDPIAware().\n"; + } + _pfnSetProcessDPIAware(); + } } #ifdef HAVE_DX9 // Use D3D to get display info. This is disabled by default as it is slow. if (request_dxdisplay_information) { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "Using Direct3D 9 to fetch display information.\n"; + } DisplaySearchParameters display_search_parameters_dx9; int dx9_display_information (DisplaySearchParameters &display_search_parameters_dx9, DisplayInformation *display_information); dx9_display_information(display_search_parameters_dx9, _display_information); @@ -703,6 +717,9 @@ WinGraphicsPipe() { #endif { // Use the Win32 API to query the available display modes. + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "Using EnumDisplaySettings to fetch display information.\n"; + } pvector display_modes; DEVMODE dm = {0}; dm.dmSize = sizeof(dm); diff --git a/panda/src/windisplay/winGraphicsPipe.h b/panda/src/windisplay/winGraphicsPipe.h index 96bdc0ed2c..2afeaf0b94 100644 --- a/panda/src/windisplay/winGraphicsPipe.h +++ b/panda/src/windisplay/winGraphicsPipe.h @@ -41,9 +41,13 @@ public: private: HINSTANCE _hUser32; + typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT); PFN_TRACKMOUSEEVENT _pfnTrackMouseEvent; + typedef BOOL (WINAPI *PFN_SETPROCESSDPIAWARE)(void); + PFN_SETPROCESSDPIAWARE _pfnSetProcessDPIAware; + public: static TypeHandle get_class_type() { return _type_handle;