summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-05-29 13:40:00 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-05-29 13:40:21 -0300
commit4f100f92d859848f44c972c08e7fbf37c04e8d3e (patch)
tree988ebf8014e22d2ded723d79e91e990c2c9bd1f9 /platform/windows/os_windows.cpp
parentd31696e3dbe54111cfcf444abf854a55c94bdb76 (diff)
DPI Detection support
Windows only for now. Many builds may break (older visual studio, mingw32)
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index bf8b0ee6b5..8bb5de5d5d 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -57,6 +57,13 @@
#include <regstr.h>
#include <process.h>
+#if (_MSC_VER >= 1700)
+#define HIDPI_SUPPORT
+#endif
+
+#ifdef HIDPI_SUPPORT
+#include <ShellScalingAPI.h>
+#endif
static const WORD MAX_CONSOLE_LINES = 1500;
extern "C" {
@@ -854,7 +861,13 @@ BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPR
minfo.rect.pos.y=lprcMonitor->top;
minfo.rect.size.x=lprcMonitor->right - lprcMonitor->left;
minfo.rect.size.y=lprcMonitor->bottom - lprcMonitor->top;
-
+#ifdef HIDPI_SUPPORT
+ UINT dpix,dpiy;
+ GetDpiForMonitor(hMonitor,MDT_EFFECTIVE_DPI,&dpix,&dpiy);
+ minfo.dpi=(dpix + dpiy)/2;
+#else
+ minfo.dpi=72;
+#endif
self->monitor_info.push_back(minfo);
return TRUE;
@@ -1366,6 +1379,14 @@ Size2 OS_Windows::get_screen_size(int p_screen) const{
return Vector2( monitor_info[p_screen].rect.size );
}
+
+int OS_Windows::get_screen_dpi(int p_screen) const {
+
+ ERR_FAIL_INDEX_V(p_screen,monitor_info.size(),72);
+ UINT dpix,dpiy;
+ return monitor_info[p_screen].dpi;
+
+}
Point2 OS_Windows::get_window_position() const{
RECT r;