blob: 852dc9dfcd38c99e32665241a36671bbd04fe527 [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001From d11b41a7ff0234f3832d6aabdf498807d1463c18 Mon Sep 17 00:00:00 2001
Patrick Williamsc0f7c042017-02-23 20:41:17 -06002From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3Date: Tue, 21 Jun 2016 15:11:39 +0300
Brad Bishop19323692019-04-05 15:28:33 -04004Subject: [PATCH] Add --disable-opengl configure option
Patrick Williamsc0f7c042017-02-23 20:41:17 -06005
6--disable-opengl will remove the dependency on libepoxy and on the
7OpenGL APIs. This is useful for those who want to keep using gtk+3
8without the "opengl" distro feature.
9
10GtkGLArea is still part of the API (it just doesn't work) even when
11OpenGL is disabled. GdkX11GLContext was removed from the Gtk API
12completely: that object exposes GL API elements so it had to be at
13the very least modified.
14
15The patch is _not_ great from a maintenance point of view and
16modifying the library API is also a fairly nasty thing to do.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017Next long term release (4.0) will require alternative solutions
18as it actually will depend on OpenGL.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019
20Upstream-Status: Inappropriate [Evil eye expected from upstream]
21Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040022
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023---
Brad Bishop19323692019-04-05 15:28:33 -040024 configure.ac | 13 ++++-
25 demos/gtk-demo/glarea.c | 14 ++++++
26 docs/tools/Makefile.am | 9 +++-
27 docs/tools/widgets.c | 4 +-
Brad Bishop15ae2502019-06-18 21:44:24 -040028 gdk/Makefile.am | 8 ++-
Brad Bishop19323692019-04-05 15:28:33 -040029 gdk/gdkdisplay.c | 4 +-
30 gdk/gdkgl.c | 10 ++++
31 gdk/gdkglcontext.c | 6 +++
32 gdk/gdkwindow.c | 13 +++++
33 gdk/x11/Makefile.am | 30 +++++++++--
34 gdk/x11/gdkdisplay-x11.c | 6 ++-
35 gdk/x11/gdkscreen-x11.c | 5 ++
36 gdk/x11/gdkwindow-x11.c | 4 ++
37 gdk/x11/gdkx-autocleanups.h | 2 +
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 gdk/x11/{gdkx.h => gdkx-with-gl-context.h} | 1 -
Brad Bishop19323692019-04-05 15:28:33 -040039 gdk/x11/gdkx-without-gl-context.h | 58 ++++++++++++++++++++++
Brad Bishop316dfdd2018-06-25 12:45:53 -040040 gtk/Makefile.am | 3 +-
Brad Bishop19323692019-04-05 15:28:33 -040041 gtk/gtkglarea.c | 20 +++++++-
42 gtk/inspector/general.c | 6 +++
43 tests/Makefile.am | 10 ++--
44 testsuite/gtk/objects-finalize.c | 2 +
Brad Bishop15ae2502019-06-18 21:44:24 -040045 21 files changed, 208 insertions(+), 20 deletions(-)
Brad Bishop316dfdd2018-06-25 12:45:53 -040046 rename gdk/x11/{gdkx.h => gdkx-with-gl-context.h} (98%)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047 create mode 100644 gdk/x11/gdkx-without-gl-context.h
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048
49diff --git a/configure.ac b/configure.ac
Brad Bishop15ae2502019-06-18 21:44:24 -040050index 2c4733b..18ae66c 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051--- a/configure.ac
52+++ b/configure.ac
Brad Bishop15ae2502019-06-18 21:44:24 -040053@@ -352,6 +352,15 @@ AC_ARG_ENABLE(cloudproviders,
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 [AS_HELP_STRING([--enable-cloudproviders],
55 [enable libcloudproviders integration])],
56 [cloudproviders_set=yes])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060057+AC_ARG_ENABLE(opengl,
58+ [AS_HELP_STRING([--enable-opengl],
59+ [When enabled, Gtk+ will use libepoxy and exposes GtkGLArea widget ])])
60+AS_IF([test "x$enable_opengl" != "xno"], [
61+ AC_DEFINE([HAVE_OPENGL], [1], [libepoxy and opengl APIs are available at buildtime])
62+ EPOXY_PACKAGES="epoxy >= epoxy_required_version"
63+])
64+AM_CONDITIONAL([HAVE_OPENGL],[test "x$enable_opengl" != "xno"])
65+
66 AC_ARG_ENABLE(glx,
67 [AS_HELP_STRING([--enable-glx],
68 [When enabled Gdk will try to initialize GLX])])
Brad Bishop15ae2502019-06-18 21:44:24 -040069@@ -1370,7 +1379,7 @@ CFLAGS="$saved_cflags"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060070 LDFLAGS="$saved_ldflags"
71
72 GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version"
Brad Bishop15ae2502019-06-18 21:44:24 -040073-GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES fribidi >= fribidi_required_version"
74+GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends $EPOXY_PACKAGES $CLOUDPROVIDER_PACKAGES fribidi >= fribidi_required_version"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075
76 PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
77 GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
Brad Bishop15ae2502019-06-18 21:44:24 -040078@@ -1404,7 +1413,7 @@ fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060079 PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
80
81 GTK_PACKAGES="atk >= atk_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version gdk-pixbuf-2.0 >= gdk_pixbuf_required_version gio-2.0 >= glib_required_version"
Brad Bishop15ae2502019-06-18 21:44:24 -040082-GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version"
83+GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $EPOXY_PACKAGES fribidi >= fribidi_required_version"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060084 if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then
85 GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
86 fi
87diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -050088index b51e4ae..82409c7 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -060089--- a/demos/gtk-demo/glarea.c
90+++ b/demos/gtk-demo/glarea.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -050091@@ -3,9 +3,12 @@
92 * GtkGLArea is a widget that allows custom drawing using OpenGL calls.
93 */
Patrick Williamsc0f7c042017-02-23 20:41:17 -060094
Brad Bishop6e60e8b2018-02-01 10:27:11 -050095+#include "config.h"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060096 #include <math.h>
97 #include <gtk/gtk.h>
98+#if HAVE_OPENGL
99 #include <epoxy/gl.h>
100+#endif
101
102 static GtkWidget *demo_window = NULL;
103
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500104@@ -23,6 +26,8 @@ enum {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600105 /* Rotation angles on each axis */
106 static float rotation_angles[N_AXIS] = { 0.0 };
107
108+#ifdef HAVE_OPENGL
109+
110 /* The object we are drawing */
111 static const GLfloat vertex_data[] = {
112 0.f, 0.5f, 0.f, 1.f,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113@@ -215,6 +220,7 @@ compute_mvp (float *res,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600114 static GLuint position_buffer;
115 static GLuint program;
116 static GLuint mvp_location;
117+#endif
118
119 /* We need to set up our state when we realize the GtkGLArea widget */
120 static void
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500121@@ -241,8 +247,10 @@ realize (GtkWidget *widget)
122 fragment_path = "/glarea/glarea-gl.fs.glsl";
123 }
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600124
125+#ifdef HAVE_OPENGL
126 init_buffers (&position_buffer, NULL);
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 init_shaders (vertex_path, fragment_path, &program, &mvp_location);
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600128+#endif
129 }
130
131 /* We should tear down the state when unrealizing */
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500132@@ -254,10 +262,13 @@ unrealize (GtkWidget *widget)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600133 if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
134 return;
135
136+#ifdef HAVE_OPENGL
137 glDeleteBuffers (1, &position_buffer);
138 glDeleteProgram (program);
139+#endif
140 }
141
142+#ifdef HAVE_OPENGL
143 static void
144 draw_triangle (void)
145 {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500146@@ -290,6 +301,7 @@ draw_triangle (void)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600147 glBindBuffer (GL_ARRAY_BUFFER, 0);
148 glUseProgram (0);
149 }
150+#endif
151
152 static gboolean
153 render (GtkGLArea *area,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154@@ -298,6 +310,7 @@ render (GtkGLArea *area,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600155 if (gtk_gl_area_get_error (area) != NULL)
156 return FALSE;
157
158+#ifdef HAVE_OPENGL
159 /* Clear the viewport */
160 glClearColor (0.5, 0.5, 0.5, 1.0);
161 glClear (GL_COLOR_BUFFER_BIT);
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500162@@ -307,6 +320,7 @@ render (GtkGLArea *area,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600163
164 /* Flush the contents of the pipeline */
165 glFlush ();
166+#endif
167
168 return TRUE;
169 }
170diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am
171index 6a6d70f..5cdf312 100644
172--- a/docs/tools/Makefile.am
173+++ b/docs/tools/Makefile.am
174@@ -9,13 +9,18 @@ AM_CPPFLAGS = \
175 $(GTK_DEBUG_FLAGS) \
176 $(GTK_DEP_CFLAGS)
177
178+if HAVE_OPENGL
179+GEARS_LDADD = $(top_builddir)/tests/gtkgears.o
180+endif
181+
182 DEPS = \
183- $(top_builddir)/gtk/libgtk-3.la
184+ $(top_builddir)/gtk/libgtk-3.la \
185+ $(GEARS_LDADD)
186
187 LDADDS = \
188 $(top_builddir)/gtk/libgtk-3.la \
189 $(top_builddir)/gdk/libgdk-3.la \
190- $(top_builddir)/tests/gtkgears.o \
191+ $(GEARS_LDADD) \
192 $(GTK_DEP_LIBS) \
193 $(GDK_DEP_LIBS) \
194 -lm
195diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
196index 932daf1..54239d6 100644
197--- a/docs/tools/widgets.c
198+++ b/docs/tools/widgets.c
199@@ -1526,9 +1526,11 @@ create_gl_area (void)
200 widget = gtk_frame_new (NULL);
201 gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
202
203+#ifdef HAVE_OPENGL
204 gears = gtk_gears_new ();
205 gtk_container_add (GTK_CONTAINER (widget), gears);
206-
207+#endif
208+
209 info = new_widget_info ("glarea", widget, MEDIUM);
210
211 return info;
Brad Bishop15ae2502019-06-18 21:44:24 -0400212diff --git a/gdk/Makefile.am b/gdk/Makefile.am
213index 689ee52..d6b4e70 100644
214--- a/gdk/Makefile.am
215+++ b/gdk/Makefile.am
216@@ -274,7 +274,6 @@ x11_introspection_files = \
217 x11/gdkeventsource.c \
218 x11/gdkeventtranslator.c \
219 x11/gdkgeometry-x11.c \
220- x11/gdkglcontext-x11.c \
221 x11/gdkkeys-x11.c \
222 x11/gdkmain-x11.c \
223 x11/gdkmonitor-x11.c \
224@@ -300,7 +299,6 @@ x11_introspection_files = \
225 x11/gdkx11display.h \
226 x11/gdkx11displaymanager.h \
227 x11/gdkx11dnd.h \
228- x11/gdkx11glcontext.h \
229 x11/gdkx11keys.h \
230 x11/gdkx11monitor.h \
231 x11/gdkx11property.h \
232@@ -310,6 +308,12 @@ x11_introspection_files = \
233 x11/gdkx11visual.h \
234 x11/gdkx11window.h
235
236+if HAVE_OPENGL
237+x11_introspection_files += \
238+ x11/gdkglcontext-x11.c \
239+ x11/gdkx11glcontext.h
240+endif
241+
242 GdkX11-3.0.gir: libgdk-3.la Gdk-3.0.gir Makefile
243 GdkX11_3_0_gir_SCANNERFLAGS = \
244 --identifier-prefix=Gdk \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600245diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400246index 06d4187..832711c 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600247--- a/gdk/gdkdisplay.c
248+++ b/gdk/gdkdisplay.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400249@@ -2416,7 +2416,9 @@ gboolean
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600250 gdk_display_make_gl_context_current (GdkDisplay *display,
251 GdkGLContext *context)
252 {
253- return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
254+ if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current)
255+ return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
256+ return FALSE;
257 }
258
259 GdkRenderingMode
260diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
Brad Bishop19323692019-04-05 15:28:33 -0400261index 933e204..1767508 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600262--- a/gdk/gdkgl.c
263+++ b/gdk/gdkgl.c
Brad Bishop19323692019-04-05 15:28:33 -0400264@@ -26,7 +26,9 @@
265 # include "win32/gdkwin32.h"
266 #endif
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600267
268+#ifdef HAVE_OPENGL
269 #include <epoxy/gl.h>
270+#endif
271 #include <math.h>
272 #include <string.h>
273
Brad Bishop19323692019-04-05 15:28:33 -0400274@@ -40,6 +42,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600275 g_object_ref (window), g_object_unref);
276 }
277
278+#ifdef HAVE_OPENGL
279 static const char *
280 get_vertex_type_name (int type)
281 {
Brad Bishop19323692019-04-05 15:28:33 -0400282@@ -212,6 +215,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600283 glUseProgram (paint_data->current_program->program);
284 }
285 }
286+#endif
287
288 void
289 gdk_gl_texture_quads (GdkGLContext *paint_context,
Brad Bishop19323692019-04-05 15:28:33 -0400290@@ -220,6 +224,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500291 GdkTexturedQuad *quads,
292 gboolean flip_colors)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600293 {
294+#ifdef HAVE_OPENGL
295 GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
296 GdkGLContextProgram *program;
297 GdkWindow *window = gdk_gl_context_get_window (paint_context);
Brad Bishop19323692019-04-05 15:28:33 -0400298@@ -293,6 +298,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600299
300 glDisableVertexAttribArray (program->position_location);
301 glDisableVertexAttribArray (program->uv_location);
302+#endif
303 }
304
305 /* x,y,width,height describes a rectangle in the gl render buffer
Brad Bishop19323692019-04-05 15:28:33 -0400306@@ -341,6 +347,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600307 int width,
308 int height)
309 {
310+#ifdef HAVE_OPENGL
311 GdkGLContext *paint_context;
312 cairo_surface_t *image;
313 cairo_matrix_t matrix;
Brad Bishop19323692019-04-05 15:28:33 -0400314@@ -718,6 +725,7 @@ out:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600315 if (clip_region)
316 cairo_region_destroy (clip_region);
317
318+#endif
319 }
320
321 /* This is always called with the paint context current */
Brad Bishop19323692019-04-05 15:28:33 -0400322@@ -725,6 +733,7 @@ void
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600323 gdk_gl_texture_from_surface (cairo_surface_t *surface,
324 cairo_region_t *region)
325 {
326+#ifdef HAVE_OPENGL
327 GdkGLContext *paint_context;
328 cairo_surface_t *image;
329 double device_x_offset, device_y_offset;
Brad Bishop19323692019-04-05 15:28:33 -0400330@@ -825,4 +834,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600331
332 glDisable (GL_SCISSOR_TEST);
333 glDeleteTextures (1, &texture_id);
334+#endif
335 }
336diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
Brad Bishop19323692019-04-05 15:28:33 -0400337index dfbed63..556f0a3 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600338--- a/gdk/gdkglcontext.c
339+++ b/gdk/gdkglcontext.c
340@@ -85,7 +85,9 @@
341 #include "gdkintl.h"
342 #include "gdk-private.h"
343
344+#ifdef HAVE_OPENGL
345 #include <epoxy/gl.h>
346+#endif
347
348 typedef struct {
349 GdkDisplay *display;
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500350@@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600351 int height,
352 guint texture_target)
353 {
354+#ifdef HAVE_OPENGL
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500355 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600356
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500357 g_return_if_fail (GDK_IS_GL_CONTEXT (context));
358@@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
359 glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride));
360 }
361 }
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600362+#endif
363 }
364
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500365 static gboolean
366@@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600367 static void
368 gdk_gl_context_check_extensions (GdkGLContext *context)
369 {
370+#ifdef HAVE_OPENGL
371 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
372 gboolean has_npot, has_texture_rectangle;
373
Brad Bishop19323692019-04-05 15:28:33 -0400374@@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600375 priv->use_texture_rectangle ? "yes" : "no"));
376
377 priv->extensions_checked = TRUE;
378+#endif
379 }
380
381 /**
382diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400383index 1416409..e3b5630 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600384--- a/gdk/gdkwindow.c
385+++ b/gdk/gdkwindow.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500386@@ -45,7 +45,9 @@
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600387
388 #include <math.h>
389
390+#ifdef HAVE_OPENGL
391 #include <epoxy/gl.h>
392+#endif
393
394 /* for the use of round() */
395 #include "fallback-c89.c"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400396@@ -2822,6 +2824,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600397 {
398 GError *internal_error = NULL;
399
400+#ifndef HAVE_OPENGL
401+ g_set_error_literal (error, GDK_GL_ERROR,
402+ GDK_GL_ERROR_NOT_AVAILABLE,
403+ _("GL support disabled with --disable-opengl"));
404+ return NULL;
405+#endif
406+
407 if (_gdk_gl_flags & GDK_GL_DISABLE)
408 {
409 g_set_error_literal (error, GDK_GL_ERROR,
Brad Bishop316dfdd2018-06-25 12:45:53 -0400410@@ -2957,6 +2966,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600411 }
412 else
413 {
414+#ifdef HAVE_OPENGL
415 gdk_gl_context_make_current (context);
416 /* With gl we always need a surface to combine the gl
417 drawing with the native drawing. */
Brad Bishop316dfdd2018-06-25 12:45:53 -0400418@@ -2971,6 +2981,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600419 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
420
421 glViewport (0, 0, ww, wh);
422+#endif
423 }
424 }
425
Brad Bishop316dfdd2018-06-25 12:45:53 -0400426@@ -3034,6 +3045,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600427
428 gdk_gl_context_make_current (window->gl_paint_context);
429
430+#ifdef HAVE_OPENGL
431 if (!cairo_region_is_empty (opaque_region))
432 gdk_gl_texture_from_surface (window->current_paint.surface,
433 opaque_region);
Brad Bishop316dfdd2018-06-25 12:45:53 -0400434@@ -3044,6 +3056,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600435 window->current_paint.need_blend_region);
436 glDisable(GL_BLEND);
437 }
438+#endif
439
440 cairo_region_destroy (opaque_region);
441
442diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500443index 6289f3a..cbbac79 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600444--- a/gdk/x11/Makefile.am
445+++ b/gdk/x11/Makefile.am
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500446@@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600447 gdkeventtranslator.c \
448 gdkeventtranslator.h \
449 gdkgeometry-x11.c \
450- gdkglcontext-x11.c \
451- gdkglcontext-x11.h \
452 gdkkeys-x11.c \
453 gdkmain-x11.c \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500454 gdkmonitor-x11.c \
455@@ -56,14 +54,32 @@ libgdk_x11_la_SOURCES = \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600456 gdkwindow-x11.h \
457 gdkxftdefaults.c \
458 gdkxid.c \
459- gdkx.h \
460 gdkprivate-x11.h \
461 xsettings-client.h \
462 xsettings-client.c
463
464+if HAVE_OPENGL
465+libgdk_x11_la_SOURCES += \
466+ gdkglcontext-x11.c \
467+ gdkglcontext-x11.h
468+endif
469+
470 libgdkinclude_HEADERS = \
471 gdkx.h
472
473+if HAVE_OPENGL
474+GDKX_HEADER = gdkx-with-gl-context.h
475+else
476+GDKX_HEADER = gdkx-without-gl-context.h
477+endif
478+
479+BUILT_SOURCES = gdkx.h
480+
481+.PHONY: gdkx.h
482+gdkx.h:
483+ $(AM_V_GEN) cd $(srcdir) \
484+ && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h )
485+
486 libgdkx11include_HEADERS = \
487 gdkx-autocleanups.h \
488 gdkx11applaunchcontext.h \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500489@@ -77,7 +93,6 @@ libgdkx11include_HEADERS = \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600490 gdkx11display.h \
491 gdkx11displaymanager.h \
492 gdkx11dnd.h \
493- gdkx11glcontext.h \
494 gdkx11keys.h \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500495 gdkx11monitor.h \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600496 gdkx11property.h \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500497@@ -87,9 +102,16 @@ libgdkx11include_HEADERS = \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600498 gdkx11visual.h \
499 gdkx11window.h
500
501+if HAVE_OPENGL
502+libgdkx11include_HEADERS += gdkx11glcontext.h
503+endif
504+
505 # We need to include all these C files here since the conditionals
506 # don't seem to be correctly expanded for the dist files.
507 EXTRA_DIST += \
508+ gdkx.h \
509 gdksettings.c
510
511+MAINTAINERCLEANFILES = gdkx.h
512+
513 -include $(top_srcdir)/git.mk
514diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400515index 5b95196..9a2f2a2 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600516--- a/gdk/x11/gdkdisplay-x11.c
517+++ b/gdk/x11/gdkdisplay-x11.c
518@@ -37,7 +37,9 @@
519 #include "gdkdisplay-x11.h"
520 #include "gdkprivate-x11.h"
521 #include "gdkscreen-x11.h"
522+#ifdef HAVE_OPENGL
523 #include "gdkglcontext-x11.h"
524+#endif
525 #include "gdk-private.h"
526
527 #include <glib.h>
Brad Bishop15ae2502019-06-18 21:44:24 -0400528@@ -3184,7 +3186,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600529 display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
530 display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
531
532- display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
533+#ifdef HAVE_OPENGL
534+ display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
535+#endif
536
537 display_class->get_default_seat = gdk_x11_display_get_default_seat;
538
539diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
Brad Bishop19323692019-04-05 15:28:33 -0400540index 272cecd..2bb34ac 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600541--- a/gdk/x11/gdkscreen-x11.c
542+++ b/gdk/x11/gdkscreen-x11.c
Brad Bishop19323692019-04-05 15:28:33 -0400543@@ -1675,3 +1675,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600544 {
545 return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP");
546 }
547+
548+#ifndef HAVE_OPENGL
549+/* Function from in gdk/x11/gdkglcontext-x11.c */
550+void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen) {}
551+#endif
552diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400553index f92a146..89f900a 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600554--- a/gdk/x11/gdkwindow-x11.c
555+++ b/gdk/x11/gdkwindow-x11.c
556@@ -36,7 +36,9 @@
557 #include "gdkasync.h"
558 #include "gdkeventsource.h"
559 #include "gdkdisplay-x11.h"
560+#ifdef HAVE_OPENGL
561 #include "gdkglcontext-x11.h"
562+#endif
563 #include "gdkprivate-x11.h"
564 #include "gdk-private.h"
565
Brad Bishop15ae2502019-06-18 21:44:24 -0400566@@ -5839,7 +5841,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600567 impl_class->set_opaque_region = gdk_x11_window_set_opaque_region;
568 impl_class->set_shadow_width = gdk_x11_window_set_shadow_width;
569 impl_class->show_window_menu = gdk_x11_window_show_window_menu;
570+#ifdef HAVE_OPENGL
571 impl_class->create_gl_context = gdk_x11_window_create_gl_context;
572 impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
573+#endif
574 impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
575 }
576diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h
577index edb0ea7..a317d61 100644
578--- a/gdk/x11/gdkx-autocleanups.h
579+++ b/gdk/x11/gdkx-autocleanups.h
580@@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref)
581 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref)
582 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref)
583 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref)
584+#ifdef HAVE_OPENGL
585 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref)
586+#endif
587 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref)
588 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref)
589 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400590diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx-with-gl-context.h
591similarity index 98%
592rename from gdk/x11/gdkx.h
593rename to gdk/x11/gdkx-with-gl-context.h
594index 1f64bcc..ae05fa6 100644
595--- a/gdk/x11/gdkx.h
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600596+++ b/gdk/x11/gdkx-with-gl-context.h
Brad Bishop316dfdd2018-06-25 12:45:53 -0400597@@ -45,7 +45,6 @@
598 #include <gdk/x11/gdkx11dnd.h>
599 #include <gdk/x11/gdkx11glcontext.h>
600 #include <gdk/x11/gdkx11keys.h>
601-#include <gdk/x11/gdkx11monitor.h>
602 #include <gdk/x11/gdkx11property.h>
603 #include <gdk/x11/gdkx11screen.h>
604 #include <gdk/x11/gdkx11selection.h>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600605diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h
606new file mode 100644
607index 0000000..c9e2617
608--- /dev/null
609+++ b/gdk/x11/gdkx-without-gl-context.h
610@@ -0,0 +1,58 @@
611+/* GDK - The GIMP Drawing Kit
612+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
613+ *
614+ * This library is free software; you can redistribute it and/or
615+ * modify it under the terms of the GNU Lesser General Public
616+ * License as published by the Free Software Foundation; either
617+ * version 2 of the License, or (at your option) any later version.
618+ *
619+ * This library is distributed in the hope that it will be useful,
620+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
621+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
622+ * Lesser General Public License for more details.
623+ *
624+ * You should have received a copy of the GNU Lesser General Public
625+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
626+ */
627+
628+/*
629+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
630+ * file for a list of people on the GTK+ Team. See the ChangeLog
631+ * files for a list of changes. These files are distributed with
632+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
633+ */
634+
635+#ifndef __GDK_X_H__
636+#define __GDK_X_H__
637+
638+#include <gdk/gdk.h>
639+
640+#include <X11/Xlib.h>
641+#include <X11/Xutil.h>
642+
643+#define __GDKX_H_INSIDE__
644+
645+#include <gdk/x11/gdkx11applaunchcontext.h>
646+#include <gdk/x11/gdkx11cursor.h>
647+#include <gdk/x11/gdkx11device.h>
648+#include <gdk/x11/gdkx11device-core.h>
649+#include <gdk/x11/gdkx11device-xi2.h>
650+#include <gdk/x11/gdkx11devicemanager.h>
651+#include <gdk/x11/gdkx11devicemanager-core.h>
652+#include <gdk/x11/gdkx11devicemanager-xi2.h>
653+#include <gdk/x11/gdkx11display.h>
654+#include <gdk/x11/gdkx11displaymanager.h>
655+#include <gdk/x11/gdkx11dnd.h>
656+#include <gdk/x11/gdkx11keys.h>
657+#include <gdk/x11/gdkx11property.h>
658+#include <gdk/x11/gdkx11screen.h>
659+#include <gdk/x11/gdkx11selection.h>
660+#include <gdk/x11/gdkx11utils.h>
661+#include <gdk/x11/gdkx11visual.h>
662+#include <gdk/x11/gdkx11window.h>
663+
664+#include <gdk/x11/gdkx-autocleanups.h>
665+
666+#undef __GDKX_H_INSIDE__
667+
668+#endif /* __GDK_X_H__ */
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600669diff --git a/gtk/Makefile.am b/gtk/Makefile.am
Brad Bishop15ae2502019-06-18 21:44:24 -0400670index e556e9d..ce912d7 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600671--- a/gtk/Makefile.am
672+++ b/gtk/Makefile.am
Brad Bishop15ae2502019-06-18 21:44:24 -0400673@@ -1441,7 +1441,6 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600674 && cp xgen-gptbc gtkprivatetypebuiltins.c \
675 && rm -f xgen-gptbc
676
677-
678 gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gtk/deprecated/*.h $(top_srcdir)/gdk/*.h Makefile
Brad Bishop15ae2502019-06-18 21:44:24 -0400679 $(AM_V_GEN) export LC_ALL=C ; \
680 (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtkx.h>') > xgen-gtfsrc.c && \
681@@ -1449,7 +1448,7 @@ gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_src
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600682 ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \
683 $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \
684 sort | uniq | \
685- $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \
686+ $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; s/^.*gdk_x11_gl.*$$/#ifdef HAVE_OPENGL\n&\n#endif/; }' >> xgen-gtf \
687 && cp xgen-gtf $@ && rm -f xgen-gtf
Brad Bishop19323692019-04-05 15:28:33 -0400688 $(srcdir)/gtktestutils.c: gtktypefuncs.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600689
690diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
Brad Bishop19323692019-04-05 15:28:33 -0400691index ea383c0..bb4eb64 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600692--- a/gtk/gtkglarea.c
693+++ b/gtk/gtkglarea.c
694@@ -28,7 +28,9 @@
695 #include "gtkprivate.h"
696 #include "gtkrender.h"
697
698+#ifdef HAVE_OPENGL
699 #include <epoxy/gl.h>
700+#endif
701
702 /**
703 * SECTION:gtkglarea
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500704@@ -368,9 +370,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600705 static void
706 gtk_gl_area_resize (GtkGLArea *area, int width, int height)
707 {
708+#ifdef HAVE_OPENGL
709 glViewport (0, 0, width, height);
710+#endif
711 }
712
713+#ifdef HAVE_OPENGL
714 /*
715 * Creates all the buffer objects needed for rendering the scene
716 */
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500717@@ -482,6 +487,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600718
719 priv->needs_render = TRUE;
720 }
721+#endif
722
723 /**
724 * gtk_gl_area_attach_buffers:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500725@@ -500,6 +506,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600726 void
727 gtk_gl_area_attach_buffers (GtkGLArea *area)
728 {
729+#ifdef HAVE_OPENGL
730 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
731
732 g_return_if_fail (GTK_IS_GL_AREA (area));
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500733@@ -532,11 +539,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600734 glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
735 GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer);
736 }
737+#endif
738 }
739
740 static void
741 gtk_gl_area_delete_buffers (GtkGLArea *area)
742 {
743+#ifdef HAVE_OPENGL
744 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
745
746 if (priv->context == NULL)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500747@@ -568,6 +577,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600748 glDeleteFramebuffersEXT (1, &priv->frame_buffer);
749 priv->frame_buffer = 0;
750 }
751+#endif
752 }
753
754 static void
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500755@@ -678,6 +688,7 @@ gtk_gl_area_draw (GtkWidget *widget,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600756 GtkGLArea *area = GTK_GL_AREA (widget);
757 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
758 gboolean unused;
759+#ifdef HAVE_OPENGL
760 int w, h, scale;
761 GLenum status;
762
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500763@@ -689,7 +700,6 @@ gtk_gl_area_draw (GtkWidget *widget,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600764 gtk_widget_get_allocated_height (widget));
765 return FALSE;
766 }
767-
768 if (priv->context == NULL)
769 return FALSE;
770
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500771@@ -735,6 +745,14 @@ gtk_gl_area_draw (GtkWidget *widget,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600772 }
773
774 return TRUE;
775+#else
776+ if (priv->error != NULL)
777+ gtk_gl_area_draw_error_screen (area,
778+ cr,
779+ gtk_widget_get_allocated_width (widget),
780+ gtk_widget_get_allocated_height (widget));
781+ return FALSE;
782+#endif
783 }
784
785 static gboolean
786diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500787index c241ec8..24576dd 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600788--- a/gtk/inspector/general.c
789+++ b/gtk/inspector/general.c
790@@ -33,8 +33,10 @@
791
792 #ifdef GDK_WINDOWING_X11
793 #include "x11/gdkx.h"
794+#ifdef HAVE_OPENGL
795 #include <epoxy/glx.h>
796 #endif
797+#endif
798
799 #ifdef GDK_WINDOWING_WIN32
800 #include "win32/gdkwin32.h"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500801@@ -196,6 +198,7 @@ add_label_row (GtkInspectorGeneral *gen,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600802 gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label);
803 }
804
805+#ifdef HAVE_OPENGL
806 #ifdef GDK_WINDOWING_X11
807 static void
808 append_glx_extension_row (GtkInspectorGeneral *gen,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500809@@ -205,6 +208,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen,
810 add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0);
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600811 }
812 #endif
813+#endif
814
815 #ifdef GDK_WINDOWING_WAYLAND
816 static void
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500817@@ -254,6 +258,7 @@ wayland_get_display (struct wl_display *wl_display)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600818 static void
819 init_gl (GtkInspectorGeneral *gen)
820 {
821+#ifdef HAVE_OPENGL
822 #ifdef GDK_WINDOWING_X11
823 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
824 {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500825@@ -280,6 +285,7 @@ init_gl (GtkInspectorGeneral *gen)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600826 }
827 else
828 #endif
829+#endif
830 #ifdef GDK_WINDOWING_WAYLAND
831 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
832 {
833diff --git a/tests/Makefile.am b/tests/Makefile.am
Brad Bishop19323692019-04-05 15:28:33 -0400834index 7c5ca99..e4a4546 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600835--- a/tests/Makefile.am
836+++ b/tests/Makefile.am
837@@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
838 testfullscreen \
839 testgeometry \
840 testgiconpixbuf \
841- testglarea \
842- testglblending \
843 testgrid \
844 testgtk \
845 testheaderbar \
Brad Bishop19323692019-04-05 15:28:33 -0400846@@ -172,12 +170,18 @@ noinst_PROGRAMS = $(TEST_PROGS) \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600847 testactionbar \
848 testwindowsize \
849 testpopover \
850- gdkgears \
851 listmodel \
852 testpopup \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500853 testpopupat \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600854 $(NULL)
855
856+if HAVE_OPENGL
857+noinst_PROGRAMS +=
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500858+ testglarea \
859+ testglblending \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600860+ gdkgears
861+endif
862+
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500863 if USE_WAYLAND
864 noinst_PROGRAMS += testforeign
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600865 endif
866diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500867index 0b3a519..07b096f 100644
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600868--- a/testsuite/gtk/objects-finalize.c
869+++ b/testsuite/gtk/objects-finalize.c
Brad Bishop316dfdd2018-06-25 12:45:53 -0400870@@ -115,7 +115,9 @@ main (int argc, char **argv)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600871 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE &&
872 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 &&
873 all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER &&
874+#ifdef HAVE_OPENGL
875 all_types[i] != GDK_TYPE_X11_GL_CONTEXT &&
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600876+#endif
Brad Bishop316dfdd2018-06-25 12:45:53 -0400877 #endif
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600878 /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */
879 all_types[i] != GDK_TYPE_PIXBUF_LOADER &&