SDL: Cleaned up fullscreen toggle functions.
FIXME: Window height sometimes not restored correctly (observed on Linux / X11).
This commit is contained in:
parent
103b4fa8eb
commit
77fffc1336
@ -315,102 +315,38 @@ static Bit32u sdl_sym_to_bx_key(SDLKey sym)
|
||||
|
||||
void switch_to_windowed(void)
|
||||
{
|
||||
SDL_Surface *tmp;
|
||||
SDL_Rect src, dst;
|
||||
src.x = 0; src.y = 0;
|
||||
src.w = res_x; src.h = res_y;
|
||||
dst.x = 0; dst.y = 0;
|
||||
|
||||
tmp = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE,
|
||||
res_x,
|
||||
res_y,
|
||||
32,
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
#else
|
||||
0x000000ff,
|
||||
0x0000ff00,
|
||||
0x00ff0000,
|
||||
0xff000000
|
||||
#endif
|
||||
);
|
||||
|
||||
SDL_BlitSurface(sdl_fullscreen,&src,tmp,&dst);
|
||||
SDL_UpdateRect(tmp,0,0,res_x,res_y);
|
||||
SDL_FreeSurface(sdl_fullscreen);
|
||||
sdl_fullscreen = NULL;
|
||||
|
||||
sdl_screen = SDL_SetVideoMode(res_x,res_y+headerbar_height+statusbar_height,32, SDL_SWSURFACE);
|
||||
dst.y = headerbar_height;
|
||||
SDL_BlitSurface(tmp,&src,sdl_screen,&dst);
|
||||
SDL_UpdateRect(tmp,0,0,res_x,res_y+headerbar_height+statusbar_height);
|
||||
SDL_FreeSurface(tmp);
|
||||
|
||||
bx_gui->show_headerbar();
|
||||
DEV_vga_refresh(1);
|
||||
SDL_ShowCursor(1);
|
||||
if (sdl_grab==1) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
|
||||
sdl_grab = 0;
|
||||
bx_gui->toggle_mouse_enable();
|
||||
if (sdl_grab == 1) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
sdl_grab = 0;
|
||||
bx_gui->toggle_mouse_enable();
|
||||
}
|
||||
bx_gui->flush();
|
||||
}
|
||||
|
||||
|
||||
void switch_to_fullscreen(void)
|
||||
{
|
||||
SDL_Surface *tmp;
|
||||
SDL_Rect src, dst;
|
||||
src.x = 0; src.y = headerbar_height;
|
||||
src.w = res_x; src.h = res_y;
|
||||
dst.x = 0; dst.y = 0;
|
||||
|
||||
tmp = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE,
|
||||
res_x,
|
||||
res_y,
|
||||
32,
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
#else
|
||||
0x000000ff,
|
||||
0x0000ff00,
|
||||
0x00ff0000,
|
||||
0xff000000
|
||||
#endif
|
||||
);
|
||||
|
||||
SDL_BlitSurface(sdl_screen,&src,tmp,&dst);
|
||||
SDL_UpdateRect(tmp,0,0,res_x,res_y);
|
||||
SDL_FreeSurface(sdl_screen);
|
||||
sdl_screen = NULL;
|
||||
|
||||
#ifdef ANDROID
|
||||
sdl_fullscreen = SDL_SetVideoMode(res_x,res_y,32, SDL_SWSURFACE|SDL_FULLSCREEN);
|
||||
#else
|
||||
sdl_fullscreen = SDL_SetVideoMode(res_x,res_y,32, SDL_HWSURFACE|SDL_FULLSCREEN);
|
||||
#endif
|
||||
src.y = 0;
|
||||
SDL_BlitSurface(tmp,&src,sdl_fullscreen,&dst);
|
||||
SDL_FreeSurface(tmp);
|
||||
|
||||
DEV_vga_refresh(1);
|
||||
SDL_ShowCursor(0);
|
||||
#ifndef ANDROID
|
||||
if (sdl_grab==0) {
|
||||
if (sdl_grab == 0) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
sdl_grab = 1;
|
||||
bx_gui->toggle_mouse_enable();
|
||||
}
|
||||
#endif
|
||||
bx_gui->flush();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user