sdl2: fixes, cleanups and opengl preparation.
cover sdl2: fixes, cleanups and opengl preparation.
Hi,
This patch series is a brings a bunch of fixes and inprovements to the sdl2 ui code. Proper window scaling and working keyboard grabs are the most noteworthy ones. It also reorganizes the code in preparation for adding opengl support to sdl2.
please review,
Gerd
Gerd Hoffmann (10):
sdl: move version logic from source code to makefile
sdl2: rename sdl2_state to sdl2_console, move to header file
sdl2: move keyboard input code to new sdl2-input.c
sdl2: turn on keyboard grabs
sdl2: move sdl_update to new sdl2-2d.c
sdl2: overhaul window size handling
sdl2: move sdl_switch to sdl2-2d.c
sdl2: add+use sdl2_2d_redraw function.
sdl2: factor out sdl2_poll_events
sdl2: move sdl2_2d_refresh to sdl2-2d.c
include/ui/sdl2.h | 27 +++++ ui/Makefile.objs | 7 +- ui/sdl.c | 3 - ui/sdl2-2d.c | 123 ++++++++++++++++++++ ui/sdl2-input.c | 106 +++++++++++++++++ ui/sdl2.c | 333 +++++++++++++----------------------------------------- 6 files changed, 343 insertions(+), 256 deletions(-) create mode 100644 include/ui/sdl2.h create mode 100644 ui/sdl2-2d.c create mode 100644 ui/sdl2-input.c
Signature · 1 line
1.8.3.1
PATCH 1/10 sdl: move version logic from source code to makefile
Compile sdl.c / sdl2.c depending on CONFIG_SDLABI instead of compiling both and have version #ifdefs in the source code.
--- ui/Makefile.objs | 7 ++++++- ui/sdl.c | 3 --- ui/sdl2.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)
ui/Makefile.objs +6 -1
@@ -16,7 +16,12 @@ common-obj-$(CONFIG_CURSES) += curses.o common-obj-$(CONFIG_VNC) += $(vnc-obj-y) common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o -sdl.mo-objs := sdl.o sdl_zoom.o sdl2.o +ifeq ($(CONFIG_SDLABI),1.2) +sdl.mo-objs := sdl.o sdl_zoom.o +endif +ifeq ($(CONFIG_SDLABI),2.0) +sdl.mo-objs := sdl2.o +endif sdl.mo-cflags := $(SDL_CFLAGS) gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
ui/sdl.c +0 -3
@@ -26,8 +26,6 @@#undef WIN32_LEAN_AND_MEAN#include <SDL.h> - -#if SDL_MAJOR_VERSION ==1 #include <SDL_syswm.h> #include "qemu-common.h"
@@ -958,4 +956,3 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)atexit (sdl_cleanup); } -#endif
ui/sdl2.c +0 -3
@@ -27,8 +27,6 @@#undef WIN32_LEAN_AND_MEAN#include <SDL.h> - -#if SDL_MAJOR_VERSION ==2 #include <SDL_syswm.h> #include "qemu-common.h"
@@ -912,4 +910,3 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)atexit (sdl_cleanup); } -#endif
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/10] sdl: move version logic from source code to makefile
Quoted 9 lines · Gerd Hoffmann
Compile
sdl.c/sdl2.cdepending onCONFIG_SDLABIinstead of compiling both and have version #ifdefs in the source code.Signed-off-by Gerd Hoffmann <[email protected]>--- ui/Makefile.objs | 7 ++++++- ui/sdl.c | 3 --- ui/sdl2.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)
PATCH 2/10 sdl2: rename sdl2_state to sdl2_console, move to header file
In reply to Gerd HoffmannCreate sdl2.h header file, in preparation for sdl2 code splitup. Populate it with sdl2_console struct (renamed from sdl2_state).
--- include/ui/sdl2.h | 11 ++++++++++ ui/sdl2.c | 63 ++++++++++++++++++++++++------------------------------- 2 files changed, 38 insertions(+), 36 deletions(-) create mode 100644 include/ui/sdl2.h
include/ui/sdl2.h new file +11 -0
@@ -0,0 +1,11 @@ +struct sdl2_console { +DisplayChangeListener dcl; +DisplaySurface *surface; +SDL_Texture *texture; +SDL_Window *real_window; +SDL_Renderer *real_renderer; +int idx; +int last_vm_running;/* per console for caption reasons */ +int x, y; +int hidden; +};
ui/sdl2.c +27 -36
219 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/10] sdl2: rename sdl2_state to sdl2_console, move to header file
Quoted 17 lines · Gerd Hoffmann
Create
sdl2.hheader file, in preparation for sdl2 code splitup. Populate it withsdl2_consolestruct (renamed fromsdl2_state).Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 11 ++++++++++ ui/sdl2.c | 63 ++++++++++++++++++++++++------------------------------- 2 files changed, 38 insertions(+), 36 deletions(-)create mode 100644
include/ui/sdl2.hinclude/ui/sdl2.h new file +1
-0@@ -0,0 +1,11 @@ +struct sdl2_console {
include/ui/sdl2.h line 11
Quoted 10 lines
include/ui/sdl2.h new file +10
-0+DisplayChangeListener dcl; +DisplaySurface *surface; +SDL_Texture *texture; +SDL_Window *real_window; +SDL_Renderer *real_renderer; +int idx; +int last_vm_running;/* per console for caption reasons */ +int x, y; +int hidden; +};
Is there a reason why you did not use include guards?
Max
Re: [Qemu-devel] [PATCH 02/10] sdl2: rename sdl2_state to sdl2_console, move to header file
Quoted 10 lines
include/ui/sdl2.h line 2
Quoted 8 lines
include/ui/sdl2.h new file +2
-0@@ -0,0 +1,11 @@ +struct sdl2_console { +DisplayChangeListener dcl;Is there a reason why you did not use include guards?
Fixed.
cheers,
Gerd
PATCH 3/10 sdl2: move keyboard input code to new sdl2-input.c
In reply to Gerd Hoffmann--- include/ui/sdl2.h | 4 +++ ui/Makefile.objs | 2 +- ui/sdl2-input.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 75 ++------------------------------------ 4 files changed, 114 insertions(+), 73 deletions(-) create mode 100644 ui/sdl2-input.c
include/ui/sdl2.h +4 -0
@@ -9,3 +9,7 @@ struct sdl2_console {int x, y;int hidden; }; + +void sdl2_reset_keys (struct sdl2_console *scon); +void sdl2_process_key (struct sdl2_console *scon, +SDL_KeyboardEvent *ev);
ui/Makefile.objs +1 -1
@@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2) sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) -sdl.mo-objs := sdl2.o +sdl.mo-objs := sdl2.o sdl2-input.o endif sdl.mo-cflags := $(SDL_CFLAGS)
ui/sdl2-input.c new file +106 -0
106 lines not on this page · raw message
ui/sdl2.c +3 -72
110 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl2-input.c
Quoted 77 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 4 +++ ui/Makefile.objs | 2 +- ui/sdl2-input.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 75 ++------------------------------------ 4 files changed, 114 insertions(+), 73 deletions(-)create mode 100644
ui/sdl2-input.cinclude/ui/sdl2.h +4
-0@@ -9,3 +9,7 @@ struct sdl2_console {int x, y;int hidden; }; + +void sdl2_reset_keys (struct sdl2_console *scon); +void sdl2_process_key (struct sdl2_console *scon, +SDL_KeyboardEvent *ev);ui/Makefile.objs +1
-1@@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2) sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) -sdl.mo-objs := sdl2.o +sdl.mo-objs := sdl2.o sdl2-input.o endif sdl.mo-cflags := $(SDL_CFLAGS)ui/sdl2-input.c new file +37
-0@@ -0,0 +1,106 @@ +/* +* QEMU SDL display driver +* +* Copyright (c) 2003 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ + +/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ +#undef WIN32_LEAN_AND_MEAN + +#include <SDL.h> +#include <SDL_syswm.h> + +#include "qemu-common.h" +#include "ui/console.h" +#include "ui/input.h" +#include "ui/sdl2.h" +#include "sysemu/sysemu.h" +
ui/sdl2-input.c line 47
Quoted 10 lines
ui/sdl2-input.c new file +10
-0+#include "sdl2-keymap.h" + +static uint8_t modifiers_state[SDL_NUM_SCANCODES ]; + +void sdl2_reset_keys (struct sdl2_console *scon) +{ +QemuConsole *con = scon ? scon->dcl.con :NULL ; +int i; + +for (i =0 ; i <256 ; i++) {
Should this be SDL_NUM_SCANCODES?
ui/sdl2-input.c line 54
Quoted 7 lines
ui/sdl2-input.c new file +7
-0+if (modifiers_state[i]) { +int qcode = sdl2_scancode_to_qcode[i]; +qemu_input_event_send_key_qcode (con, qcode, false); + modifiers_state[i] =0 ; + } + } +}
Max
Re: [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl2-input.c
Hi,
Quoted 10 lines
ui/sdl2-input.c line 47
Quoted 8 lines
ui/sdl2-input.c new file +8
-0+static uint8_t modifiers_state[SDL_NUM_SCANCODES ]; + +void sdl2_reset_keys (struct sdl2_console *scon) +{ +QemuConsole *con = scon ? scon->dcl.con :NULL ; +int i; + +for (i =0 ; i <256 ; i++) {Should this be
SDL_NUM_SCANCODES?
Yes, fixed.
thanks,
Gerd
PATCH 4/10 sdl2: turn on keyboard grabs
In reply to Gerd HoffmannMakes quite some keys actually go to the guest instead of being captured by the host window manager.
--- ui/sdl2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ui/sdl2.c +4 -3
@@ -189,11 +189,11 @@ static void sdl_update_caption(struct sdl2_console *scon) status =" [Stopped]" ; }else if (gui_grab) {if (alt_grab) { - status =" - Press Ctrl-Alt-Shift to exit mouse grab" ; + status =" - Press Ctrl-Alt-Shift to exit grab" ; }else if (ctrl_grab) { - status =" - Press Right-Ctrl to exit mouse grab" ; + status =" - Press Right-Ctrl to exit grab" ; }else { - status =" - Press Ctrl-Alt to exit mouse grab" ; + status =" - Press Ctrl-Alt to exit grab" ; } }
@@ -785,6 +785,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) SDL_GetError());exit (1 ); } +SDL_SetHint (SDL_HINT_GRAB_KEYBOARD ,"1" );for (i =0 ;; i++) {QemuConsole *con =qemu_console_lookup_by_index (i);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 04/10] sdl2: turn on keyboard grabs
Quoted 7 lines · Gerd Hoffmann
Makes quite some keys actually go to the guest instead of being captured by the host window manager.
Signed-off-by Gerd Hoffmann <[email protected]>--- ui/sdl2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
PATCH 5/10 sdl2: move sdl_update to new sdl2-2d.c
In reply to Gerd HoffmannCreate new sdl2-2d file for 2d display rendering. Move over sdl_update code, and rename to sdl2_2d_update.
--- include/ui/sdl2.h | 3 +++ ui/Makefile.objs | 2 +- ui/sdl2-2d.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 35 +++++-------------------------- 4 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 ui/sdl2-2d.c
include/ui/sdl2.h +3 -0
@@ -13,3 +13,6 @@ struct sdl2_console {void sdl2_reset_keys (struct sdl2_console *scon);void sdl2_process_key (struct sdl2_console *scon,SDL_KeyboardEvent *ev); + +void sdl2_2d_update (DisplayChangeListener *dcl, +int x,int y,int w,int h);
ui/Makefile.objs +1 -1
@@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2) sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) -sdl.mo-objs := sdl2.o sdl2-input.o +sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o endif sdl.mo-cflags := $(SDL_CFLAGS)
ui/sdl2-2d.c new file +61 -0
61 lines not on this page · raw message
ui/sdl2.c +5 -30
@@ -72,31 +72,6 @@ static struct sdl2_console *get_scon_from_window(uint32_t window_id)return NULL ; } -static void sdl_update (DisplayChangeListener *dcl, -int x,int y,int w,int h) -{ - struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); -SDL_Rect rect; -DisplaySurface *surf =qemu_console_surface (dcl->con); - -if (!surf) { -return ; - } -if (!scon->texture) { -return ; - } - - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; - -SDL_UpdateTexture (scon->texture,NULL ,surface_data (surf), -surface_stride (surf)); -SDL_RenderCopy (scon->real_renderer, scon->texture, &rect, &rect); -SDL_RenderPresent (scon->real_renderer); -} -static void do_sdl_resize (struct sdl2_console *scon,int width,int height,int bpp) {
@@ -609,7 +584,7 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)break ;case SDL_WINDOWEVENT_EXPOSED :SDL_GetWindowSize (SDL_GetWindowFromID (ev->window.windowID), &w, &h); -sdl_update (dcl,0 ,0 , w, h); +sdl2_2d_update (dcl,0 ,0 , w, h);break ;case SDL_WINDOWEVENT_FOCUS_GAINED :case SDL_WINDOWEVENT_ENTER :
@@ -746,9 +721,9 @@ static void sdl_cleanup(void)SDL_QuitSubSystem (SDL_INIT_VIDEO ); } -static const DisplayChangeListenerOps dcl_ops = { - .dpy_name ="sdl" , - .dpy_gfx_update = sdl_update, +static const DisplayChangeListenerOps dcl_2d_ops = { + .dpy_name ="sdl2-2d" , + .dpy_gfx_update = sdl2_2d_update, .dpy_gfx_switch = sdl_switch, .dpy_refresh = sdl_refresh, .dpy_mouse_set = sdl_mouse_warp,
@@ -800,7 +775,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)if (!qemu_console_is_graphic (con)) { sdl2_console[i].hidden = true; } - sdl2_console[i].dcl.ops = &dcl_ops; + sdl2_console[i].dcl.ops = &dcl_2d_ops; sdl2_console[i].dcl.con = con;register_displaychangelistener (&sdl2_console[i].dcl); sdl2_console[i].idx = i;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 05/10] sdl2: move sdl_update to new sdl2-2d.c
Quoted 90 lines · Gerd Hoffmann
Create new sdl2-2d file for 2d display rendering. Move over
sdl_updatecode, and rename tosdl2_2d_update.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 3 +++ ui/Makefile.objs | 2 +- ui/sdl2-2d.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 35 +++++-------------------------- 4 files changed, 70 insertions(+), 31 deletions(-)create mode 100644
ui/sdl2-2d.cinclude/ui/sdl2.h +3
-0@@ -13,3 +13,6 @@ struct sdl2_console {void sdl2_reset_keys (struct sdl2_console *scon);void sdl2_process_key (struct sdl2_console *scon,SDL_KeyboardEvent *ev); + +void sdl2_2d_update (DisplayChangeListener *dcl, +int x,int y,int w,int h);ui/Makefile.objs +1
-1@@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2) sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) -sdl.mo-objs := sdl2.o sdl2-input.o +sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o endif sdl.mo-cflags := $(SDL_CFLAGS)ui/sdl2-2d.c new file +48
-0@@ -0,0 +1,61 @@ +/* +* QEMU SDL display driver +* +* Copyright (c) 2003 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ + +/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ +#undef WIN32_LEAN_AND_MEAN + +#include <SDL.h> +#include <SDL_syswm.h> + +#include "qemu-common.h" +#include "ui/console.h" +#include "ui/input.h" +#include "ui/sdl2.h" +#include "sysemu/sysemu.h" + +void sdl2_2d_update (DisplayChangeListener *dcl, +int x,int y,int w,int h) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); +DisplaySurface *surf =qemu_console_surface (dcl->con); +SDL_Rect rect; + +if (!surf) { +return ; + } +if (!scon->texture) {
ui/sdl2-2d.c line 58
Quoted 10 lines
ui/sdl2-2d.c new file +10
-0+return ; + } + + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + +SDL_UpdateTexture (scon->texture,NULL ,surface_data (surf), +surface_stride (surf));
Hm, I'm wondering whether this could be optimized by passing &rect instead of NULL and calculating the start address from surface_data(surf) and rect...
Anyway:
PATCH 6/10 sdl2: overhaul window size handling
In reply to Gerd HoffmannSplit do_sdl_resize function (which does alot more than just resizing) into three: sdl2_window_{create,destroy,resize}.
Fix SDL_Renderer handling: must be guest display size not host window size, and SDL2 will magically handle all scaling for us.
Make fullscreen actually enter fullscreen mode and simplify the code. There is no need to store the original window size, the window manager will do that for us.
--- ui/sdl2.c | 172 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 79 insertions(+), 93 deletions(-)
ui/sdl2.c +79 -93
@@ -41,9 +41,6 @@ static struct sdl2_console *sdl2_console;static SDL_Surface *guest_sprite_surface;static int gui_grab;/* if true, all keyboard/mouse events are grabbed */ -static bool gui_saved_scaling; -static int gui_saved_width; -static int gui_saved_height;static int gui_saved_grab;static int gui_fullscreen;static int gui_noframe;
@@ -56,7 +53,6 @@ static int absolute_enabled;static int guest_cursor;static int guest_x, guest_y;static SDL_Cursor *guest_sprite; -static int scaling_active;static Notifier mouse_mode_notifier;static void sdl_update_caption (struct sdl2_console *scon);
@@ -72,86 +68,96 @@ static struct sdl2_console *get_scon_from_window(uint32_t window_id)return NULL ; } -static void do_sdl_resize (struct sdl2_console *scon,int width,int height, -int bpp) +static void sdl2_window_create (struct sdl2_console *scon) { -int flags; +int flags =0 ; -if (scon->real_window && scon->real_renderer) { -if (width && height) { -SDL_RenderSetLogicalSize (scon->real_renderer, width, height); -SDL_SetWindowSize (scon->real_window, width, height); - }else { -SDL_DestroyRenderer (scon->real_renderer); -SDL_DestroyWindow (scon->real_window); - scon->real_renderer =NULL ; - scon->real_window =NULL ; - } +if (!scon->surface) { +return ; + } +assert (!scon->real_window); + +if (gui_fullscreen) { + flags |=SDL_WINDOW_FULLSCREEN ; }else { -if (!width || !height) { -return ; - } - flags =0 ; -if (gui_fullscreen) { - flags |=SDL_WINDOW_FULLSCREEN ; - }else { - flags |=SDL_WINDOW_RESIZABLE ; - } -if (scon->hidden) { - flags |=SDL_WINDOW_HIDDEN ; - } + flags |=SDL_WINDOW_RESIZABLE ; + } +if (scon->hidden) { + flags |=SDL_WINDOW_HIDDEN ; + } - scon->real_window =SDL_CreateWindow ("" ,SDL_WINDOWPOS_UNDEFINED , -SDL_WINDOWPOS_UNDEFINED , - width, height, flags); - scon->real_renderer =SDL_CreateRenderer (scon->real_window,-1 ,0 ); -sdl_update_caption (scon); + scon->real_window =SDL_CreateWindow ("" ,SDL_WINDOWPOS_UNDEFINED , +SDL_WINDOWPOS_UNDEFINED , +surface_width (scon->surface), +surface_height (scon->surface), + flags); + scon->real_renderer =SDL_CreateRenderer (scon->real_window,-1 ,0 ); +sdl_update_caption (scon); +} + +static void sdl2_window_destroy (struct sdl2_console *scon) +{ +if (!scon->real_window) { +return ; } + +SDL_DestroyRenderer (scon->real_renderer); + scon->real_renderer =NULL ; +SDL_DestroyWindow (scon->real_window); + scon->real_window =NULL ; +} + +static void sdl2_window_resize (struct sdl2_console *scon) +{ +if (!scon->real_window) { +return ; + } + +SDL_SetWindowSize (scon->real_window, +surface_width (scon->surface), +surface_height (scon->surface)); }static void sdl_switch (DisplayChangeListener *dcl,DisplaySurface *new_surface) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); -int format =0 ; -int idx = scon->idx;DisplaySurface *old_surface = scon->surface; +int format =0 ; -/* temporary hack: allows to call sdl_switch to handle scaling changes */ -if (new_surface) { - scon->surface = new_surface; - } + scon->surface = new_surface; -if (!new_surface && idx >0 ) { - scon->surface =NULL ; +if (scon->texture) { +SDL_DestroyTexture (scon->texture); + scon->texture =NULL ; } -if (new_surface ==NULL ) { -do_sdl_resize (scon,0 ,0 ,0 ); - }else { -do_sdl_resize (scon,surface_width (scon->surface), -surface_height (scon->surface),0 ); +if (!new_surface) { +sdl2_window_destroy (scon); +return ; } -if (old_surface && scon->texture) { -SDL_DestroyTexture (scon->texture); - scon->texture =NULL ; +if (!scon->real_window) { +sdl2_window_create (scon); + }else if (old_surface && + ((surface_width (old_surface) !=surface_width (new_surface)) || + (surface_height (old_surface) !=surface_height (new_surface)))) { +sdl2_window_resize (scon); } -if (new_surface) { -if (!scon->texture) { -if (surface_bits_per_pixel (scon->surface) ==16 ) { - format =SDL_PIXELFORMAT_RGB565 ; - }else if (surface_bits_per_pixel (scon->surface) ==32 ) { - format =SDL_PIXELFORMAT_ARGB8888 ; - } +SDL_RenderSetLogicalSize (scon->real_renderer, +surface_width (new_surface), +surface_height (new_surface)); - scon->texture =SDL_CreateTexture (scon->real_renderer, format, -SDL_TEXTUREACCESS_STREAMING , -surface_width (new_surface), -surface_height (new_surface)); - } +if (surface_bits_per_pixel (scon->surface) ==16 ) { + format =SDL_PIXELFORMAT_RGB565 ; + }else if (surface_bits_per_pixel (scon->surface) ==32 ) { + format =SDL_PIXELFORMAT_ARGB8888 ; } + scon->texture =SDL_CreateTexture (scon->real_renderer, format, +SDL_TEXTUREACCESS_STREAMING , +surface_width (new_surface), +surface_height (new_surface)); }static void sdl_update_caption (struct sdl2_console *scon)
@@ -338,39 +344,19 @@ static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy,qemu_input_event_sync (); } -static void sdl_scale (struct sdl2_console *scon,int width,int height) -{ -int bpp =0 ; -do_sdl_resize (scon, width, height, bpp); - scaling_active =1 ; -} -static void toggle_full_screen (struct sdl2_console *scon) { -int width =surface_width (scon->surface); -int height =surface_height (scon->surface); -int bpp =surface_bits_per_pixel (scon->surface); - gui_fullscreen = !gui_fullscreen;if (gui_fullscreen) { -SDL_GetWindowSize (scon->real_window, - &gui_saved_width, &gui_saved_height); - gui_saved_scaling = scaling_active; - -do_sdl_resize (scon, width, height, bpp); - scaling_active =0 ; - +SDL_SetWindowFullscreen (scon->real_window, +SDL_WINDOW_FULLSCREEN_DESKTOP ); gui_saved_grab = gui_grab;sdl_grab_start (scon); }else { -if (gui_saved_scaling) { -sdl_scale (scon, gui_saved_width, gui_saved_height); - }else { -do_sdl_resize (scon, width, height,0 ); - }if (!gui_saved_grab) {sdl_grab_end (scon); } +SDL_SetWindowFullscreen (scon->real_window,0 ); }graphic_hw_invalidate (scon->dcl.con);graphic_hw_update (scon->dcl.con);
@@ -419,14 +405,13 @@ static void handle_keydown(SDL_Event *ev) gui_keysym =1 ;break ;case SDL_SCANCODE_U : -if (scaling_active) { - scaling_active =0 ; -sdl_switch (&scon->dcl,NULL ); -graphic_hw_invalidate (scon->dcl.con); -graphic_hw_update (scon->dcl.con); - } +sdl2_window_destroy (scon); +sdl2_window_create (scon); +graphic_hw_invalidate (scon->dcl.con); +graphic_hw_update (scon->dcl.con); gui_keysym =1 ;break ; +#if 0 case SDL_SCANCODE_KP_PLUS :case SDL_SCANCODE_KP_MINUS :if (!gui_fullscreen) {
@@ -439,12 +424,14 @@ static void handle_keydown(SDL_Event *ev) 160); height = (surface_height (scon->surface) * width) /surface_width (scon->surface); - +fprintf (stderr,"%s: scale to %dx%d\n" , + __func__, width, height);sdl_scale (scon, width, height);graphic_hw_invalidate (NULL );graphic_hw_update (NULL ); gui_keysym = 1; } +#endif default :break ; }
@@ -571,7 +558,6 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)switch (ev->window.event) {case SDL_WINDOWEVENT_RESIZED : -sdl_scale (scon, ev->window.data1, ev->window.data2); {QemuUIInfo info;memset (&info,0 ,sizeof (info));
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/10] sdl2: overhaul window size handling
Quoted 20 lines · Gerd Hoffmann
Split
do_sdl_resizefunction (which does alot more than just resizing) into three: sdl2_window_{create,destroy,resize}.Fix
SDL_Rendererhandling: must be guest display size not host window size, and SDL2 will magically handle all scaling for us.Make fullscreen actually enter fullscreen mode and simplify the code. There is no need to store the original window size, the window manager will do that for us.
Signed-off-by Gerd Hoffmann <[email protected]>--- ui/sdl2.c | 172 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 79 insertions(+), 93 deletions(-)ui/sdl2.c +0
-0
ui/sdl2.c static void handle_keydown(SDL_Event *ev) · line 428
Quoted 6 lines
ui/sdl2.c +2
-1@@ -439,12 +424,14 @@ static void handle_keydown(SDL_Event *ev) 160); height = (surface_height (scon->surface) * width) /surface_width (scon->surface); - +fprintf (stderr,"%s: scale to %dx%d\n" , + __func__, width, height);
I forgot to ask: What's the reason for this fprintf()? Thanks to "#if 0" it doesn't do anything, but it seems kind of strange if this block would not be commented out...
Max
Re: [Qemu-devel] [PATCH 06/10] sdl2: overhaul window size handling
Hi,
Quoted 11 lines
ui/sdl2.c static void handle_keydown(SDL_Event *ev) · line 428
Quoted 7 lines
ui/sdl2.c +2
-1@@ -439,12 +424,14 @@ static void handle_keydown(SDL_Event *ev) 160); height = (surface_height (scon->surface) * width) /surface_width (scon->surface); - +fprintf (stderr,"%s: scale to %dx%d\n" , + __func__, width, height);I forgot to ask: What's the reason for this
fprintf()? Thanks to "#if 0" it doesn't do anything, but it seems kind of strange if this block would not be commented out...
Just a debug printf. Will go away when this code gets re-enabled.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 06/10] sdl2: overhaul window size handling
In reply to Gerd HoffmannQuoted 19 lines · Gerd Hoffmann
Split
do_sdl_resizefunction (which does alot more than just resizing) into three: sdl2_window_{create,destroy,resize}.Fix
SDL_Rendererhandling: must be guest display size not host window size, and SDL2 will magically handle all scaling for us.Make fullscreen actually enter fullscreen mode and simplify the code. There is no need to store the original window size, the window manager will do that for us.
Signed-off-by Gerd Hoffmann <[email protected]>--- ui/sdl2.c | 172 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 79 insertions(+), 93 deletions(-)ui/sdl2.c +0
-0
[snip]
ui/sdl2.c static struct sdl2_console *get_scon_from_window(uint32_t window_id) · line 126
Quoted 8 lines
static void sdl_switch(DisplayChangeListener *dcl, DisplaySurface *new_surface) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);ui/sdl2.c +1
-2-int format =0 ; -int idx = scon->idx;DisplaySurface *old_surface = scon->surface; +int format =0 ;
Moving "format" seems unnecessary, but of course it doesn't matter.
PATCH 7/10 sdl2: move sdl_switch to sdl2-2d.c
In reply to Gerd HoffmannMove sdl_switch to sdl2-2d.c file, rename to sdl2_2d_switch.
--- include/ui/sdl2.h | 6 ++++++ ui/sdl2-2d.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 50 ++++---------------------------------------------- 3 files changed, 52 insertions(+), 46 deletions(-)
include/ui/sdl2.h +6 -0
@@ -10,9 +10,15 @@ struct sdl2_console {int hidden; }; +void sdl2_window_create (struct sdl2_console *scon); +void sdl2_window_destroy (struct sdl2_console *scon); +void sdl2_window_resize (struct sdl2_console *scon); +void sdl2_reset_keys (struct sdl2_console *scon);void sdl2_process_key (struct sdl2_console *scon,SDL_KeyboardEvent *ev);void sdl2_2d_update (DisplayChangeListener *dcl,int x,int y,int w,int h); +void sdl2_2d_switch (DisplayChangeListener *dcl, +DisplaySurface *new_surface);
ui/sdl2-2d.c +42 -0
45 lines not on this page · raw message
ui/sdl2.c +4 -46
80 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 07/10] sdl2: move sdl_switch to sdl2-2d.c
Quoted 8 lines · Gerd Hoffmann
Move
sdl_switchtosdl2-2d.cfile, rename tosdl2_2d_switch.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 6 ++++++ ui/sdl2-2d.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 50 ++++---------------------------------------------- 3 files changed, 52 insertions(+), 46 deletions(-)
PATCH 8/10 sdl2: add+use sdl2_2d_redraw function.
In reply to Gerd HoffmannAdd a new sdl2_2d_redraw function for a complete screen refresh, so we can stop using graphic_hw_invalidate for that. There is no need to bother console / gfx emulation code if we are just going to re-blit the screen after window resizes.
--- include/ui/sdl2.h | 1 + ui/sdl2-2d.c | 11 +++++++++++ ui/sdl2.c | 17 ++++++----------- 3 files changed, 18 insertions(+), 11 deletions(-)
include/ui/sdl2.h +1 -0
@@ -22,3 +22,4 @@ void sdl2_2d_update(DisplayChangeListener *dcl, int x, int y, int w, int h);void sdl2_2d_switch (DisplayChangeListener *dcl,DisplaySurface *new_surface); +void sdl2_2d_redraw (struct sdl2_console *scon);
ui/sdl2-2d.c +11 -0
@@ -100,4 +100,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,SDL_TEXTUREACCESS_STREAMING ,surface_width (new_surface), surface_height(new_surface)); +sdl2_2d_redraw (scon); +} + +void sdl2_2d_redraw (struct sdl2_console *scon) +{ +if (!scon->surface) { +return ; + } +sdl2_2d_update (&scon->dcl,0 ,0 , +surface_width (scon->surface), +surface_height (scon->surface)); }
ui/sdl2.c +6 -11
@@ -316,8 +316,7 @@ static void toggle_full_screen(struct sdl2_console *scon) }SDL_SetWindowFullscreen (scon->real_window,0 ); } -graphic_hw_invalidate (scon->dcl.con); -graphic_hw_update (scon->dcl.con); +sdl2_2d_redraw (scon); }static void handle_keydown (SDL_Event *ev)
@@ -365,8 +364,8 @@ static void handle_keydown(SDL_Event *ev)case SDL_SCANCODE_U :sdl2_window_destroy (scon);sdl2_window_create (scon); -graphic_hw_invalidate (scon->dcl.con); -graphic_hw_update (scon->dcl.con); +/* re-create texture */ +sdl2_2d_switch (&scon->dcl, scon->surface); gui_keysym =1 ;break ;#if 0
@@ -385,8 +384,7 @@ static void handle_keydown(SDL_Event *ev)fprintf (stderr,"%s: scale to %dx%d\n" , __func__, width, height);sdl_scale (scon, width, height); -graphic_hw_invalidate (NULL ); -graphic_hw_update (NULL ); +sdl2_2d_redraw (scon); gui_keysym = 1; }#endif
@@ -511,7 +509,6 @@ static void handle_mousewheel(SDL_Event *ev)static void handle_windowevent (DisplayChangeListener *dcl,SDL_Event *ev) { -int w, h;struct sdl2_console *scon =get_scon_from_window (ev->key.windowID);switch (ev->window.event) {
@@ -523,12 +520,10 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev) info.height = ev->window.data2;dpy_set_ui_info (scon->dcl.con, &info); } -graphic_hw_invalidate (scon->dcl.con); -graphic_hw_update (scon->dcl.con); +sdl2_2d_redraw (scon);break ;case SDL_WINDOWEVENT_EXPOSED : -SDL_GetWindowSize (SDL_GetWindowFromID (ev->window.windowID), &w, &h); -sdl2_2d_update (dcl,0 ,0 , w, h); +sdl2_2d_redraw (scon);break ;case SDL_WINDOWEVENT_FOCUS_GAINED :case SDL_WINDOWEVENT_ENTER :
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 08/10] sdl2: add+use sdl2_2d_redraw function.
Quoted 11 lines · Gerd Hoffmann
Add a new
sdl2_2d_redrawfunction for a complete screen refresh, so we can stop usinggraphic_hw_invalidatefor that. There is no need to bother console / gfx emulation code if we are just going to re-blit the screen after window resizes.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 1 + ui/sdl2-2d.c | 11 +++++++++++ ui/sdl2.c | 17 ++++++----------- 3 files changed, 18 insertions(+), 11 deletions(-)
PATCH 9/10 sdl2: factor out sdl2_poll_events
In reply to Gerd HoffmannCreate a new function to poll and handle sdl2 events, which is then just called from the refresh timer.
--- include/ui/sdl2.h | 1 + ui/sdl2.c | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-)
include/ui/sdl2.h +1 -0
@@ -13,6 +13,7 @@ struct sdl2_console {void sdl2_window_create (struct sdl2_console *scon);void sdl2_window_destroy (struct sdl2_console *scon);void sdl2_window_resize (struct sdl2_console *scon); +void sdl2_poll_events (struct sdl2_console *scon);void sdl2_reset_keys (struct sdl2_console *scon); void sdl2_process_key(struct sdl2_console *scon,
ui/sdl2.c +13 -10
@@ -507,10 +507,8 @@ static void handle_mousewheel(SDL_Event *ev)qemu_input_event_sync (); } -static void handle_windowevent (DisplayChangeListener *dcl,SDL_Event *ev) +static void handle_windowevent (struct sdl2_console *scon,SDL_Event *ev) { -struct sdl2_console *scon =get_scon_from_window (ev->key.windowID); -switch (ev->window.event) {case SDL_WINDOWEVENT_RESIZED : {
@@ -537,10 +535,10 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev) }break ;case SDL_WINDOWEVENT_RESTORED : -update_displaychangelistener (dcl,GUI_REFRESH_INTERVAL_DEFAULT ); +update_displaychangelistener (&scon->dcl,GUI_REFRESH_INTERVAL_DEFAULT );break ;case SDL_WINDOWEVENT_MINIMIZED : -update_displaychangelistener (dcl,500 ); +update_displaychangelistener (&scon->dcl,500 );break ;case SDL_WINDOWEVENT_CLOSE :if (!no_quit) {
@@ -551,9 +549,8 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev) } } -static void sdl_refresh (DisplayChangeListener *dcl) +void sdl2_poll_events (struct sdl2_console *scon) { - struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);SDL_Event ev1, *ev = &ev1;if (scon->last_vm_running !=runstate_is_running ()) {
@@ -561,8 +558,6 @@ static void sdl_refresh(DisplayChangeListener *dcl)sdl_update_caption (scon); } -graphic_hw_update (dcl->con); -while (SDL_PollEvent (ev)) {switch (ev->type) {case SDL_KEYDOWN :
@@ -591,7 +586,7 @@ static void sdl_refresh(DisplayChangeListener *dcl)handle_mousewheel (ev);break ;case SDL_WINDOWEVENT : -handle_windowevent (dcl, ev); +handle_windowevent (scon, ev);break ;default :break ;
@@ -599,6 +594,14 @@ static void sdl_refresh(DisplayChangeListener *dcl) } } +static void sdl_refresh (DisplayChangeListener *dcl) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); + +graphic_hw_update (dcl->con); +sdl2_poll_events (scon); +} +static void sdl_mouse_warp (DisplayChangeListener *dcl,int x,int y,int on) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 09/10] sdl2: factor out sdl2_poll_events
Quoted 8 lines · Gerd Hoffmann
Create a new function to poll and handle sdl2 events, which is then just called from the refresh timer.
Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 1 + ui/sdl2.c | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-)
PATCH 10/10 sdl2: move sdl2_2d_refresh to sdl2-2d.c
In reply to Gerd HoffmannNow that common event handling code is split off, we can move over sdl_refresh to sdl2-2d.c, and rename it to sdl2_2d_refresh.
--- include/ui/sdl2.h | 1 + ui/sdl2-2d.c | 9 +++++++++ ui/sdl2.c | 10 +--------- 3 files changed, 11 insertions(+), 9 deletions(-)
include/ui/sdl2.h +1 -0
@@ -23,4 +23,5 @@ void sdl2_2d_update(DisplayChangeListener *dcl, int x, int y, int w, int h);void sdl2_2d_switch (DisplayChangeListener *dcl,DisplaySurface *new_surface); +void sdl2_2d_refresh (DisplayChangeListener *dcl);void sdl2_2d_redraw (struct sdl2_console *scon);
ui/sdl2-2d.c +9 -0
@@ -103,6 +103,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,sdl2_2d_redraw (scon); } +void sdl2_2d_refresh (DisplayChangeListener *dcl) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); + +assert (!scon->opengl); +graphic_hw_update (dcl->con); +sdl2_poll_events (scon); +} +void sdl2_2d_redraw (struct sdl2_console *scon) {if (!scon->surface) {
ui/sdl2.c +1 -9
@@ -594,14 +594,6 @@ void sdl2_poll_events(struct sdl2_console *scon) } } -static void sdl_refresh (DisplayChangeListener *dcl) -{ - struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); - -graphic_hw_update (dcl->con); -sdl2_poll_events (scon); -} -static void sdl_mouse_warp (DisplayChangeListener *dcl,int x,int y,int on) {
@@ -667,7 +659,7 @@ static const DisplayChangeListenerOps dcl_2d_ops = { .dpy_name = "sdl2-2d", .dpy_gfx_update = sdl2_2d_update, .dpy_gfx_switch = sdl2_2d_switch, - .dpy_refresh = sdl_refresh, + .dpy_refresh = sdl2_2d_refresh, .dpy_mouse_set = sdl_mouse_warp, .dpy_cursor_define = sdl_mouse_define, };
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/10] sdl2: move sdl2_2d_refresh to sdl2-2d.c
Quoted 25 lines · Gerd Hoffmann
Now that common event handling code is split off, we can move over
sdl_refreshtosdl2-2d.c, and rename it tosdl2_2d_refresh.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 1 + ui/sdl2-2d.c | 9 +++++++++ ui/sdl2.c | 10 +--------- 3 files changed, 11 insertions(+), 9 deletions(-)include/ui/sdl2.h +1
-0@@ -23,4 +23,5 @@ void sdl2_2d_update(DisplayChangeListener *dcl, int x, int y, int w, int h);void sdl2_2d_switch (DisplayChangeListener *dcl,DisplaySurface *new_surface); +void sdl2_2d_refresh (DisplayChangeListener *dcl);void sdl2_2d_redraw (struct sdl2_console *scon);ui/sdl2-2d.c +0
-0
ui/sdl2-2d.c void sdl2_2d_switch(DisplayChangeListener *dcl, · line 110
Quoted 8 lines
ui/sdl2-2d.c +5
-0@@ -103,6 +103,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,sdl2_2d_redraw (scon); } +void sdl2_2d_refresh (DisplayChangeListener *dcl) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); + +assert (!scon->opengl);
This doesn't compile for me because this flag is not added by this series.
With this assertion moved to the OpenGL series:
Re: [Qemu-devel] [PATCH 10/10] sdl2: move sdl2_2d_refresh to sdl2-2d.c
Quoted 29 lines · Max Reitz
Quoted 28 lines · Gerd Hoffmann
Now that common event handling code is split off, we can move over
sdl_refreshtosdl2-2d.c, and rename it tosdl2_2d_refresh.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 1 + ui/sdl2-2d.c | 9 +++++++++ ui/sdl2.c | 10 +--------- 3 files changed, 11 insertions(+), 9 deletions(-)include/ui/sdl2.h +1
-0@@ -23,4 +23,5 @@ void sdl2_2d_update(DisplayChangeListener *dcl, int x, int y, int w, int h);void sdl2_2d_switch (DisplayChangeListener *dcl,DisplaySurface *new_surface); +void sdl2_2d_refresh (DisplayChangeListener *dcl);void sdl2_2d_redraw (struct sdl2_console *scon);ui/sdl2-2d.c +0
-0@@ -103,6 +103,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,sdl2_2d_redraw (scon); }
Quoted 7 lines
ui/sdl2-2d.c void sdl2_2d_switch(DisplayChangeListener *dcl, · line 110
Quoted 5 lines
ui/sdl2-2d.c +5
-0+void sdl2_2d_refresh (DisplayChangeListener *dcl) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); + +assert (!scon->opengl);This doesn't compile for me because this flag is not added by this series.
Fixed.
cheers,
Gerd