From b4da4940eb0b3aa22a4eb0e6ba3faef3a40bfa8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Mar 2020 22:10:24 +0100 Subject: [PATCH] Revert "(Win32) Move global state to struct" This reverts commit dfa1288988c1bc2618fda62ec6e90955e7b57b12. --- gfx/common/win32_common.c | 300 ++++++++++++++------------------------ 1 file changed, 112 insertions(+), 188 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index f208d388eb..dbd81c2927 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -111,10 +111,6 @@ #define WM_POINTERUP 0x0247 #endif -#ifndef MAX_MONITORS -#define MAX_MONITORS 9 -#endif - const GUID GUID_DEVINTERFACE_HID = { 0x4d1e55b2, 0xf16f, 0x11Cf, { 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } }; #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x501 static HDEVNOTIFY notification_handler; @@ -140,17 +136,14 @@ typedef struct DISPLAYCONFIG_2DREGION_CUSTOM { UINT32 cy; } DISPLAYCONFIG_2DREGION_CUSTOM; -typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM { UINT64 pixelRate; DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq; DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq; DISPLAYCONFIG_2DREGION_CUSTOM activeSize; DISPLAYCONFIG_2DREGION_CUSTOM totalSize; - union - { - struct - { + union { + struct { UINT32 videoStandard :16; UINT32 vSyncFreqDivider :6; UINT32 reserved :10; @@ -160,20 +153,16 @@ typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM UINT32 scanLineOrdering; } DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM -{ +typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM { DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo; } DISPLAYCONFIG_TARGET_MODE_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM { LUID adapterId; UINT32 id; - union - { + union { UINT32 modeInfoIdx; - struct - { + struct { UINT32 cloneGroupId :16; UINT32 sourceModeInfoIdx :16; } dummystructname; @@ -181,43 +170,36 @@ typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM UINT32 statusFlags; } DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM { POINTL PathSourceSize; RECTL DesktopImageRegion; RECTL DesktopImageClip; } DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM -{ +typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM { UINT32 width; UINT32 height; UINT32 pixelFormat; POINTL position; } DISPLAYCONFIG_SOURCE_MODE_CUSTOM; -typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM { UINT32 infoType; UINT32 id; LUID adapterId; - union - { + union { DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode; DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode; DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo; } dummyunionname; } DISPLAYCONFIG_MODE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM { LUID adapterId; UINT32 id; - union - { + union { UINT32 modeInfoIdx; - struct - { + struct { UINT32 desktopModeInfoIdx :16; UINT32 targetModeInfoIdx :16; } dummystructname; @@ -231,8 +213,7 @@ typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM UINT32 statusFlags; } DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM -{ +typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM { DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo; DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo; UINT32 flags; @@ -241,45 +222,22 @@ typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO_CUSTOM*, UINT32*, DISPLAYCONFIG_MODE_INFO_CUSTOM*, UINT32*); typedef LONG (WINAPI *GETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*); -typedef struct win32_common_state -{ - bool resized; - bool doubleclick_on_titlebar; - bool taskbar_is_created; - bool quit; - - int pos_x; - int pos_y; - unsigned pos_width; - unsigned pos_height; - unsigned taskbar_message; - unsigned monitor_count; - - HMONITOR monitor_last; - HMONITOR monitor_all[MAX_MONITORS]; -} win32_common_state_t; - -static win32_common_state_t win32_common_st = -{ - false, /* resized */ - false, /* doubleclick_on_titlebar */ - false, /* taskbar_is_created */ - false, /* quit */ - CW_USEDEFAULT, /* pos_x */ - CW_USEDEFAULT, /* pos_y */ - 0, /* pos_width */ - 0, /* pos_height */ - 0, /* taskbar_message */ - 0, /* monitor_count */ - - NULL, /* monitor_last */ -}; - +static bool g_win32_resized = false; bool g_win32_restore_desktop = false; +static bool doubleclick_on_titlebar = false; +static bool taskbar_is_created = false; bool g_win32_inited = false; +static bool g_win32_quit = false; + +static int g_win32_pos_x = CW_USEDEFAULT; +static int g_win32_pos_y = CW_USEDEFAULT; +static unsigned g_win32_pos_width = 0; +static unsigned g_win32_pos_height = 0; unsigned g_win32_resize_width = 0; unsigned g_win32_resize_height = 0; +static unsigned g_taskbar_message = 0; +static unsigned win32_monitor_count = 0; static void *curD3D = NULL; @@ -322,29 +280,32 @@ typedef enum _POWER_REQUEST_TYPE typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT; #endif +#ifndef MAX_MONITORS +#define MAX_MONITORS 9 +#endif + #if defined(_MSC_VER) && _MSC_VER <= 1200 #define INT_PTR_COMPAT int #else #define INT_PTR_COMPAT INT_PTR #endif +static HMONITOR win32_monitor_last; +static HMONITOR win32_monitor_all[MAX_MONITORS]; + bool win32_taskbar_is_created(void) { - win32_common_state_t *g_win32 = &win32_common_st; - return g_win32->taskbar_is_created; + return taskbar_is_created; } bool doubleclick_on_titlebar_pressed(void) { - win32_common_state_t *g_win32 = &win32_common_st; - return g_win32->doubleclick_on_titlebar; + return doubleclick_on_titlebar; } void unset_doubleclick_on_titlebar(void) { - win32_common_state_t *g_win32 = &win32_common_st; - - g_win32->doubleclick_on_titlebar = false; + doubleclick_on_titlebar = false; } static INT_PTR_COMPAT CALLBACK PickCoreProc( @@ -414,23 +375,20 @@ static INT_PTR_COMPAT CALLBACK PickCoreProc( static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - win32_common_state_t *g_win32 = &win32_common_st; - - g_win32->monitor_all[g_win32->monitor_count++] = hMonitor; + win32_monitor_all[win32_monitor_count++] = hMonitor; return TRUE; } void win32_monitor_from_window(void) { #ifndef _XBOX - win32_common_state_t - *g_win32 = &win32_common_st; - ui_window_t *window = (ui_window_t*) - ui_companion_driver_get_window_ptr(); + ui_window_t *window = NULL; - g_win32->monitor_last = + win32_monitor_last = MonitorFromWindow(main_window.hwnd, MONITOR_DEFAULTTONEAREST); + window = (ui_window_t*)ui_companion_driver_get_window_ptr(); + if (window) window->destroy(&main_window); #endif @@ -452,14 +410,11 @@ int win32_change_display_settings(const char *str, void *devmode_data, void win32_monitor_get_info(void) { MONITORINFOEX current_mon; - win32_common_state_t - *g_win32 = &win32_common_st; memset(¤t_mon, 0, sizeof(current_mon)); current_mon.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(g_win32->monitor_last, - (LPMONITORINFO)¤t_mon); + GetMonitorInfo(win32_monitor_last, (LPMONITORINFO)¤t_mon); win32_change_display_settings(current_mon.szDevice, NULL, 0); } @@ -470,27 +425,25 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) settings_t *settings = config_get_ptr(); MONITORINFOEX *mon = (MONITORINFOEX*)data; HMONITOR *hm_to_use = (HMONITOR*)hm_data; - win32_common_state_t - *g_win32 = &win32_common_st; unsigned fs_monitor = settings->uints.video_monitor_index; - if (!g_win32->monitor_last) - g_win32->monitor_last = MonitorFromWindow(GetDesktopWindow(), + if (!win32_monitor_last) + win32_monitor_last = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - *hm_to_use = g_win32->monitor_last; + *hm_to_use = win32_monitor_last; - if (fs_monitor && fs_monitor <= g_win32->monitor_count - && g_win32->monitor_all[fs_monitor - 1]) + if (fs_monitor && fs_monitor <= win32_monitor_count + && win32_monitor_all[fs_monitor - 1]) { - *hm_to_use = g_win32->monitor_all[fs_monitor - 1]; + *hm_to_use = win32_monitor_all[fs_monitor - 1]; *mon_id = fs_monitor - 1; } else { - for (i = 0; i < g_win32->monitor_count; i++) + for (i = 0; i < win32_monitor_count; i++) { - if (g_win32->monitor_all[i] != *hm_to_use) + if (win32_monitor_all[i] != *hm_to_use) continue; *mon_id = i; @@ -626,8 +579,6 @@ static void win32_save_position(void) { RECT rect; WINDOWPLACEMENT placement; - win32_common_state_t - *g_win32 = &win32_common_st; int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); int title_bar_height = GetSystemMetrics(SM_CYCAPTION); int menu_bar_height = GetSystemMetrics(SM_CYMENU); @@ -638,17 +589,17 @@ static void win32_save_position(void) memset(&placement, 0, sizeof(placement)); - placement.length = sizeof(placement); + placement.length = sizeof(placement); GetWindowPlacement(main_window.hwnd, &placement); - g_win32->pos_x = placement.rcNormalPosition.left; - g_win32->pos_y = placement.rcNormalPosition.top; + g_win32_pos_x = placement.rcNormalPosition.left; + g_win32_pos_y = placement.rcNormalPosition.top; if (GetWindowRect(main_window.hwnd, &rect)) { - g_win32->pos_width = rect.right - rect.left; - g_win32->pos_height = rect.bottom - rect.top; + g_win32_pos_width = rect.right - rect.left; + g_win32_pos_height = rect.bottom - rect.top; } if (window_save_positions) { @@ -656,14 +607,10 @@ static void win32_save_position(void) !retroarch_is_forced_fullscreen() && !retroarch_is_switching_display_mode()) { - settings->uints.window_position_x = g_win32->pos_x; - settings->uints.window_position_y = g_win32->pos_y; - settings->uints.window_position_width = g_win32->pos_width - - border_thickness * 2; - settings->uints.window_position_height = g_win32->pos_height - - border_thickness * 2 - - title_bar_height - - (ui_menubar_enable ? menu_bar_height : 0); + settings->uints.window_position_x = g_win32_pos_x; + settings->uints.window_position_y = g_win32_pos_y; + settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2; + settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height - (ui_menubar_enable ? menu_bar_height : 0); } } } @@ -877,13 +824,11 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { bool keydown = true; - win32_common_state_t - *g_win32 = &win32_common_st; switch (message) { case WM_NCLBUTTONDBLCLK: - g_win32->doubleclick_on_titlebar = true; + doubleclick_on_titlebar = true; break; case WM_SYSCOMMAND: /* Prevent screensavers, etc, while running. */ @@ -989,7 +934,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, case WM_CLOSE: case WM_DESTROY: case WM_QUIT: - g_win32->quit = true; + g_win32_quit = true; *quit = true; /* fall-through */ case WM_MOVE: @@ -1005,7 +950,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, { g_win32_resize_width = LOWORD(lparam); g_win32_resize_height = HIWORD(lparam); - g_win32->resized = true; + g_win32_resized = true; } } *quit = true; @@ -1027,9 +972,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { LRESULT ret; - bool quit = false; - win32_common_state_t - *g_win32 = &win32_common_st; + bool quit = false; switch (message) { @@ -1041,8 +984,8 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif #ifdef HAVE_DINPUT if (input_get_ptr() == &input_dinput) @@ -1055,10 +998,10 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, #endif break; case WM_NCLBUTTONDBLCLK: - g_win32->doubleclick_on_titlebar = true; + doubleclick_on_titlebar = true; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_DROPFILES: @@ -1078,8 +1021,8 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_CREATE: @@ -1104,8 +1047,6 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, { LRESULT ret; bool quit = false; - win32_common_state_t - *g_win32 = &win32_common_st; switch (message) { @@ -1117,8 +1058,8 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif #ifdef HAVE_DINPUT if (dinput_wgl && dinput_handle_message(dinput_wgl, @@ -1127,10 +1068,10 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, #endif break; case WM_NCLBUTTONDBLCLK: - g_win32->doubleclick_on_titlebar = true; + doubleclick_on_titlebar = true; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_DROPFILES: @@ -1151,12 +1092,12 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_CREATE: - create_graphics_context(hwnd, &g_win32->quit); + create_graphics_context(hwnd, &g_win32_quit); if (DragAcceptFiles_func) DragAcceptFiles_func(hwnd, true); return 0; @@ -1172,8 +1113,6 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, { LRESULT ret; bool quit = false; - win32_common_state_t - *g_win32 = &win32_common_st; switch (message) { @@ -1185,8 +1124,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif #ifdef HAVE_DINPUT if (dinput_gdi && dinput_handle_message(dinput_gdi, @@ -1195,10 +1134,10 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, #endif break; case WM_NCLBUTTONDBLCLK: - g_win32->doubleclick_on_titlebar = true; + doubleclick_on_titlebar = true; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_PAINT: @@ -1235,8 +1174,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, } #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; } @@ -1257,12 +1196,12 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ - if (g_win32->taskbar_message && message == g_win32->taskbar_message) - g_win32->taskbar_is_created = true; + if (g_taskbar_message && message == g_taskbar_message) + taskbar_is_created = true; #endif break; case WM_CREATE: - create_gdi_context(hwnd, &g_win32->quit); + create_gdi_context(hwnd, &g_win32_quit); if (DragAcceptFiles_func) DragAcceptFiles_func(hwnd, true); return 0; @@ -1286,19 +1225,17 @@ bool win32_window_create(void *data, unsigned style, bool window_save_positions = settings->bools.video_window_save_positions; unsigned user_width = width; unsigned user_height = height; - win32_common_state_t - *g_win32 = &win32_common_st; if (window_save_positions && !fullscreen) { - user_width = g_win32->pos_width; - user_height= g_win32->pos_height; + user_width = g_win32_pos_width; + user_height= g_win32_pos_height; } main_window.hwnd = CreateWindowEx(0, msg_hash_to_str(MSG_PROGRAM), msg_hash_to_str(MSG_PROGRAM), style, - fullscreen ? mon_rect->left : g_win32->pos_x, - fullscreen ? mon_rect->top : g_win32->pos_y, + fullscreen ? mon_rect->left : g_win32_pos_x, + fullscreen ? mon_rect->top : g_win32_pos_y, user_width, user_height, NULL, NULL, NULL, data); @@ -1306,7 +1243,7 @@ bool win32_window_create(void *data, unsigned style, return false; #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */ - g_win32->taskbar_message = RegisterWindowMessage("TaskbarButtonCreated"); + g_taskbar_message = RegisterWindowMessage("TaskbarButtonCreated"); memset(¬ification_filter, 0, sizeof(notification_filter)); notification_filter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); @@ -1386,14 +1323,11 @@ bool win32_get_metrics(void *data, void win32_monitor_init(void) { #if !defined(_XBOX) - win32_common_state_t - *g_win32 = &win32_common_st; - - g_win32->monitor_count = 0; + win32_monitor_count = 0; EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); #endif - g_win32->quit = false; + g_win32_quit = false; } static bool win32_monitor_set_fullscreen( @@ -1433,19 +1367,17 @@ void win32_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height) { #if !defined(_XBOX) - win32_common_state_t - *g_win32 = &win32_common_st; bool video_is_threaded = video_driver_is_threaded(); if (video_is_threaded) ui_companion_win32.application->process_events(); - *quit = g_win32->quit; + *quit = g_win32_quit; - if (g_win32->resized) + if (g_win32_resized) { *resize = true; *width = g_win32_resize_width; - *height = g_win32_resize_width; - g_win32->resized = false; + *height = g_win32_resize_height; + g_win32_resized = false; } #endif } @@ -1542,7 +1474,6 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, unsigned window_position_y = settings->uints.window_position_y; unsigned window_position_width = settings->uints.window_position_width; unsigned window_position_height = settings->uints.window_position_height; - win32_common_state_t *g_win32 = &win32_common_st; if (fullscreen) { @@ -1583,27 +1514,24 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, if (video_window_save_positions) { /* Set position from config */ - int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); - int title_bar_height = GetSystemMetrics(SM_CYCAPTION); - win32_common_state_t - *g_win32 = &win32_common_st; + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); - g_win32->pos_x = window_position_x; - g_win32->pos_y = window_position_y; - g_win32->pos_width = window_position_width + g_win32_pos_x = window_position_x; + g_win32_pos_y = window_position_y; + g_win32_pos_width = window_position_width + border_thickness * 2; - g_win32->pos_height = window_position_height + g_win32_pos_height = window_position_height + border_thickness * 2 + title_bar_height; - if ( (g_win32->pos_width != 0) && - (g_win32->pos_height != 0)) + if (g_win32_pos_width != 0 && g_win32_pos_height != 0) position_set_from_config = true; } if (position_set_from_config) { - g_win32_resize_width = *width = g_win32->pos_width; - g_win32_resize_height = *height = g_win32->pos_height; + g_win32_resize_width = *width = g_win32_pos_width; + g_win32_resize_height = *height = g_win32_pos_height; } else { @@ -1666,8 +1594,6 @@ bool win32_set_video_mode(void *data, int res = 0; unsigned mon_id = 0; HMONITOR hm_to_use = NULL; - win32_common_state_t - *g_win32 = &win32_common_st; settings_t *settings = config_get_ptr(); bool windowed_full = settings->bools.video_windowed_fullscreen; @@ -1694,7 +1620,7 @@ bool win32_set_video_mode(void *data, /* Wait until context is created (or failed to do so ...). * Please don't remove the (res = ) as GetMessage can return -1. */ - while (!g_win32_inited && !g_win32->quit + while (!g_win32_inited && !g_win32_quit && (res = GetMessage(&msg, main_window.hwnd, 0, 0)) != 0) { if (res == -1) @@ -1707,7 +1633,7 @@ bool win32_set_video_mode(void *data, DispatchMessage(&msg); } - if (g_win32->quit) + if (g_win32_quit) return false; #endif @@ -1751,10 +1677,8 @@ HWND win32_get_window(void) void win32_window_reset(void) { - win32_common_state_t *g_win32 = &win32_common_st; - - g_win32->quit = false; - g_win32_restore_desktop = false; + g_win32_quit = false; + g_win32_restore_desktop = false; } void win32_destroy_window(void)