diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 85e711875e..cc8a8331d1 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -79,9 +79,11 @@ void win32_monitor_init(void) EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); } -void win32_monitor_from_window(HWND data) +void win32_monitor_from_window(HWND data, bool destroy) { win32_monitor_last = MonitorFromWindow(data, MONITOR_DEFAULTTONEAREST); + if (destroy) + DestroyWindow(data); } void win32_monitor_get_info(void) @@ -103,7 +105,7 @@ void win32_monitor_info(void *data, void *hm_data) HMONITOR *hm_to_use = (HMONITOR*)hm_data; if (!win32_monitor_last) - win32_monitor_from_window(GetDesktopWindow()); + win32_monitor_from_window(GetDesktopWindow(), false); *hm_to_use = win32_monitor_last; fs_monitor = settings->video.monitor_index; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 358212a101..c24b463677 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -18,6 +18,12 @@ #define WIN32_COMMON_H__ #include + +#ifndef _XBOX +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include #include "../../driver.h" #include "../video_context_driver.h" @@ -27,8 +33,6 @@ extern "C" { #endif #ifndef _XBOX -#define WIN32_LEAN_AND_MEAN -#include #include "../drivers_wm/win32_resource.h" LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, @@ -38,7 +42,7 @@ LRESULT win32_menu_loop(HWND handle, WPARAM wparam); void win32_monitor_init(void); -void win32_monitor_from_window(HWND data); +void win32_monitor_from_window(HWND data, bool destroy); void win32_monitor_get_info(void); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 895a17a43c..80856f1bb7 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -583,8 +583,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_hwnd) { - win32_monitor_from_window(g_hwnd); - DestroyWindow(g_hwnd); + win32_monitor_from_window(g_hwnd, true); UnregisterClass("RetroArch", GetModuleHandle(NULL)); g_hwnd = NULL; }