From 9207acd6f2c94edecff90339076606584d36a9dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 08:30:37 +0100 Subject: [PATCH] Expand win32_window_init --- gfx/common/win32_common.cpp | 12 +++++++++--- gfx/common/win32_common.h | 2 +- gfx/d3d/d3d.cpp | 2 +- gfx/drivers_context/wgl_ctx.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index d838e2d913..89511fb25c 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -247,24 +247,30 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, return DefWindowProc(hwnd, message, wparam, lparam); } -bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen, const char *class_name) { #ifndef _XBOX wndclass->cbSize = sizeof(WNDCLASSEX); wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wndclass->lpfnWndProc = WndProc; wndclass->hInstance = GetModuleHandle(NULL); wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass->lpszClassName = "RetroArch"; + wndclass->lpszClassName = (class_name == NULL) ? "RetroArch" : class_name; 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->lpfnWndProc = WndProc; + if (!RegisterClassEx(wndclass)) return false; + /* TODO/FIXME - this is ugly. Find a better way */ + if (class_name != NULL) /* this is non-NULL when we want a window for shader dialogs, abort here */ + return true; + if (!win32_shader_dlg_init()) RARCH_ERR("[WGL]: wgl_shader_dlg_init() failed.\n"); #endif diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 6d1cb105e0..70f4683ac0 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -61,7 +61,7 @@ bool win32_set_video_mode(void *data, bool win32_monitor_set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name); -bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen, const char *class_name); bool win32_window_create(void *data, unsigned style, RECT *mon_rect, unsigned width, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2c71240de0..87a395cd42 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -575,7 +575,7 @@ static bool d3d_construct(d3d_video_t *d3d, #endif memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); - win32_window_init(&d3d->windowClass, true); + win32_window_init(&d3d->windowClass, true, NULL); #ifdef HAVE_MONITOR bool windowed_full; diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 2fbc84db20..89f4cbf6ec 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -310,7 +310,7 @@ static bool gfx_ctx_wgl_init(void *data) win32_window_reset(); win32_monitor_init(); - if (!win32_window_init(&wndclass, true)) + if (!win32_window_init(&wndclass, true, NULL)) return false; return true;