static SDL_Surface *guest_screen = NULL;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
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_fullscreen;
static int gui_noframe;
static int gui_key_modifier_pressed;
static int gui_keysym;
-static int gui_fullscreen_initial_grab;
static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
static uint8_t modifiers_state[256];
static int width, height;
// printf("resizing to %d %d\n", w, h);
- flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_RESIZABLE;
- if (gui_fullscreen)
+ flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
+ if (gui_fullscreen) {
flags |= SDL_FULLSCREEN;
+ } else {
+ flags |= SDL_RESIZABLE;
+ }
if (gui_noframe)
flags |= SDL_NOFRAME;
sdl_update_caption();
}
-static void sdl_mouse_mode_change(Notifier *notify)
+static void sdl_mouse_mode_change(Notifier *notify, void *data)
{
if (kbd_mouse_is_absolute()) {
if (!absolute_enabled) {
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)
{
gui_fullscreen = !gui_fullscreen;
- do_sdl_resize(real_screen->w, real_screen->h, real_screen->format->BitsPerPixel);
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),
+ ds_get_bits_per_pixel(ds));
scaling_active = 0;
+
gui_saved_grab = gui_grab;
sdl_grab_start();
} else {
- if (!gui_saved_grab)
+ 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 || !is_graphic_console()) {
sdl_grab_end();
+ }
}
vga_hw_invalidate();
vga_hw_update();
gui_keysym = 1;
break;
case 0x16: /* 'u' key on US keyboard */
- scaling_active = 0;
- sdl_resize(ds);
- vga_hw_invalidate();
- vga_hw_update();
+ if (scaling_active) {
+ scaling_active = 0;
+ sdl_resize(ds);
+ vga_hw_invalidate();
+ vga_hw_update();
+ }
+ gui_keysym = 1;
break;
case 0x02 ... 0x0a: /* '1' to '9' keys */
/* Reset the modifiers sent to the current console */
'SDL_WM_GrabInput(SDL_GRAB_ON)'
from blocking all the application
(SDL bug). */
- if (SDL_GetAppState() & SDL_APPACTIVE)
+ if (is_graphic_console() &&
+ SDL_GetAppState() & SDL_APPACTIVE) {
sdl_grab_start();
+ }
} else {
sdl_grab_end();
}
sdl_process_key(&ev->key);
break;
case SDL_QUIT:
- if (!no_quit)
+ if (!no_quit) {
+ no_shutdown = 0;
qemu_system_shutdown_request();
+ }
break;
case SDL_MOUSEMOTION:
if (gui_grab || kbd_mouse_is_absolute() ||
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
- {
+ if (is_graphic_console()) {
SDL_MouseButtonEvent *bev = &ev->button;
if (!gui_grab && !kbd_mouse_is_absolute()) {
if (ev->type == SDL_MOUSEBUTTONDOWN &&
break;
case SDL_ACTIVEEVENT:
if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS &&
- !ev->active.gain && !gui_fullscreen_initial_grab) {
+ !ev->active.gain && !gui_fullscreen) {
sdl_grab_end();
}
if (ev->active.state & SDL_APPACTIVE) {
}
}
break;
- case SDL_VIDEORESIZE:
- {
- 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);
- }
+ case SDL_VIDEORESIZE:
+ sdl_scale(ds, ev->resize.w, ev->resize.h);
vga_hw_invalidate();
vga_hw_update();
break;
- }
default:
break;
}
qemu_free(filename);
}
+ if (full_screen) {
+ gui_fullscreen = 1;
+ sdl_grab_start();
+ }
+
dcl = qemu_mallocz(sizeof(DisplayChangeListener));
dcl->dpy_update = sdl_update;
dcl->dpy_resize = sdl_resize;
sdl_cursor_normal = SDL_GetCursor();
atexit(sdl_cleanup);
- if (full_screen) {
- gui_fullscreen = 1;
- gui_fullscreen_initial_grab = 1;
- sdl_grab_start();
- }
}