summaryrefslogtreecommitdiffstats
path: root/meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch')
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch832
1 files changed, 832 insertions, 0 deletions
diff --git a/meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch b/meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch
new file mode 100644
index 0000000000..8552f53e3e
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch
@@ -0,0 +1,832 @@
1From a8fa547fdc1416b330aced805f5343ad912932ae Mon Sep 17 00:00:00 2001
2From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3Date: Tue, 21 Jun 2016 15:11:39 +0300
4Subject: [PATCH 3/4] Add --disable-opengl configure option
5
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.
17Long-term it would be good to find an alternative solution to this
18(maybe a no-op backend for libepoxy?)
19
20Upstream-Status: Inappropriate [Evil eye expected from upstream]
21Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
22---
23 configure.ac | 13 +++++--
24 demos/gtk-demo/glarea.c | 13 +++++++
25 docs/tools/Makefile.am | 9 +++--
26 docs/tools/widgets.c | 4 ++-
27 gdk/gdkdisplay.c | 4 ++-
28 gdk/gdkgl.c | 10 ++++++
29 gdk/gdkglcontext.c | 6 ++++
30 gdk/gdkwindow.c | 13 +++++++
31 gdk/x11/Makefile.am | 30 +++++++++++++---
32 gdk/x11/gdkdisplay-x11.c | 6 +++-
33 gdk/x11/gdkscreen-x11.c | 5 +++
34 gdk/x11/gdkwindow-x11.c | 4 +++
35 gdk/x11/gdkx-autocleanups.h | 2 ++
36 gdk/x11/{gdkx.h => gdkx-with-gl-context.h} | 0
37 gdk/x11/gdkx-without-gl-context.h | 58 ++++++++++++++++++++++++++++++
38 gtk/Makefile.am | 3 +-
39 gtk/gtkglarea.c | 20 ++++++++++-
40 gtk/inspector/general.c | 6 ++++
41 tests/Makefile.am | 10 ++++--
42 testsuite/gtk/objects-finalize.c | 2 ++
43 20 files changed, 201 insertions(+), 17 deletions(-)
44 rename gdk/x11/{gdkx.h => gdkx-with-gl-context.h} (100%)
45 create mode 100644 gdk/x11/gdkx-without-gl-context.h
46
47diff --git a/configure.ac b/configure.ac
48index e27da49..a3e9beb 100644
49--- a/configure.ac
50+++ b/configure.ac
51@@ -342,6 +342,15 @@ AC_ARG_ENABLE(mir-backend,
52 [enable the Mir gdk backend])],
53 [backend_set=yes])
54
55+AC_ARG_ENABLE(opengl,
56+ [AS_HELP_STRING([--enable-opengl],
57+ [When enabled, Gtk+ will use libepoxy and exposes GtkGLArea widget ])])
58+AS_IF([test "x$enable_opengl" != "xno"], [
59+ AC_DEFINE([HAVE_OPENGL], [1], [libepoxy and opengl APIs are available at buildtime])
60+ EPOXY_PACKAGES="epoxy >= epoxy_required_version"
61+])
62+AM_CONDITIONAL([HAVE_OPENGL],[test "x$enable_opengl" != "xno"])
63+
64 AC_ARG_ENABLE(glx,
65 [AS_HELP_STRING([--enable-glx],
66 [When enabled Gdk will try to initialize GLX])])
67@@ -1333,7 +1342,7 @@ CFLAGS="$saved_cflags"
68 LDFLAGS="$saved_ldflags"
69
70 GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version"
71-GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends epoxy >= epoxy_required_version"
72+GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends $EPOXY_PACKAGES"
73
74 PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
75 GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
76@@ -1367,7 +1376,7 @@ fi
77 PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
78
79 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"
80-GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES epoxy >= epoxy_required_version"
81+GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $EPOXY_PACKAGES"
82 if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then
83 GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
84 fi
85diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c
86index 3aba729..c6c79f7 100644
87--- a/demos/gtk-demo/glarea.c
88+++ b/demos/gtk-demo/glarea.c
89@@ -5,7 +5,9 @@
90
91 #include <math.h>
92 #include <gtk/gtk.h>
93+#if HAVE_OPENGL
94 #include <epoxy/gl.h>
95+#endif
96
97 static GtkWidget *demo_window = NULL;
98
99@@ -23,6 +25,8 @@ enum {
100 /* Rotation angles on each axis */
101 static float rotation_angles[N_AXIS] = { 0.0 };
102
103+#ifdef HAVE_OPENGL
104+
105 /* The object we are drawing */
106 static const GLfloat vertex_data[] = {
107 0.f, 0.5f, 0.f, 1.f,
108@@ -213,6 +217,7 @@ compute_mvp (float *res,
109 static GLuint position_buffer;
110 static GLuint program;
111 static GLuint mvp_location;
112+#endif
113
114 /* We need to set up our state when we realize the GtkGLArea widget */
115 static void
116@@ -223,8 +228,10 @@ realize (GtkWidget *widget)
117 if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
118 return;
119
120+#ifdef HAVE_OPENGL
121 init_buffers (&position_buffer, NULL);
122 init_shaders (&program, &mvp_location);
123+#endif
124 }
125
126 /* We should tear down the state when unrealizing */
127@@ -236,10 +243,13 @@ unrealize (GtkWidget *widget)
128 if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
129 return;
130
131+#ifdef HAVE_OPENGL
132 glDeleteBuffers (1, &position_buffer);
133 glDeleteProgram (program);
134+#endif
135 }
136
137+#ifdef HAVE_OPENGL
138 static void
139 draw_triangle (void)
140 {
141@@ -272,6 +282,7 @@ draw_triangle (void)
142 glBindBuffer (GL_ARRAY_BUFFER, 0);
143 glUseProgram (0);
144 }
145+#endif
146
147 static gboolean
148 render (GtkGLArea *area,
149@@ -280,6 +291,7 @@ render (GtkGLArea *area,
150 if (gtk_gl_area_get_error (area) != NULL)
151 return FALSE;
152
153+#ifdef HAVE_OPENGL
154 /* Clear the viewport */
155 glClearColor (0.5, 0.5, 0.5, 1.0);
156 glClear (GL_COLOR_BUFFER_BIT);
157@@ -289,6 +301,7 @@ render (GtkGLArea *area,
158
159 /* Flush the contents of the pipeline */
160 glFlush ();
161+#endif
162
163 return TRUE;
164 }
165diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am
166index 6a6d70f..5cdf312 100644
167--- a/docs/tools/Makefile.am
168+++ b/docs/tools/Makefile.am
169@@ -9,13 +9,18 @@ AM_CPPFLAGS = \
170 $(GTK_DEBUG_FLAGS) \
171 $(GTK_DEP_CFLAGS)
172
173+if HAVE_OPENGL
174+GEARS_LDADD = $(top_builddir)/tests/gtkgears.o
175+endif
176+
177 DEPS = \
178- $(top_builddir)/gtk/libgtk-3.la
179+ $(top_builddir)/gtk/libgtk-3.la \
180+ $(GEARS_LDADD)
181
182 LDADDS = \
183 $(top_builddir)/gtk/libgtk-3.la \
184 $(top_builddir)/gdk/libgdk-3.la \
185- $(top_builddir)/tests/gtkgears.o \
186+ $(GEARS_LDADD) \
187 $(GTK_DEP_LIBS) \
188 $(GDK_DEP_LIBS) \
189 -lm
190diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
191index 932daf1..54239d6 100644
192--- a/docs/tools/widgets.c
193+++ b/docs/tools/widgets.c
194@@ -1526,9 +1526,11 @@ create_gl_area (void)
195 widget = gtk_frame_new (NULL);
196 gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
197
198+#ifdef HAVE_OPENGL
199 gears = gtk_gears_new ();
200 gtk_container_add (GTK_CONTAINER (widget), gears);
201-
202+#endif
203+
204 info = new_widget_info ("glarea", widget, MEDIUM);
205
206 return info;
207diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
208index 6150ef7..2223629 100644
209--- a/gdk/gdkdisplay.c
210+++ b/gdk/gdkdisplay.c
211@@ -2360,7 +2360,9 @@ gboolean
212 gdk_display_make_gl_context_current (GdkDisplay *display,
213 GdkGLContext *context)
214 {
215- return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
216+ if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current)
217+ return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
218+ return FALSE;
219 }
220
221 GdkRenderingMode
222diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
223index e8ba770..ba7c84b 100644
224--- a/gdk/gdkgl.c
225+++ b/gdk/gdkgl.c
226@@ -22,7 +22,9 @@
227
228 #include "gdkinternals.h"
229
230+#ifdef HAVE_OPENGL
231 #include <epoxy/gl.h>
232+#endif
233 #include <math.h>
234 #include <string.h>
235
236@@ -36,6 +38,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
237 g_object_ref (window), g_object_unref);
238 }
239
240+#ifdef HAVE_OPENGL
241 static const char *
242 get_vertex_type_name (int type)
243 {
244@@ -254,6 +257,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data)
245 glUseProgram (paint_data->current_program->program);
246 }
247 }
248+#endif
249
250 void
251 gdk_gl_texture_quads (GdkGLContext *paint_context,
252@@ -261,6 +265,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
253 int n_quads,
254 GdkTexturedQuad *quads)
255 {
256+#ifdef HAVE_OPENGL
257 GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
258 GdkGLContextProgram *program;
259 GdkWindow *window = gdk_gl_context_get_window (paint_context);
260@@ -324,6 +329,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
261
262 glDisableVertexAttribArray (program->position_location);
263 glDisableVertexAttribArray (program->uv_location);
264+#endif
265 }
266
267 /* x,y,width,height describes a rectangle in the gl render buffer
268@@ -372,6 +378,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
269 int width,
270 int height)
271 {
272+#ifdef HAVE_OPENGL
273 GdkGLContext *paint_context;
274 cairo_surface_t *image;
275 cairo_matrix_t matrix;
276@@ -692,6 +699,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
277 if (clip_region)
278 cairo_region_destroy (clip_region);
279
280+#endif
281 }
282
283 /* This is always called with the paint context current */
284@@ -699,6 +707,7 @@ void
285 gdk_gl_texture_from_surface (cairo_surface_t *surface,
286 cairo_region_t *region)
287 {
288+#ifdef HAVE_OPENGL
289 GdkGLContext *paint_context;
290 cairo_surface_t *image;
291 double device_x_offset, device_y_offset;
292@@ -799,4 +808,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
293
294 glDisable (GL_SCISSOR_TEST);
295 glDeleteTextures (1, &texture_id);
296+#endif
297 }
298diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
299index 00a33eb..bd8a793 100644
300--- a/gdk/gdkglcontext.c
301+++ b/gdk/gdkglcontext.c
302@@ -85,7 +85,9 @@
303 #include "gdkintl.h"
304 #include "gdk-private.h"
305
306+#ifdef HAVE_OPENGL
307 #include <epoxy/gl.h>
308+#endif
309
310 typedef struct {
311 GdkDisplay *display;
312@@ -239,6 +241,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
313 int height,
314 guint texture_target)
315 {
316+#ifdef HAVE_OPENGL
317 g_return_if_fail (GDK_IS_GL_CONTEXT (context));
318
319 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
320@@ -246,6 +249,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
321 glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
322 cairo_image_surface_get_data (image_surface));
323 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
324+#endif
325 }
326
327 static void
328@@ -635,6 +639,7 @@ gdk_gl_context_realize (GdkGLContext *context,
329 static void
330 gdk_gl_context_check_extensions (GdkGLContext *context)
331 {
332+#ifdef HAVE_OPENGL
333 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
334 gboolean has_npot, has_texture_rectangle;
335
336@@ -677,6 +682,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
337 priv->use_texture_rectangle ? "yes" : "no"));
338
339 priv->extensions_checked = TRUE;
340+#endif
341 }
342
343 /**
344diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
345index 66ebb9d..74a0c3a 100644
346--- a/gdk/gdkwindow.c
347+++ b/gdk/gdkwindow.c
348@@ -44,7 +44,9 @@
349
350 #include <math.h>
351
352+#ifdef HAVE_OPENGL
353 #include <epoxy/gl.h>
354+#endif
355
356 /* for the use of round() */
357 #include "fallback-c89.c"
358@@ -2759,6 +2761,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
359 {
360 GError *internal_error = NULL;
361
362+#ifndef HAVE_OPENGL
363+ g_set_error_literal (error, GDK_GL_ERROR,
364+ GDK_GL_ERROR_NOT_AVAILABLE,
365+ _("GL support disabled with --disable-opengl"));
366+ return NULL;
367+#endif
368+
369 if (_gdk_gl_flags & GDK_GL_DISABLE)
370 {
371 g_set_error_literal (error, GDK_GL_ERROR,
372@@ -2955,6 +2964,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
373 }
374 else
375 {
376+#ifdef HAVE_OPENGL
377 gdk_gl_context_make_current (context);
378 /* With gl we always need a surface to combine the gl
379 drawing with the native drawing. */
380@@ -2969,6 +2979,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
381 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
382
383 glViewport (0, 0, ww, wh);
384+#endif
385 }
386 }
387
388@@ -3117,6 +3128,7 @@ gdk_window_end_paint (GdkWindow *window)
389
390 gdk_gl_context_make_current (window->gl_paint_context);
391
392+#ifdef HAVE_OPENGL
393 if (!cairo_region_is_empty (opaque_region))
394 gdk_gl_texture_from_surface (window->current_paint.surface,
395 opaque_region);
396@@ -3127,6 +3139,7 @@ gdk_window_end_paint (GdkWindow *window)
397 window->current_paint.need_blend_region);
398 glDisable(GL_BLEND);
399 }
400+#endif
401
402 cairo_region_destroy (opaque_region);
403
404diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
405index c488a31..4ce3c07 100644
406--- a/gdk/x11/Makefile.am
407+++ b/gdk/x11/Makefile.am
408@@ -39,8 +39,6 @@ libgdk_x11_la_SOURCES = \
409 gdkeventtranslator.c \
410 gdkeventtranslator.h \
411 gdkgeometry-x11.c \
412- gdkglcontext-x11.c \
413- gdkglcontext-x11.h \
414 gdkkeys-x11.c \
415 gdkmain-x11.c \
416 gdkproperty-x11.c \
417@@ -53,14 +51,32 @@ libgdk_x11_la_SOURCES = \
418 gdkwindow-x11.h \
419 gdkxftdefaults.c \
420 gdkxid.c \
421- gdkx.h \
422 gdkprivate-x11.h \
423 xsettings-client.h \
424 xsettings-client.c
425
426+if HAVE_OPENGL
427+libgdk_x11_la_SOURCES += \
428+ gdkglcontext-x11.c \
429+ gdkglcontext-x11.h
430+endif
431+
432 libgdkinclude_HEADERS = \
433 gdkx.h
434
435+if HAVE_OPENGL
436+GDKX_HEADER = gdkx-with-gl-context.h
437+else
438+GDKX_HEADER = gdkx-without-gl-context.h
439+endif
440+
441+BUILT_SOURCES = gdkx.h
442+
443+.PHONY: gdkx.h
444+gdkx.h:
445+ $(AM_V_GEN) cd $(srcdir) \
446+ && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h )
447+
448 libgdkx11include_HEADERS = \
449 gdkx-autocleanups.h \
450 gdkx11applaunchcontext.h \
451@@ -74,7 +90,6 @@ libgdkx11include_HEADERS = \
452 gdkx11display.h \
453 gdkx11displaymanager.h \
454 gdkx11dnd.h \
455- gdkx11glcontext.h \
456 gdkx11keys.h \
457 gdkx11property.h \
458 gdkx11screen.h \
459@@ -83,9 +98,16 @@ libgdkx11include_HEADERS = \
460 gdkx11visual.h \
461 gdkx11window.h
462
463+if HAVE_OPENGL
464+libgdkx11include_HEADERS += gdkx11glcontext.h
465+endif
466+
467 # We need to include all these C files here since the conditionals
468 # don't seem to be correctly expanded for the dist files.
469 EXTRA_DIST += \
470+ gdkx.h \
471 gdksettings.c
472
473+MAINTAINERCLEANFILES = gdkx.h
474+
475 -include $(top_srcdir)/git.mk
476diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
477index de91c64..42d50f6 100644
478--- a/gdk/x11/gdkdisplay-x11.c
479+++ b/gdk/x11/gdkdisplay-x11.c
480@@ -37,7 +37,9 @@
481 #include "gdkdisplay-x11.h"
482 #include "gdkprivate-x11.h"
483 #include "gdkscreen-x11.h"
484+#ifdef HAVE_OPENGL
485 #include "gdkglcontext-x11.h"
486+#endif
487 #include "gdk-private.h"
488
489 #include <glib.h>
490@@ -2959,7 +2961,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
491 display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
492 display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
493
494- display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
495+#ifdef HAVE_OPENGL
496+ display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
497+#endif
498
499 display_class->get_default_seat = gdk_x11_display_get_default_seat;
500
501diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
502index 9d8ed20..bd46b00 100644
503--- a/gdk/x11/gdkscreen-x11.c
504+++ b/gdk/x11/gdkscreen-x11.c
505@@ -1968,3 +1968,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen)
506 {
507 return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP");
508 }
509+
510+#ifndef HAVE_OPENGL
511+/* Function from in gdk/x11/gdkglcontext-x11.c */
512+void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen) {}
513+#endif
514diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
515index 9ed087a..30d6eb7 100644
516--- a/gdk/x11/gdkwindow-x11.c
517+++ b/gdk/x11/gdkwindow-x11.c
518@@ -36,7 +36,9 @@
519 #include "gdkasync.h"
520 #include "gdkeventsource.h"
521 #include "gdkdisplay-x11.h"
522+#ifdef HAVE_OPENGL
523 #include "gdkglcontext-x11.h"
524+#endif
525 #include "gdkprivate-x11.h"
526 #include "gdk-private.h"
527
528@@ -5782,7 +5784,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
529 impl_class->set_opaque_region = gdk_x11_window_set_opaque_region;
530 impl_class->set_shadow_width = gdk_x11_window_set_shadow_width;
531 impl_class->show_window_menu = gdk_x11_window_show_window_menu;
532+#ifdef HAVE_OPENGL
533 impl_class->create_gl_context = gdk_x11_window_create_gl_context;
534 impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
535+#endif
536 impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
537 }
538diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h
539index edb0ea7..a317d61 100644
540--- a/gdk/x11/gdkx-autocleanups.h
541+++ b/gdk/x11/gdkx-autocleanups.h
542@@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref)
543 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref)
544 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref)
545 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref)
546+#ifdef HAVE_OPENGL
547 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref)
548+#endif
549 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref)
550 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref)
551 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref)
552diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx-with-gl-context.h
553similarity index 100%
554rename from gdk/x11/gdkx.h
555rename to gdk/x11/gdkx-with-gl-context.h
556diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h
557new file mode 100644
558index 0000000..c9e2617
559--- /dev/null
560+++ b/gdk/x11/gdkx-without-gl-context.h
561@@ -0,0 +1,58 @@
562+/* GDK - The GIMP Drawing Kit
563+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
564+ *
565+ * This library is free software; you can redistribute it and/or
566+ * modify it under the terms of the GNU Lesser General Public
567+ * License as published by the Free Software Foundation; either
568+ * version 2 of the License, or (at your option) any later version.
569+ *
570+ * This library is distributed in the hope that it will be useful,
571+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
572+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
573+ * Lesser General Public License for more details.
574+ *
575+ * You should have received a copy of the GNU Lesser General Public
576+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
577+ */
578+
579+/*
580+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
581+ * file for a list of people on the GTK+ Team. See the ChangeLog
582+ * files for a list of changes. These files are distributed with
583+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
584+ */
585+
586+#ifndef __GDK_X_H__
587+#define __GDK_X_H__
588+
589+#include <gdk/gdk.h>
590+
591+#include <X11/Xlib.h>
592+#include <X11/Xutil.h>
593+
594+#define __GDKX_H_INSIDE__
595+
596+#include <gdk/x11/gdkx11applaunchcontext.h>
597+#include <gdk/x11/gdkx11cursor.h>
598+#include <gdk/x11/gdkx11device.h>
599+#include <gdk/x11/gdkx11device-core.h>
600+#include <gdk/x11/gdkx11device-xi2.h>
601+#include <gdk/x11/gdkx11devicemanager.h>
602+#include <gdk/x11/gdkx11devicemanager-core.h>
603+#include <gdk/x11/gdkx11devicemanager-xi2.h>
604+#include <gdk/x11/gdkx11display.h>
605+#include <gdk/x11/gdkx11displaymanager.h>
606+#include <gdk/x11/gdkx11dnd.h>
607+#include <gdk/x11/gdkx11keys.h>
608+#include <gdk/x11/gdkx11property.h>
609+#include <gdk/x11/gdkx11screen.h>
610+#include <gdk/x11/gdkx11selection.h>
611+#include <gdk/x11/gdkx11utils.h>
612+#include <gdk/x11/gdkx11visual.h>
613+#include <gdk/x11/gdkx11window.h>
614+
615+#include <gdk/x11/gdkx-autocleanups.h>
616+
617+#undef __GDKX_H_INSIDE__
618+
619+#endif /* __GDK_X_H__ */
620diff --git a/gtk/Makefile.am b/gtk/Makefile.am
621index 6a53a2b..49a35e6 100644
622--- a/gtk/Makefile.am
623+++ b/gtk/Makefile.am
624@@ -1351,14 +1351,13 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins.
625 && cp xgen-gptbc gtkprivatetypebuiltins.c \
626 && rm -f xgen-gptbc
627
628-
629 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
630 $(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtkx.h>') > xgen-gtfsrc.c && \
631 echo 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS' > xgen-gtf && \
632 ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \
633 $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \
634 sort | uniq | \
635- $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \
636+ $(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 \
637 && cp xgen-gtf $@ && rm -f xgen-gtf
638 gtktestutils.c: gtktypefuncs.c
639
640diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
641index 245fc6b..4214ad1 100644
642--- a/gtk/gtkglarea.c
643+++ b/gtk/gtkglarea.c
644@@ -28,7 +28,9 @@
645 #include "gtkprivate.h"
646 #include "gtkrender.h"
647
648+#ifdef HAVE_OPENGL
649 #include <epoxy/gl.h>
650+#endif
651
652 /**
653 * SECTION:gtkglarea
654@@ -357,9 +359,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
655 static void
656 gtk_gl_area_resize (GtkGLArea *area, int width, int height)
657 {
658+#ifdef HAVE_OPENGL
659 glViewport (0, 0, width, height);
660+#endif
661 }
662
663+#ifdef HAVE_OPENGL
664 /*
665 * Creates all the buffer objects needed for rendering the scene
666 */
667@@ -467,6 +472,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
668
669 priv->needs_render = TRUE;
670 }
671+#endif
672
673 /**
674 * gtk_gl_area_attach_buffers:
675@@ -485,6 +491,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
676 void
677 gtk_gl_area_attach_buffers (GtkGLArea *area)
678 {
679+#ifdef HAVE_OPENGL
680 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
681
682 g_return_if_fail (GTK_IS_GL_AREA (area));
683@@ -517,11 +524,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area)
684 glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
685 GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer);
686 }
687+#endif
688 }
689
690 static void
691 gtk_gl_area_delete_buffers (GtkGLArea *area)
692 {
693+#ifdef HAVE_OPENGL
694 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
695
696 if (priv->context == NULL)
697@@ -553,6 +562,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
698 glDeleteFramebuffersEXT (1, &priv->frame_buffer);
699 priv->frame_buffer = 0;
700 }
701+#endif
702 }
703
704 static void
705@@ -663,6 +673,7 @@ gtk_gl_area_draw (GtkWidget *widget,
706 GtkGLArea *area = GTK_GL_AREA (widget);
707 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
708 gboolean unused;
709+#ifdef HAVE_OPENGL
710 int w, h, scale;
711 GLenum status;
712
713@@ -674,7 +685,6 @@ gtk_gl_area_draw (GtkWidget *widget,
714 gtk_widget_get_allocated_height (widget));
715 return FALSE;
716 }
717-
718 if (priv->context == NULL)
719 return FALSE;
720
721@@ -720,6 +730,14 @@ gtk_gl_area_draw (GtkWidget *widget,
722 }
723
724 return TRUE;
725+#else
726+ if (priv->error != NULL)
727+ gtk_gl_area_draw_error_screen (area,
728+ cr,
729+ gtk_widget_get_allocated_width (widget),
730+ gtk_widget_get_allocated_height (widget));
731+ return FALSE;
732+#endif
733 }
734
735 static gboolean
736diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
737index 4eab3a7..c4e900e 100644
738--- a/gtk/inspector/general.c
739+++ b/gtk/inspector/general.c
740@@ -33,8 +33,10 @@
741
742 #ifdef GDK_WINDOWING_X11
743 #include "x11/gdkx.h"
744+#ifdef HAVE_OPENGL
745 #include <epoxy/glx.h>
746 #endif
747+#endif
748
749 #ifdef GDK_WINDOWING_WIN32
750 #include "win32/gdkwin32.h"
751@@ -147,6 +149,7 @@ append_extension_row (GtkInspectorGeneral *gen,
752 gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label);
753 }
754
755+#ifdef HAVE_OPENGL
756 #ifdef GDK_WINDOWING_X11
757 static void
758 append_glx_extension_row (GtkInspectorGeneral *gen,
759@@ -156,6 +159,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen,
760 append_extension_row (gen, ext, epoxy_has_glx_extension (dpy, 0, ext));
761 }
762 #endif
763+#endif
764
765 #ifdef GDK_WINDOWING_WAYLAND
766 static void
767@@ -171,6 +175,7 @@ append_egl_extension_row (GtkInspectorGeneral *gen,
768 static void
769 init_gl (GtkInspectorGeneral *gen)
770 {
771+#ifdef HAVE_OPENGL
772 #ifdef GDK_WINDOWING_X11
773 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
774 {
775@@ -197,6 +202,7 @@ init_gl (GtkInspectorGeneral *gen)
776 }
777 else
778 #endif
779+#endif
780 #ifdef GDK_WINDOWING_WAYLAND
781 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
782 {
783diff --git a/tests/Makefile.am b/tests/Makefile.am
784index 681807d..2941a36 100644
785--- a/tests/Makefile.am
786+++ b/tests/Makefile.am
787@@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
788 testfullscreen \
789 testgeometry \
790 testgiconpixbuf \
791- testglarea \
792- testglblending \
793 testgrid \
794 testgtk \
795 testheaderbar \
796@@ -169,11 +167,17 @@ noinst_PROGRAMS = $(TEST_PROGS) \
797 testactionbar \
798 testwindowsize \
799 testpopover \
800- gdkgears \
801 listmodel \
802 testpopup \
803 $(NULL)
804
805+if HAVE_OPENGL
806+noinst_PROGRAMS +=
807+ testglarea \
808+ testglblending \
809+ gdkgears
810+endif
811+
812 if USE_X11
813 noinst_PROGRAMS += testerrors
814 endif
815diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
816index e0ebee0..703643c 100644
817--- a/testsuite/gtk/objects-finalize.c
818+++ b/testsuite/gtk/objects-finalize.c
819@@ -115,8 +115,10 @@ main (int argc, char **argv)
820 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE &&
821 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 &&
822 all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER &&
823+#ifdef HAVE_OPENGL
824 all_types[i] != GDK_TYPE_X11_GL_CONTEXT &&
825 #endif
826+#endif
827 /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */
828 all_types[i] != GDK_TYPE_PIXBUF_LOADER &&
829 all_types[i] != gdk_pixbuf_simple_anim_iter_get_type())
830--
8312.1.4
832