summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-02-20 14:05:00 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-02-20 14:05:00 +0000
commita6e0344fa0e09413324835ae122c4cadd7890231 (patch)
tree29c7a1a860a9d8e5f30a4fc92fa86a448b13ca74 /ui
parentb487e2b2ff6e9fff8a45a9600d6de3a7bf82666a (diff)
parent63ad932567df012ff4bf820a9ed0e2affd9dc5af (diff)
downloadqemu-a6e0344fa0e09413324835ae122c4cadd7890231.tar.gz
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180220-pull-request' into staging
ui: reorganize and cleanup display command line parsing. gtk: fix gtk3 warnings. # gpg: Signature made Tue 20 Feb 2018 13:46:53 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20180220-pull-request: ui: Reorder vte terminal packing to avoid gtk3 warnings vl: drop display_type variable vl: drop request_opengl variable vl: drop full_screen variable cocoa: use DisplayOptions curses: use DisplayOptions egl-headless: use DisplayOptions vl: drop no_quit variable sdl: use DisplayOptions gtk: add and use DisplayOptions + DisplayGTK vl: rename DisplayType to LegacyDisplayType vl: deprecate -no-frame Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/cocoa.m4
-rw-r--r--ui/curses.c2
-rw-r--r--ui/egl-headless.c2
-rw-r--r--ui/gtk.c36
-rw-r--r--ui/sdl.c19
-rw-r--r--ui/sdl2.c33
6 files changed, 56 insertions, 40 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 51db47cd71..90d9aa57ea 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1683,12 +1683,12 @@ static void addRemovableDevicesMenuItems(void)
qapi_free_BlockInfoList(pointerToFree);
}
-void cocoa_display_init(DisplayState *ds, int full_screen)
+void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
{
COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
/* if fullscreen mode is to be used */
- if (full_screen == true) {
+ if (opts->has_full_screen && opts->full_screen) {
[NSApp activateIgnoringOtherApps: YES];
[(QemuCocoaAppController *)[[NSApplication sharedApplication] delegate] toggleFullScreen: nil];
}
diff --git a/ui/curses.c b/ui/curses.c
index 85503876c0..479b77bd03 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -434,7 +434,7 @@ static const DisplayChangeListenerOps dcl_ops = {
.dpy_text_cursor = curses_cursor_position,
};
-void curses_display_init(DisplayState *ds, int full_screen)
+void curses_display_init(DisplayState *ds, DisplayOptions *opts)
{
#ifndef _WIN32
if (!isatty(1)) {
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 5d50226869..38b3766548 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -154,7 +154,7 @@ static const DisplayChangeListenerOps egl_ops = {
.dpy_gl_update = egl_scanout_flush,
};
-void egl_headless_init(void)
+void egl_headless_init(DisplayOptions *opts)
{
QemuConsole *con;
egl_dpy *edpy;
diff --git a/ui/gtk.c b/ui/gtk.c
index 1537751afa..ab646b70e1 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -230,6 +230,8 @@ struct GtkDisplayState {
bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
bool ignore_keys;
+
+ DisplayOptions *opts;
};
typedef struct VCChardev {
@@ -778,9 +780,14 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
void *opaque)
{
GtkDisplayState *s = opaque;
+ bool allow_close = true;
int i;
- if (!no_quit) {
+ if (s->opts->has_window_close && !s->opts->window_close) {
+ allow_close = false;
+ }
+
+ if (allow_close) {
for (i = 0; i < s->nb_vcs; i++) {
if (s->vc[i].type != GD_VC_GFX) {
continue;
@@ -1945,8 +1952,8 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
scrollbar = gtk_vscrollbar_new(vadjustment);
#endif
- gtk_box_pack_start(GTK_BOX(box), vc->vte.terminal, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(box), scrollbar, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(box), scrollbar, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(box), vc->vte.terminal, TRUE, TRUE, 0);
vc->vte.box = box;
vc->vte.scrollbar = scrollbar;
@@ -2290,7 +2297,7 @@ static void gd_create_menus(GtkDisplayState *s)
static gboolean gtkinit;
-void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
+void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
{
VirtualConsole *vc;
@@ -2302,6 +2309,8 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
fprintf(stderr, "gtk initialization failed\n");
exit(1);
}
+ assert(opts->type == DISPLAY_TYPE_GTK);
+ s->opts = opts;
#if !GTK_CHECK_VERSION(3, 0, 0)
g_printerr("Running QEMU with GTK 2.x is deprecated, and will be removed\n"
@@ -2388,15 +2397,17 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
vc && vc->type == GD_VC_VTE);
#endif
- if (full_screen) {
+ if (opts->has_full_screen &&
+ opts->full_screen) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
- if (grab_on_hover) {
+ if (opts->u.gtk.has_grab_on_hover &&
+ opts->u.gtk.grab_on_hover) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
}
-void early_gtk_display_init(int opengl)
+void early_gtk_display_init(DisplayOptions *opts)
{
/* The QEMU code relies on the assumption that it's always run in
* the C locale. Therefore it is not prepared to deal with
@@ -2422,11 +2433,8 @@ void early_gtk_display_init(int opengl)
return;
}
- switch (opengl) {
- case -1: /* default */
- case 0: /* off */
- break;
- case 1: /* on */
+ assert(opts->type == DISPLAY_TYPE_GTK);
+ if (opts->has_gl && opts->gl) {
#if defined(CONFIG_OPENGL)
#if defined(CONFIG_GTK_GL)
gtk_gl_area_init();
@@ -2434,10 +2442,6 @@ void early_gtk_display_init(int opengl)
gtk_egl_init();
#endif
#endif
- break;
- default:
- g_assert_not_reached();
- break;
}
keycode_map = gd_get_keymap(&keycode_maplen);
diff --git a/ui/sdl.c b/ui/sdl.c
index a6bff301eb..963cdf77a7 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -41,6 +41,7 @@
static DisplayChangeListener *dcl;
static DisplaySurface *surface;
+static DisplayOptions *opts;
static SDL_Surface *real_screen;
static SDL_Surface *guest_screen = NULL;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
@@ -769,6 +770,7 @@ static void handle_activation(SDL_Event *ev)
static void sdl_refresh(DisplayChangeListener *dcl)
{
SDL_Event ev1, *ev = &ev1;
+ bool allow_close = true;
int idle = 1;
if (last_vm_running != runstate_is_running()) {
@@ -793,7 +795,10 @@ static void sdl_refresh(DisplayChangeListener *dcl)
handle_keyup(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);
}
@@ -892,9 +897,9 @@ static const DisplayChangeListenerOps dcl_ops = {
.dpy_cursor_define = sdl_mouse_define,
};
-void sdl_display_early_init(int opengl)
+void sdl_display_early_init(DisplayOptions *opts)
{
- if (opengl == 1 /* on */) {
+ if (opts->has_gl && opts->gl) {
fprintf(stderr,
"SDL1 display code has no opengl support.\n"
"Please recompile qemu with SDL2, using\n"
@@ -902,7 +907,7 @@ void sdl_display_early_init(int opengl)
}
}
-void sdl_display_init(DisplayState *ds, int full_screen)
+void sdl_display_init(DisplayState *ds, DisplayOptions *o)
{
int flags;
uint8_t data = 0;
@@ -910,6 +915,8 @@ void sdl_display_init(DisplayState *ds, int full_screen)
SDL_SysWMinfo info;
char *filename;
+ assert(o->type == DISPLAY_TYPE_SDL);
+ opts = o;
#if defined(__APPLE__)
/* always use generic keymaps */
if (!keyboard_layout)
@@ -924,7 +931,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
"in a future release. Please switch to SDL 2.0 instead\n");
- if (!full_screen) {
+ if (opts->has_full_screen && opts->full_screen) {
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
}
#ifdef __linux__
@@ -967,7 +974,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();
}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 858e04d7c0..6e96a4a24c 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);
}