All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/24] RfC: rework display initialization
@ 2017-11-17 10:30 Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support Gerd Hoffmann
                   ` (24 more replies)
  0 siblings, 25 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

  Hi,

This series reworks the qemu display initialization.  Changes:

  * Create a QAPI DisplayOptions type for display configuration.
  * Switch all display initialization calls to accept DisplayOptions
    instead of a bunch of bools.
  * Add a registry for displays, and remove alot of #ifdefs from vl.c
  * Build sdl, gtk and curses as modules.

For now I'm looking for comments especially on the DisplayOptions QAPI
type.  Is there a more elegant way than the empty DisplayNoOpts struct
(see patch #5)?

cheers,
  Gerd

Gerd Hoffmann (24):
  sdl: remove -no-frame support
  sdl: remove -alt-grab and -ctrl-grab support
  sdl: use ctrl-alt-g as grab hotkey
  vl: rename DisplayType to LegacyDisplayType
  gtk: add and use DisplayOptions + DisplayGTK
  sdl: use DisplayOptions
  vl: drop no_quit variable
  egl-headless: use DisplayOptions
  curses: use DisplayOptions
  cocoa: use DisplayOptions
  vl: drop full_screen variable
  vl: drop display_type variable
  vl: drop request_opengl variable
  console: add qemu display registry, add gtk
  sdl: hook up to display registry
  cocoa: hook up to display registry
  curses: hook up to display registry
  egl-headless: hook up to display registry
  console: add and use qemu_display_find_default
  console: add ui module loading support
  sdl: build as module
  gtk: build as module
  curses: build as module
  build: opengl should not need X11

 configure             |  17 +++--
 Makefile.objs         |   1 +
 include/qemu/module.h |   1 +
 include/ui/console.h  |  77 +++------------------
 ui/console.c          |  59 ++++++++++++++++
 ui/curses.c           |  14 +++-
 ui/egl-headless.c     |  20 +++++-
 ui/gtk.c              |  45 ++++++++----
 ui/sdl.c              |  89 ++++++++++--------------
 ui/sdl2.c             |  92 ++++++++++++-------------
 vl.c                  | 186 +++++++++++++-------------------------------------
 qapi/ui.json          |  49 +++++++++++++
 ui/Makefile.objs      |  26 ++++---
 ui/cocoa.m            |  16 ++++-
 14 files changed, 348 insertions(+), 344 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 14:21   ` Daniel P. Berrange
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support Gerd Hoffmann
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

SDL2 doesn't support this any more, the SDL_NOFRAME window flag is gone.
Drop the code, print a notice when the option is still used.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  5 ++---
 ui/sdl.c             |  8 +-------
 ui/sdl2.c            |  7 +------
 vl.c                 | 15 ++++-----------
 4 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 580dfc57ee..7b35778444 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -436,7 +436,7 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
 /* sdl.c */
 #ifdef CONFIG_SDL
 void sdl_display_early_init(int opengl);
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
+void sdl_display_init(DisplayState *ds, int full_screen);
 #else
 static inline void sdl_display_early_init(int opengl)
 {
@@ -444,8 +444,7 @@ static inline void sdl_display_early_init(int opengl)
     error_report("SDL support is disabled");
     abort();
 }
-static inline void sdl_display_init(DisplayState *ds, int full_screen,
-                                    int no_frame)
+static inline void sdl_display_init(DisplayState *ds, int full_screen)
 {
     /* This must never be called if CONFIG_SDL is disabled */
     error_report("SDL support is disabled");
diff --git a/ui/sdl.c b/ui/sdl.c
index 7b71a9ac58..f3adbb7a64 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -48,7 +48,6 @@ 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_grab_code = KMOD_LALT | KMOD_LCTRL;
@@ -114,8 +113,6 @@ static void do_sdl_resize(int width, int height, int bpp)
     } else {
         flags |= SDL_RESIZABLE;
     }
-    if (gui_noframe)
-        flags |= SDL_NOFRAME;
 
     tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
     if (!real_screen) {
@@ -944,7 +941,7 @@ void sdl_display_early_init(int opengl)
     }
 }
 
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+void sdl_display_init(DisplayState *ds, int full_screen)
 {
     int flags;
     uint8_t data = 0;
@@ -963,9 +960,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
             exit(1);
     }
 
-    if (no_frame)
-        gui_noframe = 1;
-
     if (!full_screen) {
         setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
     }
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 53dd447fd2..3802a9b477 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -38,7 +38,6 @@ static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
 
 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_grab_code = KMOD_LALT | KMOD_LCTRL;
@@ -756,7 +755,7 @@ void sdl_display_early_init(int opengl)
     }
 }
 
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+void sdl_display_init(DisplayState *ds, int full_screen)
 {
     int flags;
     uint8_t data = 0;
@@ -764,10 +763,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     int i;
     SDL_SysWMinfo info;
 
-    if (no_frame) {
-        gui_noframe = 1;
-    }
-
 #ifdef __linux__
     /* on Linux, SDL may use fbcon|directfb|svgalib when run without
      * accessible $DISPLAY to open X11 window.  This is often the case
diff --git a/vl.c b/vl.c
index 7372424fa7..4d8553b433 100644
--- a/vl.c
+++ b/vl.c
@@ -151,7 +151,6 @@ static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
-static int no_frame = 0;
 int no_quit = 0;
 static bool grab_on_hover;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
@@ -2165,13 +2164,7 @@ static DisplayType select_display(const char *p)
 
             if (strstart(opts, ",frame=", &nextopt)) {
                 opts = nextopt;
-                if (strstart(opts, "on", &nextopt)) {
-                    no_frame = 0;
-                } else if (strstart(opts, "off", &nextopt)) {
-                    no_frame = 1;
-                } else {
-                    goto invalid_sdl_args;
-                }
+                warn_report("frame sdl option is unsupported, ignoring");
             } else if (strstart(opts, ",alt_grab=", &nextopt)) {
                 opts = nextopt;
                 if (strstart(opts, "on", &nextopt)) {
@@ -3784,7 +3777,7 @@ int main(int argc, char **argv, char **envp)
                 full_screen = 1;
                 break;
             case QEMU_OPTION_no_frame:
-                no_frame = 1;
+                warn_report("-no-frame switch is unsupported, ignoring");
                 break;
             case QEMU_OPTION_alt_grab:
                 alt_grab = 1;
@@ -4473,7 +4466,7 @@ int main(int argc, char **argv, char **envp)
 #endif
     }
 
-    if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
+    if ((alt_grab || ctrl_grab) && display_type != DT_SDL) {
         error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
                      "for SDL, ignoring option");
     }
@@ -4824,7 +4817,7 @@ int main(int argc, char **argv, char **envp)
         curses_display_init(ds, full_screen);
         break;
     case DT_SDL:
-        sdl_display_init(ds, full_screen, no_frame);
+        sdl_display_init(ds, full_screen);
         break;
     case DT_COCOA:
         cocoa_display_init(ds, full_screen);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 14:22   ` Daniel P. Berrange
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 03/24] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
                   ` (22 subsequent siblings)
  24 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

With absolute pointer devices such as usb-tablet being widely used
mouse grabs (for relative pointing devices) should be rarely needed
these days.  So the benefit of the options to configure the hotkey
modifiers for grab (and other actions) seems questionable.  Which
is expecially true for the -ctrl-grab which isn't handled in the
handle_keyup() code.

Drop the code, print a notice when the option is still used.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c  | 22 +++-------------------
 ui/sdl2.c | 23 +++--------------------
 vl.c      | 26 ++++----------------------
 3 files changed, 10 insertions(+), 61 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index f3adbb7a64..2c85482b5e 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -364,12 +364,7 @@ static void sdl_update_caption(void)
     if (!runstate_is_running())
         status = " [Stopped]";
     else if (gui_grab) {
-        if (alt_grab)
-            status = " - Press Ctrl-Alt-Shift to exit mouse grab";
-        else if (ctrl_grab)
-            status = " - Press Right-Ctrl to exit mouse grab";
-        else
-            status = " - Press Ctrl-Alt to exit mouse grab";
+        status = " - Press Ctrl-Alt to exit mouse grab";
     }
 
     if (qemu_name) {
@@ -556,14 +551,7 @@ static void handle_keydown(SDL_Event *ev)
     int mod_state;
     int keycode;
 
-    if (alt_grab) {
-        mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
-                    (gui_grab_code | KMOD_LSHIFT);
-    } else if (ctrl_grab) {
-        mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
-    } else {
-        mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
-    }
+    mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
     gui_key_modifier_pressed = mod_state;
 
     if (gui_key_modifier_pressed) {
@@ -701,11 +689,7 @@ static void handle_keyup(SDL_Event *ev)
 {
     int mod_state;
 
-    if (!alt_grab) {
-        mod_state = (ev->key.keysym.mod & gui_grab_code);
-    } else {
-        mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT));
-    }
+    mod_state = (ev->key.keysym.mod & gui_grab_code);
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
         if (gui_keysym == 0) {
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 3802a9b477..e15566877b 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -139,13 +139,7 @@ static void sdl_update_caption(struct sdl2_console *scon)
     if (!runstate_is_running()) {
         status = " [Stopped]";
     } else if (gui_grab) {
-        if (alt_grab) {
-            status = " - Press Ctrl-Alt-Shift to exit grab";
-        } else if (ctrl_grab) {
-            status = " - Press Right-Ctrl to exit grab";
-        } else {
-            status = " - Press Ctrl-Alt to exit grab";
-        }
+        status = " - Press Ctrl-Alt to exit grab";
     }
 
     if (qemu_name) {
@@ -336,14 +330,7 @@ static void handle_keydown(SDL_Event *ev)
     int mod_state, win;
     struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
 
-    if (alt_grab) {
-        mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
-            (gui_grab_code | KMOD_LSHIFT);
-    } else if (ctrl_grab) {
-        mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
-    } else {
-        mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
-    }
+    mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
     gui_key_modifier_pressed = mod_state;
 
     if (gui_key_modifier_pressed) {
@@ -420,11 +407,7 @@ static void handle_keyup(SDL_Event *ev)
     int mod_state;
     struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
 
-    if (!alt_grab) {
-        mod_state = (ev->key.keysym.mod & gui_grab_code);
-    } else {
-        mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT));
-    }
+    mod_state = (ev->key.keysym.mod & gui_grab_code);
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
         if (gui_keysym == 0) {
diff --git a/vl.c b/vl.c
index 4d8553b433..7dab7523a6 100644
--- a/vl.c
+++ b/vl.c
@@ -175,8 +175,6 @@ QEMUOptionRom option_rom[MAX_OPTION_ROMS];
 int nb_option_roms;
 int old_param = 0;
 const char *qemu_name;
-int alt_grab = 0;
-int ctrl_grab = 0;
 unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
 int boot_menu;
@@ -2167,22 +2165,10 @@ static DisplayType select_display(const char *p)
                 warn_report("frame sdl option is unsupported, ignoring");
             } else if (strstart(opts, ",alt_grab=", &nextopt)) {
                 opts = nextopt;
-                if (strstart(opts, "on", &nextopt)) {
-                    alt_grab = 1;
-                } else if (strstart(opts, "off", &nextopt)) {
-                    alt_grab = 0;
-                } else {
-                    goto invalid_sdl_args;
-                }
+                warn_report("ctrl_grab sdl option is unsupported, ignoring");
             } else if (strstart(opts, ",ctrl_grab=", &nextopt)) {
                 opts = nextopt;
-                if (strstart(opts, "on", &nextopt)) {
-                    ctrl_grab = 1;
-                } else if (strstart(opts, "off", &nextopt)) {
-                    ctrl_grab = 0;
-                } else {
-                    goto invalid_sdl_args;
-                }
+                warn_report("alt_grab sdl option is unsupported, ignoring");
             } else if (strstart(opts, ",window_close=", &nextopt)) {
                 opts = nextopt;
                 if (strstart(opts, "on", &nextopt)) {
@@ -3780,10 +3766,10 @@ int main(int argc, char **argv, char **envp)
                 warn_report("-no-frame switch is unsupported, ignoring");
                 break;
             case QEMU_OPTION_alt_grab:
-                alt_grab = 1;
+                warn_report("-alt-grab switch is unsupported, ignoring");
                 break;
             case QEMU_OPTION_ctrl_grab:
-                ctrl_grab = 1;
+                warn_report("-ctrl-grab switch is unsupported, ignoring");
                 break;
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
@@ -4466,10 +4452,6 @@ int main(int argc, char **argv, char **envp)
 #endif
     }
 
-    if ((alt_grab || ctrl_grab) && display_type != DT_SDL) {
-        error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
-                     "for SDL, ignoring option");
-    }
     if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
         error_report("-no-quit is only valid for GTK and SDL, "
                      "ignoring option");
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 03/24] sdl: use ctrl-alt-g as grab hotkey
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 04/24] vl: rename DisplayType to LegacyDisplayType Gerd Hoffmann
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Be consistent with gtk and cocoa.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c  | 26 +++++++++++---------------
 ui/sdl2.c | 22 +++++++++-------------
 2 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 2c85482b5e..6ce67eeb5a 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -364,7 +364,7 @@ static void sdl_update_caption(void)
     if (!runstate_is_running())
         status = " [Stopped]";
     else if (gui_grab) {
-        status = " - Press Ctrl-Alt to exit mouse grab";
+        status = " - Press Ctrl-Alt-G to exit mouse grab";
     }
 
     if (qemu_name) {
@@ -561,6 +561,16 @@ static void handle_keydown(SDL_Event *ev)
             toggle_full_screen();
             gui_keysym = 1;
             break;
+        case 0x22: /* 'g' key */
+            if (!gui_grab) {
+                if (qemu_console_is_graphic(NULL)) {
+                    sdl_grab_start();
+                }
+            } else if (!gui_fullscreen) {
+                sdl_grab_end();
+            }
+            gui_keysym = 1;
+            break;
         case 0x16: /* 'u' key on US keyboard */
             if (scaling_active) {
                 scaling_active = 0;
@@ -692,20 +702,6 @@ static void handle_keyup(SDL_Event *ev)
     mod_state = (ev->key.keysym.mod & gui_grab_code);
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
-        if (gui_keysym == 0) {
-            /* exit/enter grab if pressing Ctrl-Alt */
-            if (!gui_grab) {
-                if (qemu_console_is_graphic(NULL)) {
-                    sdl_grab_start();
-                }
-            } else if (!gui_fullscreen) {
-                sdl_grab_end();
-            }
-            /* SDL does not send back all the modifiers key, so we must
-             * correct it. */
-            reset_keys();
-            return;
-        }
         gui_keysym = 0;
     }
     if (qemu_console_is_graphic(NULL) && !gui_keysym) {
diff --git a/ui/sdl2.c b/ui/sdl2.c
index e15566877b..105c461b21 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -139,7 +139,7 @@ static void sdl_update_caption(struct sdl2_console *scon)
     if (!runstate_is_running()) {
         status = " [Stopped]";
     } else if (gui_grab) {
-        status = " - Press Ctrl-Alt to exit grab";
+        status = " - Press Ctrl-Alt-G to exit grab";
     }
 
     if (qemu_name) {
@@ -364,6 +364,14 @@ static void handle_keydown(SDL_Event *ev)
             toggle_full_screen(scon);
             gui_keysym = 1;
             break;
+        case SDL_SCANCODE_G:
+            gui_keysym = 1;
+            if (!gui_grab) {
+                sdl_grab_start(scon);
+            } else if (!gui_fullscreen) {
+                sdl_grab_end(scon);
+            }
+            break;
         case SDL_SCANCODE_U:
             sdl2_window_destroy(scon);
             sdl2_window_create(scon);
@@ -410,18 +418,6 @@ static void handle_keyup(SDL_Event *ev)
     mod_state = (ev->key.keysym.mod & gui_grab_code);
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
-        if (gui_keysym == 0) {
-            /* exit/enter grab if pressing Ctrl-Alt */
-            if (!gui_grab) {
-                sdl_grab_start(scon);
-            } else if (!gui_fullscreen) {
-                sdl_grab_end(scon);
-            }
-            /* SDL does not send back all the modifiers key, so we must
-             * correct it. */
-            sdl2_reset_keys(scon);
-            return;
-        }
         gui_keysym = 0;
     }
     if (!gui_keysym) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 04/24] vl: rename DisplayType to LegacyDisplayType
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 03/24] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 05/24] gtk: add and use DisplayOptions + DisplayGTK Gerd Hoffmann
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

qapi DisplayType will replace the current enum.  For the transition both
will coexist though, so rename it so we don't have a name clash.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index 7dab7523a6..3310ae60d3 100644
--- a/vl.c
+++ b/vl.c
@@ -2139,7 +2139,7 @@ static void select_vgahw(const char *p)
     }
 }
 
-typedef enum DisplayType {
+typedef enum LegacyDisplayType {
     DT_DEFAULT,
     DT_CURSES,
     DT_SDL,
@@ -2147,12 +2147,12 @@ typedef enum DisplayType {
     DT_GTK,
     DT_EGL,
     DT_NONE,
-} DisplayType;
+} LegacyDisplayType;
 
-static DisplayType select_display(const char *p)
+static LegacyDisplayType select_display(const char *p)
 {
     const char *opts;
-    DisplayType display = DT_DEFAULT;
+    LegacyDisplayType display = DT_DEFAULT;
 
     if (strstart(p, "sdl", &opts)) {
 #ifdef CONFIG_SDL
@@ -3092,7 +3092,7 @@ int main(int argc, char **argv, char **envp)
     const char *incoming = NULL;
     bool userconfig = true;
     bool nographic = false;
-    DisplayType display_type = DT_DEFAULT;
+    LegacyDisplayType display_type = DT_DEFAULT;
     int display_remote = 0;
     const char *log_mask = NULL;
     const char *log_file = NULL;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 05/24] gtk: add and use DisplayOptions + DisplayGTK
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 04/24] vl: rename DisplayType to LegacyDisplayType Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 06/24] sdl: use DisplayOptions Gerd Hoffmann
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Eric Blake, Paolo Bonzini

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.

FIXME: more elegant solution than DisplayNoOpts struct?

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  9 ++++-----
 ui/gtk.c             | 32 ++++++++++++++++++--------------
 vl.c                 | 23 ++++++++++++++++++-----
 qapi/ui.json         | 44 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 84 insertions(+), 24 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 7b35778444..58d1a3d27c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -511,18 +511,17 @@ int index_from_key(const char *key, size_t key_length);
 
 /* gtk.c */
 #ifdef CONFIG_GTK
-void early_gtk_display_init(int opengl);
-void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover);
+void early_gtk_display_init(DisplayOptions *opts);
+void gtk_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void gtk_display_init(DisplayState *ds, bool full_screen,
-                                    bool grab_on_hover)
+static inline void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_GTK is disabled */
     error_report("GTK support is disabled");
     abort();
 }
 
-static inline void early_gtk_display_init(int opengl)
+static inline void early_gtk_display_init(DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_GTK is disabled */
     error_report("GTK support is disabled");
diff --git a/ui/gtk.c b/ui/gtk.c
index 342e96fbe9..c2426dd44e 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -180,6 +180,8 @@ struct GtkDisplayState {
     bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
     bool has_evdev;
     bool ignore_keys;
+
+    DisplayOptions *opts;
 };
 
 typedef struct VCChardev {
@@ -728,9 +730,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;
@@ -2235,7 +2242,7 @@ static void gd_set_keycode_type(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;
 
@@ -2247,6 +2254,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;
 
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 #if GTK_CHECK_VERSION(3, 2, 0)
@@ -2328,17 +2337,19 @@ 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));
     }
 
     gd_set_keycode_type(s);
 }
 
-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
@@ -2364,11 +2375,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();
@@ -2376,10 +2384,6 @@ void early_gtk_display_init(int opengl)
         gtk_egl_init();
 #endif
 #endif
-        break;
-    default:
-        g_assert_not_reached();
-        break;
     }
 
 #if defined(CONFIG_VTE)
diff --git a/vl.c b/vl.c
index 3310ae60d3..af67c86de0 100644
--- a/vl.c
+++ b/vl.c
@@ -151,8 +151,8 @@ static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
+static DisplayOptions dpy;
 int no_quit = 0;
-static bool grab_on_hover;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -2224,24 +2224,29 @@ static LegacyDisplayType select_display(const char *p)
     } else if (strstart(p, "gtk", &opts)) {
 #ifdef CONFIG_GTK
         display = DT_GTK;
+        dpy.type = DISPLAY_TYPE_GTK;
         while (*opts) {
             const char *nextopt;
 
             if (strstart(opts, ",grab_on_hover=", &nextopt)) {
                 opts = nextopt;
+                dpy.u.gtk.has_grab_on_hover = true;
                 if (strstart(opts, "on", &nextopt)) {
-                    grab_on_hover = true;
+                    dpy.u.gtk.grab_on_hover = true;
                 } else if (strstart(opts, "off", &nextopt)) {
-                    grab_on_hover = false;
+                    dpy.u.gtk.grab_on_hover = false;
                 } else {
                     goto invalid_gtk_args;
                 }
             } else if (strstart(opts, ",gl=", &nextopt)) {
                 opts = nextopt;
+                dpy.has_gl = true;
                 if (strstart(opts, "on", &nextopt)) {
                     request_opengl = 1;
+                    dpy.gl = true;
                 } else if (strstart(opts, "off", &nextopt)) {
                     request_opengl = 0;
+                    dpy.gl = false;
                 } else {
                     goto invalid_gtk_args;
                 }
@@ -2258,6 +2263,7 @@ static LegacyDisplayType select_display(const char *p)
 #endif
     } else if (strstart(p, "none", &opts)) {
         display = DT_NONE;
+        dpy.type = DISPLAY_TYPE_NONE;
     } else {
         error_report("unknown display type");
         exit(1);
@@ -3374,6 +3380,7 @@ int main(int argc, char **argv, char **envp)
                 qemu_opts_parse_noisily(olist, "graphics=off", false);
                 nographic = true;
                 display_type = DT_NONE;
+                dpy.type = DISPLAY_TYPE_NONE;
                 break;
             case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
@@ -3761,6 +3768,8 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_full_screen:
                 full_screen = 1;
+                dpy.has_full_screen = true;
+                dpy.full_screen = true;
                 break;
             case QEMU_OPTION_no_frame:
                 warn_report("-no-frame switch is unsupported, ignoring");
@@ -3773,6 +3782,8 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
+                dpy.has_window_close = true;
+                dpy.window_close = false;
                 break;
             case QEMU_OPTION_sdl:
 #ifdef CONFIG_SDL
@@ -4441,6 +4452,7 @@ int main(int argc, char **argv, char **envp)
     if (display_type == DT_DEFAULT && !display_remote) {
 #if defined(CONFIG_GTK)
         display_type = DT_GTK;
+        dpy.type = DISPLAY_TYPE_GTK;
 #elif defined(CONFIG_SDL)
         display_type = DT_SDL;
 #elif defined(CONFIG_COCOA)
@@ -4449,6 +4461,7 @@ int main(int argc, char **argv, char **envp)
         vnc_parse("localhost:0,to=99,id=default", &error_abort);
 #else
         display_type = DT_NONE;
+        dpy.type = DISPLAY_TYPE_NONE;
 #endif
     }
 
@@ -4458,7 +4471,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (display_type == DT_GTK) {
-        early_gtk_display_init(request_opengl);
+        early_gtk_display_init(&dpy);
     }
 
     if (display_type == DT_SDL) {
@@ -4805,7 +4818,7 @@ int main(int argc, char **argv, char **envp)
         cocoa_display_init(ds, full_screen);
         break;
     case DT_GTK:
-        gtk_display_init(ds, full_screen, grab_on_hover);
+        gtk_display_init(ds, &dpy);
         break;
     default:
         break;
diff --git a/qapi/ui.json b/qapi/ui.json
index 07b468f625..dbb745bd53 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -982,3 +982,47 @@
   'data': { '*device': 'str',
             '*head'  : 'int',
             'events' : [ 'InputEvent' ] } }
+
+
+##
+# @DisplayNoOpts:
+#
+# WIP
+#
+##
+{ 'struct'  : 'DisplayNoOpts',
+  'data'    : { } }
+
+##
+# @DisplayGTK:
+#
+# WIP
+#
+##
+{ 'struct'  : 'DisplayGTK',
+  'data'    : { '*grab-on-hover' : 'bool' } }
+
+##
+# @DisplayType:
+#
+# WIP
+#
+##
+{ 'enum'    : 'DisplayType',
+  'data'    : [ 'default', 'none', 'gtk' ] }
+
+##
+# @DisplayOptions:
+#
+# WIP
+#
+##
+{ 'union'   : 'DisplayOptions',
+  'base'    : { 'type'           : 'DisplayType',
+                '*full-screen'   : 'bool',
+                '*window-close'  : 'bool',
+                '*gl'            : 'bool' },
+  'discriminator' : 'type',
+  'data'    : { 'default'        : 'DisplayNoOpts',
+                'none'           : 'DisplayNoOpts',
+                'gtk'            : 'DisplayGTK' } }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 06/24] sdl: use DisplayOptions
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 05/24] gtk: add and use DisplayOptions + DisplayGTK Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 07/24] vl: drop no_quit variable Gerd Hoffmann
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Eric Blake, Paolo Bonzini

Switch sdl ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  8 ++++----
 ui/sdl.c             | 19 +++++++++++++------
 ui/sdl2.c            | 33 +++++++++++++++++++--------------
 vl.c                 | 13 +++++++++++--
 qapi/ui.json         |  5 +++--
 5 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 58d1a3d27c..deee5bb606 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -435,16 +435,16 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
 
 /* sdl.c */
 #ifdef CONFIG_SDL
-void sdl_display_early_init(int opengl);
-void sdl_display_init(DisplayState *ds, int full_screen);
+void sdl_display_early_init(DisplayOptions *opts);
+void sdl_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void sdl_display_early_init(int opengl)
+static inline void sdl_display_early_init(DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_SDL is disabled */
     error_report("SDL support is disabled");
     abort();
 }
-static inline void sdl_display_init(DisplayState *ds, int full_screen)
+static inline void sdl_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_SDL is disabled */
     error_report("SDL support is disabled");
diff --git a/ui/sdl.c b/ui/sdl.c
index 6ce67eeb5a..972592fe42 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -39,6 +39,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 */
@@ -788,6 +789,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()) {
@@ -812,7 +814,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);
             }
@@ -911,9 +916,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"
@@ -921,7 +926,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;
@@ -929,6 +934,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)
@@ -940,7 +947,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
             exit(1);
     }
 
-    if (!full_screen) {
+    if (opts->has_full_screen && opts->full_screen) {
         setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
     }
 #ifdef __linux__
@@ -981,7 +988,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 105c461b21..34002129e1 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 */
@@ -507,6 +508,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;
@@ -544,7 +546,10 @@ static void handle_windowevent(SDL_Event *ev)
         update_displaychangelistener(&scon->dcl, 500);
         break;
     case SDL_WINDOWEVENT_CLOSE:
-        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);
         }
@@ -565,6 +570,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()) {
@@ -587,7 +593,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);
             }
@@ -717,24 +726,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;
@@ -742,6 +744,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
@@ -816,7 +821,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);
     }
diff --git a/vl.c b/vl.c
index af67c86de0..b34fbf1a09 100644
--- a/vl.c
+++ b/vl.c
@@ -2157,6 +2157,7 @@ static LegacyDisplayType select_display(const char *p)
     if (strstart(p, "sdl", &opts)) {
 #ifdef CONFIG_SDL
         display = DT_SDL;
+        dpy.type = DISPLAY_TYPE_SDL;
         while (*opts) {
             const char *nextopt;
 
@@ -2171,19 +2172,25 @@ static LegacyDisplayType select_display(const char *p)
                 warn_report("alt_grab sdl option is unsupported, ignoring");
             } else if (strstart(opts, ",window_close=", &nextopt)) {
                 opts = nextopt;
+                dpy.has_window_close = true;
                 if (strstart(opts, "on", &nextopt)) {
                     no_quit = 0;
+                    dpy.window_close = true;
                 } else if (strstart(opts, "off", &nextopt)) {
                     no_quit = 1;
+                    dpy.window_close = false;
                 } else {
                     goto invalid_sdl_args;
                 }
             } else if (strstart(opts, ",gl=", &nextopt)) {
                 opts = nextopt;
+                dpy.has_gl = true;
                 if (strstart(opts, "on", &nextopt)) {
                     request_opengl = 1;
+                    dpy.gl = true;
                 } else if (strstart(opts, "off", &nextopt)) {
                     request_opengl = 0;
+                    dpy.gl = false;
                 } else {
                     goto invalid_sdl_args;
                 }
@@ -3788,6 +3795,7 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_sdl:
 #ifdef CONFIG_SDL
                 display_type = DT_SDL;
+                dpy.type = DISPLAY_TYPE_SDL;
                 break;
 #else
                 error_report("SDL support is disabled");
@@ -4455,6 +4463,7 @@ int main(int argc, char **argv, char **envp)
         dpy.type = DISPLAY_TYPE_GTK;
 #elif defined(CONFIG_SDL)
         display_type = DT_SDL;
+        dpy.type = DISPLAY_TYPE_SDL;
 #elif defined(CONFIG_COCOA)
         display_type = DT_COCOA;
 #elif defined(CONFIG_VNC)
@@ -4475,7 +4484,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (display_type == DT_SDL) {
-        sdl_display_early_init(request_opengl);
+        sdl_display_early_init(&dpy);
     }
 
     qemu_console_early_init();
@@ -4812,7 +4821,7 @@ int main(int argc, char **argv, char **envp)
         curses_display_init(ds, full_screen);
         break;
     case DT_SDL:
-        sdl_display_init(ds, full_screen);
+        sdl_display_init(ds, &dpy);
         break;
     case DT_COCOA:
         cocoa_display_init(ds, full_screen);
diff --git a/qapi/ui.json b/qapi/ui.json
index dbb745bd53..e7d3e8729b 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1009,7 +1009,7 @@
 #
 ##
 { 'enum'    : 'DisplayType',
-  'data'    : [ 'default', 'none', 'gtk' ] }
+  'data'    : [ 'default', 'none', 'gtk', 'sdl' ] }
 
 ##
 # @DisplayOptions:
@@ -1025,4 +1025,5 @@
   'discriminator' : 'type',
   'data'    : { 'default'        : 'DisplayNoOpts',
                 'none'           : 'DisplayNoOpts',
-                'gtk'            : 'DisplayGTK' } }
+                'gtk'            : 'DisplayGTK',
+                'sdl'            : 'DisplayNoOpts' } }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 07/24] vl: drop no_quit variable
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 06/24] sdl: use DisplayOptions Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 08/24] egl-headless: use DisplayOptions Gerd Hoffmann
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Not used any more, delete it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index b34fbf1a09..d461800f13 100644
--- a/vl.c
+++ b/vl.c
@@ -152,7 +152,6 @@ QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
 static DisplayOptions dpy;
-int no_quit = 0;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -2174,10 +2173,8 @@ static LegacyDisplayType select_display(const char *p)
                 opts = nextopt;
                 dpy.has_window_close = true;
                 if (strstart(opts, "on", &nextopt)) {
-                    no_quit = 0;
                     dpy.window_close = true;
                 } else if (strstart(opts, "off", &nextopt)) {
-                    no_quit = 1;
                     dpy.window_close = false;
                 } else {
                     goto invalid_sdl_args;
@@ -3788,7 +3785,6 @@ int main(int argc, char **argv, char **envp)
                 warn_report("-ctrl-grab switch is unsupported, ignoring");
                 break;
             case QEMU_OPTION_no_quit:
-                no_quit = 1;
                 dpy.has_window_close = true;
                 dpy.window_close = false;
                 break;
@@ -4474,7 +4470,8 @@ int main(int argc, char **argv, char **envp)
 #endif
     }
 
-    if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
+    if (dpy.has_window_close &&
+        (display_type != DT_GTK && display_type != DT_SDL)) {
         error_report("-no-quit is only valid for GTK and SDL, "
                      "ignoring option");
     }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 08/24] egl-headless: use DisplayOptions
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 07/24] vl: drop no_quit variable Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 09/24] curses: " Gerd Hoffmann
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Eric Blake, Paolo Bonzini

Switch egl-headless ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 2 +-
 ui/egl-headless.c    | 2 +-
 vl.c                 | 3 ++-
 qapi/ui.json         | 5 +++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index deee5bb606..4cb623112e 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -530,6 +530,6 @@ static inline void early_gtk_display_init(DisplayOptions *opts)
 #endif
 
 /* egl-headless.c */
-void egl_headless_init(void);
+void egl_headless_init(DisplayOptions *opts);
 
 #endif
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/vl.c b/vl.c
index d461800f13..b5cf02bb46 100644
--- a/vl.c
+++ b/vl.c
@@ -2214,6 +2214,7 @@ static LegacyDisplayType select_display(const char *p)
         request_opengl = 1;
         display_opengl = 1;
         display = DT_EGL;
+        dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
 #else
         fprintf(stderr, "egl support is disabled\n");
         exit(1);
@@ -4845,7 +4846,7 @@ int main(int argc, char **argv, char **envp)
 
 #ifdef CONFIG_OPENGL_DMABUF
     if (display_type == DT_EGL) {
-        egl_headless_init();
+        egl_headless_init(&dpy);
     }
 #endif
 
diff --git a/qapi/ui.json b/qapi/ui.json
index e7d3e8729b..372205c98f 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1009,7 +1009,7 @@
 #
 ##
 { 'enum'    : 'DisplayType',
-  'data'    : [ 'default', 'none', 'gtk', 'sdl' ] }
+  'data'    : [ 'default', 'none', 'gtk', 'sdl', 'egl-headless' ] }
 
 ##
 # @DisplayOptions:
@@ -1026,4 +1026,5 @@
   'data'    : { 'default'        : 'DisplayNoOpts',
                 'none'           : 'DisplayNoOpts',
                 'gtk'            : 'DisplayGTK',
-                'sdl'            : 'DisplayNoOpts' } }
+                'sdl'            : 'DisplayNoOpts',
+                'egl-headless'   : 'DisplayNoOpts' } }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 09/24] curses: use DisplayOptions
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 08/24] egl-headless: use DisplayOptions Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 10/24] cocoa: " Gerd Hoffmann
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Eric Blake, Paolo Bonzini

Switch curses ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 4 ++--
 ui/curses.c          | 2 +-
 vl.c                 | 4 +++-
 qapi/ui.json         | 5 +++--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 4cb623112e..9749503aa7 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -496,9 +496,9 @@ static inline int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
 
 /* curses.c */
 #ifdef CONFIG_CURSES
-void curses_display_init(DisplayState *ds, int full_screen);
+void curses_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void curses_display_init(DisplayState *ds, int full_screen)
+static inline void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_CURSES is disabled */
     error_report("curses support is disabled");
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/vl.c b/vl.c
index b5cf02bb46..b1036626eb 100644
--- a/vl.c
+++ b/vl.c
@@ -2222,6 +2222,7 @@ static LegacyDisplayType select_display(const char *p)
     } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
         display = DT_CURSES;
+        dpy.type = DISPLAY_TYPE_CURSES;
 #else
         error_report("curses support is disabled");
         exit(1);
@@ -3390,6 +3391,7 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
                 display_type = DT_CURSES;
+                dpy.type = DISPLAY_TYPE_CURSES;
 #else
                 error_report("curses support is disabled");
                 exit(1);
@@ -4816,7 +4818,7 @@ int main(int argc, char **argv, char **envp)
     /* init local displays */
     switch (display_type) {
     case DT_CURSES:
-        curses_display_init(ds, full_screen);
+        curses_display_init(ds, &dpy);
         break;
     case DT_SDL:
         sdl_display_init(ds, &dpy);
diff --git a/qapi/ui.json b/qapi/ui.json
index 372205c98f..4bb3f938f1 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1009,7 +1009,7 @@
 #
 ##
 { 'enum'    : 'DisplayType',
-  'data'    : [ 'default', 'none', 'gtk', 'sdl', 'egl-headless' ] }
+  'data'    : [ 'default', 'none', 'gtk', 'sdl', 'egl-headless', 'curses' ] }
 
 ##
 # @DisplayOptions:
@@ -1027,4 +1027,5 @@
                 'none'           : 'DisplayNoOpts',
                 'gtk'            : 'DisplayGTK',
                 'sdl'            : 'DisplayNoOpts',
-                'egl-headless'   : 'DisplayNoOpts' } }
+                'egl-headless'   : 'DisplayNoOpts',
+                'curses'         : 'DisplayNoOpts' } }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 10/24] cocoa: use DisplayOptions
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 09/24] curses: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 11/24] vl: drop full_screen variable Gerd Hoffmann
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Gerd Hoffmann, Eric Blake, Peter Maydell,
	Paolo Bonzini

Switch cocoa ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 4 ++--
 vl.c                 | 3 ++-
 qapi/ui.json         | 6 ++++--
 ui/cocoa.m           | 4 ++--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 9749503aa7..f96fd907d0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -454,9 +454,9 @@ static inline void sdl_display_init(DisplayState *ds, DisplayOptions *opts)
 
 /* cocoa.m */
 #ifdef CONFIG_COCOA
-void cocoa_display_init(DisplayState *ds, int full_screen);
+void cocoa_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void cocoa_display_init(DisplayState *ds, int full_screen)
+static inline void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     /* This must never be called if CONFIG_COCOA is disabled */
     error_report("Cocoa support is disabled");
diff --git a/vl.c b/vl.c
index b1036626eb..7d7e4ba9a1 100644
--- a/vl.c
+++ b/vl.c
@@ -4465,6 +4465,7 @@ int main(int argc, char **argv, char **envp)
         dpy.type = DISPLAY_TYPE_SDL;
 #elif defined(CONFIG_COCOA)
         display_type = DT_COCOA;
+        dpy.type = DISPLAY_TYPE_COCOA;
 #elif defined(CONFIG_VNC)
         vnc_parse("localhost:0,to=99,id=default", &error_abort);
 #else
@@ -4824,7 +4825,7 @@ int main(int argc, char **argv, char **envp)
         sdl_display_init(ds, &dpy);
         break;
     case DT_COCOA:
-        cocoa_display_init(ds, full_screen);
+        cocoa_display_init(ds, &dpy);
         break;
     case DT_GTK:
         gtk_display_init(ds, &dpy);
diff --git a/qapi/ui.json b/qapi/ui.json
index 4bb3f938f1..2baa5127cf 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1009,7 +1009,8 @@
 #
 ##
 { 'enum'    : 'DisplayType',
-  'data'    : [ 'default', 'none', 'gtk', 'sdl', 'egl-headless', 'curses' ] }
+  'data'    : [ 'default', 'none', 'gtk', 'sdl',
+                'egl-headless', 'curses', 'cocoa' ] }
 
 ##
 # @DisplayOptions:
@@ -1028,4 +1029,5 @@
                 'gtk'            : 'DisplayGTK',
                 'sdl'            : 'DisplayNoOpts',
                 'egl-headless'   : 'DisplayNoOpts',
-                'curses'         : 'DisplayNoOpts' } }
+                'curses'         : 'DisplayNoOpts',
+                'cocoa'          : 'DisplayNoOpts' } }
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..9560c07105 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1671,12 +1671,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->have_full_screen && opts->full_screen) {
         [NSApp activateIgnoringOtherApps: YES];
         [(QemuCocoaAppController *)[[NSApplication sharedApplication] delegate] toggleFullScreen: nil];
     }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 11/24] vl: drop full_screen variable
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 10/24] cocoa: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 12/24] vl: drop display_type variable Gerd Hoffmann
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Not used any more, delete it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/vl.c b/vl.c
index 7d7e4ba9a1..85c41953b3 100644
--- a/vl.c
+++ b/vl.c
@@ -150,7 +150,6 @@ static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
-static int full_screen = 0;
 static DisplayOptions dpy;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
@@ -3774,7 +3773,6 @@ int main(int argc, char **argv, char **envp)
                 loadvm = optarg;
                 break;
             case QEMU_OPTION_full_screen:
-                full_screen = 1;
                 dpy.has_full_screen = true;
                 dpy.full_screen = true;
                 break;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 12/24] vl: drop display_type variable
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 11/24] vl: drop full_screen variable Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 13/24] vl: drop request_opengl variable Gerd Hoffmann
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Switch over all leftover users to qapi DisplayType.
The delete the unused display_type variable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 52 +++++++++++++---------------------------------------
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/vl.c b/vl.c
index 85c41953b3..36eec0d1e0 100644
--- a/vl.c
+++ b/vl.c
@@ -2137,24 +2137,12 @@ static void select_vgahw(const char *p)
     }
 }
 
-typedef enum LegacyDisplayType {
-    DT_DEFAULT,
-    DT_CURSES,
-    DT_SDL,
-    DT_COCOA,
-    DT_GTK,
-    DT_EGL,
-    DT_NONE,
-} LegacyDisplayType;
-
-static LegacyDisplayType select_display(const char *p)
+static void parse_display(const char *p)
 {
     const char *opts;
-    LegacyDisplayType display = DT_DEFAULT;
 
     if (strstart(p, "sdl", &opts)) {
 #ifdef CONFIG_SDL
-        display = DT_SDL;
         dpy.type = DISPLAY_TYPE_SDL;
         while (*opts) {
             const char *nextopt;
@@ -2212,7 +2200,6 @@ static LegacyDisplayType select_display(const char *p)
 #ifdef CONFIG_OPENGL_DMABUF
         request_opengl = 1;
         display_opengl = 1;
-        display = DT_EGL;
         dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
 #else
         fprintf(stderr, "egl support is disabled\n");
@@ -2220,7 +2207,6 @@ static LegacyDisplayType select_display(const char *p)
 #endif
     } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
-        display = DT_CURSES;
         dpy.type = DISPLAY_TYPE_CURSES;
 #else
         error_report("curses support is disabled");
@@ -2228,7 +2214,6 @@ static LegacyDisplayType select_display(const char *p)
 #endif
     } else if (strstart(p, "gtk", &opts)) {
 #ifdef CONFIG_GTK
-        display = DT_GTK;
         dpy.type = DISPLAY_TYPE_GTK;
         while (*opts) {
             const char *nextopt;
@@ -2267,14 +2252,11 @@ static LegacyDisplayType select_display(const char *p)
         exit(1);
 #endif
     } else if (strstart(p, "none", &opts)) {
-        display = DT_NONE;
         dpy.type = DISPLAY_TYPE_NONE;
     } else {
         error_report("unknown display type");
         exit(1);
     }
-
-    return display;
 }
 
 static int balloon_parse(const char *arg)
@@ -3103,7 +3085,6 @@ int main(int argc, char **argv, char **envp)
     const char *incoming = NULL;
     bool userconfig = true;
     bool nographic = false;
-    LegacyDisplayType display_type = DT_DEFAULT;
     int display_remote = 0;
     const char *log_mask = NULL;
     const char *log_file = NULL;
@@ -3378,18 +3359,16 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_display:
-                display_type = select_display(optarg);
+                parse_display(optarg);
                 break;
             case QEMU_OPTION_nographic:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "graphics=off", false);
                 nographic = true;
-                display_type = DT_NONE;
                 dpy.type = DISPLAY_TYPE_NONE;
                 break;
             case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
-                display_type = DT_CURSES;
                 dpy.type = DISPLAY_TYPE_CURSES;
 #else
                 error_report("curses support is disabled");
@@ -3791,7 +3770,6 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_sdl:
 #ifdef CONFIG_SDL
-                display_type = DT_SDL;
                 dpy.type = DISPLAY_TYPE_SDL;
                 break;
 #else
@@ -4408,7 +4386,7 @@ int main(int argc, char **argv, char **envp)
             exit(1);
         }
 #ifdef CONFIG_CURSES
-        if (display_type == DT_CURSES) {
+        if (dpy.type == DISPLAY_TYPE_CURSES) {
             error_report("curses display cannot be used with -daemonize");
             exit(1);
         }
@@ -4454,35 +4432,31 @@ int main(int argc, char **argv, char **envp)
         display_remote++;
     }
 #endif
-    if (display_type == DT_DEFAULT && !display_remote) {
+    if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
 #if defined(CONFIG_GTK)
-        display_type = DT_GTK;
         dpy.type = DISPLAY_TYPE_GTK;
 #elif defined(CONFIG_SDL)
-        display_type = DT_SDL;
         dpy.type = DISPLAY_TYPE_SDL;
 #elif defined(CONFIG_COCOA)
-        display_type = DT_COCOA;
         dpy.type = DISPLAY_TYPE_COCOA;
 #elif defined(CONFIG_VNC)
         vnc_parse("localhost:0,to=99,id=default", &error_abort);
 #else
-        display_type = DT_NONE;
         dpy.type = DISPLAY_TYPE_NONE;
 #endif
     }
 
     if (dpy.has_window_close &&
-        (display_type != DT_GTK && display_type != DT_SDL)) {
+        (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) {
         error_report("-no-quit is only valid for GTK and SDL, "
                      "ignoring option");
     }
 
-    if (display_type == DT_GTK) {
+    if (dpy.type == DISPLAY_TYPE_GTK) {
         early_gtk_display_init(&dpy);
     }
 
-    if (display_type == DT_SDL) {
+    if (dpy.type == DISPLAY_TYPE_SDL) {
         sdl_display_early_init(&dpy);
     }
 
@@ -4815,17 +4789,17 @@ int main(int argc, char **argv, char **envp)
     ds = init_displaystate();
 
     /* init local displays */
-    switch (display_type) {
-    case DT_CURSES:
+    switch (dpy.type) {
+    case DISPLAY_TYPE_CURSES:
         curses_display_init(ds, &dpy);
         break;
-    case DT_SDL:
+    case DISPLAY_TYPE_SDL:
         sdl_display_init(ds, &dpy);
         break;
-    case DT_COCOA:
+    case DISPLAY_TYPE_COCOA:
         cocoa_display_init(ds, &dpy);
         break;
-    case DT_GTK:
+    case DISPLAY_TYPE_GTK:
         gtk_display_init(ds, &dpy);
         break;
     default:
@@ -4846,7 +4820,7 @@ int main(int argc, char **argv, char **envp)
     }
 
 #ifdef CONFIG_OPENGL_DMABUF
-    if (display_type == DT_EGL) {
+    if (dpy.type == DISPLAY_TYPE_EGL_HEADLESS) {
         egl_headless_init(&dpy);
     }
 #endif
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 13/24] vl: drop request_opengl variable
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (11 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 12/24] vl: drop display_type variable Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 14/24] console: add qemu display registry, add gtk Gerd Hoffmann
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Switch over the one leftover user to qapi DisplayType.
The delete the unused request_opengl variable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/vl.c b/vl.c
index 36eec0d1e0..c04cef83da 100644
--- a/vl.c
+++ b/vl.c
@@ -136,7 +136,6 @@ static const char *data_dir[16];
 static int data_dir_idx;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
-int request_opengl = -1;
 int display_opengl;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
@@ -2170,10 +2169,8 @@ static void parse_display(const char *p)
                 opts = nextopt;
                 dpy.has_gl = true;
                 if (strstart(opts, "on", &nextopt)) {
-                    request_opengl = 1;
                     dpy.gl = true;
                 } else if (strstart(opts, "off", &nextopt)) {
-                    request_opengl = 0;
                     dpy.gl = false;
                 } else {
                     goto invalid_sdl_args;
@@ -2198,7 +2195,6 @@ static void parse_display(const char *p)
         }
     } else if (strstart(p, "egl-headless", &opts)) {
 #ifdef CONFIG_OPENGL_DMABUF
-        request_opengl = 1;
         display_opengl = 1;
         dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
 #else
@@ -2232,10 +2228,8 @@ static void parse_display(const char *p)
                 opts = nextopt;
                 dpy.has_gl = true;
                 if (strstart(opts, "on", &nextopt)) {
-                    request_opengl = 1;
                     dpy.gl = true;
                 } else if (strstart(opts, "off", &nextopt)) {
-                    request_opengl = 0;
                     dpy.gl = false;
                 } else {
                     goto invalid_gtk_args;
@@ -4462,7 +4456,7 @@ int main(int argc, char **argv, char **envp)
 
     qemu_console_early_init();
 
-    if (request_opengl == 1 && display_opengl == 0) {
+    if (dpy.has_gl && dpy.gl && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
         error_report("OpenGL is not supported by the display");
 #else
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 14/24] console: add qemu display registry, add gtk
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (12 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 13/24] vl: drop request_opengl variable Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 15/24] sdl: hook up to display registry Gerd Hoffmann
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Add a registry for user interfaces.  Add qemu_display_init and
qemu_display_early_init helper functions for display initialization.

Hook up gtk ui as first user.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 32 ++++++++++++--------------------
 ui/console.c         | 34 ++++++++++++++++++++++++++++++++++
 ui/gtk.c             | 17 +++++++++++++++--
 vl.c                 | 18 ++++++------------
 4 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index f96fd907d0..b293c26477 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -433,6 +433,18 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
                                int ww, int wh);
 #endif
 
+typedef struct QemuDisplay QemuDisplay;
+
+struct QemuDisplay {
+    DisplayType type;
+    void (*early_init)(DisplayOptions *opts);
+    void (*init)(DisplayState *ds, DisplayOptions *opts);
+};
+
+void qemu_display_register(QemuDisplay *ui);
+void qemu_display_early_init(DisplayOptions *opts);
+void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
+
 /* sdl.c */
 #ifdef CONFIG_SDL
 void sdl_display_early_init(DisplayOptions *opts);
@@ -509,26 +521,6 @@ static inline void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 /* input.c */
 int index_from_key(const char *key, size_t key_length);
 
-/* gtk.c */
-#ifdef CONFIG_GTK
-void early_gtk_display_init(DisplayOptions *opts);
-void gtk_display_init(DisplayState *ds, DisplayOptions *opts);
-#else
-static inline void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_GTK is disabled */
-    error_report("GTK support is disabled");
-    abort();
-}
-
-static inline void early_gtk_display_init(DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_GTK is disabled */
-    error_report("GTK support is disabled");
-    abort();
-}
-#endif
-
 /* egl-headless.c */
 void egl_headless_init(DisplayOptions *opts);
 
diff --git a/ui/console.c b/ui/console.c
index c4c95abed7..aa8afbfe26 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2168,6 +2168,40 @@ PixelFormat qemu_default_pixelformat(int bpp)
     return pf;
 }
 
+static QemuDisplay *dpys[DISPLAY_TYPE__MAX];
+
+void qemu_display_register(QemuDisplay *ui)
+{
+    assert(ui->type < DISPLAY_TYPE__MAX);
+    dpys[ui->type] = ui;
+}
+
+void qemu_display_early_init(DisplayOptions *opts)
+{
+    assert(opts->type < DISPLAY_TYPE__MAX);
+    if (opts->type == DISPLAY_TYPE_NONE) {
+        return;
+    }
+    if (dpys[opts->type] == NULL) {
+        error_report("Display '%s' is not available.",
+                     DisplayType_lookup.array[opts->type]);
+        exit(1);
+    }
+    if (dpys[opts->type]->early_init) {
+        dpys[opts->type]->early_init(opts);
+    }
+}
+
+void qemu_display_init(DisplayState *ds, DisplayOptions *opts)
+{
+    assert(opts->type < DISPLAY_TYPE__MAX);
+    if (opts->type == DISPLAY_TYPE_NONE) {
+        return;
+    }
+    assert(dpys[opts->type] != NULL);
+    dpys[opts->type]->init(ds, opts);
+}
+
 void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp)
 {
     int val;
diff --git a/ui/gtk.c b/ui/gtk.c
index c2426dd44e..18020543ce 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2242,7 +2242,7 @@ static void gd_set_keycode_type(GtkDisplayState *s)
 
 static gboolean gtkinit;
 
-void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
+static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     VirtualConsole *vc;
 
@@ -2349,7 +2349,7 @@ void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     gd_set_keycode_type(s);
 }
 
-void early_gtk_display_init(DisplayOptions *opts)
+static 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
@@ -2390,3 +2390,16 @@ void early_gtk_display_init(DisplayOptions *opts)
     type_register(&char_gd_vc_type_info);
 #endif
 }
+
+static QemuDisplay qemu_display_gtk = {
+    .type       = DISPLAY_TYPE_GTK,
+    .early_init = early_gtk_display_init,
+    .init       = gtk_display_init,
+};
+
+static void register_gtk(void)
+{
+    qemu_display_register(&qemu_display_gtk);
+}
+
+type_init(register_gtk);
diff --git a/vl.c b/vl.c
index c04cef83da..57e775f8cd 100644
--- a/vl.c
+++ b/vl.c
@@ -2209,7 +2209,6 @@ static void parse_display(const char *p)
         exit(1);
 #endif
     } else if (strstart(p, "gtk", &opts)) {
-#ifdef CONFIG_GTK
         dpy.type = DISPLAY_TYPE_GTK;
         while (*opts) {
             const char *nextopt;
@@ -2241,10 +2240,6 @@ static void parse_display(const char *p)
             }
             opts = nextopt;
         }
-#else
-        error_report("GTK support is disabled");
-        exit(1);
-#endif
     } else if (strstart(p, "none", &opts)) {
         dpy.type = DISPLAY_TYPE_NONE;
     } else {
@@ -4439,6 +4434,9 @@ int main(int argc, char **argv, char **envp)
         dpy.type = DISPLAY_TYPE_NONE;
 #endif
     }
+    if (dpy.type == DISPLAY_TYPE_DEFAULT) {
+        dpy.type = DISPLAY_TYPE_NONE;
+    }
 
     if (dpy.has_window_close &&
         (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) {
@@ -4446,12 +4444,10 @@ int main(int argc, char **argv, char **envp)
                      "ignoring option");
     }
 
-    if (dpy.type == DISPLAY_TYPE_GTK) {
-        early_gtk_display_init(&dpy);
-    }
-
     if (dpy.type == DISPLAY_TYPE_SDL) {
         sdl_display_early_init(&dpy);
+    } else {
+        qemu_display_early_init(&dpy);
     }
 
     qemu_console_early_init();
@@ -4793,10 +4789,8 @@ int main(int argc, char **argv, char **envp)
     case DISPLAY_TYPE_COCOA:
         cocoa_display_init(ds, &dpy);
         break;
-    case DISPLAY_TYPE_GTK:
-        gtk_display_init(ds, &dpy);
-        break;
     default:
+        qemu_display_init(ds, &dpy);
         break;
     }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 15/24] sdl: hook up to display registry
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (13 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 14/24] console: add qemu display registry, add gtk Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 16/24] cocoa: " Gerd Hoffmann
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 19 -------------------
 ui/sdl.c             | 24 +++++++++++++-----------
 ui/sdl2.c            | 17 +++++++++++++++--
 vl.c                 | 15 +--------------
 4 files changed, 29 insertions(+), 46 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index b293c26477..63534ac20a 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -445,25 +445,6 @@ void qemu_display_register(QemuDisplay *ui);
 void qemu_display_early_init(DisplayOptions *opts);
 void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
 
-/* sdl.c */
-#ifdef CONFIG_SDL
-void sdl_display_early_init(DisplayOptions *opts);
-void sdl_display_init(DisplayState *ds, DisplayOptions *opts);
-#else
-static inline void sdl_display_early_init(DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_SDL is disabled */
-    error_report("SDL support is disabled");
-    abort();
-}
-static inline void sdl_display_init(DisplayState *ds, DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_SDL is disabled */
-    error_report("SDL support is disabled");
-    abort();
-}
-#endif
-
 /* cocoa.m */
 #ifdef CONFIG_COCOA
 void cocoa_display_init(DisplayState *ds, DisplayOptions *opts);
diff --git a/ui/sdl.c b/ui/sdl.c
index 972592fe42..cd850277ca 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -916,17 +916,7 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define    = sdl_mouse_define,
 };
 
-void sdl_display_early_init(DisplayOptions *opts)
-{
-    if (opts->has_gl && opts->gl) {
-        fprintf(stderr,
-                "SDL1 display code has no opengl support.\n"
-                "Please recompile qemu with SDL2, using\n"
-                "./configure --enable-sdl --with-sdlabi=2.0\n");
-    }
-}
-
-void sdl_display_init(DisplayState *ds, DisplayOptions *o)
+static void sdl1_display_init(DisplayState *ds, DisplayOptions *o)
 {
     int flags;
     uint8_t data = 0;
@@ -1033,3 +1023,15 @@ void sdl_display_init(DisplayState *ds, DisplayOptions *o)
 
     atexit(sdl_cleanup);
 }
+
+static QemuDisplay qemu_display_sdl1 = {
+    .type       = DISPLAY_TYPE_SDL,
+    .init       = sdl1_display_init,
+};
+
+static void register_sdl1(void)
+{
+    qemu_display_register(&qemu_display_sdl1);
+}
+
+type_init(register_sdl1);
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 34002129e1..0b53a12e54 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -726,7 +726,7 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
 };
 #endif
 
-void sdl_display_early_init(DisplayOptions *o)
+static void sdl2_display_early_init(DisplayOptions *o)
 {
     assert(o->type == DISPLAY_TYPE_SDL);
     if (o->has_gl && o->gl) {
@@ -736,7 +736,7 @@ void sdl_display_early_init(DisplayOptions *o)
     }
 }
 
-void sdl_display_init(DisplayState *ds, DisplayOptions *o)
+static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
 {
     int flags;
     uint8_t data = 0;
@@ -836,3 +836,16 @@ void sdl_display_init(DisplayState *ds, DisplayOptions *o)
 
     atexit(sdl_cleanup);
 }
+
+static QemuDisplay qemu_display_sdl2 = {
+    .type       = DISPLAY_TYPE_SDL,
+    .early_init = sdl2_display_early_init,
+    .init       = sdl2_display_init,
+};
+
+static void register_sdl1(void)
+{
+    qemu_display_register(&qemu_display_sdl2);
+}
+
+type_init(register_sdl1);
diff --git a/vl.c b/vl.c
index 57e775f8cd..474d982da9 100644
--- a/vl.c
+++ b/vl.c
@@ -2141,7 +2141,6 @@ static void parse_display(const char *p)
     const char *opts;
 
     if (strstart(p, "sdl", &opts)) {
-#ifdef CONFIG_SDL
         dpy.type = DISPLAY_TYPE_SDL;
         while (*opts) {
             const char *nextopt;
@@ -2182,10 +2181,6 @@ static void parse_display(const char *p)
             }
             opts = nextopt;
         }
-#else
-        error_report("SDL support is disabled");
-        exit(1);
-#endif
     } else if (strstart(p, "vnc", &opts)) {
         if (*opts == '=') {
             vnc_parse(opts + 1, &error_fatal);
@@ -4444,12 +4439,7 @@ int main(int argc, char **argv, char **envp)
                      "ignoring option");
     }
 
-    if (dpy.type == DISPLAY_TYPE_SDL) {
-        sdl_display_early_init(&dpy);
-    } else {
-        qemu_display_early_init(&dpy);
-    }
-
+    qemu_display_early_init(&dpy);
     qemu_console_early_init();
 
     if (dpy.has_gl && dpy.gl && display_opengl == 0) {
@@ -4783,9 +4773,6 @@ int main(int argc, char **argv, char **envp)
     case DISPLAY_TYPE_CURSES:
         curses_display_init(ds, &dpy);
         break;
-    case DISPLAY_TYPE_SDL:
-        sdl_display_init(ds, &dpy);
-        break;
     case DISPLAY_TYPE_COCOA:
         cocoa_display_init(ds, &dpy);
         break;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 16/24] cocoa: hook up to display registry
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (14 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 15/24] sdl: hook up to display registry Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 17/24] curses: " Gerd Hoffmann
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Peter Maydell, Paolo Bonzini

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 12 ------------
 vl.c                 |  3 ---
 ui/cocoa.m           | 14 +++++++++++++-
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 63534ac20a..81db3a0f67 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -445,18 +445,6 @@ void qemu_display_register(QemuDisplay *ui);
 void qemu_display_early_init(DisplayOptions *opts);
 void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
 
-/* cocoa.m */
-#ifdef CONFIG_COCOA
-void cocoa_display_init(DisplayState *ds, DisplayOptions *opts);
-#else
-static inline void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_COCOA is disabled */
-    error_report("Cocoa support is disabled");
-    abort();
-}
-#endif
-
 /* vnc.c */
 void vnc_display_init(const char *id);
 void vnc_display_open(const char *id, Error **errp);
diff --git a/vl.c b/vl.c
index 474d982da9..d57671b755 100644
--- a/vl.c
+++ b/vl.c
@@ -4773,9 +4773,6 @@ int main(int argc, char **argv, char **envp)
     case DISPLAY_TYPE_CURSES:
         curses_display_init(ds, &dpy);
         break;
-    case DISPLAY_TYPE_COCOA:
-        cocoa_display_init(ds, &dpy);
-        break;
     default:
         qemu_display_init(ds, &dpy);
         break;
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9560c07105..16d760eae5 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1671,7 +1671,7 @@ static void addRemovableDevicesMenuItems(void)
     qapi_free_BlockInfoList(pointerToFree);
 }
 
-void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
+static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
 
@@ -1701,3 +1701,15 @@ void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
      */
     addRemovableDevicesMenuItems();
 }
+
+static QemuDisplay qemu_display_cocoa = {
+    .type       = DISPLAY_TYPE_COCOA,
+    .init       = cocoa_display_init,
+};
+
+static void register_cocoa(void)
+{
+    qemu_display_register(&qemu_display_cocoa);
+}
+
+type_init(register_cocoa);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 17/24] curses: hook up to display registry
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (15 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 16/24] cocoa: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 18/24] egl-headless: " Gerd Hoffmann
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 12 ------------
 ui/curses.c          | 14 +++++++++++++-
 vl.c                 | 17 ++---------------
 3 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 81db3a0f67..c93a331d35 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -475,18 +475,6 @@ static inline int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
 }
 #endif
 
-/* curses.c */
-#ifdef CONFIG_CURSES
-void curses_display_init(DisplayState *ds, DisplayOptions *opts);
-#else
-static inline void curses_display_init(DisplayState *ds, DisplayOptions *opts)
-{
-    /* This must never be called if CONFIG_CURSES is disabled */
-    error_report("curses support is disabled");
-    abort();
-}
-#endif
-
 /* input.c */
 int index_from_key(const char *key, size_t key_length);
 
diff --git a/ui/curses.c b/ui/curses.c
index 479b77bd03..d55e6d74a1 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, DisplayOptions *opts)
+static void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 #ifndef _WIN32
     if (!isatty(1)) {
@@ -455,3 +455,15 @@ void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 
     invalidate = 1;
 }
+
+static QemuDisplay qemu_display_curses = {
+    .type       = DISPLAY_TYPE_CURSES,
+    .init       = curses_display_init,
+};
+
+static void register_curses(void)
+{
+    qemu_display_register(&qemu_display_curses);
+}
+
+type_init(register_curses);
diff --git a/vl.c b/vl.c
index d57671b755..07f049044b 100644
--- a/vl.c
+++ b/vl.c
@@ -2197,12 +2197,7 @@ static void parse_display(const char *p)
         exit(1);
 #endif
     } else if (strstart(p, "curses", &opts)) {
-#ifdef CONFIG_CURSES
         dpy.type = DISPLAY_TYPE_CURSES;
-#else
-        error_report("curses support is disabled");
-        exit(1);
-#endif
     } else if (strstart(p, "gtk", &opts)) {
         dpy.type = DISPLAY_TYPE_GTK;
         while (*opts) {
@@ -4766,17 +4761,9 @@ int main(int argc, char **argv, char **envp)
         qemu_register_reset(restore_boot_order, g_strdup(boot_order));
     }
 
-    ds = init_displaystate();
-
     /* init local displays */
-    switch (dpy.type) {
-    case DISPLAY_TYPE_CURSES:
-        curses_display_init(ds, &dpy);
-        break;
-    default:
-        qemu_display_init(ds, &dpy);
-        break;
-    }
+    ds = init_displaystate();
+    qemu_display_init(ds, &dpy);
 
     /* must be after terminal init, SDL library changes signal handlers */
     os_setup_signal_handling();
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 18/24] egl-headless: hook up to display registry
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (16 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 17/24] curses: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default Gerd Hoffmann
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  3 ---
 ui/egl-headless.c    | 20 +++++++++++++++++++-
 vl.c                 | 12 ------------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index c93a331d35..6c89599355 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -478,7 +478,4 @@ static inline int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
 /* input.c */
 int index_from_key(const char *key, size_t key_length);
 
-/* egl-headless.c */
-void egl_headless_init(DisplayOptions *opts);
-
 #endif
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 38b3766548..655ef4eecb 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -154,7 +154,12 @@ static const DisplayChangeListenerOps egl_ops = {
     .dpy_gl_update           = egl_scanout_flush,
 };
 
-void egl_headless_init(DisplayOptions *opts)
+static void early_egl_headless_init(DisplayOptions *opts)
+{
+    display_opengl = 1;
+}
+
+static void egl_headless_init(DisplayState *ds, DisplayOptions *opts)
 {
     QemuConsole *con;
     egl_dpy *edpy;
@@ -178,3 +183,16 @@ void egl_headless_init(DisplayOptions *opts)
         register_displaychangelistener(&edpy->dcl);
     }
 }
+
+static QemuDisplay qemu_display_egl = {
+    .type       = DISPLAY_TYPE_EGL_HEADLESS,
+    .early_init = early_egl_headless_init,
+    .init       = egl_headless_init,
+};
+
+static void register_egl(void)
+{
+    qemu_display_register(&qemu_display_egl);
+}
+
+type_init(register_egl);
diff --git a/vl.c b/vl.c
index 07f049044b..df0c10398d 100644
--- a/vl.c
+++ b/vl.c
@@ -2189,13 +2189,7 @@ static void parse_display(const char *p)
             exit(1);
         }
     } else if (strstart(p, "egl-headless", &opts)) {
-#ifdef CONFIG_OPENGL_DMABUF
-        display_opengl = 1;
         dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
-#else
-        fprintf(stderr, "egl support is disabled\n");
-        exit(1);
-#endif
     } else if (strstart(p, "curses", &opts)) {
         dpy.type = DISPLAY_TYPE_CURSES;
     } else if (strstart(p, "gtk", &opts)) {
@@ -4778,12 +4772,6 @@ int main(int argc, char **argv, char **envp)
         qemu_spice_display_init();
     }
 
-#ifdef CONFIG_OPENGL_DMABUF
-    if (dpy.type == DISPLAY_TYPE_EGL_HEADLESS) {
-        egl_headless_init(&dpy);
-    }
-#endif
-
     if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
         exit(1);
     }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (17 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 18/24] egl-headless: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 12:55   ` Darren Kenny
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 20/24] console: add ui module loading support Gerd Hoffmann
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann, Paolo Bonzini

Using the new registry instead of #ifdefs in vl.c.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  1 +
 ui/console.c         | 19 +++++++++++++++++++
 vl.c                 | 15 +++++----------
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 6c89599355..7c9e40cc9a 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -442,6 +442,7 @@ struct QemuDisplay {
 };
 
 void qemu_display_register(QemuDisplay *ui);
+bool qemu_display_find_default(DisplayOptions *opts);
 void qemu_display_early_init(DisplayOptions *opts);
 void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
 
diff --git a/ui/console.c b/ui/console.c
index aa8afbfe26..4c9ac8b21a 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2176,6 +2176,25 @@ void qemu_display_register(QemuDisplay *ui)
     dpys[ui->type] = ui;
 }
 
+bool qemu_display_find_default(DisplayOptions *opts)
+{
+    static DisplayType prio[] = {
+        DISPLAY_TYPE_GTK,
+        DISPLAY_TYPE_SDL,
+        DISPLAY_TYPE_COCOA
+    };
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(prio); i++) {
+        if (dpys[prio[i]] == NULL) {
+            continue;
+        }
+        opts->type = prio[i];
+        return true;
+    }
+    return false;
+}
+
 void qemu_display_early_init(DisplayOptions *opts)
 {
     assert(opts->type < DISPLAY_TYPE__MAX);
diff --git a/vl.c b/vl.c
index df0c10398d..f861562bb2 100644
--- a/vl.c
+++ b/vl.c
@@ -4406,17 +4406,12 @@ int main(int argc, char **argv, char **envp)
     }
 #endif
     if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
-#if defined(CONFIG_GTK)
-        dpy.type = DISPLAY_TYPE_GTK;
-#elif defined(CONFIG_SDL)
-        dpy.type = DISPLAY_TYPE_SDL;
-#elif defined(CONFIG_COCOA)
-        dpy.type = DISPLAY_TYPE_COCOA;
-#elif defined(CONFIG_VNC)
-        vnc_parse("localhost:0,to=99,id=default", &error_abort);
-#else
-        dpy.type = DISPLAY_TYPE_NONE;
+        if (!qemu_display_find_default(&dpy)) {
+            dpy.type = DISPLAY_TYPE_NONE;
+#if defined(CONFIG_VNC)
+            vnc_parse("localhost:0,to=99,id=default", &error_abort);
 #endif
+        }
     }
     if (dpy.type == DISPLAY_TYPE_DEFAULT) {
         dpy.type = DISPLAY_TYPE_NONE;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 20/24] console: add ui module loading support
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (18 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 21/24] sdl: build as module Gerd Hoffmann
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/qemu/module.h | 1 +
 ui/console.c          | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/qemu/module.h b/include/qemu/module.h
index 56dd218205..9fea75aaeb 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -53,6 +53,7 @@ typedef enum {
 #define trace_init(function) module_init(function, MODULE_INIT_TRACE)
 
 #define block_module_load_one(lib) module_load_one("block-", lib)
+#define ui_module_load_one(lib) module_load_one("ui-", lib)
 
 void register_module_init(void (*fn)(void), module_init_type type);
 void register_dso_module_init(void (*fn)(void), module_init_type type);
diff --git a/ui/console.c b/ui/console.c
index 4c9ac8b21a..9937da06a4 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2187,6 +2187,9 @@ bool qemu_display_find_default(DisplayOptions *opts)
 
     for (i = 0; i < ARRAY_SIZE(prio); i++) {
         if (dpys[prio[i]] == NULL) {
+            ui_module_load_one(DisplayType_lookup.array[prio[i]]);
+        }
+        if (dpys[prio[i]] == NULL) {
             continue;
         }
         opts->type = prio[i];
@@ -2202,6 +2205,9 @@ void qemu_display_early_init(DisplayOptions *opts)
         return;
     }
     if (dpys[opts->type] == NULL) {
+        ui_module_load_one(DisplayType_lookup.array[opts->type]);
+    }
+    if (dpys[opts->type] == NULL) {
         error_report("Display '%s' is not available.",
                      DisplayType_lookup.array[opts->type]);
         exit(1);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 21/24] sdl: build as module
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (19 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 20/24] console: add ui module loading support Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 22/24] gtk: " Gerd Hoffmann
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure        | 2 +-
 Makefile.objs    | 1 +
 ui/Makefile.objs | 6 +++---
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 0e856bbc04..7d1e9b187d 100755
--- a/configure
+++ b/configure
@@ -5754,7 +5754,7 @@ if test "$modules" = "yes"; then
   echo "CONFIG_MODULES=y" >> $config_host_mak
 fi
 if test "$sdl" = "yes" ; then
-  echo "CONFIG_SDL=y" >> $config_host_mak
+  echo "CONFIG_SDL=m" >> $config_host_mak
   echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
   echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
diff --git a/Makefile.objs b/Makefile.objs
index 285c6f3c15..a567df479c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -56,6 +56,7 @@ common-obj-y += hw/
 common-obj-y += replay/
 
 common-obj-y += ui/
+common-obj-m += ui/
 common-obj-y += bt-host.o bt-vhci.o
 bt-host.o-cflags := $(BLUEZ_CFLAGS)
 
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index ec8533d6d9..6c13d7e5ed 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -8,15 +8,15 @@ vnc-obj-y += vnc-ws.o
 vnc-obj-y += vnc-jobs.o
 
 common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o
-common-obj-y += input.o input-keymap.o input-legacy.o
+common-obj-y += input.o input-keymap.o input-legacy.o x_keymap.o
 common-obj-$(CONFIG_LINUX) += input-linux.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
-common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
-common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o
+common-obj-$(CONFIG_GTK) += gtk.o
 
+common-obj-$(CONFIG_SDL) += sdl.mo
 ifeq ($(CONFIG_SDLABI),1.2)
 sdl.mo-objs := sdl.o sdl_zoom.o
 endif
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 22/24] gtk: build as module
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (20 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 21/24] sdl: build as module Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 23/24] curses: " Gerd Hoffmann
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure        |  5 ++---
 ui/Makefile.objs | 16 ++++++++--------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 7d1e9b187d..91c9323a50 100755
--- a/configure
+++ b/configure
@@ -2470,7 +2470,6 @@ if test "$gtk" != "no"; then
             gtk_cflags="$gtk_cflags $x11_cflags"
             gtk_libs="$gtk_libs $x11_libs"
         fi
-        libs_softmmu="$gtk_libs $libs_softmmu"
         gtk="yes"
     elif test "$gtk" = "yes"; then
         feature_not_found "gtk" "Install gtk3-devel"
@@ -2720,7 +2719,6 @@ if test "$vte" != "no"; then
         vte_cflags=$($pkg_config --cflags $vtepackage)
         vte_libs=$($pkg_config --libs $vtepackage)
         vteversion=$($pkg_config --modversion $vtepackage)
-        libs_softmmu="$vte_libs $libs_softmmu"
         vte="yes"
     elif test "$vte" = "yes"; then
         if test "$gtkabi" = "3.0"; then
@@ -5860,7 +5858,7 @@ if test "$glib_subprocess" = "yes" ; then
   echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
 fi
 if test "$gtk" = "yes" ; then
-  echo "CONFIG_GTK=y" >> $config_host_mak
+  echo "CONFIG_GTK=m" >> $config_host_mak
   echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
   echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
   echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
@@ -5911,6 +5909,7 @@ fi
 if test "$vte" = "yes" ; then
   echo "CONFIG_VTE=y" >> $config_host_mak
   echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
+  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
 fi
 if test "$virglrenderer" = "yes" ; then
   echo "CONFIG_VIRGL=y" >> $config_host_mak
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 6c13d7e5ed..be3dc44cc6 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -14,7 +14,6 @@ common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
-common-obj-$(CONFIG_GTK) += gtk.o
 
 common-obj-$(CONFIG_SDL) += sdl.mo
 ifeq ($(CONFIG_SDLABI),1.2)
@@ -29,6 +28,11 @@ endif
 sdl.mo-cflags := $(SDL_CFLAGS)
 sdl.mo-libs := $(SDL_LIBS)
 
+common-obj-$(CONFIG_GTK) += gtk.mo
+gtk.mo-objs := gtk.o
+gtk.mo-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
+gtk.mo-libs := $(GTK_LIBS) $(VTE_LIBS)
+
 ifeq ($(CONFIG_OPENGL),y)
 common-obj-y += shader.o
 common-obj-y += console-gl.o
@@ -36,17 +40,13 @@ common-obj-y += egl-helpers.o
 common-obj-y += egl-context.o
 common-obj-$(CONFIG_OPENGL_DMABUF) += egl-headless.o
 ifeq ($(CONFIG_GTK_GL),y)
-common-obj-$(CONFIG_GTK) += gtk-gl-area.o
+gtk.mo-objs += gtk-gl-area.o
 else
-common-obj-$(CONFIG_GTK) += gtk-egl.o
+gtk.mo-objs += gtk-egl.o
+gtk.mo-libs += $(OPENGL_LIBS)
 endif
 endif
 
-gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
-gtk-egl.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
-gtk-gl-area.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
-
-gtk-egl.o-libs += $(OPENGL_LIBS)
 shader.o-libs += $(OPENGL_LIBS)
 console-gl.o-libs += $(OPENGL_LIBS)
 egl-helpers.o-libs += $(OPENGL_LIBS)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 23/24] curses: build as module
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (21 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 22/24] gtk: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 24/24] build: opengl should not need X11 Gerd Hoffmann
  2017-11-17 10:58 ` [Qemu-devel] [PATCH 00/24] RfC: rework display initialization no-reply
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure        | 6 +++---
 ui/Makefile.objs | 6 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 91c9323a50..67a8c2e83a 100755
--- a/configure
+++ b/configure
@@ -3190,8 +3190,6 @@ EOF
       unset IFS
       if compile_prog "$curses_inc" "$curses_lib" ; then
         curses_found=yes
-        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
-        libs_softmmu="$curses_lib $libs_softmmu"
         break
       fi
     done
@@ -5761,7 +5759,9 @@ if test "$cocoa" = "yes" ; then
   echo "CONFIG_COCOA=y" >> $config_host_mak
 fi
 if test "$curses" = "yes" ; then
-  echo "CONFIG_CURSES=y" >> $config_host_mak
+  echo "CONFIG_CURSES=m" >> $config_host_mak
+  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
+  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
 fi
 if test "$pipe2" = "yes" ; then
   echo "CONFIG_PIPE2=y" >> $config_host_mak
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index be3dc44cc6..42ef071d17 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -12,7 +12,6 @@ common-obj-y += input.o input-keymap.o input-legacy.o x_keymap.o
 common-obj-$(CONFIG_LINUX) += input-linux.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
-common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
 
 common-obj-$(CONFIG_SDL) += sdl.mo
@@ -33,6 +32,11 @@ gtk.mo-objs := gtk.o
 gtk.mo-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
 gtk.mo-libs := $(GTK_LIBS) $(VTE_LIBS)
 
+common-obj-$(CONFIG_CURSES) += curses.mo
+curses.mo-objs := curses.o
+curses.mo-cflags := $(CURSES_CFLAGS)
+curses.mo-libs := $(CURSES_LIBS)
+
 ifeq ($(CONFIG_OPENGL),y)
 common-obj-y += shader.o
 common-obj-y += console-gl.o
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH 24/24] build: opengl should not need X11
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (22 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 23/24] curses: " Gerd Hoffmann
@ 2017-11-17 10:30 ` Gerd Hoffmann
  2017-11-17 10:58 ` [Qemu-devel] [PATCH 00/24] RfC: rework display initialization no-reply
  24 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 10:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 67a8c2e83a..e344c0d08e 100755
--- a/configure
+++ b/configure
@@ -3685,8 +3685,8 @@ libs_softmmu="$libs_softmmu $fdt_libs"
 if test "$opengl" != "no" ; then
   opengl_pkgs="epoxy libdrm gbm"
   if $pkg_config $opengl_pkgs x11; then
-    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
-    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
+    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
+    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
     opengl=yes
     if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
         gtk_gl="yes"
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 00/24] RfC: rework display initialization
  2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
                   ` (23 preceding siblings ...)
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 24/24] build: opengl should not need X11 Gerd Hoffmann
@ 2017-11-17 10:58 ` no-reply
  24 siblings, 0 replies; 37+ messages in thread
From: no-reply @ 2017-11-17 10:58 UTC (permalink / raw)
  To: kraxel; +Cc: famz, qemu-devel, armbru

Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH 00/24] RfC: rework display initialization
Type: series
Message-id: 20171117103046.15943-1-kraxel@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20171117103046.15943-1-kraxel@redhat.com -> patchew/20171117103046.15943-1-kraxel@redhat.com
Switched to a new branch 'test'
8ad8a3a49f build: opengl should not need X11
6f326898be curses: build as module
f28cbe0c71 gtk: build as module
b40a8ab831 sdl: build as module
b2ff35530c console: add ui module loading support
608541ecf1 console: add and use qemu_display_find_default
c9ea5c8f98 egl-headless: hook up to display registry
e4027611d6 curses: hook up to display registry
e80738a2e4 cocoa: hook up to display registry
d4e140bc0d sdl: hook up to display registry
527146bbaf console: add qemu display registry, add gtk
33878ca938 vl: drop request_opengl variable
d788c7b02b vl: drop display_type variable
79864bf5a8 vl: drop full_screen variable
86920e800f cocoa: use DisplayOptions
c452a6e243 curses: use DisplayOptions
2c82950f1c egl-headless: use DisplayOptions
b144a95d3d vl: drop no_quit variable
640b59b752 sdl: use DisplayOptions
2a3081d35b gtk: add and use DisplayOptions + DisplayGTK
756824d0cf vl: rename DisplayType to LegacyDisplayType
a7a6f0c0b2 sdl: use ctrl-alt-g as grab hotkey
e4dde3438f sdl: remove -alt-grab and -ctrl-grab support
1c32dd624f sdl: remove -no-frame support

=== OUTPUT BEGIN ===
Checking PATCH 1/24: sdl: remove -no-frame support...
Checking PATCH 2/24: sdl: remove -alt-grab and -ctrl-grab support...
ERROR: space prohibited after that '&' (ctx:WxW)
#48: FILE: ui/sdl.c:554:
+    mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
                                    ^

ERROR: space prohibited after that '&' (ctx:WxW)
#96: FILE: ui/sdl2.c:333:
+    mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
                                    ^

total: 2 errors, 0 warnings, 135 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 3/24: sdl: use ctrl-alt-g as grab hotkey...
Checking PATCH 4/24: vl: rename DisplayType to LegacyDisplayType...
Checking PATCH 5/24: gtk: add and use DisplayOptions + DisplayGTK...
Checking PATCH 6/24: sdl: use DisplayOptions...
Checking PATCH 7/24: vl: drop no_quit variable...
Checking PATCH 8/24: egl-headless: use DisplayOptions...
Checking PATCH 9/24: curses: use DisplayOptions...
Checking PATCH 10/24: cocoa: use DisplayOptions...
Checking PATCH 11/24: vl: drop full_screen variable...
Checking PATCH 12/24: vl: drop display_type variable...
Checking PATCH 13/24: vl: drop request_opengl variable...
Checking PATCH 14/24: console: add qemu display registry, add gtk...
Checking PATCH 15/24: sdl: hook up to display registry...
Checking PATCH 16/24: cocoa: hook up to display registry...
Checking PATCH 17/24: curses: hook up to display registry...
Checking PATCH 18/24: egl-headless: hook up to display registry...
Checking PATCH 19/24: console: add and use qemu_display_find_default...
Checking PATCH 20/24: console: add ui module loading support...
Checking PATCH 21/24: sdl: build as module...
Checking PATCH 22/24: gtk: build as module...
Checking PATCH 23/24: curses: build as module...
Checking PATCH 24/24: build: opengl should not need X11...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default Gerd Hoffmann
@ 2017-11-17 12:55   ` Darren Kenny
  2017-11-17 13:24     ` Gerd Hoffmann
  0 siblings, 1 reply; 37+ messages in thread
From: Darren Kenny @ 2017-11-17 12:55 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 11:30:41AM +0100, Gerd Hoffmann wrote:
>Using the new registry instead of #ifdefs in vl.c.
>
>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>---
> include/ui/console.h |  1 +
> ui/console.c         | 19 +++++++++++++++++++
> vl.c                 | 15 +++++----------
> 3 files changed, 25 insertions(+), 10 deletions(-)
>
>diff --git a/include/ui/console.h b/include/ui/console.h
>index 6c89599355..7c9e40cc9a 100644
>--- a/include/ui/console.h
>+++ b/include/ui/console.h
>@@ -442,6 +442,7 @@ struct QemuDisplay {
> };
>
> void qemu_display_register(QemuDisplay *ui);
>+bool qemu_display_find_default(DisplayOptions *opts);
> void qemu_display_early_init(DisplayOptions *opts);
> void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
>
>diff --git a/ui/console.c b/ui/console.c
>index aa8afbfe26..4c9ac8b21a 100644
>--- a/ui/console.c
>+++ b/ui/console.c
>@@ -2176,6 +2176,25 @@ void qemu_display_register(QemuDisplay *ui)
>     dpys[ui->type] = ui;
> }
>
>+bool qemu_display_find_default(DisplayOptions *opts)
>+{
>+    static DisplayType prio[] = {
>+        DISPLAY_TYPE_GTK,
>+        DISPLAY_TYPE_SDL,
>+        DISPLAY_TYPE_COCOA
>+    };
>+    int i;
>+
>+    for (i = 0; i < ARRAY_SIZE(prio); i++) {
>+        if (dpys[prio[i]] == NULL) {
>+            continue;
>+        }
>+        opts->type = prio[i];
>+        return true;
>+    }
>+    return false;
>+}
>+
> void qemu_display_early_init(DisplayOptions *opts)
> {
>     assert(opts->type < DISPLAY_TYPE__MAX);
>diff --git a/vl.c b/vl.c
>index df0c10398d..f861562bb2 100644
>--- a/vl.c
>+++ b/vl.c
>@@ -4406,17 +4406,12 @@ int main(int argc, char **argv, char **envp)
>     }
> #endif
>     if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
>-#if defined(CONFIG_GTK)
>-        dpy.type = DISPLAY_TYPE_GTK;
>-#elif defined(CONFIG_SDL)
>-        dpy.type = DISPLAY_TYPE_SDL;
>-#elif defined(CONFIG_COCOA)
>-        dpy.type = DISPLAY_TYPE_COCOA;
>-#elif defined(CONFIG_VNC)
>-        vnc_parse("localhost:0,to=99,id=default", &error_abort);
>-#else
>-        dpy.type = DISPLAY_TYPE_NONE;
>+        if (!qemu_display_find_default(&dpy)) {
>+            dpy.type = DISPLAY_TYPE_NONE;
>+#if defined(CONFIG_VNC)
>+            vnc_parse("localhost:0,to=99,id=default", &error_abort);
> #endif

Mostly some questions on this:

- I'm curious, why is VNC not just one of the ones searched for in
  qemu_display_find_default()? 

- What if there is another display type added? Would it be added to
  qemu_display_find_default() or in this if statement?

- Is there a reason that VNC doesn't follow the same registration
  mechanism you're proposing here (as in you've no changes to that
  module in this patch set).

- In the spirit of encapsulation, would it not make sense for the
  vnc_parse() to be in the VNC code itself as a fall back if no
  specific options are given to the -vnc option?

Thanks,

Darren.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 12:55   ` Darren Kenny
@ 2017-11-17 13:24     ` Gerd Hoffmann
  2017-11-17 14:16       ` Darren Kenny
  0 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 13:24 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Markus Armbruster

  Hi,

> > -        dpy.type = DISPLAY_TYPE_NONE;
> > +        if (!qemu_display_find_default(&dpy)) {
> > +            dpy.type = DISPLAY_TYPE_NONE;
> > +#if defined(CONFIG_VNC)
> > +            vnc_parse("localhost:0,to=99,id=default", &error_abort);
> > #endif
> 
> Mostly some questions on this:
> 
> - I'm curious, why is VNC not just one of the ones searched for in
>  qemu_display_find_default()?

vnc is a bit different.  It's a remote display protocol, not a (local)
user interface.  There is no DISPLAY_TYPE_VNC for that reason (without
this series too).  And IMO it was a bad idea to add -display vnc=$config
(same as -vnc $config) in the first place.

There can be only one user interface instance, i.e. you can't have gtk
and sdl at the same time.  With vnc (and spice) that works though, i.e.
you can start qemu with some local user interface and enable vnc or
spice (even both) remote access at the same time.

> - What if there is another display type added? Would it be added to
>  qemu_display_find_default() or in this if statement?

qemu_display_find_default() most likely,
but depends on what exactly it is.

> - Is there a reason that VNC doesn't follow the same registration
>  mechanism you're proposing here (as in you've no changes to that
>  module in this patch set).

See above ;)

> - In the spirit of encapsulation, would it not make sense for the
>  vnc_parse() to be in the VNC code itself as a fall back if no
>  specific options are given to the -vnc option?

It's not that simple.  The default vnc server is started only in case
no (graphical) local user interface is available, so it's not something
the vnc code can figure purely on its own.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 13:24     ` Gerd Hoffmann
@ 2017-11-17 14:16       ` Darren Kenny
  2017-11-17 15:03         ` Gerd Hoffmann
  0 siblings, 1 reply; 37+ messages in thread
From: Darren Kenny @ 2017-11-17 14:16 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

Hi Gerd,

Thanks for clarifying things for me.

On Fri, Nov 17, 2017 at 02:24:54PM +0100, Gerd Hoffmann wrote:
>  Hi,
>
>> > -        dpy.type = DISPLAY_TYPE_NONE;
>> > +        if (!qemu_display_find_default(&dpy)) {
>> > +            dpy.type = DISPLAY_TYPE_NONE;
>> > +#if defined(CONFIG_VNC)
>> > +            vnc_parse("localhost:0,to=99,id=default", &error_abort);
>> > #endif
>>
>> Mostly some questions on this:
>>
>> - I'm curious, why is VNC not just one of the ones searched for in
>>  qemu_display_find_default()?
>
>vnc is a bit different.  It's a remote display protocol, not a (local)
>user interface.  There is no DISPLAY_TYPE_VNC for that reason (without
>this series too).  And IMO it was a bad idea to add -display vnc=$config
>(same as -vnc $config) in the first place.
>
>There can be only one user interface instance, i.e. you can't have gtk
>and sdl at the same time.  With vnc (and spice) that works though, i.e.
>you can start qemu with some local user interface and enable vnc or
>spice (even both) remote access at the same time.

Ah, wasn't sure about being able to do both a local UI and VNC -
I've only ever used one or the other :)

OK, so the odd thing then is the check for !remote_display earlier
on in the function (missing from the quote above) which seems to end
up initializing VNC (albeit with localhost) when CONFIG_VNC is
defined, but no other local display type has been selected.

But, I suppose it's not strictly incorrect with the 'localhost' :)

>
>> - What if there is another display type added? Would it be added to
>>  qemu_display_find_default() or in this if statement?
>
>qemu_display_find_default() most likely,
>but depends on what exactly it is.

OK, so neither SPICE or VNC really fit into this patchset because
they are seen as additional to the display type, not the actual
display type - SPICE is even more special too given the dependency
on a guest VM driver to really function correctly.

I wonder should there be a, similar, qemu_display_find_remote_default()
which would be used when no local display is defined. And that would
use a similar mechanism to permit selecting VNC or SPICE via
registration mechanisms over rather than the #ifdef style for remote
displays that will remain ever after this patchset (certainly could
be another patchset beyond this one).

Maybe it's not worth it, given that VNC is really he only remote UI
module you can use.

>
>> - Is there a reason that VNC doesn't follow the same registration
>>  mechanism you're proposing here (as in you've no changes to that
>>  module in this patch set).
>
>See above ;)
>
>> - In the spirit of encapsulation, would it not make sense for the
>>  vnc_parse() to be in the VNC code itself as a fall back if no
>>  specific options are given to the -vnc option?
>
>It's not that simple.  The default vnc server is started only in case
>no (graphical) local user interface is available, so it's not something
>the vnc code can figure purely on its own.

Fair enough.

Just a thought, but maybe the specific string could be defined in
vnc.h instead of a string here at least? (e.g.
VNC_DEFAULT_LOCALHOST_OPTIONS, or similar).

Thanks,

Darren.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support Gerd Hoffmann
@ 2017-11-17 14:21   ` Daniel P. Berrange
  2017-11-17 14:49     ` Gerd Hoffmann
  0 siblings, 1 reply; 37+ messages in thread
From: Daniel P. Berrange @ 2017-11-17 14:21 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 11:30:23AM +0100, Gerd Hoffmann wrote:
> SDL2 doesn't support this any more, the SDL_NOFRAME window flag is gone.
> Drop the code, print a notice when the option is still used.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/ui/console.h |  5 ++---
>  ui/sdl.c             |  8 +-------
>  ui/sdl2.c            |  7 +------
>  vl.c                 | 15 ++++-----------
>  4 files changed, 8 insertions(+), 27 deletions(-)

This needs to go through the deprecation process before we can
drop it. There's still time to get it into 2.11 deprecated list
which would cut the time needed to wait for real deletion.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support
  2017-11-17 10:30 ` [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support Gerd Hoffmann
@ 2017-11-17 14:22   ` Daniel P. Berrange
  2017-11-17 14:51     ` Gerd Hoffmann
  0 siblings, 1 reply; 37+ messages in thread
From: Daniel P. Berrange @ 2017-11-17 14:22 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 11:30:24AM +0100, Gerd Hoffmann wrote:
> With absolute pointer devices such as usb-tablet being widely used
> mouse grabs (for relative pointing devices) should be rarely needed
> these days.  So the benefit of the options to configure the hotkey
> modifiers for grab (and other actions) seems questionable.  Which
> is expecially true for the -ctrl-grab which isn't handled in the
> handle_keyup() code.
> 
> Drop the code, print a notice when the option is still used.

These need to go through the proper deprecation process too.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support
  2017-11-17 14:21   ` Daniel P. Berrange
@ 2017-11-17 14:49     ` Gerd Hoffmann
  2017-11-17 14:59       ` Daniel P. Berrange
  0 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 14:49 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 02:21:30PM +0000, Daniel P. Berrange wrote:
> On Fri, Nov 17, 2017 at 11:30:23AM +0100, Gerd Hoffmann wrote:
> > SDL2 doesn't support this any more, the SDL_NOFRAME window flag is gone.
> > Drop the code, print a notice when the option is still used.
> > 
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  include/ui/console.h |  5 ++---
> >  ui/sdl.c             |  8 +-------
> >  ui/sdl2.c            |  7 +------
> >  vl.c                 | 15 ++++-----------
> >  4 files changed, 8 insertions(+), 27 deletions(-)
> 
> This needs to go through the deprecation process before we can
> drop it. There's still time to get it into 2.11 deprecated list
> which would cut the time needed to wait for real deletion.

I fail to see the point.  SDL2 simply doesn't support it, so it never
worked with SDL2.  We switched to SDL2 as default recently.  So it seems
fair to me to just say so instead of silently ignoring the option ...

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support
  2017-11-17 14:22   ` Daniel P. Berrange
@ 2017-11-17 14:51     ` Gerd Hoffmann
  0 siblings, 0 replies; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 14:51 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 02:22:22PM +0000, Daniel P. Berrange wrote:
> On Fri, Nov 17, 2017 at 11:30:24AM +0100, Gerd Hoffmann wrote:
> > With absolute pointer devices such as usb-tablet being widely used
> > mouse grabs (for relative pointing devices) should be rarely needed
> > these days.  So the benefit of the options to configure the hotkey
> > modifiers for grab (and other actions) seems questionable.  Which
> > is expecially true for the -ctrl-grab which isn't handled in the
> > handle_keyup() code.
> > 
> > Drop the code, print a notice when the option is still used.
> 
> These need to go through the proper deprecation process too.

Ok, will do.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support
  2017-11-17 14:49     ` Gerd Hoffmann
@ 2017-11-17 14:59       ` Daniel P. Berrange
  2017-11-17 15:06         ` Daniel P. Berrange
  0 siblings, 1 reply; 37+ messages in thread
From: Daniel P. Berrange @ 2017-11-17 14:59 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 03:49:06PM +0100, Gerd Hoffmann wrote:
> On Fri, Nov 17, 2017 at 02:21:30PM +0000, Daniel P. Berrange wrote:
> > On Fri, Nov 17, 2017 at 11:30:23AM +0100, Gerd Hoffmann wrote:
> > > SDL2 doesn't support this any more, the SDL_NOFRAME window flag is gone.
> > > Drop the code, print a notice when the option is still used.
> > > 
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  include/ui/console.h |  5 ++---
> > >  ui/sdl.c             |  8 +-------
> > >  ui/sdl2.c            |  7 +------
> > >  vl.c                 | 15 ++++-----------
> > >  4 files changed, 8 insertions(+), 27 deletions(-)
> > 
> > This needs to go through the deprecation process before we can
> > drop it. There's still time to get it into 2.11 deprecated list
> > which would cut the time needed to wait for real deletion.
> 
> I fail to see the point.  SDL2 simply doesn't support it, so it never
> worked with SDL2.  We switched to SDL2 as default recently.  So it seems
> fair to me to just say so instead of silently ignoring the option ...

We still support SDL don't we, which does support it, and which this
option was targetted at ?

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 14:16       ` Darren Kenny
@ 2017-11-17 15:03         ` Gerd Hoffmann
  2017-11-17 15:55           ` Darren Kenny
  0 siblings, 1 reply; 37+ messages in thread
From: Gerd Hoffmann @ 2017-11-17 15:03 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Markus Armbruster

  Hi,

> OK, so the odd thing then is the check for !remote_display earlier
> on in the function (missing from the quote above) which seems to end
> up initializing VNC (albeit with localhost) when CONFIG_VNC is
> defined, but no other local display type has been selected.

remote_display is set in case either -vnc or -spice was given on the
command line, and qemu will not start a local user display in that case
(unless you explicitly ask for it via -display).

> OK, so neither SPICE or VNC really fit into this patchset because
> they are seen as additional to the display type, not the actual
> display type - SPICE is even more special too given the dependency
> on a guest VM driver to really function correctly.

Hmm?  spice works just fine with any display.

> I wonder should there be a, similar, qemu_display_find_remote_default()
> which would be used when no local display is defined. And that would
> use a similar mechanism to permit selecting VNC or SPICE via
> registration mechanisms over rather than the #ifdef style for remote
> displays that will remain ever after this patchset (certainly could
> be another patchset beyond this one).

Well, historically qemu tried to do alot of stuff (like picking a
display to use) automatically for the user.  And we did stick to that
for backward compatibility reasons.  But this automagic causes quite
some headache now and then, when changing things and the autmagic logic
gets into the way.  So I don't feel like adding more of this.  Also vnc
is in pretty much any qemu build, because it is enabled by default and
doesn't need any external dependencies, so falling back to spice would
be quite rare ...

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support
  2017-11-17 14:59       ` Daniel P. Berrange
@ 2017-11-17 15:06         ` Daniel P. Berrange
  0 siblings, 0 replies; 37+ messages in thread
From: Daniel P. Berrange @ 2017-11-17 15:06 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Paolo Bonzini, qemu-devel, Markus Armbruster

On Fri, Nov 17, 2017 at 02:59:54PM +0000, Daniel P. Berrange wrote:
> On Fri, Nov 17, 2017 at 03:49:06PM +0100, Gerd Hoffmann wrote:
> > On Fri, Nov 17, 2017 at 02:21:30PM +0000, Daniel P. Berrange wrote:
> > > On Fri, Nov 17, 2017 at 11:30:23AM +0100, Gerd Hoffmann wrote:
> > > > SDL2 doesn't support this any more, the SDL_NOFRAME window flag is gone.
> > > > Drop the code, print a notice when the option is still used.
> > > > 
> > > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > > ---
> > > >  include/ui/console.h |  5 ++---
> > > >  ui/sdl.c             |  8 +-------
> > > >  ui/sdl2.c            |  7 +------
> > > >  vl.c                 | 15 ++++-----------
> > > >  4 files changed, 8 insertions(+), 27 deletions(-)
> > > 
> > > This needs to go through the deprecation process before we can
> > > drop it. There's still time to get it into 2.11 deprecated list
> > > which would cut the time needed to wait for real deletion.
> > 
> > I fail to see the point.  SDL2 simply doesn't support it, so it never
> > worked with SDL2.  We switched to SDL2 as default recently.  So it seems
> > fair to me to just say so instead of silently ignoring the option ...
> 
> We still support SDL don't we, which does support it, and which this
> option was targetted at ?

Perhaps we might even consider deprecating SDL1 as a whole, then the
deprecation of -no-frame is a natural side effect ?

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default
  2017-11-17 15:03         ` Gerd Hoffmann
@ 2017-11-17 15:55           ` Darren Kenny
  0 siblings, 0 replies; 37+ messages in thread
From: Darren Kenny @ 2017-11-17 15:55 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Paolo Bonzini, Markus Armbruster

On Fri, Nov 17, 2017 at 04:03:28PM +0100, Gerd Hoffmann wrote:
>  Hi,
>
>> OK, so the odd thing then is the check for !remote_display earlier
>> on in the function (missing from the quote above) which seems to end
>> up initializing VNC (albeit with localhost) when CONFIG_VNC is
>> defined, but no other local display type has been selected.
>
>remote_display is set in case either -vnc or -spice was given on the
>command line, and qemu will not start a local user display in that case
>(unless you explicitly ask for it via -display).

Makes sense.

>
>> OK, so neither SPICE or VNC really fit into this patchset because
>> they are seen as additional to the display type, not the actual
>> display type - SPICE is even more special too given the dependency
>> on a guest VM driver to really function correctly.
>
>Hmm?  spice works just fine with any display.

Sorry, mixed that up with EGL I think.

>
>> I wonder should there be a, similar, qemu_display_find_remote_default()
>> which would be used when no local display is defined. And that would
>> use a similar mechanism to permit selecting VNC or SPICE via
>> registration mechanisms over rather than the #ifdef style for remote
>> displays that will remain ever after this patchset (certainly could
>> be another patchset beyond this one).
>
>Well, historically qemu tried to do alot of stuff (like picking a
>display to use) automatically for the user.  And we did stick to that
>for backward compatibility reasons.  But this automagic causes quite
>some headache now and then, when changing things and the autmagic logic
>gets into the way.  So I don't feel like adding more of this.  Also vnc

Agree, there are times when automagic works - but unfortunately for
more consistent usage, you are better being explicit.

>is in pretty much any qemu build, because it is enabled by default and
>doesn't need any external dependencies, so falling back to spice would
>be quite rare ...

Understood - definitely VNC is a pretty good fall-back for most
people.

Thanks for outlining your thoughts on this, very helpful in
understanding the UI code and why somethings are how they are.

Thanks,

Darren.

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2017-11-17 15:56 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 10:30 [Qemu-devel] [PATCH 00/24] RfC: rework display initialization Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 01/24] sdl: remove -no-frame support Gerd Hoffmann
2017-11-17 14:21   ` Daniel P. Berrange
2017-11-17 14:49     ` Gerd Hoffmann
2017-11-17 14:59       ` Daniel P. Berrange
2017-11-17 15:06         ` Daniel P. Berrange
2017-11-17 10:30 ` [Qemu-devel] [PATCH 02/24] sdl: remove -alt-grab and -ctrl-grab support Gerd Hoffmann
2017-11-17 14:22   ` Daniel P. Berrange
2017-11-17 14:51     ` Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 03/24] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 04/24] vl: rename DisplayType to LegacyDisplayType Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 05/24] gtk: add and use DisplayOptions + DisplayGTK Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 06/24] sdl: use DisplayOptions Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 07/24] vl: drop no_quit variable Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 08/24] egl-headless: use DisplayOptions Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 09/24] curses: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 10/24] cocoa: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 11/24] vl: drop full_screen variable Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 12/24] vl: drop display_type variable Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 13/24] vl: drop request_opengl variable Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 14/24] console: add qemu display registry, add gtk Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 15/24] sdl: hook up to display registry Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 16/24] cocoa: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 17/24] curses: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 18/24] egl-headless: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 19/24] console: add and use qemu_display_find_default Gerd Hoffmann
2017-11-17 12:55   ` Darren Kenny
2017-11-17 13:24     ` Gerd Hoffmann
2017-11-17 14:16       ` Darren Kenny
2017-11-17 15:03         ` Gerd Hoffmann
2017-11-17 15:55           ` Darren Kenny
2017-11-17 10:30 ` [Qemu-devel] [PATCH 20/24] console: add ui module loading support Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 21/24] sdl: build as module Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 22/24] gtk: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 23/24] curses: " Gerd Hoffmann
2017-11-17 10:30 ` [Qemu-devel] [PATCH 24/24] build: opengl should not need X11 Gerd Hoffmann
2017-11-17 10:58 ` [Qemu-devel] [PATCH 00/24] RfC: rework display initialization no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.