35
#include "qemu/log.h"
36
#include "qemu-main.h"
37
38
+#ifdef CONFIG_X11
39
+#include <X11/Xlib.h>
40
+#endif
41
+
42
static int sdl2_num_outputs;
43
static struct sdl2_console *sdl2_console;
44
124
/* The SDL renderer is only used by sdl2-2D, when OpenGL is disabled */
125
scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
126
}
127
+
128
+#ifdef CONFIG_OPENGL
129
+ qemu_egl_display = eglGetCurrentDisplay();
130
+#endif
131
+
132
sdl_update_caption(scon);
133
}
134
817
.dpy_gl_scanout_disable = sdl2_gl_scanout_disable,
818
.dpy_gl_scanout_texture = sdl2_gl_scanout_texture,
819
.dpy_gl_update = sdl2_gl_scanout_flush,
820
+
821
+#ifdef CONFIG_GBM
822
+ .dpy_gl_scanout_dmabuf = sdl2_gl_scanout_dmabuf,
823
+ .dpy_gl_release_dmabuf = sdl2_gl_release_dmabuf,
824
+ .dpy_has_dmabuf = sdl2_gl_has_dmabuf,
825
+#endif
826
};
827
828
static bool
850
}
851
}
852
853
+static void sdl2_set_hint_x11_force_egl(void)
854
+{
855
+#if defined(SDL_HINT_VIDEO_X11_FORCE_EGL) && defined(CONFIG_OPENGL) && \
856
+ defined(CONFIG_X11)
857
+ Display *x_disp = XOpenDisplay(NULL);
858
+ EGLDisplay egl_display;
859
+
860
+ if (!x_disp) {
861
+ return;
862
+ }
863
+
864
+ /* Prefer EGL over GLX to get dma-buf support. */
865
+ egl_display = eglGetDisplay((EGLNativeDisplayType)x_disp);
866
+
867
+ if (egl_display != EGL_NO_DISPLAY) {
868
+ /*
869
+ * Setting X11_FORCE_EGL hint doesn't make SDL to prefer X11 over
870
+ * Wayland. SDL will use Wayland driver even if XWayland presents.
871
+ * It's always safe to set the hint even if X11 is not used by SDL.
872
+ * SDL will work regardless of the hint.
873
+ */
874
+ SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
875
+ eglTerminate(egl_display);
876
+ }
877
+
878
+ XCloseDisplay(x_disp);
879
+#endif
880
+}
881
+
882
static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
883
{
884
uint8_t data = 0;
906
SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0");
907
#endif
908
SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1");
909
+ sdl2_set_hint_x11_force_egl();
910
SDL_EnableScreenSaver();
911
memset(&info, 0, sizeof(info));
912
SDL_VERSION(&info.version);
951
#endif
952
sdl2_console[i].dcl.con = con;
953
sdl2_console[i].kbd = qkbd_state_init(con);
954
+#ifdef CONFIG_OPENGL
955
if (display_opengl) {
956
qemu_console_set_display_gl_ctx(con, &sdl2_console[i].dgc);
957
+ sdl2_gl_console_init(&sdl2_console[i]);
958
}
959
+#endif
960
register_displaychangelistener(&sdl2_console[i].dcl);
961
962
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11)