Add partial support for Windows 8.1 per-monitor DPI

Related to #235.
This commit is contained in:
Camilla Berglund 2015-11-01 17:29:13 +01:00
parent 6a41d5e7ad
commit 9f3636a103
4 changed files with 49 additions and 1 deletions

View File

@ -70,6 +70,7 @@ used by the tests and examples and are not required to build the library.
- Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support - Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support
- Added `GLFW_TRUE` and `GLFW_FALSE` as client API independent boolean values - Added `GLFW_TRUE` and `GLFW_FALSE` as client API independent boolean values
- Removed dependency on external OpenGL or OpenGL ES headers - Removed dependency on external OpenGL or OpenGL ES headers
- [Win32] Added support for Windows 8.1 per-monitor DPI
- [Cocoa] Removed support for OS X 10.6 - [Cocoa] Removed support for OS X 10.6
- [X11] Bugfix: Monitor connection and disconnection events were not reported - [X11] Bugfix: Monitor connection and disconnection events were not reported
- [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end - [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end

View File

@ -99,6 +99,13 @@ static GLFWbool initLibraries(void)
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
} }
_glfw.win32.shcore.instance = LoadLibraryW(L"shcore.dll");
if (_glfw.win32.shcore.instance)
{
_glfw.win32.shcore.SetProcessDPIAwareness = (SETPROCESSDPIAWARENESS_T)
GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDPIAwareness");
}
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -114,6 +121,9 @@ static void terminateLibraries(void)
if (_glfw.win32.dwmapi.instance) if (_glfw.win32.dwmapi.instance)
FreeLibrary(_glfw.win32.dwmapi.instance); FreeLibrary(_glfw.win32.dwmapi.instance);
if (_glfw.win32.shcore.instance)
FreeLibrary(_glfw.win32.shcore.instance);
} }
// Create key code translation tables // Create key code translation tables
@ -328,7 +338,9 @@ int _glfwPlatformInit(void)
createKeyTables(); createKeyTables();
if (_glfw_SetProcessDPIAware) if (_glfw_SetProcessDPIAwareness)
_glfw_SetProcessDPIAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
else if (_glfw_SetProcessDPIAware)
_glfw_SetProcessDPIAware(); _glfw_SetProcessDPIAware();
if (!_glfwRegisterWindowClass()) if (!_glfwRegisterWindowClass())

View File

@ -86,6 +86,9 @@
#ifndef UNICODE_NOCHAR #ifndef UNICODE_NOCHAR
#define UNICODE_NOCHAR 0xFFFF #define UNICODE_NOCHAR 0xFFFF
#endif #endif
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
#if WINVER < 0x0601 #if WINVER < 0x0601
typedef struct tagCHANGEFILTERSTRUCT typedef struct tagCHANGEFILTERSTRUCT
@ -99,6 +102,15 @@ typedef struct tagCHANGEFILTERSTRUCT
#endif #endif
#endif /*Windows 7*/ #endif /*Windows 7*/
#ifndef DPI_ENUMS_DECLARED
typedef enum PROCESS_DPI_AWARENESS
{
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
#endif /*DPI_ENUMS_DECLARED*/
// winmm.dll function pointer typedefs // winmm.dll function pointer typedefs
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT); typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO); typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
@ -121,6 +133,10 @@ typedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);
#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled #define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled
#define _glfw_DwmFlush _glfw.win32.dwmapi.DwmFlush #define _glfw_DwmFlush _glfw.win32.dwmapi.DwmFlush
// shcore.dll function pointer typedefs
typedef HRESULT (WINAPI * SETPROCESSDPIAWARENESS_T)(PROCESS_DPI_AWARENESS);
#define _glfw_SetProcessDPIAwareness _glfw.win32.shcore.SetProcessDPIAwareness
#include "win32_tls.h" #include "win32_tls.h"
#include "winmm_joystick.h" #include "winmm_joystick.h"
@ -191,6 +207,12 @@ typedef struct _GLFWlibraryWin32
DWMFLUSH_T DwmFlush; DWMFLUSH_T DwmFlush;
} dwmapi; } dwmapi;
// shcore.dll
struct {
HINSTANCE instance;
SETPROCESSDPIAWARENESS_T SetProcessDPIAwareness;
} shcore;
} _GLFWlibraryWin32; } _GLFWlibraryWin32;

View File

@ -584,6 +584,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
break; break;
} }
case WM_DPICHANGED:
{
RECT* rect = (RECT*) lParam;
SetWindowPos(window->win32.handle,
HWND_TOP,
rect->left,
rect->top,
rect->right - rect->left,
rect->bottom - rect->top,
SWP_NOACTIVATE | SWP_NOZORDER);
break;
}
case WM_DEVICECHANGE: case WM_DEVICECHANGE:
{ {
if (DBT_DEVNODES_CHANGED == wParam) if (DBT_DEVNODES_CHANGED == wParam)