From 4e594c643702325d30844ccbb196c46838e35932 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 16 Sep 2020 10:29:50 +0200 Subject: [PATCH] Move win32_window_init outside of ui_win32.c and to gfx/common/win32_common.c --- gfx/common/win32_common.c | 35 +++++++++++++++++++++++++ ui/drivers/ui_win32.c | 55 ++------------------------------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 41bd4cc0a7..8713de9d7f 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -2009,3 +2009,38 @@ void win32_setup_pixel_format(HDC hdc, bool supports_gl) SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); } + +#ifndef __WINRT__ +unsigned short win32_get_langid_from_retro_lang(enum retro_language lang); + +bool win32_window_init(WNDCLASSEX *wndclass, + bool fullscreen, const char *class_name) +{ +#if _WIN32_WINNT >= 0x0501 + /* Use the language set in the config for the menubar... + * also changes the console language. */ + SetThreadUILanguage(win32_get_langid_from_retro_lang( + (enum retro_language) + *msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))); +#endif + wndclass->cbSize = sizeof(WNDCLASSEX); + wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wndclass->hInstance = GetModuleHandle(NULL); + wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass->lpszClassName = class_name ? class_name : "RetroArch"; + wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDI_ICON)); + wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); + if (!fullscreen) + wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW; + + if (class_name) + wndclass->style |= CS_CLASSDC; + + if (!RegisterClassEx(wndclass)) + return false; + + return true; +} +#endif diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 4398a57108..531998dc79 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -53,59 +53,8 @@ #include "ui_win32.h" -typedef struct ui_companion_win32 -{ - void *empty; -} ui_companion_win32_t; - -#ifndef __WINRT__ -bool win32_window_init(WNDCLASSEX *wndclass, - bool fullscreen, const char *class_name) -{ -#if _WIN32_WINNT >= 0x0501 - /* Use the language set in the config for the menubar... also changes the console language. */ - SetThreadUILanguage(win32_get_langid_from_retro_lang((enum retro_language)*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))); -#endif - wndclass->cbSize = sizeof(WNDCLASSEX); - wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wndclass->hInstance = GetModuleHandle(NULL); - wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass->lpszClassName = (class_name != NULL) ? class_name : "RetroArch"; - wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); - if (!fullscreen) - wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW; - - if (class_name != NULL) - wndclass->style |= CS_CLASSDC; - - if (!RegisterClassEx(wndclass)) - return false; - - return true; -} -#endif - -static void ui_companion_win32_deinit(void *data) -{ - ui_companion_win32_t *handle = (ui_companion_win32_t*)data; - - if (handle) - free(handle); -} - -static void *ui_companion_win32_init(void) -{ - ui_companion_win32_t *handle = (ui_companion_win32_t*) - calloc(1, sizeof(*handle)); - - if (!handle) - return NULL; - - return handle; -} - +static void ui_companion_win32_deinit(void *data) { } +static void *ui_companion_win32_init(void) { return (void*)-1; } static void ui_companion_win32_notify_content_loaded(void *data) { } static void ui_companion_win32_toggle(void *data, bool force) { } static void ui_companion_win32_event_command(