From b46c9cea877d5edc7a26aeb7cea79b771f2b390f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 10 Apr 2015 09:30:18 +0200 Subject: [PATCH] Create win32_show_cursor --- gfx/common/win32_common.c | 10 ++++++++++ gfx/common/win32_common.h | 2 ++ gfx/drivers_context/d3d_ctx.cpp | 7 +------ gfx/drivers_context/wgl_ctx.c | 12 ++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 175fe06c0a..b415a8a58d 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -216,3 +216,13 @@ bool win32_get_metrics(void *data, return true; #endif } + +void win32_show_cursor(bool state) +{ +#ifdef HAVE_WINDOW + if (state) + while (ShowCursor(TRUE) < 0); + else + while (ShowCursor(FALSE) >= 0); +#endif +} diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 1cc1293d72..4a78bda07e 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -40,6 +40,8 @@ LRESULT win32_menu_loop(HWND handle, WPARAM wparam); bool win32_get_metrics(void *data, enum display_metric_types type, float *value); +void win32_show_cursor(bool state); + #ifdef __cplusplus } #endif diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 75a2052fef..45eda6e3e9 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -156,12 +156,7 @@ static void gfx_ctx_d3d_show_mouse(void *data, bool state) { (void)data; -#ifdef HAVE_WINDOW - if (state) - while (ShowCursor(TRUE) < 0); - else - while (ShowCursor(FALSE) >= 0); -#endif + win32_show_cursor(state); } void d3d_make_d3dpp(void *data, diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index e2375499a6..38933dceae 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -440,14 +440,6 @@ static bool set_fullscreen(unsigned width, unsigned height, char *dev_name) return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; } -static void show_cursor(bool show) -{ - if (show) - while (ShowCursor(TRUE) < 0); - else - while (ShowCursor(FALSE) >= 0); -} - static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use) { unsigned fs_monitor; @@ -544,7 +536,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, SetFocus(g_hwnd); } - show_cursor(!fullscreen); + win32_show_cursor(!fullscreen); /* Wait until GL context is created (or failed to do so ...) */ while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0)) @@ -685,7 +677,7 @@ static bool gfx_ctx_wgl_bind_api(void *data, static void gfx_ctx_wgl_show_mouse(void *data, bool state) { (void)data; - show_cursor(state); + win32_show_cursor(state); } static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable)