From fe91f36aa5bd846cea816cf0a9b7a13dd76559c1 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 2 Feb 2018 12:10:15 +0100 Subject: sdl: use DisplayOptions Switch sdl ui to use qapi DisplayOptions for configuration. Signed-off-by: Gerd Hoffmann Reviewed-by: Eric Blake Message-id: 20180202111022.19269-6-kraxel@redhat.com Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'ui/sdl2.c') diff --git a/ui/sdl2.c b/ui/sdl2.c index 858e04d..6e96a4a 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -32,6 +32,7 @@ static int sdl2_num_outputs; static struct sdl2_console *sdl2_console; +static DisplayOptions *opts; static SDL_Surface *guest_sprite_surface; static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ @@ -526,6 +527,7 @@ static void handle_mousewheel(SDL_Event *ev) static void handle_windowevent(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->window.windowID); + bool allow_close = true; if (!scon) { return; @@ -572,7 +574,10 @@ static void handle_windowevent(SDL_Event *ev) break; case SDL_WINDOWEVENT_CLOSE: if (qemu_console_is_graphic(scon->dcl.con)) { - if (!no_quit) { + if (opts->has_window_close && !opts->window_close) { + allow_close = false; + } + if (allow_close) { no_shutdown = 0; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); } @@ -593,6 +598,7 @@ static void handle_windowevent(SDL_Event *ev) void sdl2_poll_events(struct sdl2_console *scon) { SDL_Event ev1, *ev = &ev1; + bool allow_close = true; int idle = 1; if (scon->last_vm_running != runstate_is_running()) { @@ -615,7 +621,10 @@ void sdl2_poll_events(struct sdl2_console *scon) handle_textinput(ev); break; case SDL_QUIT: - if (!no_quit) { + if (opts->has_window_close && !opts->window_close) { + allow_close = false; + } + if (allow_close) { no_shutdown = 0; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); } @@ -750,24 +759,17 @@ static const DisplayChangeListenerOps dcl_gl_ops = { }; #endif -void sdl_display_early_init(int opengl) +void sdl_display_early_init(DisplayOptions *o) { - switch (opengl) { - case -1: /* default */ - case 0: /* off */ - break; - case 1: /* on */ + assert(o->type == DISPLAY_TYPE_SDL); + if (o->has_gl && o->gl) { #ifdef CONFIG_OPENGL display_opengl = 1; #endif - break; - default: - g_assert_not_reached(); - break; } } -void sdl_display_init(DisplayState *ds, int full_screen) +void sdl_display_init(DisplayState *ds, DisplayOptions *o) { int flags; uint8_t data = 0; @@ -775,6 +777,9 @@ void sdl_display_init(DisplayState *ds, int full_screen) int i; SDL_SysWMinfo info; + assert(o->type == DISPLAY_TYPE_SDL); + opts = o; + #ifdef __linux__ /* on Linux, SDL may use fbcon|directfb|svgalib when run without * accessible $DISPLAY to open X11 window. This is often the case @@ -849,7 +854,7 @@ void sdl_display_init(DisplayState *ds, int full_screen) g_free(filename); } - if (full_screen) { + if (opts->has_full_screen && opts->full_screen) { gui_fullscreen = 1; sdl_grab_start(0); } -- cgit v1.1