mirror of https://github.com/xqemu/xqemu.git
sdl: use DisplayOptions
Switch sdl ui to use qapi DisplayOptions for configuration. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20180202111022.19269-6-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
0c8d706532
commit
fe91f36aa5
|
@ -431,16 +431,16 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
|
||||||
|
|
||||||
/* sdl.c */
|
/* sdl.c */
|
||||||
#ifdef CONFIG_SDL
|
#ifdef CONFIG_SDL
|
||||||
void sdl_display_early_init(int opengl);
|
void sdl_display_early_init(DisplayOptions *opts);
|
||||||
void sdl_display_init(DisplayState *ds, int full_screen);
|
void sdl_display_init(DisplayState *ds, DisplayOptions *opts);
|
||||||
#else
|
#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 */
|
/* This must never be called if CONFIG_SDL is disabled */
|
||||||
error_report("SDL support is disabled");
|
error_report("SDL support is disabled");
|
||||||
abort();
|
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 */
|
/* This must never be called if CONFIG_SDL is disabled */
|
||||||
error_report("SDL support is disabled");
|
error_report("SDL support is disabled");
|
||||||
|
|
|
@ -1020,7 +1020,7 @@
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
{ 'enum' : 'DisplayType',
|
{ 'enum' : 'DisplayType',
|
||||||
'data' : [ 'none', 'gtk' ] }
|
'data' : [ 'none', 'gtk', 'sdl' ] }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @DisplayOptions:
|
# @DisplayOptions:
|
||||||
|
@ -1042,4 +1042,5 @@
|
||||||
'*gl' : 'bool' },
|
'*gl' : 'bool' },
|
||||||
'discriminator' : 'type',
|
'discriminator' : 'type',
|
||||||
'data' : { 'none' : 'DisplayNoOpts',
|
'data' : { 'none' : 'DisplayNoOpts',
|
||||||
'gtk' : 'DisplayGTK' } }
|
'gtk' : 'DisplayGTK',
|
||||||
|
'sdl' : 'DisplayNoOpts' } }
|
||||||
|
|
19
ui/sdl.c
19
ui/sdl.c
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
static DisplayChangeListener *dcl;
|
static DisplayChangeListener *dcl;
|
||||||
static DisplaySurface *surface;
|
static DisplaySurface *surface;
|
||||||
|
static DisplayOptions *opts;
|
||||||
static SDL_Surface *real_screen;
|
static SDL_Surface *real_screen;
|
||||||
static SDL_Surface *guest_screen = NULL;
|
static SDL_Surface *guest_screen = NULL;
|
||||||
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
||||||
|
@ -769,6 +770,7 @@ static void handle_activation(SDL_Event *ev)
|
||||||
static void sdl_refresh(DisplayChangeListener *dcl)
|
static void sdl_refresh(DisplayChangeListener *dcl)
|
||||||
{
|
{
|
||||||
SDL_Event ev1, *ev = &ev1;
|
SDL_Event ev1, *ev = &ev1;
|
||||||
|
bool allow_close = true;
|
||||||
int idle = 1;
|
int idle = 1;
|
||||||
|
|
||||||
if (last_vm_running != runstate_is_running()) {
|
if (last_vm_running != runstate_is_running()) {
|
||||||
|
@ -793,7 +795,10 @@ static void sdl_refresh(DisplayChangeListener *dcl)
|
||||||
handle_keyup(ev);
|
handle_keyup(ev);
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
if (!no_quit) {
|
if (opts->has_window_close && !opts->window_close) {
|
||||||
|
allow_close = false;
|
||||||
|
}
|
||||||
|
if (allow_close) {
|
||||||
no_shutdown = 0;
|
no_shutdown = 0;
|
||||||
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
||||||
}
|
}
|
||||||
|
@ -892,9 +897,9 @@ static const DisplayChangeListenerOps dcl_ops = {
|
||||||
.dpy_cursor_define = sdl_mouse_define,
|
.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,
|
fprintf(stderr,
|
||||||
"SDL1 display code has no opengl support.\n"
|
"SDL1 display code has no opengl support.\n"
|
||||||
"Please recompile qemu with SDL2, using\n"
|
"Please recompile qemu with SDL2, using\n"
|
||||||
|
@ -902,7 +907,7 @@ void sdl_display_early_init(int opengl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdl_display_init(DisplayState *ds, int full_screen)
|
void sdl_display_init(DisplayState *ds, DisplayOptions *o)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
|
@ -910,6 +915,8 @@ void sdl_display_init(DisplayState *ds, int full_screen)
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
|
assert(o->type == DISPLAY_TYPE_SDL);
|
||||||
|
opts = o;
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
/* always use generic keymaps */
|
/* always use generic keymaps */
|
||||||
if (!keyboard_layout)
|
if (!keyboard_layout)
|
||||||
|
@ -924,7 +931,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
|
||||||
g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
|
g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
|
||||||
"in a future release. Please switch to SDL 2.0 instead\n");
|
"in a future release. Please switch to SDL 2.0 instead\n");
|
||||||
|
|
||||||
if (!full_screen) {
|
if (opts->has_full_screen && opts->full_screen) {
|
||||||
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
|
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -967,7 +974,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (full_screen) {
|
if (opts->has_full_screen && opts->full_screen) {
|
||||||
gui_fullscreen = 1;
|
gui_fullscreen = 1;
|
||||||
sdl_grab_start();
|
sdl_grab_start();
|
||||||
}
|
}
|
||||||
|
|
33
ui/sdl2.c
33
ui/sdl2.c
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
static int sdl2_num_outputs;
|
static int sdl2_num_outputs;
|
||||||
static struct sdl2_console *sdl2_console;
|
static struct sdl2_console *sdl2_console;
|
||||||
|
static DisplayOptions *opts;
|
||||||
|
|
||||||
static SDL_Surface *guest_sprite_surface;
|
static SDL_Surface *guest_sprite_surface;
|
||||||
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
|
||||||
|
@ -526,6 +527,7 @@ static void handle_mousewheel(SDL_Event *ev)
|
||||||
static void handle_windowevent(SDL_Event *ev)
|
static void handle_windowevent(SDL_Event *ev)
|
||||||
{
|
{
|
||||||
struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
|
struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
|
||||||
|
bool allow_close = true;
|
||||||
|
|
||||||
if (!scon) {
|
if (!scon) {
|
||||||
return;
|
return;
|
||||||
|
@ -572,7 +574,10 @@ static void handle_windowevent(SDL_Event *ev)
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
if (qemu_console_is_graphic(scon->dcl.con)) {
|
if (qemu_console_is_graphic(scon->dcl.con)) {
|
||||||
if (!no_quit) {
|
if (opts->has_window_close && !opts->window_close) {
|
||||||
|
allow_close = false;
|
||||||
|
}
|
||||||
|
if (allow_close) {
|
||||||
no_shutdown = 0;
|
no_shutdown = 0;
|
||||||
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
||||||
}
|
}
|
||||||
|
@ -593,6 +598,7 @@ static void handle_windowevent(SDL_Event *ev)
|
||||||
void sdl2_poll_events(struct sdl2_console *scon)
|
void sdl2_poll_events(struct sdl2_console *scon)
|
||||||
{
|
{
|
||||||
SDL_Event ev1, *ev = &ev1;
|
SDL_Event ev1, *ev = &ev1;
|
||||||
|
bool allow_close = true;
|
||||||
int idle = 1;
|
int idle = 1;
|
||||||
|
|
||||||
if (scon->last_vm_running != runstate_is_running()) {
|
if (scon->last_vm_running != runstate_is_running()) {
|
||||||
|
@ -615,7 +621,10 @@ void sdl2_poll_events(struct sdl2_console *scon)
|
||||||
handle_textinput(ev);
|
handle_textinput(ev);
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
if (!no_quit) {
|
if (opts->has_window_close && !opts->window_close) {
|
||||||
|
allow_close = false;
|
||||||
|
}
|
||||||
|
if (allow_close) {
|
||||||
no_shutdown = 0;
|
no_shutdown = 0;
|
||||||
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
|
||||||
}
|
}
|
||||||
|
@ -750,24 +759,17 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sdl_display_early_init(int opengl)
|
void sdl_display_early_init(DisplayOptions *o)
|
||||||
{
|
{
|
||||||
switch (opengl) {
|
assert(o->type == DISPLAY_TYPE_SDL);
|
||||||
case -1: /* default */
|
if (o->has_gl && o->gl) {
|
||||||
case 0: /* off */
|
|
||||||
break;
|
|
||||||
case 1: /* on */
|
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
display_opengl = 1;
|
display_opengl = 1;
|
||||||
#endif
|
#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;
|
int flags;
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
|
@ -775,6 +777,9 @@ void sdl_display_init(DisplayState *ds, int full_screen)
|
||||||
int i;
|
int i;
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
|
|
||||||
|
assert(o->type == DISPLAY_TYPE_SDL);
|
||||||
|
opts = o;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* on Linux, SDL may use fbcon|directfb|svgalib when run without
|
/* on Linux, SDL may use fbcon|directfb|svgalib when run without
|
||||||
* accessible $DISPLAY to open X11 window. This is often the case
|
* accessible $DISPLAY to open X11 window. This is often the case
|
||||||
|
@ -849,7 +854,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (full_screen) {
|
if (opts->has_full_screen && opts->full_screen) {
|
||||||
gui_fullscreen = 1;
|
gui_fullscreen = 1;
|
||||||
sdl_grab_start(0);
|
sdl_grab_start(0);
|
||||||
}
|
}
|
||||||
|
|
13
vl.c
13
vl.c
|
@ -2101,6 +2101,7 @@ static LegacyDisplayType select_display(const char *p)
|
||||||
if (strstart(p, "sdl", &opts)) {
|
if (strstart(p, "sdl", &opts)) {
|
||||||
#ifdef CONFIG_SDL
|
#ifdef CONFIG_SDL
|
||||||
display = DT_SDL;
|
display = DT_SDL;
|
||||||
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
while (*opts) {
|
while (*opts) {
|
||||||
const char *nextopt;
|
const char *nextopt;
|
||||||
|
|
||||||
|
@ -2135,19 +2136,25 @@ static LegacyDisplayType select_display(const char *p)
|
||||||
}
|
}
|
||||||
} else if (strstart(opts, ",window_close=", &nextopt)) {
|
} else if (strstart(opts, ",window_close=", &nextopt)) {
|
||||||
opts = nextopt;
|
opts = nextopt;
|
||||||
|
dpy.has_window_close = true;
|
||||||
if (strstart(opts, "on", &nextopt)) {
|
if (strstart(opts, "on", &nextopt)) {
|
||||||
no_quit = 0;
|
no_quit = 0;
|
||||||
|
dpy.window_close = true;
|
||||||
} else if (strstart(opts, "off", &nextopt)) {
|
} else if (strstart(opts, "off", &nextopt)) {
|
||||||
no_quit = 1;
|
no_quit = 1;
|
||||||
|
dpy.window_close = false;
|
||||||
} else {
|
} else {
|
||||||
goto invalid_sdl_args;
|
goto invalid_sdl_args;
|
||||||
}
|
}
|
||||||
} else if (strstart(opts, ",gl=", &nextopt)) {
|
} else if (strstart(opts, ",gl=", &nextopt)) {
|
||||||
opts = nextopt;
|
opts = nextopt;
|
||||||
|
dpy.has_gl = true;
|
||||||
if (strstart(opts, "on", &nextopt)) {
|
if (strstart(opts, "on", &nextopt)) {
|
||||||
request_opengl = 1;
|
request_opengl = 1;
|
||||||
|
dpy.gl = true;
|
||||||
} else if (strstart(opts, "off", &nextopt)) {
|
} else if (strstart(opts, "off", &nextopt)) {
|
||||||
request_opengl = 0;
|
request_opengl = 0;
|
||||||
|
dpy.gl = false;
|
||||||
} else {
|
} else {
|
||||||
goto invalid_sdl_args;
|
goto invalid_sdl_args;
|
||||||
}
|
}
|
||||||
|
@ -3668,6 +3675,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
case QEMU_OPTION_sdl:
|
case QEMU_OPTION_sdl:
|
||||||
#ifdef CONFIG_SDL
|
#ifdef CONFIG_SDL
|
||||||
display_type = DT_SDL;
|
display_type = DT_SDL;
|
||||||
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
error_report("SDL support is disabled");
|
error_report("SDL support is disabled");
|
||||||
|
@ -4334,6 +4342,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
dpy.type = DISPLAY_TYPE_GTK;
|
dpy.type = DISPLAY_TYPE_GTK;
|
||||||
#elif defined(CONFIG_SDL)
|
#elif defined(CONFIG_SDL)
|
||||||
display_type = DT_SDL;
|
display_type = DT_SDL;
|
||||||
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
#elif defined(CONFIG_COCOA)
|
#elif defined(CONFIG_COCOA)
|
||||||
display_type = DT_COCOA;
|
display_type = DT_COCOA;
|
||||||
#elif defined(CONFIG_VNC)
|
#elif defined(CONFIG_VNC)
|
||||||
|
@ -4358,7 +4367,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display_type == DT_SDL) {
|
if (display_type == DT_SDL) {
|
||||||
sdl_display_early_init(request_opengl);
|
sdl_display_early_init(&dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_console_early_init();
|
qemu_console_early_init();
|
||||||
|
@ -4693,7 +4702,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
curses_display_init(ds, full_screen);
|
curses_display_init(ds, full_screen);
|
||||||
break;
|
break;
|
||||||
case DT_SDL:
|
case DT_SDL:
|
||||||
sdl_display_init(ds, full_screen);
|
sdl_display_init(ds, &dpy);
|
||||||
break;
|
break;
|
||||||
case DT_COCOA:
|
case DT_COCOA:
|
||||||
cocoa_display_init(ds, full_screen);
|
cocoa_display_init(ds, full_screen);
|
||||||
|
|
Loading…
Reference in New Issue