aboutsummaryrefslogtreecommitdiff
path: root/ui/gtk.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-02-02 12:10:14 +0100
committerGerd Hoffmann <kraxel@redhat.com>2018-02-20 12:12:04 +0100
commit0c8d7065325d84cb2521c0b52f383561d2541415 (patch)
treec99d887272a8f4713cb293323508091f1e734ad0 /ui/gtk.c
parentbe045e6bb8c63ea4d7b4d7775febe18ccdf8dd24 (diff)
gtk: add and use DisplayOptions + DisplayGTK
Add QAPI DisplayType enum, DisplayOptions union and DisplayGTK struct. Switch gtk configuration to use the qapi type. Some bookkeeping (fullscreen for example) is done twice now, this is temporary until more/all UIs are switched over to qapi configuration. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20180202111022.19269-5-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 1537751afa..ad4910c70d 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;
@@ -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);