GLX: Add extra glXMakeContextCurrent () call to work around a DRI issue
authorLuca Bacci <luca.bacci982@gmail.com>
Thu, 1 Dec 2022 17:18:23 +0000 (18:18 +0100)
committerLuca Bacci <luca.bacci982@gmail.com>
Fri, 2 Dec 2022 13:20:43 +0000 (14:20 +0100)
Reference: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7808

Fixes #4499, #5387, #5170

gdk/x11/gdkglcontext-glx.c

index 229fe4afaf244917078b30c472a4487ae45f6ba8..6be6eb7e16dea5ceba3153f93a13e85bc2cd7d26 100644 (file)
@@ -232,6 +232,12 @@ gdk_x11_gl_context_glx_make_current (GdkGLContext *context,
                      "Making GLX context %p current to drawable %lu",
                      context, (unsigned long) drawable);
 
+  /* Work around a glitch, see
+   * https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5281
+   */
+  if (glXGetCurrentContext () != self->glx_context)
+    glXMakeContextCurrent (dpy, None, None, NULL);
+
   if (!glXMakeContextCurrent (dpy, drawable, drawable, self->glx_context))
     return FALSE;