ui/gdk: Restore original context after new context creation
Get currently bound GL context when creating new GL context and restore it after the creation for consistency with behavior expected by virglrenderer that assumes context-creation doesn't switch context. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Message-ID: <20260303151422.977399-5-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-7-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Dmitry Osipenko committed
Mar 4, 2026 at 16:50 UTC
47ab60066835fb324f35f13dc717c9f33f864185
1 file changed
+9
-3
ui/gtk-gl-area.c
+9
-3
@@ -250,11 +250,13 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
250
QEMUGLParams *params)
251
{
252
VirtualConsole *vc = container_of(dgc, VirtualConsole, gfx.dgc);
253
+ GdkGLContext *ctx, *current_ctx;
254
GdkWindow *window;
254
- GdkGLContext *ctx;
255
GError *err = NULL;
256
int major, minor;
257
258
+ current_ctx = gdk_gl_context_get_current();
259
+
260
window = gtk_widget_get_window(vc->gfx.drawing_area);
261
ctx = gdk_window_create_gl_context(window, &err);
262
if (err) {
@@ -275,8 +277,12 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
277
278
gdk_gl_context_make_current(ctx);
279
gdk_gl_context_get_version(ctx, &major, &minor);
278
- gdk_gl_context_clear_current();
279
- gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
280
+
281
+ if (current_ctx) {
282
+ gdk_gl_context_make_current(current_ctx);
283
+ } else {
284
+ gdk_gl_context_clear_current();
285
+ }
286
287
if (gd_cmp_gl_context_version(major, minor, params) == -1) {
288
/* created ctx version < requested version */