ui: build curses, gtk and sdl as modules.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJanQRYAAoJEEy22O7T6HE46p0P/38Ux4Yd8HZUkdCFuvZ8AH7u
 KUe4/K6LZosvmt2nn8p7eSLLdOMWhkCd7EJfpAyjlkZTjk7VU+SFZNVajpIDy4pO
 mmbKu9F/au2mPzKpvGx+44OGRkY+s6l4WnSIzWHm/3M5MbKksqOqfRmcprIv+kNe
 z14bY8AecV47UC9/5tZu2Kfe5jlBajsVdP0ZMFM0ROgSJd7bUjyoVX7iBCyqHXuF
 BpKMbphTiFV2fQrAaKCooLiCD1JKqow42N8lfGg0ytxfBTBIJVuB7d6l6nVCZVxg
 fxogbE2ciLUx9cPm5X0jgfL+pXgSHiGCurtlWEDRb9DI1TTJlO/ssK/+vLBlKE9L
 qKVzDjaiXtieNZh1SK5zUOC0kDEr6LtfZLJG1o0Lqit0OV6/OS7Qq0T3/dOwmqWe
 3V6HRV8CYJkUKn2QqREpE6jv2pFLuHEuoeyFfTE92pK4yS7pgZOfaKqq4FXy+cu3
 wpWx/qmu1Mz5A8fnzNW+v6juhrgYxychRdkw7MWPjm0MDIaYcHV/Fp/yzlO4L1FE
 hEet5xXT48n/3/Cdj+ivFv6+4XELWMw09UUKEkZCHnSClA8UUZU9hbvsTXRqcAef
 TFO6s6t+c7Ya8tnsw4qNsk4lLVtMGp67L0Rfvh527ShxDHsRA/wl8PSyRUdQ7YlM
 l3MVmAnyZom8AR6EA/BG
 =Zc72
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180305-pull-request' into staging

ui: build curses, gtk and sdl as modules.

# gpg: Signature made Mon 05 Mar 2018 08:48:24 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20180305-pull-request:
  ui/sdl: build as module
  audio: rename CONFIG_* to CONFIG_AUDIO_*
  ui/curses: build as module
  ui/gtk: build as module
  configure: opengl doesn't depend on x11
  configure: add X11 vars to config-host.mak
  console: add ui module loading support
  console: add and use qemu_display_find_default
  egl-headless: switch over to new display registry
  curses: switch over to new display registry
  cocoa: switch over to new display registry
  sdl: switch over to new display registry
  console: add qemu display registry, add gtk

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-03-05 15:16:30 +00:00
commit 4ee02f53be
16 changed files with 220 additions and 176 deletions

View file

@ -11,14 +11,16 @@ 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-$(CONFIG_LINUX) += input-linux.o
common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
common-obj-$(CONFIG_SDL) += sdl.mo
common-obj-$(CONFIG_COCOA) += cocoa.o
common-obj-$(CONFIG_CURSES) += curses.o
common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
common-obj-$(call lnot,$(CONFIG_VNC)) += vnc-stubs.o
common-obj-$(CONFIG_GTK) += gtk.o
common-obj-$(if $(CONFIG_WIN32),n,$(if $(CONFIG_SDL),y,$(CONFIG_GTK))) += x_keymap.o
common-obj-$(CONFIG_X11) += x_keymap.o
x_keymap.o-cflags := $(X11_CFLAGS)
x_keymap.o-libs := $(X11_LIBS)
# ui-sdl module
common-obj-$(CONFIG_SDL) += sdl.mo
ifeq ($(CONFIG_SDLABI),1.2)
sdl.mo-objs := sdl.o sdl_zoom.o
endif
@ -31,6 +33,17 @@ endif
sdl.mo-cflags := $(SDL_CFLAGS)
sdl.mo-libs := $(SDL_LIBS)
# ui-gtk module
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)
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
@ -38,17 +51,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)

View file

@ -1683,7 +1683,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");
@ -1713,3 +1713,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);

View file

@ -2180,6 +2180,65 @@ 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;
}
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) {
ui_module_load_one(DisplayType_lookup.array[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);
if (opts->type == DISPLAY_TYPE_NONE) {
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);
}
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;

View file

@ -435,7 +435,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)) {
@ -456,3 +456,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);

View file

@ -164,7 +164,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;
@ -188,3 +193,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);

View file

@ -2297,7 +2297,7 @@ static void gd_create_menus(GtkDisplayState *s)
static gboolean gtkinit;
void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
{
VirtualConsole *vc;
@ -2407,7 +2407,7 @@ void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
}
}
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
@ -2450,3 +2450,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);

View file

@ -901,17 +901,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;
@ -1023,3 +1013,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);

View file

@ -751,7 +751,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) {
@ -761,7 +761,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;
@ -861,3 +861,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);