Move getting XWindow ID from baum driver to graphical backend
v4 cover Move getting XWindow ID from baum driver to graphical backend
Hello,
This is a respin of moving getting XWindow ID from baum to actual graphical backends. This only contains the new API, the move of existing code to the new API, and the addition of support for SDL2. Gtk will need more discussion and work.
Compared to v3, this makes the API use a QemuConsole* parameter instead of an integer index,
Samuel
Samuel Thibault (3):
console: add API to get underlying gui window ID
console: move window ID code from baum to sdl
sdl2: set window ID
backends/baum.c | 31 ++++++++----------------------- include/ui/console.h | 4 ++++ ui/console.c | 11 +++++++++++ ui/sdl.c | 25 +++++++++++++++++++++++++ ui/sdl2.c | 7 +++++++ 5 files changed, 55 insertions(+), 23 deletions(-)
Signature · 1 line
2.11.0
PATCH v4 1/3 console: add API to get underlying gui window ID
This adds two console functions, qemu_console_set_window_id and qemu_graphic_console_get_window_id, to let graphical backend record the window id in the QemuConsole structure, and let the baum driver read it.
---
Difference from v4: select console with a QemuConsole* parameter instead of an integer index.
--- include/ui/console.h | 4 ++++ ui/console.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
include/ui/console.h +4 -0
@@ -394,6 +394,10 @@ uint32_t qemu_console_get_head(QemuConsole *con);QemuUIInfo *qemu_console_get_ui_info (QemuConsole *con);int qemu_console_get_width (QemuConsole *con,int fallback);int qemu_console_get_height (QemuConsole *con,int fallback); +/* Return the low-level window id for the console */ +int qemu_console_get_window_id (QemuConsole *con); +/* Set the low-level window id for the console */ +void qemu_console_set_window_id (QemuConsole *con,int window_id);void console_select (unsigned int index);void qemu_console_resize (QemuConsole *con,int width,int height);
ui/console.c +11 -0
@@ -124,6 +124,7 @@ struct QemuConsole {int dcls;DisplayChangeListener *gl;bool gl_block; +int window_id;/* Graphic console state. */ Object *device;
@@ -273,6 +274,16 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) } } +int qemu_console_get_window_id (QemuConsole *con) +{ +return con->window_id; +} + +void qemu_console_set_window_id (QemuConsole *con,int window_id) +{ + con->window_id = window_id; +} +void graphic_hw_invalidate (QemuConsole *con) {if (!con) {
Signature · 1 line
2.11.0
PATCH v4 2/3 console: move window ID code from baum to sdl
In reply to Samuel ThibaultThis moves the SDL bits for window ID from the baum driver to SDL, as well as fixing the build for non-X11.
---
Difference from v3: Use qemu_console_lookup_by_index and qemu_console_is_graphic to access the console
--- backends/baum.c | 31 ++++++++----------------------- ui/sdl.c | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 23 deletions(-)
backends/baum.c +8 -23
@@ -27,12 +27,10 @@#include "sysemu/char.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "ui/console.h" #include <brlapi.h> #include <brlapi_constants.h> #include <brlapi_keycodes.h> -#ifdef CONFIG_SDL -#include <SDL_syswm.h> -#endif #if 0 #define DPRINTF (fmt, ...) \
@@ -227,12 +225,8 @@ 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; +int tty =BRLAPI_TTY_DEFAULT ; +QemuConsole *con;if (baum->deferred_init) {return 1 ;
@@ -243,21 +237,12 @@ 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 = BRLAPI_TTY_DEFAULT; -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) + con =qemu_console_lookup_by_index (0 ); +if (con &&qemu_console_is_graphic (con)) { + tty =qemu_console_get_window_id (con); +if (tty ==-1 ) + tty =BRLAPI_TTY_DEFAULT ; } -#endif -#endifif (brlapi__enterTtyMode (baum->brlapi, tty,NULL ) ==-1 ) {brlapi_perror ("baum: brlapi__enterTtyMode" );
ui/sdl.c +25 -0
@@ -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 (con, 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 (con, (int ) (uintptr_t ) info.window); +#else +qemu_console_set_window_id (con, info.data); +#endif + }else { +break ; + } + } + } +atexit (sdl_cleanup); }
Signature · 1 line
2.11.0
PATCH v4 3/3 sdl2: set window ID
In reply to Samuel ThibaultThis uses the console API to record the window ID of the SDL2 windows.
--- ui/sdl2.c | 7 +++++++ 1 file changed, 7 insertions(+)
ui/sdl2.c +7 -0
@@ -761,6 +761,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)uint8_t data =0 ;char *filename;int i; +SDL_SysWMinfo info;if (no_frame) { gui_noframe =1 ;
@@ -786,6 +787,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)exit (1 ); }SDL_SetHint (SDL_HINT_GRAB_KEYBOARD ,"1" ); +memset (&info,0 ,sizeof (info)); +SDL_VERSION (&info.version);for (i =0 ;; i++) {QemuConsole *con =qemu_console_lookup_by_index (i);
@@ -813,6 +816,10 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)#endif sdl2_console[i].dcl.con = con;register_displaychangelistener (&sdl2_console[i].dcl); + +if (SDL_GetWindowWMInfo (sdl2_console[i].real_window, &info)) { +qemu_console_set_window_id (con, info.info.x11.window); + } }/* Load a 32x32x4 image. White pixels are transparent. */
Signature · 1 line
2.11.0
Quoted 9 lines · Samuel Thibault
Hello,
This is a respin of moving getting XWindow ID from baum to actual graphical backends. This only contains the new API, the move of existing code to the new API, and the addition of support for SDL2. Gtk will need more discussion and work.
Compared to v3, this makes the API use a QemuConsole* parameter instead of an integer index,
Added to ui queue.
thanks,
Gerd