Move win32_window_init outside of ui_win32.c and to gfx/common/win32_common.c

This commit is contained in:
twinaphex 2020-09-16 10:29:50 +02:00
parent 4c1c0cc80d
commit 4e594c6437
2 changed files with 37 additions and 53 deletions

View File

@ -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

View File

@ -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(