gdk: Make GDK_DEBUG GL backend selection global
authorBenjamin Otte <otte@redhat.com>
Sat, 2 Oct 2021 03:21:29 +0000 (05:21 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 5 Oct 2021 02:48:15 +0000 (04:48 +0200)
We have a global GdkGLBackendType now, just set it.

This way, using the variable forces the backend type, and we don't need
special code handling the env vars in the backends.

It also means setting the env var will now "work" on GDK backends that
don't even support that GL backend and simualte another GDK backend
having registered that GL backend already. So you can run
  GDK_DEBUG=gl-wgl gtk4-demo
on test what Wayland will do when WGL is in use.

gdk/gdk.c
gdk/win32/gdkdisplay-win32.c
gdk/x11/gdkdisplay-x11.c

index cd8c0bdcc8f0e007757daa5a49d61e78809c9253..8f0cbbb3bbf45dbb4fbfe5b534fa27d2b68b12ff 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -31,6 +31,7 @@
 #include "gdkconstructor.h"
 #include "gdkdebug.h"
 #include "gdkdisplay.h"
+#include "gdkglcontextprivate.h"
 #include "gdkintl.h"
 #include "gdk-private.h"
 
@@ -294,6 +295,14 @@ gdk_pre_parse (void)
                                           gdk_debug_keys,
                                           G_N_ELEMENTS (gdk_debug_keys));
 
+  /* These are global */
+  if (GDK_DEBUG_CHECK (GL_EGL))
+    gdk_gl_backend_use (GDK_GL_EGL);
+  else if (GDK_DEBUG_CHECK (GL_GLX))
+    gdk_gl_backend_use (GDK_GL_GLX);
+  else if (GDK_DEBUG_CHECK (GL_WGL))
+    gdk_gl_backend_use (GDK_GL_WGL);
+
 #ifndef G_HAS_CONSTRUCTORS
   stash_desktop_startup_notification_id ();
 #endif
index 323ef8a7d8b6ef5de8501ae1fe92e2e5b9f8ca78..5495f0f6afdbd482611d76b0ffba653c4b5bf819 100644 (file)
@@ -1152,13 +1152,6 @@ gdk_win32_display_init_gl_backend (GdkDisplay  *display,
 {
   gboolean result = FALSE;
 
-#ifdef GDK_WIN32_ENABLE_EGL
-  if (GDK_DISPLAY_DEBUG_CHECK (display, GL_EGL))
-    return gdk_win32_display_init_egl (display, error);
-#endif
-  if (GDK_DISPLAY_DEBUG_CHECK (display, GL_WGL))
-    return gdk_win32_display_init_wgl (display, error);
-
   /* No env vars set, do the regular GL initialization, first WGL and then EGL,
    * as WGL is the more tried-and-tested configuration.
    */
index 6e5fd276f7cca6bd70666fc209b38e141134a5ac..2e4273db8f7bcbcd44b6250ff696fc408d36490c 100644 (file)
@@ -2893,11 +2893,6 @@ gdk_x11_display_init_gl_backend (GdkX11Display  *self,
 {
   GdkDisplay *display G_GNUC_UNUSED = GDK_DISPLAY (self);
 
-  if (GDK_DISPLAY_DEBUG_CHECK (display, GL_EGL))
-    return gdk_x11_display_init_egl (self, TRUE, out_visual, out_depth, error);
-  if (GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX))
-    return gdk_x11_display_init_glx (self, out_visual, out_depth, error);
-
   /* No env vars set, do the regular GL initialization.
    * 
    * We try EGL first, but are very picky about what we accept.