Remove related stuff for non-background switch mode (in Allegro source code for Win32).

This commit is contained in:
David Capello 2010-11-04 21:51:09 -03:00
parent b539bd933c
commit 21957f2164
2 changed files with 3 additions and 63 deletions

View File

@ -32,9 +32,6 @@
int _win_app_foreground = TRUE; int _win_app_foreground = TRUE;
static HANDLE foreground_event = NULL;
static int allegro_thread_priority = THREAD_PRIORITY_NORMAL;
/* _win_reset_switch_mode: /* _win_reset_switch_mode:
@ -49,9 +46,6 @@ void _win_reset_switch_mode(void)
set_display_switch_mode(SWITCH_BACKGROUND); set_display_switch_mode(SWITCH_BACKGROUND);
_win_app_foreground = TRUE; _win_app_foreground = TRUE;
/* This has a nice side-effect: releasing the blocked threads. */
SetEvent(foreground_event);
} }
@ -60,7 +54,6 @@ void _win_reset_switch_mode(void)
*/ */
void sys_directx_display_switch_init(void) void sys_directx_display_switch_init(void)
{ {
foreground_event = CreateEvent(NULL, TRUE, TRUE, NULL);
_win_reset_switch_mode(); _win_reset_switch_mode();
} }
@ -70,7 +63,6 @@ void sys_directx_display_switch_init(void)
*/ */
void sys_directx_display_switch_exit(void) void sys_directx_display_switch_exit(void)
{ {
CloseHandle(foreground_event);
} }
@ -107,8 +99,6 @@ int sys_directx_set_display_switch_mode(int mode)
*/ */
void _win_switch_in(void) void _win_switch_in(void)
{ {
int mode;
_TRACE(PREFIX_I "switch in\n"); _TRACE(PREFIX_I "switch in\n");
_win_app_foreground = TRUE; _win_app_foreground = TRUE;
@ -119,17 +109,6 @@ void _win_switch_in(void)
if (win_gfx_driver && win_gfx_driver->switch_in) if (win_gfx_driver && win_gfx_driver->switch_in)
win_gfx_driver->switch_in(); win_gfx_driver->switch_in();
/* handle switch modes */
mode = get_display_switch_mode();
if ((mode == SWITCH_AMNESIA) || (mode == SWITCH_PAUSE)) {
_TRACE(PREFIX_I "AMNESIA or PAUSE mode recovery\n");
SetEvent(foreground_event);
/* restore old priority and wake up */
SetThreadPriority(allegro_thread, allegro_thread_priority);
}
_switch_in(); _switch_in();
} }
@ -140,8 +119,6 @@ void _win_switch_in(void)
*/ */
void _win_switch_out(void) void _win_switch_out(void)
{ {
int mode;
_TRACE(PREFIX_I "switch out\n"); _TRACE(PREFIX_I "switch out\n");
_win_app_foreground = FALSE; _win_app_foreground = FALSE;
@ -149,19 +126,6 @@ void _win_switch_out(void)
if (win_gfx_driver && win_gfx_driver->switch_out) if (win_gfx_driver && win_gfx_driver->switch_out)
win_gfx_driver->switch_out(); win_gfx_driver->switch_out();
/* handle switch modes */
mode = get_display_switch_mode();
if ((mode == SWITCH_AMNESIA) || (mode == SWITCH_PAUSE)) {
_TRACE(PREFIX_I "AMNESIA or PAUSE mode suspension\n");
ResetEvent(foreground_event);
/* if the thread doesn't stop, lower its priority only if another window is active */
allegro_thread_priority = GetThreadPriority(allegro_thread);
if ((HINSTANCE)GetWindowLong(GetForegroundWindow(), GWL_HINSTANCE) != allegro_inst)
SetThreadPriority(allegro_thread, THREAD_PRIORITY_LOWEST);
}
_switch_out(); _switch_out();
} }
@ -173,12 +137,5 @@ void _win_switch_out(void)
*/ */
int _win_thread_switch_out(void) int _win_thread_switch_out(void)
{ {
int mode = get_display_switch_mode();
if ((mode == SWITCH_AMNESIA) || (mode == SWITCH_PAUSE)) {
WaitForSingleObject(foreground_event, INFINITE);
return TRUE;
}
return FALSE; return FALSE;
} }

View File

@ -71,7 +71,6 @@ static HANDLE wnd_thread = NULL;
static int old_style = 0; static int old_style = 0;
/* custom window msgs */ /* custom window msgs */
#define SWITCH_TIMER 1
static UINT msg_call_proc = 0; static UINT msg_call_proc = 0;
static UINT msg_suicide = 0; static UINT msg_suicide = 0;
@ -152,23 +151,9 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
if (HIWORD(wparam)) if (HIWORD(wparam))
break; break;
if (gfx_driver && !gfx_driver->windowed) {
/* 1.2s delay to let Windows complete the switch in fullscreen mode */
SetTimer(allegro_wnd, SWITCH_TIMER, 1200, NULL);
}
else {
/* no delay in windowed mode */ /* no delay in windowed mode */
_win_switch_in(); _win_switch_in();
} }
}
break;
case WM_TIMER:
if (wparam == SWITCH_TIMER) {
KillTimer(allegro_wnd, SWITCH_TIMER);
_win_switch_in();
return 0;
}
break; break;
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
@ -508,9 +493,7 @@ int init_directx_window(void)
switch (result) { switch (result) {
case WAIT_OBJECT_0: /* window was created successfully */ case WAIT_OBJECT_0: /* window was created successfully */
wnd_thread = events[1]; wnd_thread = events[1];
SetThreadPriority(wnd_thread, THREAD_PRIORITY_ABOVE_NORMAL);
break; break;
default: /* thread failed to create window */ default: /* thread failed to create window */
return -1; return -1;
} }