diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c
index 34f04c46c7..284058e1d4 100644
--- a/gfx/common/win32_common.c
+++ b/gfx/common/win32_common.c
@@ -13,10 +13,8 @@
* If not, see .
*/
-#include "../../driver.h"
#include "../../general.h"
#include "win32_common.h"
-#include
#if !defined(_XBOX) && defined(_WIN32)
@@ -182,3 +180,39 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
return 0L;
}
#endif
+
+bool win32_get_metrics(void *data,
+ enum display_metric_types type, float *value)
+{
+#ifdef _XBOX
+ return false;
+#else
+ HDC monitor = GetDC(NULL);
+ int pixels_x = GetDeviceCaps(monitor, HORZRES);
+ int pixels_y = GetDeviceCaps(monitor, VERTRES);
+ int physical_width = GetDeviceCaps(monitor, HORZSIZE);
+ int physical_height = GetDeviceCaps(monitor, VERTSIZE);
+
+ ReleaseDC(NULL, monitor);
+
+ switch (type)
+ {
+ case DISPLAY_METRIC_MM_WIDTH:
+ *value = physical_width;
+ break;
+ case DISPLAY_METRIC_MM_HEIGHT:
+ *value = physical_height;
+ break;
+ case DISPLAY_METRIC_DPI:
+ /* 25.4 mm in an inch. */
+ *value = 254 * pixels_x / physical_width / 10;
+ break;
+ case DISPLAY_METRIC_NONE:
+ default:
+ *value = 0;
+ return false;
+ }
+
+ return true;
+#endif
+}
diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h
index 53054277db..dbd181bd7f 100644
--- a/gfx/common/win32_common.h
+++ b/gfx/common/win32_common.h
@@ -17,6 +17,11 @@
#ifndef WIN32_COMMON_H__
#define WIN32_COMMON_H__
+#include
+#include
+#include "../../driver.h"
+#include "../video_context_driver.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -32,6 +37,9 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
LRESULT win32_menu_loop(HWND handle, WPARAM wparam);
#endif
+bool win32_get_metrics(void *data,
+ enum display_metric_types type, float *value);
+
#ifdef __cplusplus
}
#endif
diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp
index 65a1b5bb2b..b0714753da 100644
--- a/gfx/drivers_context/d3d_ctx.cpp
+++ b/gfx/drivers_context/d3d_ctx.cpp
@@ -495,37 +495,7 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
static bool gfx_ctx_d3d_get_metrics(void *data,
enum display_metric_types type, float *value)
{
-#ifdef _XBOX
- return false;
-#else
- HDC monitor = GetDC(NULL);
- int pixels_x = GetDeviceCaps(monitor, HORZRES);
- int pixels_y = GetDeviceCaps(monitor, VERTRES);
- int physical_width = GetDeviceCaps(monitor, HORZSIZE);
- int physical_height = GetDeviceCaps(monitor, VERTSIZE);
-
- ReleaseDC(NULL, monitor);
-
- switch (type)
- {
- case DISPLAY_METRIC_MM_WIDTH:
- *value = physical_width;
- break;
- case DISPLAY_METRIC_MM_HEIGHT:
- *value = physical_height;
- break;
- case DISPLAY_METRIC_DPI:
- /* 25.4 mm in an inch. */
- *value = 254 * pixels_x / physical_width / 10;
- break;
- case DISPLAY_METRIC_NONE:
- default:
- *value = 0;
- return false;
- }
-
- return true;
-#endif
+ return win32_get_metrics(data, type, value);
}
const gfx_ctx_driver_t gfx_ctx_d3d = {
diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c
index ba38d85df5..b49dde7304 100644
--- a/gfx/drivers_context/wgl_ctx.c
+++ b/gfx/drivers_context/wgl_ctx.c
@@ -667,34 +667,7 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
static bool gfx_ctx_wgl_get_metrics(void *data,
enum display_metric_types type, float *value)
{
- bool ret = true;
- HDC monitor = GetDC(NULL);
- int pixels_x = GetDeviceCaps(monitor, HORZRES);
- int pixels_y = GetDeviceCaps(monitor, VERTRES);
- int physical_width = GetDeviceCaps(monitor, HORZSIZE);
- int physical_height = GetDeviceCaps(monitor, VERTSIZE);
-
- ReleaseDC(NULL, monitor);
-
- switch (type)
- {
- case DISPLAY_METRIC_MM_WIDTH:
- *value = physical_width;
- break;
- case DISPLAY_METRIC_MM_HEIGHT:
- *value = physical_height;
- break;
- case DISPLAY_METRIC_DPI:
- /* 25.4 mm in an inch. */
- *value = 254 * pixels_x / physical_width / 10;
- break;
- case DISPLAY_METRIC_NONE:
- default:
- *value = 0;
- return false;
- }
-
- return true;
+ return win32_get_metrics(data, type, value);
}
static bool gfx_ctx_wgl_bind_api(void *data,
diff --git a/griffin/griffin.c b/griffin/griffin.c
index f0a930b4e1..d38d511451 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -86,11 +86,15 @@ CHEATS
/*============================================================
UI COMMON CONTEXT
============================================================ */
-#if defined(_WIN32) && !defined(_XBOX)
+#if defined(_WIN32)
#include "../gfx/common/win32_common.c"
+
+#ifndef _XBOX
#include "../gfx/drivers_wm/win32_dwm_common.c"
#endif
+#endif
+
/*============================================================
VIDEO CONTEXT
============================================================ */