(Win32) Create g_win32_flags - reduce amount of global booleans kept
around for state
This commit is contained in:
parent
b41f6b2885
commit
18639cca6e
|
@ -288,20 +288,16 @@ typedef struct win32_common_state
|
||||||
unsigned taskbar_message;
|
unsigned taskbar_message;
|
||||||
#endif
|
#endif
|
||||||
unsigned monitor_count;
|
unsigned monitor_count;
|
||||||
bool quit;
|
|
||||||
bool resized;
|
|
||||||
} win32_common_state_t;
|
} win32_common_state_t;
|
||||||
|
|
||||||
/* TODO/FIXME - globals */
|
/* TODO/FIXME - globals */
|
||||||
bool g_win32_restore_desktop = false;
|
|
||||||
bool g_win32_inited = false;
|
|
||||||
unsigned g_win32_resize_width = 0;
|
unsigned g_win32_resize_width = 0;
|
||||||
unsigned g_win32_resize_height = 0;
|
unsigned g_win32_resize_height = 0;
|
||||||
float g_win32_refresh_rate = 0;
|
float g_win32_refresh_rate = 0;
|
||||||
ui_window_win32_t main_window;
|
ui_window_win32_t main_window;
|
||||||
|
|
||||||
/* TODO/FIXME - static globals */
|
/* TODO/FIXME - static globals */
|
||||||
static bool taskbar_is_created = false;
|
uint8_t g_win32_flags = 0;
|
||||||
static HMONITOR win32_monitor_last;
|
static HMONITOR win32_monitor_last;
|
||||||
static HMONITOR win32_monitor_all[MAX_MONITORS];
|
static HMONITOR win32_monitor_all[MAX_MONITORS];
|
||||||
|
|
||||||
|
@ -314,14 +310,12 @@ static win32_common_state_t win32_st =
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
0, /* taskbar_message */
|
0, /* taskbar_message */
|
||||||
#endif
|
#endif
|
||||||
false, /* quit */
|
|
||||||
0, /* monitor_count */
|
0, /* monitor_count */
|
||||||
false /* resized */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool win32_taskbar_is_created(void)
|
uint8_t win32_get_flags(void)
|
||||||
{
|
{
|
||||||
return taskbar_is_created;
|
return g_win32_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR_COMPAT CALLBACK pick_core_proc(
|
static INT_PTR_COMPAT CALLBACK pick_core_proc(
|
||||||
|
@ -889,9 +883,6 @@ static LRESULT CALLBACK wnd_proc_common(
|
||||||
bool *quit, HWND hwnd, UINT message,
|
bool *quit, HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = (win32_common_state_t*)&win32_st;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
|
@ -936,7 +927,7 @@ static LRESULT CALLBACK wnd_proc_common(
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
g_win32->quit = true;
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
*quit = true;
|
*quit = true;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
|
@ -952,7 +943,7 @@ static LRESULT CALLBACK wnd_proc_common(
|
||||||
{
|
{
|
||||||
g_win32_resize_width = LOWORD(lparam);
|
g_win32_resize_width = LOWORD(lparam);
|
||||||
g_win32_resize_height = HIWORD(lparam);
|
g_win32_resize_height = HIWORD(lparam);
|
||||||
g_win32->resized = true;
|
g_win32_flags |= WIN32_CMN_FLAG_RESIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*quit = true;
|
*quit = true;
|
||||||
|
@ -1034,7 +1025,7 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
|
@ -1051,7 +1042,7 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
|
||||||
return ret;
|
return ret;
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_CLIP_WINDOW
|
#ifdef HAVE_CLIP_WINDOW
|
||||||
|
@ -1111,7 +1102,7 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
|
@ -1128,7 +1119,7 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
|
||||||
return ret;
|
return ret;
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
|
@ -1243,7 +1234,7 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
{
|
{
|
||||||
|
@ -1268,7 +1259,7 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
||||||
return ret;
|
return ret;
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_CLIP_WINDOW
|
#ifdef HAVE_CLIP_WINDOW
|
||||||
|
@ -1298,14 +1289,12 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
||||||
LRESULT CALLBACK wnd_proc_d3d_common(HWND hwnd, UINT message,
|
LRESULT CALLBACK wnd_proc_d3d_common(HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
|
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1316,14 +1305,12 @@ LRESULT CALLBACK wnd_proc_d3d_common(HWND hwnd, UINT message,
|
||||||
LRESULT CALLBACK wnd_proc_d3d_winraw(HWND hwnd, UINT message,
|
LRESULT CALLBACK wnd_proc_d3d_winraw(HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
|
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,14 +1322,12 @@ LRESULT CALLBACK wnd_proc_d3d_winraw(HWND hwnd, UINT message,
|
||||||
LRESULT CALLBACK wnd_proc_d3d_dinput(HWND hwnd, UINT message,
|
LRESULT CALLBACK wnd_proc_d3d_dinput(HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
|
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1361,10 +1346,13 @@ LRESULT CALLBACK wnd_proc_wgl_dinput(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_wgl_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_wgl_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,10 +1368,13 @@ LRESULT CALLBACK wnd_proc_wgl_winraw(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_wgl_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_wgl_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1398,7 +1389,10 @@ LRESULT CALLBACK wnd_proc_wgl_common(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_wgl_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_wgl_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1418,7 +1412,10 @@ LRESULT CALLBACK wnd_proc_vk_dinput(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_vk_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_vk_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1436,7 +1433,10 @@ LRESULT CALLBACK wnd_proc_vk_winraw(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_vk_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_vk_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1453,7 +1453,10 @@ LRESULT CALLBACK wnd_proc_vk_common(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_vk_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_vk_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1473,7 +1476,10 @@ LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_gdi_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_gdi_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1506,7 +1512,7 @@ LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if ( g_win32->taskbar_message
|
if ( g_win32->taskbar_message
|
||||||
&& message == g_win32->taskbar_message)
|
&& message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1528,10 @@ LRESULT CALLBACK wnd_proc_gdi_winraw(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_gdi_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_gdi_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1555,7 +1564,7 @@ LRESULT CALLBACK wnd_proc_gdi_winraw(HWND hwnd, UINT message,
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if ( g_win32->taskbar_message
|
if ( g_win32->taskbar_message
|
||||||
&& message == g_win32->taskbar_message)
|
&& message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1570,7 +1579,10 @@ LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
|
||||||
|
|
||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
create_gdi_context(hwnd, &g_win32->quit);
|
bool is_quit = false;
|
||||||
|
create_gdi_context(hwnd, &is_quit);
|
||||||
|
if (is_quit)
|
||||||
|
g_win32_flags |= WIN32_CMN_FLAG_QUIT;
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1603,7 +1615,7 @@ LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
|
||||||
#ifdef HAVE_TASKBAR
|
#ifdef HAVE_TASKBAR
|
||||||
if ( g_win32->taskbar_message
|
if ( g_win32->taskbar_message
|
||||||
&& message == g_win32->taskbar_message)
|
&& message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1755,7 +1767,7 @@ void win32_monitor_init(void)
|
||||||
EnumDisplayMonitors(NULL, NULL,
|
EnumDisplayMonitors(NULL, NULL,
|
||||||
win32_monitor_enum_proc, 0);
|
win32_monitor_enum_proc, 0);
|
||||||
#endif
|
#endif
|
||||||
g_win32->quit = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
|
@ -1776,14 +1788,14 @@ void win32_check_window(void *data,
|
||||||
bool video_is_threaded = video_driver_is_threaded();
|
bool video_is_threaded = video_driver_is_threaded();
|
||||||
if (video_is_threaded)
|
if (video_is_threaded)
|
||||||
ui_companion_win32.application->process_events();
|
ui_companion_win32.application->process_events();
|
||||||
*quit = g_win32->quit;
|
*quit = g_win32_flags & WIN32_CMN_FLAG_QUIT;
|
||||||
|
|
||||||
if (g_win32->resized)
|
if (g_win32_flags & WIN32_CMN_FLAG_RESIZED)
|
||||||
{
|
{
|
||||||
*resize = true;
|
*resize = true;
|
||||||
*width = g_win32_resize_width;
|
*width = g_win32_resize_width;
|
||||||
*height = g_win32_resize_height;
|
*height = g_win32_resize_height;
|
||||||
g_win32->resized = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_RESIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2042,7 +2054,7 @@ HWND win32_get_window(void) { return NULL; }
|
||||||
#else
|
#else
|
||||||
bool win32_has_focus(void *data)
|
bool win32_has_focus(void *data)
|
||||||
{
|
{
|
||||||
if (g_win32_inited)
|
if (g_win32_flags & WIN32_CMN_FLAG_INITED)
|
||||||
if (GetForegroundWindow() == main_window.hwnd)
|
if (GetForegroundWindow() == main_window.hwnd)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -2289,8 +2301,6 @@ bool win32_set_video_mode(void *data,
|
||||||
int res = 0;
|
int res = 0;
|
||||||
unsigned mon_id = 0;
|
unsigned mon_id = 0;
|
||||||
HMONITOR hm_to_use = NULL;
|
HMONITOR hm_to_use = NULL;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = (win32_common_state_t*)&win32_st;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
bool windowed_full = settings->bools.video_windowed_fullscreen;
|
bool windowed_full = settings->bools.video_windowed_fullscreen;
|
||||||
|
|
||||||
|
@ -2318,7 +2328,8 @@ bool win32_set_video_mode(void *data,
|
||||||
|
|
||||||
/* Wait until context is created (or failed to do so ...).
|
/* Wait until context is created (or failed to do so ...).
|
||||||
* Please don't remove the (res = ) as GetMessage can return -1. */
|
* Please don't remove the (res = ) as GetMessage can return -1. */
|
||||||
while (!g_win32_inited && !g_win32->quit
|
while ( !(g_win32_flags & WIN32_CMN_FLAG_INITED)
|
||||||
|
&& !(g_win32_flags & WIN32_CMN_FLAG_QUIT)
|
||||||
&& (res = GetMessage(&msg, main_window.hwnd, 0, 0)) != 0)
|
&& (res = GetMessage(&msg, main_window.hwnd, 0, 0)) != 0)
|
||||||
{
|
{
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
|
@ -2331,7 +2342,7 @@ bool win32_set_video_mode(void *data,
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win32->quit)
|
if (g_win32_flags & WIN32_CMN_FLAG_QUIT)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2361,11 +2372,8 @@ bool win32_get_client_rect(RECT* rect)
|
||||||
|
|
||||||
void win32_window_reset(void)
|
void win32_window_reset(void)
|
||||||
{
|
{
|
||||||
win32_common_state_t
|
g_win32_flags &= ~(WIN32_CMN_FLAG_QUIT
|
||||||
*g_win32 = (win32_common_state_t*)&win32_st;
|
| WIN32_CMN_FLAG_RESTORE_DESKTOP);
|
||||||
|
|
||||||
g_win32->quit = false;
|
|
||||||
g_win32_restore_desktop = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void win32_destroy_window(void)
|
void win32_destroy_window(void)
|
||||||
|
|
|
@ -65,12 +65,21 @@
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
enum win32_common_flags
|
||||||
|
{
|
||||||
|
WIN32_CMN_FLAG_QUIT = (1 << 0),
|
||||||
|
WIN32_CMN_FLAG_RESIZED = (1 << 1),
|
||||||
|
WIN32_CMN_FLAG_TASKBAR_CREATED = (1 << 2),
|
||||||
|
WIN32_CMN_FLAG_RESTORE_DESKTOP = (1 << 3),
|
||||||
|
WIN32_CMN_FLAG_INITED = (1 << 4)
|
||||||
|
};
|
||||||
|
|
||||||
|
extern uint8_t g_win32_flags;
|
||||||
|
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
extern unsigned g_win32_resize_width;
|
extern unsigned g_win32_resize_width;
|
||||||
extern unsigned g_win32_resize_height;
|
extern unsigned g_win32_resize_height;
|
||||||
extern float g_win32_refresh_rate;
|
extern float g_win32_refresh_rate;
|
||||||
extern bool g_win32_inited;
|
|
||||||
extern bool g_win32_restore_desktop;
|
|
||||||
extern ui_window_win32_t main_window;
|
extern ui_window_win32_t main_window;
|
||||||
|
|
||||||
void win32_monitor_get_info(void);
|
void win32_monitor_get_info(void);
|
||||||
|
@ -151,7 +160,7 @@ void win32_window_reset(void);
|
||||||
|
|
||||||
void win32_destroy_window(void);
|
void win32_destroy_window(void);
|
||||||
|
|
||||||
bool win32_taskbar_is_created(void);
|
uint8_t win32_get_flags(void);
|
||||||
|
|
||||||
float win32_get_refresh_rate(void *data);
|
float win32_get_refresh_rate(void *data);
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,7 @@ static bool win32_display_server_set_window_opacity(
|
||||||
static bool win32_display_server_set_window_progress(
|
static bool win32_display_server_set_window_progress(
|
||||||
void *data, int progress, bool finished)
|
void *data, int progress, bool finished)
|
||||||
{
|
{
|
||||||
|
uint8_t win32_flags = 0;
|
||||||
HWND hwnd = win32_get_window();
|
HWND hwnd = win32_get_window();
|
||||||
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
||||||
|
|
||||||
|
@ -178,7 +179,8 @@ static bool win32_display_server_set_window_progress(
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef HAS_TASKBAR_EXT
|
#ifdef HAS_TASKBAR_EXT
|
||||||
if (!serv->taskbar_list || !win32_taskbar_is_created())
|
win32_flags = win32_get_flags();
|
||||||
|
if (!serv->taskbar_list || !(win32_flags & WIN32_CMN_FLAG_TASKBAR_CREATED))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (progress == -1)
|
if (progress == -1)
|
||||||
|
|
|
@ -68,12 +68,12 @@ static void gfx_ctx_gdi_update_title(void)
|
||||||
static void gfx_ctx_gdi_get_video_size(
|
static void gfx_ctx_gdi_get_video_size(
|
||||||
unsigned *width, unsigned *height)
|
unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
HWND window = win32_get_window();
|
HWND window = win32_get_window();
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
*width = g_win32_resize_width;
|
*width = g_win32_resize_width;
|
||||||
*height = g_win32_resize_height;
|
*height = g_win32_resize_height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,8 +84,8 @@ static void gfx_ctx_gdi_get_video_size(
|
||||||
|
|
||||||
win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
|
win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
|
||||||
mon_rect = current_mon.rcMonitor;
|
mon_rect = current_mon.rcMonitor;
|
||||||
*width = mon_rect.right - mon_rect.left;
|
*width = mon_rect.right - mon_rect.left;
|
||||||
*height = mon_rect.bottom - mon_rect.top;
|
*height = mon_rect.bottom - mon_rect.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,9 @@ static bool gfx_ctx_gdi_init(void)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wndclass = {0};
|
WNDCLASSEX wndclass = {0};
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
uint8_t win32_flags = win32_get_flags();
|
||||||
|
|
||||||
if (g_win32_inited)
|
if (win32_flags & WIN32_CMN_FLAG_INITED)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
win32_window_reset();
|
win32_window_reset();
|
||||||
|
@ -130,13 +131,13 @@ static void gfx_ctx_gdi_destroy(void)
|
||||||
win32_destroy_window();
|
win32_destroy_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win32_restore_desktop)
|
if (g_win32_flags & WIN32_CMN_FLAG_RESTORE_DESKTOP)
|
||||||
{
|
{
|
||||||
win32_monitor_get_info();
|
win32_monitor_get_info();
|
||||||
g_win32_restore_desktop = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_RESTORE_DESKTOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_win32_inited = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_gdi_set_video_mode(
|
static bool gfx_ctx_gdi_set_video_mode(
|
||||||
|
@ -188,7 +189,7 @@ void create_gdi_context(HWND hwnd, bool *quit)
|
||||||
|
|
||||||
win32_setup_pixel_format(win32_gdi_hdc, false);
|
win32_setup_pixel_format(win32_gdi_hdc, false);
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdi_gfx_create(gdi_t *gdi)
|
static void gdi_gfx_create(gdi_t *gdi)
|
||||||
|
|
|
@ -78,7 +78,7 @@ void create_vk_context(HWND hwnd, bool *quit)
|
||||||
width, height, win32_vk_interval))
|
width, height, win32_vk_interval))
|
||||||
*quit = true;
|
*quit = true;
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_w_vk_swap_interval(void *data, int interval)
|
static void gfx_ctx_w_vk_swap_interval(void *data, int interval)
|
||||||
|
@ -210,27 +210,28 @@ static void gfx_ctx_w_vk_destroy(void *data)
|
||||||
win32_destroy_window();
|
win32_destroy_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win32_restore_desktop)
|
if (g_win32_flags & WIN32_CMN_FLAG_RESTORE_DESKTOP)
|
||||||
{
|
{
|
||||||
win32_monitor_get_info();
|
win32_monitor_get_info();
|
||||||
g_win32_restore_desktop = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_RESTORE_DESKTOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vk)
|
if (vk)
|
||||||
free(vk);
|
free(vk);
|
||||||
|
|
||||||
g_win32_inited = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *gfx_ctx_w_vk_init(void *video_driver)
|
static void *gfx_ctx_w_vk_init(void *video_driver)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wndclass = {0};
|
WNDCLASSEX wndclass = {0};
|
||||||
gfx_ctx_w_vk_data_t *vk = (gfx_ctx_w_vk_data_t*)calloc(1, sizeof(*vk));
|
gfx_ctx_w_vk_data_t *vk = (gfx_ctx_w_vk_data_t*)calloc(1, sizeof(*vk));
|
||||||
|
uint8_t win32_flags = win32_get_flags();
|
||||||
|
|
||||||
if (!vk)
|
if (!vk)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (g_win32_inited)
|
if (win32_flags & WIN32_CMN_FLAG_INITED)
|
||||||
gfx_ctx_w_vk_destroy(NULL);
|
gfx_ctx_w_vk_destroy(NULL);
|
||||||
|
|
||||||
win32_window_reset();
|
win32_window_reset();
|
||||||
|
|
|
@ -208,7 +208,7 @@ static void create_gl_context(HWND hwnd, bool *quit)
|
||||||
if (win32_hrc)
|
if (win32_hrc)
|
||||||
{
|
{
|
||||||
if (wglMakeCurrent(win32_hdc, win32_hrc))
|
if (wglMakeCurrent(win32_hdc, win32_hrc))
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
else
|
else
|
||||||
*quit = true;
|
*quit = true;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ static void create_gles_context(HWND hwnd, bool *quit)
|
||||||
if (!egl_create_surface(&win32_egl, hwnd))
|
if (!egl_create_surface(&win32_egl, hwnd))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
g_win32_inited = true;
|
g_win32_flags |= WIN32_CMN_FLAG_INITED;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -582,10 +582,10 @@ static void gfx_ctx_wgl_destroy(void *data)
|
||||||
win32_destroy_window();
|
win32_destroy_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win32_restore_desktop)
|
if (g_win32_flags & WIN32_CMN_FLAG_RESTORE_DESKTOP)
|
||||||
{
|
{
|
||||||
win32_monitor_get_info();
|
win32_monitor_get_info();
|
||||||
g_win32_restore_desktop = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_RESTORE_DESKTOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DYNAMIC
|
#ifdef HAVE_DYNAMIC
|
||||||
|
@ -597,7 +597,7 @@ static void gfx_ctx_wgl_destroy(void *data)
|
||||||
|
|
||||||
wgl_adaptive_vsync = false;
|
wgl_adaptive_vsync = false;
|
||||||
win32_core_hw_context_enable = false;
|
win32_core_hw_context_enable = false;
|
||||||
g_win32_inited = false;
|
g_win32_flags &= ~WIN32_CMN_FLAG_INITED;
|
||||||
win32_major = 0;
|
win32_major = 0;
|
||||||
win32_minor = 0;
|
win32_minor = 0;
|
||||||
p_swap_interval = NULL;
|
p_swap_interval = NULL;
|
||||||
|
@ -608,11 +608,12 @@ static void *gfx_ctx_wgl_init(void *video_driver)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wndclass = {0};
|
WNDCLASSEX wndclass = {0};
|
||||||
gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)calloc(1, sizeof(*wgl));
|
gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)calloc(1, sizeof(*wgl));
|
||||||
|
uint8_t win32_flags = win32_get_flags();
|
||||||
|
|
||||||
if (!wgl)
|
if (!wgl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (g_win32_inited)
|
if (win32_flags & WIN32_CMN_FLAG_INITED)
|
||||||
gfx_ctx_wgl_destroy(NULL);
|
gfx_ctx_wgl_destroy(NULL);
|
||||||
|
|
||||||
#ifdef HAVE_DYNAMIC
|
#ifdef HAVE_DYNAMIC
|
||||||
|
|
Loading…
Reference in New Issue