Call SetProcessDPIAware() to fix issues caused by DPI virtualization in Windows 8.1

This commit is contained in:
rdb 2015-11-01 20:01:39 +01:00
parent 368390536b
commit d8fedc1bc0
4 changed files with 28 additions and 0 deletions

View File

@ -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"));

View File

@ -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;

View File

@ -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<DisplayMode> display_modes;
DEVMODE dm = {0};
dm.dmSize = sizeof(dm);

View File

@ -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;