Received: from eggs.gnu.org ([2001:4830:134:3::10]:33498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1F0U-0000AW-Pz for qemu-devel@nongnu.org; Mon, 31 Oct 2016 12:00:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1F0O-0003M2-TQ for qemu-devel@nongnu.org; Mon, 31 Oct 2016 12:00:18 -0400 Received: from hera.aquilenet.fr ([141.255.128.1]:47568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1F0O-0003LQ-Mk for qemu-devel@nongnu.org; Mon, 31 Oct 2016 12:00:12 -0400 From: Samuel Thibault Date: Mon, 31 Oct 2016 17:00:05 +0100 Message-Id: <20161031160007.6047-3-samuel.thibault@ens-lyon.org> In-Reply-To: <20161031160007.6047-1-samuel.thibault@ens-lyon.org> References: <20161031160007.6047-1-samuel.thibault@ens-lyon.org> Subject: [Qemu-devel] [PATCH 2/4] console: move window ID code from baum to sdl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kraxel@redhat.com Cc: Samuel Thibault This moves the SDL bits for window ID from the baum driver to SDL, as well as fixing the build for non-X11. Signed-off-by: Samuel Thibault --- backends/baum.c | 25 +++---------------------- ui/sdl.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/backends/baum.c b/backends/baum.c index b92369d..5d7d27c 100644 --- a/backends/baum.c +++ b/backends/baum.c @@ -27,12 +27,10 @@ #include "sysemu/char.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "ui/console.h" #include #include #include -#ifdef CONFIG_SDL -#include -#endif #if 0 #define DPRINTF(fmt, ...) \ @@ -227,11 +225,6 @@ static const uint8_t nabcc_translation[2][256] = { /* The guest OS has started discussing with us, finish initializing BrlAPI */ static int baum_deferred_init(BaumDriverState *baum) { -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) - SDL_SysWMinfo info; -#endif -#endif int tty; if (baum->deferred_init) { @@ -243,21 +236,9 @@ static int baum_deferred_init(BaumDriverState *baum) return 0; } -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) - memset(&info, 0, sizeof(info)); - SDL_VERSION(&info.version); - if (SDL_GetWMInfo(&info)) { - tty = info.info.x11.wmwindow; - } else { -#endif -#endif + tty = qemu_graphic_console_get_window_id(); + if (tty == -1) tty = BRLAPI_TTY_DEFAULT; -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) - } -#endif -#endif if (brlapi__enterTtyMode(baum->brlapi, tty, NULL) == -1) { brlapi_perror("baum: brlapi__enterTtyMode"); diff --git a/ui/sdl.c b/ui/sdl.c index d8cf5bc..8d9d171 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -947,6 +947,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) int flags; uint8_t data = 0; const SDL_VideoInfo *vi; + SDL_SysWMinfo info; char *filename; #if defined(__APPLE__) @@ -1023,5 +1024,29 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); sdl_cursor_normal = SDL_GetCursor(); + memset(&info, 0, sizeof(info)); + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) { + int i; + for (i = 0; ; i++) { + /* All consoles share the same window */ + QemuConsole *con = qemu_console_lookup_by_index(i); + if (con) { +#if defined(SDL_VIDEO_DRIVER_X11) + qemu_console_set_window_id(i, info.info.x11.wmwindow); +#elif defined(SDL_VIDEO_DRIVER_NANOX) || \ + defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || \ + defined(SDL_VIDEO_DRIVER_GAPI) || \ + defined(SDL_VIDEO_DRIVER_RISCOS) + qemu_console_set_window_id(i, (int) (uintptr_t) info.window); +#else + qemu_console_set_window_id(i, info.data); +#endif + } else { + break; + } + } + } + atexit(sdl_cleanup); } -- 2.10.1