mirror of https://github.com/xqemu/xqemu.git
sdl: Restore scaling mode on return from full screen
Save the scaling mode and its geometry when going full screen, restore it when returning to windowed mode. CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
2a8ad7da54
commit
f9977897ee
44
ui/sdl.c
44
ui/sdl.c
|
@ -39,6 +39,9 @@ static SDL_Surface *real_screen;
|
||||||
static SDL_Surface *guest_screen = NULL;
|
static SDL_Surface *guest_screen = NULL;
|
||||||
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
||||||
static int last_vm_running;
|
static int last_vm_running;
|
||||||
|
static bool gui_saved_scaling;
|
||||||
|
static int gui_saved_width;
|
||||||
|
static int gui_saved_height;
|
||||||
static int gui_saved_grab;
|
static int gui_saved_grab;
|
||||||
static int gui_fullscreen;
|
static int gui_fullscreen;
|
||||||
static int gui_noframe;
|
static int gui_noframe;
|
||||||
|
@ -526,16 +529,42 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state
|
||||||
kbd_mouse_event(dx, dy, dz, buttons);
|
kbd_mouse_event(dx, dy, dz, buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sdl_scale(DisplayState *ds, int width, int height)
|
||||||
|
{
|
||||||
|
int bpp = real_screen->format->BitsPerPixel;
|
||||||
|
|
||||||
|
if (bpp != 16 && bpp != 32) {
|
||||||
|
bpp = 32;
|
||||||
|
}
|
||||||
|
do_sdl_resize(width, height, bpp);
|
||||||
|
scaling_active = 1;
|
||||||
|
if (!is_buffer_shared(ds->surface)) {
|
||||||
|
ds->surface = qemu_resize_displaysurface(ds, ds_get_width(ds),
|
||||||
|
ds_get_height(ds));
|
||||||
|
dpy_resize(ds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void toggle_full_screen(DisplayState *ds)
|
static void toggle_full_screen(DisplayState *ds)
|
||||||
{
|
{
|
||||||
gui_fullscreen = !gui_fullscreen;
|
gui_fullscreen = !gui_fullscreen;
|
||||||
|
if (gui_fullscreen) {
|
||||||
|
gui_saved_width = real_screen->w;
|
||||||
|
gui_saved_height = real_screen->h;
|
||||||
|
gui_saved_scaling = scaling_active;
|
||||||
|
|
||||||
do_sdl_resize(ds_get_width(ds), ds_get_height(ds),
|
do_sdl_resize(ds_get_width(ds), ds_get_height(ds),
|
||||||
ds_get_bits_per_pixel(ds));
|
ds_get_bits_per_pixel(ds));
|
||||||
if (gui_fullscreen) {
|
|
||||||
scaling_active = 0;
|
scaling_active = 0;
|
||||||
|
|
||||||
gui_saved_grab = gui_grab;
|
gui_saved_grab = gui_grab;
|
||||||
sdl_grab_start();
|
sdl_grab_start();
|
||||||
} else {
|
} else {
|
||||||
|
if (gui_saved_scaling) {
|
||||||
|
sdl_scale(ds, gui_saved_width, gui_saved_height);
|
||||||
|
} else {
|
||||||
|
do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0);
|
||||||
|
}
|
||||||
if (!gui_saved_grab)
|
if (!gui_saved_grab)
|
||||||
sdl_grab_end();
|
sdl_grab_end();
|
||||||
}
|
}
|
||||||
|
@ -738,21 +767,10 @@ static void sdl_refresh(DisplayState *ds)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_VIDEORESIZE:
|
case SDL_VIDEORESIZE:
|
||||||
{
|
sdl_scale(ds, ev->resize.w, ev->resize.h);
|
||||||
SDL_ResizeEvent *rev = &ev->resize;
|
|
||||||
int bpp = real_screen->format->BitsPerPixel;
|
|
||||||
if (bpp != 16 && bpp != 32)
|
|
||||||
bpp = 32;
|
|
||||||
do_sdl_resize(rev->w, rev->h, bpp);
|
|
||||||
scaling_active = 1;
|
|
||||||
if (!is_buffer_shared(ds->surface)) {
|
|
||||||
ds->surface = qemu_resize_displaysurface(ds, ds_get_width(ds), ds_get_height(ds));
|
|
||||||
dpy_resize(ds);
|
|
||||||
}
|
|
||||||
vga_hw_invalidate();
|
vga_hw_invalidate();
|
||||||
vga_hw_update();
|
vga_hw_update();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue