summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2022-12-16 15:58:28 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-17 23:49:56 +0000
commit9eb2b0bb7ab4b047acc11c3ce0034aa4def49432 (patch)
tree97b0c900020963f6fd82b69d2dad2bf7bf787de7
parent4a246e06cb62efff8bfd20cdf3dde31e24f9b711 (diff)
downloadpoky-9eb2b0bb7ab4b047acc11c3ce0034aa4def49432.tar.gz
gtk+3: port to Meson
GTK+ 3.24.36 will drop the autotools build, so get ahead of the curve and switch to Meson. The tarball is missing one meson.build file so add that explictly for now. (From OE-Core rev: f9b0930eab6cf89bbf80c565676c89997b610206) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3.inc34
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/0002-Do-not-try-to-initialize-GL-without-libGL.patch57
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch874
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/buildpaths.patch57
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/link_fribidi.patch19
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/meson.build14
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3/opengl.patch765
-rw-r--r--meta/recipes-gnome/gtk+/gtk+3_3.24.35.bb6
8 files changed, 851 insertions, 975 deletions
diff --git a/meta/recipes-gnome/gtk+/gtk+3.inc b/meta/recipes-gnome/gtk+/gtk+3.inc
index 5b7b73ac8d..1d726b5696 100644
--- a/meta/recipes-gnome/gtk+/gtk+3.inc
+++ b/meta/recipes-gnome/gtk+/gtk+3.inc
@@ -6,12 +6,11 @@ HOMEPAGE = "http://www.gtk.org"
6BUGTRACKER = "https://bugzilla.gnome.org/" 6BUGTRACKER = "https://bugzilla.gnome.org/"
7SECTION = "libs" 7SECTION = "libs"
8 8
9DEPENDS = "glib-2.0 cairo pango atk jpeg libpng gdk-pixbuf \ 9DEPENDS = "glib-2.0 cairo pango atk jpeg libpng gdk-pixbuf gdk-pixbuf-native"
10 gdk-pixbuf-native"
11 10
12LICENSE = "LGPL-2.0-only & LGPL-2.0-or-later & LGPL-2.1-or-later" 11LICENSE = "LGPL-2.0-only & LGPL-2.0-or-later & LGPL-2.1-or-later"
13 12
14inherit autotools gettext pkgconfig gtk-doc update-alternatives gtk-immodules-cache gsettings features_check gobject-introspection 13inherit meson gettext pkgconfig gtk-doc update-alternatives gtk-immodules-cache gsettings features_check gobject-introspection
15 14
16BBCLASSEXTEND = "native nativesdk" 15BBCLASSEXTEND = "native nativesdk"
17 16
@@ -22,10 +21,6 @@ UPSTREAM_CHECK_REGEX = "[^\d\.](?P<pver>3\.([1-8]?[02468])+(\.\d+)+)\.tar"
22 21
23ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}" 22ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"
24 23
25# This should be in autotools.bbclass, but until something elses uses it putting
26# it here avoids rebuilding everything.
27export PKG_CONFIG_FOR_BUILD = "${STAGING_BINDIR_NATIVE}/pkg-config-native"
28
29do_configure:prepend() { 24do_configure:prepend() {
30 # These files are generated by wayland-scanner but will race over modification 25 # These files are generated by wayland-scanner but will race over modification
31 # time between the copies in the sysroot from wayland-protocols and the copy 26 # time between the copies in the sysroot from wayland-protocols and the copy
@@ -33,27 +28,21 @@ do_configure:prepend() {
33 rm -f ${S}/modules/input/*-text-input-*.[ch] 28 rm -f ${S}/modules/input/*-text-input-*.[ch]
34} 29}
35 30
36EXTRA_OECONF += " \ 31GTKDOC_MESON_OPTION = 'gtk_doc'
37 --disable-glibtest \
38 --disable-xinerama \
39 --enable-modules \
40 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "", "--disable-gtk-doc", d)} \
41 "
42 32
43do_compile:prepend() { 33EXTRA_OEMESON = "-Dxinerama=no -Dtests=false"
44 export GIR_EXTRA_LIBS_PATH="${B}/gdk/.libs" 34EXTRA_OEMESON:append:class-native = " -Ddemos=false -Dexamples=false"
45}
46 35
47PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'opengl wayland x11', d)}" 36PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'opengl wayland x11', d)}"
48PACKAGECONFIG:class-native = "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" 37PACKAGECONFIG:class-native = "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}"
49PACKAGECONFIG:class-nativesdk = "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" 38PACKAGECONFIG:class-nativesdk = "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}"
50 39
51PACKAGECONFIG[x11] = "--enable-x11-backend,--disable-x11-backend,at-spi2-atk fontconfig libx11 libxext libxcursor libxi libxdamage libxrandr libxrender libxcomposite libxfixes" 40PACKAGECONFIG[x11] = "-Dx11_backend=true,-Dx11_backend=false,at-spi2-atk fontconfig libx11 libxext libxcursor libxi libxdamage libxrandr libxrender libxcomposite libxfixes"
52# this is provided by oe-core patch that removes epoxy/gl dependency from a X11 build 41# this is provided by oe-core patch that removes epoxy/gl dependency from a X11 build
53PACKAGECONFIG[opengl] = "--enable-opengl,--disable-opengl,libepoxy" 42PACKAGECONFIG[opengl] = "-Dopengl=true,-Dopengl=false,libepoxy"
54PACKAGECONFIG[wayland] = "--enable-wayland-backend,--disable-wayland-backend,wayland wayland-protocols libxkbcommon virtual/egl virtual/libgles2 wayland-native" 43PACKAGECONFIG[wayland] = "-Dwayland_backend=true,-Dwayland_backend=false,wayland wayland-protocols libxkbcommon virtual/egl virtual/libgles2 wayland-native"
55PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups" 44PACKAGECONFIG[cups] = "-Dprint_backends=cups,-Dprint_backends=file,cups"
56PACKAGECONFIG[colord] = "--enable-colord,--disable-colord,colord" 45PACKAGECONFIG[colord] = "-Dcolord=yes,-Dcolord=no,colord"
57 46
58prepare_gtk_scripts() { 47prepare_gtk_scripts() {
59 mv ${D}${bindir}/gtk-update-icon-cache ${D}${bindir}/gtk-update-icon-cache-3.0 48 mv ${D}${bindir}/gtk-update-icon-cache ${D}${bindir}/gtk-update-icon-cache-3.0
@@ -96,7 +85,8 @@ FILES:${PN}-demo = "${bindir}/gtk3-demo \
96FILES:${PN}:append = " ${bindir}/gtk-update-icon-cache-3.0 \ 85FILES:${PN}:append = " ${bindir}/gtk-update-icon-cache-3.0 \
97 ${bindir}/gtk-query-immodules-3.0 \ 86 ${bindir}/gtk-query-immodules-3.0 \
98 ${bindir}/gtk-launch \ 87 ${bindir}/gtk-launch \
99 ${datadir}/themes ${sysconfdir} ${datadir}/glib-2.0/schemas/ \ 88 ${datadir}/themes ${datadir}/gtk-3.0/emoji \
89 ${sysconfdir} ${datadir}/glib-2.0/schemas/ \
100 ${libdir}/gtk-3.0/${LIBV}/engines/libpixmap.so \ 90 ${libdir}/gtk-3.0/${LIBV}/engines/libpixmap.so \
101 ${libdir}/gtk-3.0/modules/*.so" 91 ${libdir}/gtk-3.0/modules/*.so"
102 92
diff --git a/meta/recipes-gnome/gtk+/gtk+3/0002-Do-not-try-to-initialize-GL-without-libGL.patch b/meta/recipes-gnome/gtk+/gtk+3/0002-Do-not-try-to-initialize-GL-without-libGL.patch
deleted file mode 100644
index 80dc2d7a05..0000000000
--- a/meta/recipes-gnome/gtk+/gtk+3/0002-Do-not-try-to-initialize-GL-without-libGL.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1From 6575ab0f0e8c1bba033ad1616511e37a2ec995ff Mon Sep 17 00:00:00 2001
2From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3Date: Fri, 16 Oct 2015 16:35:16 +0300
4Subject: [PATCH] Do not try to initialize GL without libGL
5
6_gdk_x11_screen_update_visuals_for_gl() will end up calling epoxys
7GLX api which will exit() if libGL.so.1 is not present. We do not
8want that to happen and we don't want every app to have to set
9"GDK_GL=disabled" environment variable: so use #ifdef set based on
10opengl distro feature.
11
12Upstream is not interested in the fix as it is: Either epoxy should be
13fixed (to not exit) or GTK+ possibly could do some additional probing
14before calling epoxy APIs.
15
16Upstream-Status: Denied
17Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
18
19---
20 configure.ac | 6 ++++++
21 gdk/x11/gdkvisual-x11.c | 5 +++++
22 2 files changed, 11 insertions(+)
23
24diff --git a/configure.ac b/configure.ac
25index e9f5583..bd651bb 100644
26--- a/configure.ac
27+++ b/configure.ac
28@@ -346,6 +346,12 @@ AC_ARG_ENABLE(cloudproviders,
29 [AS_HELP_STRING([--enable-cloudproviders],
30 [enable libcloudproviders integration])],
31 [cloudproviders_set=yes])
32+AC_ARG_ENABLE(glx,
33+ [AS_HELP_STRING([--enable-glx],
34+ [When enabled Gdk will try to initialize GLX])])
35+AS_IF([test "x$enable_glx" != "xno"], [
36+ AC_DEFINE([HAVE_GLX], [], [GLX will be available at runtime])
37+])
38
39 AC_ARG_ENABLE(profiler,
40 [AS_HELP_STRING([--enable-profiler],
41diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c
42index 81479d8..3c8c5c0 100644
43--- a/gdk/x11/gdkvisual-x11.c
44+++ b/gdk/x11/gdkvisual-x11.c
45@@ -306,7 +306,12 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
46 /* If GL is available we want to pick better default/rgba visuals,
47 as we care about glx details such as alpha/depth/stencil depth,
48 stereo and double buffering */
49+ /* update_visuals_for_gl() will end up calling epoxy GLX api which
50+ will exit if libgl is not there: so only do this if we know GL
51+ is available */
52+#ifdef HAVE_GLX
53 _gdk_x11_screen_update_visuals_for_gl (screen);
54+#endif
55 }
56
57 gint
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
deleted file mode 100644
index fe67144536..0000000000
--- a/meta/recipes-gnome/gtk+/gtk+3/0003-Add-disable-opengl-configure-option.patch
+++ /dev/null
@@ -1,874 +0,0 @@
1From e59cb71740ff70022bb2d9bd3685a1d77b43cac0 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] 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.
17Next long term release (4.0) will require alternative solutions
18as it actually will depend on OpenGL.
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 | 14 ++++++
25 docs/tools/Makefile.am | 9 +++-
26 docs/tools/widgets.c | 4 +-
27 gdk/gdk-sources.inc | 8 ++-
28 gdk/gdkdisplay.c | 4 +-
29 gdk/gdkgl.c | 10 ++++
30 gdk/gdkglcontext.c | 6 +++
31 gdk/gdkwindow.c | 13 +++++
32 gdk/x11/Makefile.am | 30 +++++++++--
33 gdk/x11/gdkdisplay-x11.c | 6 ++-
34 gdk/x11/gdkscreen-x11.c | 5 ++
35 gdk/x11/gdkwindow-x11.c | 4 ++
36 gdk/x11/gdkx-autocleanups.h | 2 +
37 gdk/x11/{gdkx.h => gdkx-with-gl-context.h} | 1 -
38 gdk/x11/gdkx-without-gl-context.h | 58 ++++++++++++++++++++++
39 gtk/Makefile.am | 2 +-
40 gtk/gtkglarea.c | 20 +++++++-
41 gtk/inspector/general.c | 6 +++
42 tests/Makefile.am | 10 ++--
43 testsuite/gtk/objects-finalize.c | 2 +
44 21 files changed, 208 insertions(+), 19 deletions(-)
45 rename gdk/x11/{gdkx.h => gdkx-with-gl-context.h} (98%)
46 create mode 100644 gdk/x11/gdkx-without-gl-context.h
47
48diff --git a/configure.ac b/configure.ac
49index 9ed65e5f8a..70c68364ff 100644
50--- a/configure.ac
51+++ b/configure.ac
52@@ -346,6 +346,15 @@ AC_ARG_ENABLE(cloudproviders,
53 [AS_HELP_STRING([--enable-cloudproviders],
54 [enable libcloudproviders integration])],
55 [cloudproviders_set=yes])
56+AC_ARG_ENABLE(opengl,
57+ [AS_HELP_STRING([--enable-opengl],
58+ [When enabled, Gtk+ will use libepoxy and exposes GtkGLArea widget ])])
59+AS_IF([test "x$enable_opengl" != "xno"], [
60+ AC_DEFINE([HAVE_OPENGL], [1], [libepoxy and opengl APIs are available at buildtime])
61+ EPOXY_PACKAGES="epoxy >= epoxy_required_version"
62+])
63+AM_CONDITIONAL([HAVE_OPENGL],[test "x$enable_opengl" != "xno"])
64+
65 AC_ARG_ENABLE(glx,
66 [AS_HELP_STRING([--enable-glx],
67 [When enabled Gdk will try to initialize GLX])])
68@@ -1367,7 +1376,7 @@ CFLAGS="$saved_cflags"
69 LDFLAGS="$saved_ldflags"
70
71 GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version"
72-GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version"
73+GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends $EPOXY_PACKAGES $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version"
74
75 PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
76 GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
77@@ -1401,7 +1410,7 @@ fi
78 PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
79
80 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"
81-GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version"
82+GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $EPOXY_PACKAGES fribidi >= fribidi_required_version"
83 if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then
84 GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
85 fi
86diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c
87index b51e4ae1fe..82409c7358 100644
88--- a/demos/gtk-demo/glarea.c
89+++ b/demos/gtk-demo/glarea.c
90@@ -3,9 +3,12 @@
91 * GtkGLArea is a widget that allows custom drawing using OpenGL calls.
92 */
93
94+#include "config.h"
95 #include <math.h>
96 #include <gtk/gtk.h>
97+#if HAVE_OPENGL
98 #include <epoxy/gl.h>
99+#endif
100
101 static GtkWidget *demo_window = NULL;
102
103@@ -23,6 +26,8 @@ enum {
104 /* Rotation angles on each axis */
105 static float rotation_angles[N_AXIS] = { 0.0 };
106
107+#ifdef HAVE_OPENGL
108+
109 /* The object we are drawing */
110 static const GLfloat vertex_data[] = {
111 0.f, 0.5f, 0.f, 1.f,
112@@ -215,6 +220,7 @@ compute_mvp (float *res,
113 static GLuint position_buffer;
114 static GLuint program;
115 static GLuint mvp_location;
116+#endif
117
118 /* We need to set up our state when we realize the GtkGLArea widget */
119 static void
120@@ -241,8 +247,10 @@ realize (GtkWidget *widget)
121 fragment_path = "/glarea/glarea-gl.fs.glsl";
122 }
123
124+#ifdef HAVE_OPENGL
125 init_buffers (&position_buffer, NULL);
126 init_shaders (vertex_path, fragment_path, &program, &mvp_location);
127+#endif
128 }
129
130 /* We should tear down the state when unrealizing */
131@@ -254,10 +262,13 @@ unrealize (GtkWidget *widget)
132 if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
133 return;
134
135+#ifdef HAVE_OPENGL
136 glDeleteBuffers (1, &position_buffer);
137 glDeleteProgram (program);
138+#endif
139 }
140
141+#ifdef HAVE_OPENGL
142 static void
143 draw_triangle (void)
144 {
145@@ -290,6 +301,7 @@ draw_triangle (void)
146 glBindBuffer (GL_ARRAY_BUFFER, 0);
147 glUseProgram (0);
148 }
149+#endif
150
151 static gboolean
152 render (GtkGLArea *area,
153@@ -298,6 +310,7 @@ render (GtkGLArea *area,
154 if (gtk_gl_area_get_error (area) != NULL)
155 return FALSE;
156
157+#ifdef HAVE_OPENGL
158 /* Clear the viewport */
159 glClearColor (0.5, 0.5, 0.5, 1.0);
160 glClear (GL_COLOR_BUFFER_BIT);
161@@ -307,6 +320,7 @@ render (GtkGLArea *area,
162
163 /* Flush the contents of the pipeline */
164 glFlush ();
165+#endif
166
167 return TRUE;
168 }
169diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am
170index bec43e3a55..189e8fc926 100644
171--- a/docs/tools/Makefile.am
172+++ b/docs/tools/Makefile.am
173@@ -9,13 +9,18 @@ AM_CPPFLAGS = \
174 $(GTK_DEBUG_FLAGS) \
175 $(GTK_DEP_CFLAGS)
176
177+if HAVE_OPENGL
178+GEARS_LDADD = $(top_builddir)/tests/gtkgears.o
179+endif
180+
181 DEPS = \
182- $(top_builddir)/gtk/libgtk-3.la
183+ $(top_builddir)/gtk/libgtk-3.la \
184+ $(GEARS_LDADD)
185
186 LDADDS = \
187 $(top_builddir)/gtk/libgtk-3.la \
188 $(top_builddir)/gdk/libgdk-3.la \
189- $(top_builddir)/tests/gtkgears.o \
190+ $(GEARS_LDADD) \
191 $(GTK_DEP_LIBS) \
192 $(GDK_DEP_LIBS) \
193 -lm
194diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
195index 932daf1746..54239d6129 100644
196--- a/docs/tools/widgets.c
197+++ b/docs/tools/widgets.c
198@@ -1526,9 +1526,11 @@ create_gl_area (void)
199 widget = gtk_frame_new (NULL);
200 gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
201
202+#ifdef HAVE_OPENGL
203 gears = gtk_gears_new ();
204 gtk_container_add (GTK_CONTAINER (widget), gears);
205-
206+#endif
207+
208 info = new_widget_info ("glarea", widget, MEDIUM);
209
210 return info;
211diff --git a/gdk/gdk-sources.inc b/gdk/gdk-sources.inc
212index 9235edb6cf..349acb8f4c 100644
213--- a/gdk/gdk-sources.inc
214+++ b/gdk/gdk-sources.inc
215@@ -146,7 +146,6 @@ x11_introspection_files = \
216 x11/gdkeventsource.c \
217 x11/gdkeventtranslator.c \
218 x11/gdkgeometry-x11.c \
219- x11/gdkglcontext-x11.c \
220 x11/gdkkeys-x11.c \
221 x11/gdkmain-x11.c \
222 x11/gdkmonitor-x11.c \
223@@ -172,7 +171,6 @@ x11_introspection_files = \
224 x11/gdkx11display.h \
225 x11/gdkx11displaymanager.h \
226 x11/gdkx11dnd.h \
227- x11/gdkx11glcontext.h \
228 x11/gdkx11keys.h \
229 x11/gdkx11monitor.h \
230 x11/gdkx11property.h \
231@@ -182,6 +180,12 @@ x11_introspection_files = \
232 x11/gdkx11visual.h \
233 x11/gdkx11window.h
234
235+if HAVE_OPENGL
236+x11_introspection_files += \
237+ x11/gdkglcontext-x11.c \
238+ x11/gdkx11glcontext.h
239+endif
240+
241 w32_introspection_files = \
242 win32/gdkcursor-win32.c \
243 win32/gdkdevicemanager-win32.c \
244diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
245index 748f54860c..911ab2a65f 100644
246--- a/gdk/gdkdisplay.c
247+++ b/gdk/gdkdisplay.c
248@@ -2420,7 +2420,9 @@ gboolean
249 gdk_display_make_gl_context_current (GdkDisplay *display,
250 GdkGLContext *context)
251 {
252- return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
253+ if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current)
254+ return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
255+ return FALSE;
256 }
257
258 GdkRenderingMode
259diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
260index 9690077cc2..55f85ef605 100644
261--- a/gdk/gdkgl.c
262+++ b/gdk/gdkgl.c
263@@ -26,7 +26,9 @@
264 # include "win32/gdkwin32.h"
265 #endif
266
267+#ifdef HAVE_OPENGL
268 #include <epoxy/gl.h>
269+#endif
270 #include <math.h>
271 #include <string.h>
272
273@@ -40,6 +42,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
274 g_object_ref (window), g_object_unref);
275 }
276
277+#ifdef HAVE_OPENGL
278 static const char *
279 get_vertex_type_name (int type)
280 {
281@@ -212,6 +215,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data)
282 glUseProgram (paint_data->current_program->program);
283 }
284 }
285+#endif
286
287 void
288 gdk_gl_texture_quads (GdkGLContext *paint_context,
289@@ -220,6 +224,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
290 GdkTexturedQuad *quads,
291 gboolean flip_colors)
292 {
293+#ifdef HAVE_OPENGL
294 GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
295 GdkGLContextProgram *program;
296 GdkWindow *window = gdk_gl_context_get_window (paint_context);
297@@ -293,6 +298,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
298
299 glDisableVertexAttribArray (program->position_location);
300 glDisableVertexAttribArray (program->uv_location);
301+#endif
302 }
303
304 /* x,y,width,height describes a rectangle in the gl render buffer
305@@ -341,6 +347,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
306 int width,
307 int height)
308 {
309+#ifdef HAVE_OPENGL
310 GdkGLContext *paint_context;
311 cairo_surface_t *image;
312 cairo_matrix_t matrix;
313@@ -718,6 +725,7 @@ out:
314 if (clip_region)
315 cairo_region_destroy (clip_region);
316
317+#endif
318 }
319
320 /* This is always called with the paint context current */
321@@ -725,6 +733,7 @@ void
322 gdk_gl_texture_from_surface (cairo_surface_t *surface,
323 cairo_region_t *region)
324 {
325+#ifdef HAVE_OPENGL
326 GdkGLContext *paint_context;
327 cairo_surface_t *image;
328 double device_x_offset, device_y_offset;
329@@ -825,4 +834,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
330
331 glDisable (GL_SCISSOR_TEST);
332 glDeleteTextures (1, &texture_id);
333+#endif
334 }
335diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
336index 3b23639e1c..1f04f8e0b2 100644
337--- a/gdk/gdkglcontext.c
338+++ b/gdk/gdkglcontext.c
339@@ -85,7 +85,9 @@
340 #include "gdkintl.h"
341 #include "gdk-private.h"
342
343+#ifdef HAVE_OPENGL
344 #include <epoxy/gl.h>
345+#endif
346
347 typedef struct {
348 GdkDisplay *display;
349@@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
350 int height,
351 guint texture_target)
352 {
353+#ifdef HAVE_OPENGL
354 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
355
356 g_return_if_fail (GDK_IS_GL_CONTEXT (context));
357@@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
358 glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride));
359 }
360 }
361+#endif
362 }
363
364 static gboolean
365@@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context,
366 static void
367 gdk_gl_context_check_extensions (GdkGLContext *context)
368 {
369+#ifdef HAVE_OPENGL
370 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
371 gboolean has_npot, has_texture_rectangle;
372
373@@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
374 priv->use_texture_rectangle ? "yes" : "no"));
375
376 priv->extensions_checked = TRUE;
377+#endif
378 }
379
380 /**
381diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
382index 727b0cf1f4..d4d91b0d16 100644
383--- a/gdk/gdkwindow.c
384+++ b/gdk/gdkwindow.c
385@@ -45,7 +45,9 @@
386
387 #include <math.h>
388
389+#ifdef HAVE_OPENGL
390 #include <epoxy/gl.h>
391+#endif
392
393 /* for the use of round() */
394 #include "fallback-c89.c"
395@@ -2844,6 +2846,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
396 {
397 GError *internal_error = NULL;
398
399+#ifndef HAVE_OPENGL
400+ g_set_error_literal (error, GDK_GL_ERROR,
401+ GDK_GL_ERROR_NOT_AVAILABLE,
402+ _("GL support disabled with --disable-opengl"));
403+ return NULL;
404+#endif
405+
406 if (_gdk_gl_flags & GDK_GL_DISABLE)
407 {
408 g_set_error_literal (error, GDK_GL_ERROR,
409@@ -2979,6 +2988,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
410 }
411 else
412 {
413+#ifdef HAVE_OPENGL
414 gdk_gl_context_make_current (context);
415 /* With gl we always need a surface to combine the gl
416 drawing with the native drawing. */
417@@ -2993,6 +3003,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
418 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
419
420 glViewport (0, 0, ww, wh);
421+#endif
422 }
423 }
424
425@@ -3056,6 +3067,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
426
427 gdk_gl_context_make_current (window->gl_paint_context);
428
429+#ifdef HAVE_OPENGL
430 if (!cairo_region_is_empty (opaque_region))
431 gdk_gl_texture_from_surface (window->current_paint.surface,
432 opaque_region);
433@@ -3066,6 +3078,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
434 window->current_paint.need_blend_region);
435 glDisable(GL_BLEND);
436 }
437+#endif
438
439 cairo_region_destroy (opaque_region);
440
441diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
442index 32b1f24434..63523130ce 100644
443--- a/gdk/x11/Makefile.am
444+++ b/gdk/x11/Makefile.am
445@@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \
446 gdkeventtranslator.c \
447 gdkeventtranslator.h \
448 gdkgeometry-x11.c \
449- gdkglcontext-x11.c \
450- gdkglcontext-x11.h \
451 gdkkeys-x11.c \
452 gdkmain-x11.c \
453 gdkmonitor-x11.c \
454@@ -56,14 +54,32 @@ libgdk_x11_la_SOURCES = \
455 gdkwindow-x11.h \
456 gdkxftdefaults.c \
457 gdkxid.c \
458- gdkx.h \
459 gdkprivate-x11.h \
460 xsettings-client.h \
461 xsettings-client.c
462
463+if HAVE_OPENGL
464+libgdk_x11_la_SOURCES += \
465+ gdkglcontext-x11.c \
466+ gdkglcontext-x11.h
467+endif
468+
469 libgdkinclude_HEADERS = \
470 gdkx.h
471
472+if HAVE_OPENGL
473+GDKX_HEADER = gdkx-with-gl-context.h
474+else
475+GDKX_HEADER = gdkx-without-gl-context.h
476+endif
477+
478+BUILT_SOURCES = gdkx.h
479+
480+.PHONY: gdkx.h
481+gdkx.h:
482+ $(AM_V_GEN) cd $(srcdir) \
483+ && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h )
484+
485 libgdkx11include_HEADERS = \
486 gdkx-autocleanups.h \
487 gdkx11applaunchcontext.h \
488@@ -77,7 +93,6 @@ libgdkx11include_HEADERS = \
489 gdkx11display.h \
490 gdkx11displaymanager.h \
491 gdkx11dnd.h \
492- gdkx11glcontext.h \
493 gdkx11keys.h \
494 gdkx11monitor.h \
495 gdkx11property.h \
496@@ -87,10 +102,17 @@ libgdkx11include_HEADERS = \
497 gdkx11visual.h \
498 gdkx11window.h
499
500+if HAVE_OPENGL
501+libgdkx11include_HEADERS += gdkx11glcontext.h
502+endif
503+
504 # We need to include all these C files here since the conditionals
505 # don't seem to be correctly expanded for the dist files.
506 EXTRA_DIST += \
507+ gdkx.h \
508 gdksettings.c \
509 meson.build
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
515index 7e08f472cc..30fd7b6089 100644
516--- 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 #include "gdkprofilerprivate.h"
527
528@@ -3191,7 +3193,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
529 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
540index c2b7480c48..114fd4c67a 100644
541--- a/gdk/x11/gdkscreen-x11.c
542+++ b/gdk/x11/gdkscreen-x11.c
543@@ -1842,3 +1842,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen)
544 {
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
553index 194bc82e29..0302bb68d4 100644
554--- 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
566@@ -5888,7 +5890,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
567 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 edb0ea7dbf..a317d61cca 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)
590diff --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 1f64bccb6d..ae05fa6b1f 100644
595--- a/gdk/x11/gdkx.h
596+++ b/gdk/x11/gdkx-with-gl-context.h
597@@ -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>
605diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h
606new file mode 100644
607index 0000000000..c9e261720f
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__ */
669diff --git a/gtk/Makefile.am b/gtk/Makefile.am
670index 946e72febc..b01da7f128 100644
671--- a/gtk/Makefile.am
672+++ b/gtk/Makefile.am
673@@ -467,7 +467,7 @@ gtktypefuncs.inc: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_s
674 ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \
675 $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \
676 sort | uniq | \
677- $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \
678+ $(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 \
679 && cp xgen-gtf $@ && rm -f xgen-gtf
680 $(srcdir)/gtktestutils.c: gtktypefuncs.inc
681
682diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
683index 802303ea9f..33001cfb61 100644
684--- a/gtk/gtkglarea.c
685+++ b/gtk/gtkglarea.c
686@@ -29,7 +29,9 @@
687 #include "gtkprivate.h"
688 #include "gtkrender.h"
689
690+#ifdef HAVE_OPENGL
691 #include <epoxy/gl.h>
692+#endif
693
694 /**
695 * SECTION:gtkglarea
696@@ -369,9 +371,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
697 static void
698 gtk_gl_area_resize (GtkGLArea *area, int width, int height)
699 {
700+#ifdef HAVE_OPENGL
701 glViewport (0, 0, width, height);
702+#endif
703 }
704
705+#ifdef HAVE_OPENGL
706 /*
707 * Creates all the buffer objects needed for rendering the scene
708 */
709@@ -483,6 +488,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
710
711 priv->needs_render = TRUE;
712 }
713+#endif
714
715 /**
716 * gtk_gl_area_attach_buffers:
717@@ -501,6 +507,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
718 void
719 gtk_gl_area_attach_buffers (GtkGLArea *area)
720 {
721+#ifdef HAVE_OPENGL
722 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
723
724 g_return_if_fail (GTK_IS_GL_AREA (area));
725@@ -533,11 +540,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area)
726 glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
727 GL_RENDERBUFFER, priv->depth_stencil_buffer);
728 }
729+#endif
730 }
731
732 static void
733 gtk_gl_area_delete_buffers (GtkGLArea *area)
734 {
735+#ifdef HAVE_OPENGL
736 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
737
738 if (priv->context == NULL)
739@@ -569,6 +578,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
740 glDeleteFramebuffers (1, &priv->frame_buffer);
741 priv->frame_buffer = 0;
742 }
743+#endif
744 }
745
746 static void
747@@ -679,6 +689,7 @@ gtk_gl_area_draw (GtkWidget *widget,
748 GtkGLArea *area = GTK_GL_AREA (widget);
749 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
750 gboolean unused;
751+#ifdef HAVE_OPENGL
752 int w, h, scale;
753 GLenum status;
754
755@@ -690,7 +701,6 @@ gtk_gl_area_draw (GtkWidget *widget,
756 gtk_widget_get_allocated_height (widget));
757 return FALSE;
758 }
759-
760 if (priv->context == NULL)
761 return FALSE;
762
763@@ -736,6 +746,14 @@ gtk_gl_area_draw (GtkWidget *widget,
764 }
765
766 return TRUE;
767+#else
768+ if (priv->error != NULL)
769+ gtk_gl_area_draw_error_screen (area,
770+ cr,
771+ gtk_widget_get_allocated_width (widget),
772+ gtk_widget_get_allocated_height (widget));
773+ return FALSE;
774+#endif
775 }
776
777 static gboolean
778diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
779index 4fd0c3039c..a8e59ed077 100644
780--- a/gtk/inspector/general.c
781+++ b/gtk/inspector/general.c
782@@ -33,8 +33,10 @@
783
784 #ifdef GDK_WINDOWING_X11
785 #include "x11/gdkx.h"
786+#ifdef HAVE_OPENGL
787 #include <epoxy/glx.h>
788 #endif
789+#endif
790
791 #ifdef GDK_WINDOWING_WIN32
792 #include "win32/gdkwin32.h"
793@@ -217,6 +219,7 @@ add_label_row (GtkInspectorGeneral *gen,
794 gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label);
795 }
796
797+#ifdef HAVE_OPENGL
798 #ifdef GDK_WINDOWING_X11
799 static void
800 append_glx_extension_row (GtkInspectorGeneral *gen,
801@@ -226,6 +229,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen,
802 add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0);
803 }
804 #endif
805+#endif
806
807 #ifdef GDK_WINDOWING_WAYLAND
808 static void
809@@ -275,6 +279,7 @@ wayland_get_display (struct wl_display *wl_display)
810 static void
811 init_gl (GtkInspectorGeneral *gen)
812 {
813+#ifdef HAVE_OPENGL
814 #ifdef GDK_WINDOWING_X11
815 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
816 {
817@@ -301,6 +306,7 @@ init_gl (GtkInspectorGeneral *gen)
818 }
819 else
820 #endif
821+#endif
822 #ifdef GDK_WINDOWING_WAYLAND
823 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
824 {
825diff --git a/tests/Makefile.am b/tests/Makefile.am
826index f283e89831..5e7180e923 100644
827--- a/tests/Makefile.am
828+++ b/tests/Makefile.am
829@@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
830 testfullscreen \
831 testgeometry \
832 testgiconpixbuf \
833- testglarea \
834- testglblending \
835 testgrid \
836 testgtk \
837 testheaderbar \
838@@ -172,12 +170,18 @@ noinst_PROGRAMS = $(TEST_PROGS) \
839 testactionbar \
840 testwindowsize \
841 testpopover \
842- gdkgears \
843 listmodel \
844 testpopup \
845 testpopupat \
846 $(NULL)
847
848+if HAVE_OPENGL
849+noinst_PROGRAMS +=
850+ testglarea \
851+ testglblending \
852+ gdkgears
853+endif
854+
855 if USE_WAYLAND
856 noinst_PROGRAMS += testforeign
857 endif
858diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
859index 24540e313f..e0f863ab6a 100644
860--- a/testsuite/gtk/objects-finalize.c
861+++ b/testsuite/gtk/objects-finalize.c
862@@ -116,7 +116,9 @@ main (int argc, char **argv)
863 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE &&
864 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 &&
865 all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER &&
866+#ifdef HAVE_OPENGL
867 all_types[i] != GDK_TYPE_X11_GL_CONTEXT &&
868+#endif
869 #endif
870 /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */
871 all_types[i] != GDK_TYPE_PIXBUF_LOADER &&
872--
8732.34.1
874
diff --git a/meta/recipes-gnome/gtk+/gtk+3/buildpaths.patch b/meta/recipes-gnome/gtk+/gtk+3/buildpaths.patch
new file mode 100644
index 0000000000..627d1d4b7e
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk+3/buildpaths.patch
@@ -0,0 +1,57 @@
1Use basename not full filename to remove buildpaths from the packages.
2
3Upstream-Status: Backport [8eb4e59613a0979757332eb833231b947d61f13d]
4Signed-off-by: Ross Burton <ross.burton@arm.com>
5
6diff --git a/gdk/gdkenumtypes.c.template b/gdk/gdkenumtypes.c.template
7index df9edfefa1..c5104e0e0d 100644
8--- a/gdk/gdkenumtypes.c.template
9+++ b/gdk/gdkenumtypes.c.template
10@@ -5,7 +5,7 @@
11 /*** END file-header ***/
12
13 /*** BEGIN file-production ***/
14-/* enumerations from "@filename@" */
15+/* enumerations from "@basename@" */
16 /*** END file-production ***/
17
18 /*** BEGIN value-header ***/
19diff --git a/gtk/gtkprivatetypebuiltins.c.template b/gtk/gtkprivatetypebuiltins.c.template
20index 2565208bfc..d7961be8ef 100644
21--- a/gtk/gtkprivatetypebuiltins.c.template
22+++ b/gtk/gtkprivatetypebuiltins.c.template
23@@ -7,7 +7,7 @@
24 /*** END file-header ***/
25
26 /*** BEGIN file-production ***/
27-/* enumerations from "@filename@" */
28+/* enumerations from "@basename@" */
29 /*** END file-production ***/
30
31 /*** BEGIN value-header ***/
32diff --git a/gtk/gtkprivatetypebuiltins.h.template b/gtk/gtkprivatetypebuiltins.h.template
33index a21e9aac05..5ecd4d392f 100644
34--- a/gtk/gtkprivatetypebuiltins.h.template
35+++ b/gtk/gtkprivatetypebuiltins.h.template
36@@ -14,7 +14,7 @@ G_BEGIN_DECLS
37
38 /*** BEGIN file-production ***/
39
40-/* enumerations from "@filename@" */
41+/* enumerations from "@basename@" */
42 /*** END file-production ***/
43
44 /*** BEGIN value-header ***/
45diff --git a/gtk/gtktypebuiltins.c.template b/gtk/gtktypebuiltins.c.template
46index f4d748b7b9..9a5a360f09 100644
47--- a/gtk/gtktypebuiltins.c.template
48+++ b/gtk/gtktypebuiltins.c.template
49@@ -6,7 +6,7 @@
50 /*** END file-header ***/
51
52 /*** BEGIN file-production ***/
53-/* enumerations from "@filename@" */
54+/* enumerations from "@basename@" */
55 /*** END file-production ***/
56
57 /*** BEGIN value-header ***/
diff --git a/meta/recipes-gnome/gtk+/gtk+3/link_fribidi.patch b/meta/recipes-gnome/gtk+/gtk+3/link_fribidi.patch
deleted file mode 100644
index e4bbd799f1..0000000000
--- a/meta/recipes-gnome/gtk+/gtk+3/link_fribidi.patch
+++ /dev/null
@@ -1,19 +0,0 @@
1Link with libfribidi, this is to avoid under linking where these functions are
2used but the library is not linked in, and they are marked undefined by BFD linker
3but gold linker refuses to link
4
5| ./.libs/libgdk-3.so: error: undefined reference to 'fribidi_get_bidi_type'
6
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8Upstream-Status: Pending
9
10--- a/gdk/Makefile.am
11+++ b/gdk/Makefile.am
12@@ -55,6 +55,7 @@ LDADD = \
13 -version-info $(LT_VERSION_INFO) \
14 -export-dynamic \
15 -rpath $(libdir) \
16+ -lfribidi \
17 $(no_undefined)
18
19 #
diff --git a/meta/recipes-gnome/gtk+/gtk+3/meson.build b/meta/recipes-gnome/gtk+/gtk+3/meson.build
new file mode 100644
index 0000000000..94cf47a37f
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk+3/meson.build
@@ -0,0 +1,14 @@
1# This file is missing from the 3.24.35 tarball
2
3wayland_cursor_sources = files([
4 'wayland-cursor.c',
5 'xcursor.c',
6 'os-compatibility.c'
7])
8
9libwayland_cursor = static_library('wayland+cursor',
10 sources: wayland_cursor_sources,
11 include_directories: [ confinc, ],
12 dependencies: [ glib_dep, wlclientdep, ],
13 c_args: common_cflags,
14)
diff --git a/meta/recipes-gnome/gtk+/gtk+3/opengl.patch b/meta/recipes-gnome/gtk+/gtk+3/opengl.patch
new file mode 100644
index 0000000000..ddec2c72d7
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk+3/opengl.patch
@@ -0,0 +1,765 @@
1From a6fb8ee9cfd5e0f8c4450d48b582614e2de8201c Mon Sep 17 00:00:00 2001
2From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3Date: Fri, 16 Oct 2015 16:35:16 +0300
4Subject: [PATCH] Do not try to initialize GL without libGL
5
6_gdk_x11_screen_update_visuals_for_gl() will end up calling epoxys
7GLX api which will exit() if libGL.so.1 is not present. We do not
8want that to happen and we don't want every app to have to set
9"GDK_GL=disabled" environment variable: so use #ifdef set based on
10opengl distro feature.
11
12Upstream is not interested in the fix as it is: Either epoxy should be
13fixed (to not exit) or GTK+ possibly could do some additional probing
14before calling epoxy APIs.
15
16Upstream-Status: Denied
17Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
18---
19 config.h.meson | 2 ++
20 demos/gtk-demo/meson.build | 5 ++++-
21 docs/tools/meson.build | 7 +++++--
22 docs/tools/widgets.c | 6 +++++-
23 gdk/gdkconfig.h.meson | 1 +
24 gdk/gdkdisplay.c | 4 ++++
25 gdk/gdkgl.c | 10 ++++++++++
26 gdk/gdkglcontext.c | 6 ++++++
27 gdk/gdkwindow.c | 13 +++++++++++++
28 gdk/meson.build | 8 +++++++-
29 gdk/x11/Makefile.am | 2 --
30 gdk/x11/gdkdisplay-x11.c | 6 +++++-
31 gdk/x11/gdkvisual-x11.c | 5 +++++
32 gdk/x11/gdkwindow-x11.c | 4 ++++
33 gdk/x11/gdkx-autocleanups.h | 2 ++
34 gdk/x11/gdkx.h | 2 ++
35 gdk/x11/meson.build | 7 +++++--
36 gtk/gtkglarea.c | 19 +++++++++++++++++++
37 gtk/inspector/general.c | 6 ++++++
38 meson.build | 17 ++++++++++++++---
39 meson_options.txt | 2 ++
40 tests/meson.build | 9 +++++++--
41 testsuite/gtk/objects-finalize.c | 2 ++
42 23 files changed, 130 insertions(+), 15 deletions(-)
43
44diff --git a/config.h.meson b/config.h.meson
45index b502611cb7..0bf6678d5e 100644
46--- a/config.h.meson
47+++ b/config.h.meson
48@@ -20,6 +20,8 @@
49 /* define if we have colord */
50 #mesondefine HAVE_COLORD
51
52+#mesondefine HAVE_OPENGL
53+
54 /* Define if the GNU dcgettext() function is already present or preinstalled.
55 */
56 #mesondefine HAVE_DCGETTEXT
57diff --git a/demos/gtk-demo/meson.build b/demos/gtk-demo/meson.build
58index 252da16d05..4b57cff6ac 100644
59--- a/demos/gtk-demo/meson.build
60+++ b/demos/gtk-demo/meson.build
61@@ -28,7 +28,6 @@ demos = files([
62 'fishbowl.c',
63 'foreigndrawing.c',
64 'gestures.c',
65- 'glarea.c',
66 'headerbar.c',
67 'hypertext.c',
68 'iconview.c',
69@@ -87,6 +86,10 @@ elif harfbuzz_dep.found() and pangoft_dep.found()
70 gtkdemo_deps += [harfbuzz_dep, pangoft_dep]
71 endif
72
73+if opengl_enabled
74+ demos += files('glarea.c')
75+endif
76+
77 if os_unix
78 demos += files('pagesetup.c')
79 endif
80diff --git a/docs/tools/meson.build b/docs/tools/meson.build
81index 05621ee7ed..3d0a333b32 100644
82--- a/docs/tools/meson.build
83+++ b/docs/tools/meson.build
84@@ -2,10 +2,13 @@ if x11_enabled
85 doc_shooter_sources = [
86 'shadow.c',
87 'shooter.c',
88- 'widgets.c',
89- '../../tests/gtkgears.c',
90+ 'widgets.c'
91 ]
92
93+ if opengl_enabled
94+ doc_shooter_sources += ['../../tests/gtkgears.c']
95+ endif
96+
97 doc_shooter = executable('doc-shooter', doc_shooter_sources,
98 include_directories: [ confinc, gdkinc, gtkinc, testinc, ],
99 dependencies: libgtk_dep)
100diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
101index 932daf1746..348807e133 100644
102--- a/docs/tools/widgets.c
103+++ b/docs/tools/widgets.c
104@@ -8,7 +8,9 @@
105 #include <X11/Xatom.h>
106 #include <gdkx.h>
107 #include "widgets.h"
108+#ifdef HAVE_OPENGL
109 #include "gtkgears.h"
110+#endif
111
112 #define SMALL_WIDTH 240
113 #define SMALL_HEIGHT 75
114@@ -1526,9 +1528,11 @@ create_gl_area (void)
115 widget = gtk_frame_new (NULL);
116 gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
117
118+#ifdef HAVE_OPENGL
119 gears = gtk_gears_new ();
120 gtk_container_add (GTK_CONTAINER (widget), gears);
121-
122+#endif
123+
124 info = new_widget_info ("glarea", widget, MEDIUM);
125
126 return info;
127diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson
128index 7db19e0470..088651bafa 100644
129--- a/gdk/gdkconfig.h.meson
130+++ b/gdk/gdkconfig.h.meson
131@@ -15,6 +15,7 @@ G_BEGIN_DECLS
132 #mesondefine GDK_WINDOWING_WAYLAND
133 #mesondefine GDK_WINDOWING_WIN32
134 #mesondefine GDK_WINDOWING_QUARTZ
135+#mesondefine GDK_WITH_OPENGL
136
137 G_END_DECLS
138
139diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
140index 748f54860c..04ef2c09d4 100644
141--- a/gdk/gdkdisplay.c
142+++ b/gdk/gdkdisplay.c
143@@ -2420,7 +2420,11 @@ gboolean
144 gdk_display_make_gl_context_current (GdkDisplay *display,
145 GdkGLContext *context)
146 {
147+#ifdef HAVE_OPENGL
148 return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
149+#else
150+ return FALSE;
151+#endif
152 }
153
154 GdkRenderingMode
155diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
156index 9690077cc2..55f85ef605 100644
157--- a/gdk/gdkgl.c
158+++ b/gdk/gdkgl.c
159@@ -26,7 +26,9 @@
160 # include "win32/gdkwin32.h"
161 #endif
162
163+#ifdef HAVE_OPENGL
164 #include <epoxy/gl.h>
165+#endif
166 #include <math.h>
167 #include <string.h>
168
169@@ -40,6 +42,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
170 g_object_ref (window), g_object_unref);
171 }
172
173+#ifdef HAVE_OPENGL
174 static const char *
175 get_vertex_type_name (int type)
176 {
177@@ -212,6 +215,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data)
178 glUseProgram (paint_data->current_program->program);
179 }
180 }
181+#endif
182
183 void
184 gdk_gl_texture_quads (GdkGLContext *paint_context,
185@@ -220,6 +224,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
186 GdkTexturedQuad *quads,
187 gboolean flip_colors)
188 {
189+#ifdef HAVE_OPENGL
190 GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
191 GdkGLContextProgram *program;
192 GdkWindow *window = gdk_gl_context_get_window (paint_context);
193@@ -293,6 +298,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
194
195 glDisableVertexAttribArray (program->position_location);
196 glDisableVertexAttribArray (program->uv_location);
197+#endif
198 }
199
200 /* x,y,width,height describes a rectangle in the gl render buffer
201@@ -341,6 +347,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
202 int width,
203 int height)
204 {
205+#ifdef HAVE_OPENGL
206 GdkGLContext *paint_context;
207 cairo_surface_t *image;
208 cairo_matrix_t matrix;
209@@ -718,6 +725,7 @@ out:
210 if (clip_region)
211 cairo_region_destroy (clip_region);
212
213+#endif
214 }
215
216 /* This is always called with the paint context current */
217@@ -725,6 +733,7 @@ void
218 gdk_gl_texture_from_surface (cairo_surface_t *surface,
219 cairo_region_t *region)
220 {
221+#ifdef HAVE_OPENGL
222 GdkGLContext *paint_context;
223 cairo_surface_t *image;
224 double device_x_offset, device_y_offset;
225@@ -825,4 +834,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
226
227 glDisable (GL_SCISSOR_TEST);
228 glDeleteTextures (1, &texture_id);
229+#endif
230 }
231diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
232index 3b23639e1c..1f04f8e0b2 100644
233--- a/gdk/gdkglcontext.c
234+++ b/gdk/gdkglcontext.c
235@@ -85,7 +85,9 @@
236 #include "gdkintl.h"
237 #include "gdk-private.h"
238
239+#ifdef HAVE_OPENGL
240 #include <epoxy/gl.h>
241+#endif
242
243 typedef struct {
244 GdkDisplay *display;
245@@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
246 int height,
247 guint texture_target)
248 {
249+#ifdef HAVE_OPENGL
250 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
251
252 g_return_if_fail (GDK_IS_GL_CONTEXT (context));
253@@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
254 glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride));
255 }
256 }
257+#endif
258 }
259
260 static gboolean
261@@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context,
262 static void
263 gdk_gl_context_check_extensions (GdkGLContext *context)
264 {
265+#ifdef HAVE_OPENGL
266 GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
267 gboolean has_npot, has_texture_rectangle;
268
269@@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
270 priv->use_texture_rectangle ? "yes" : "no"));
271
272 priv->extensions_checked = TRUE;
273+#endif
274 }
275
276 /**
277diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
278index 727b0cf1f4..d4d91b0d16 100644
279--- a/gdk/gdkwindow.c
280+++ b/gdk/gdkwindow.c
281@@ -45,7 +45,9 @@
282
283 #include <math.h>
284
285+#ifdef HAVE_OPENGL
286 #include <epoxy/gl.h>
287+#endif
288
289 /* for the use of round() */
290 #include "fallback-c89.c"
291@@ -2844,6 +2846,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
292 {
293 GError *internal_error = NULL;
294
295+#ifndef HAVE_OPENGL
296+ g_set_error_literal (error, GDK_GL_ERROR,
297+ GDK_GL_ERROR_NOT_AVAILABLE,
298+ _("GL support disabled with --disable-opengl"));
299+ return NULL;
300+#endif
301+
302 if (_gdk_gl_flags & GDK_GL_DISABLE)
303 {
304 g_set_error_literal (error, GDK_GL_ERROR,
305@@ -2979,6 +2988,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
306 }
307 else
308 {
309+#ifdef HAVE_OPENGL
310 gdk_gl_context_make_current (context);
311 /* With gl we always need a surface to combine the gl
312 drawing with the native drawing. */
313@@ -2993,6 +3003,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
314 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
315
316 glViewport (0, 0, ww, wh);
317+#endif
318 }
319 }
320
321@@ -3056,6 +3067,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
322
323 gdk_gl_context_make_current (window->gl_paint_context);
324
325+#ifdef HAVE_OPENGL
326 if (!cairo_region_is_empty (opaque_region))
327 gdk_gl_texture_from_surface (window->current_paint.surface,
328 opaque_region);
329@@ -3066,6 +3078,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
330 window->current_paint.need_blend_region);
331 glDisable(GL_BLEND);
332 }
333+#endif
334
335 cairo_region_destroy (opaque_region);
336
337diff --git a/gdk/meson.build b/gdk/meson.build
338index 4bb1bf2b6c..64172b8d3e 100644
339--- a/gdk/meson.build
340+++ b/gdk/meson.build
341@@ -56,7 +56,6 @@ gdk_gir_public_headers = files(
342 'gdkdrawingcontext.h',
343 'gdkevents.h',
344 'gdkframetimings.h',
345- 'gdkglcontext.h',
346 'gdkkeys.h',
347 'gdkkeysyms.h',
348 'gdkmain.h',
349@@ -78,6 +77,12 @@ gdk_gir_public_headers = files(
350 'gdkwindow.h',
351 )
352 gdk_nogir_public_headers = [files('gdkkeysyms-compat.h')]
353+if opengl_enabled
354+gdk_gir_public_headers += files('gdkglcontext.h')
355+else
356+gdk_nogir_public_headers += files('gdkglcontext.h')
357+endif
358+
359 gdk_public_headers = gdk_gir_public_headers + gdk_nogir_public_headers
360 install_headers(gdk_public_headers, subdir : 'gtk-3.0/gdk')
361
362@@ -166,6 +171,7 @@ gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled)
363 gdkconfig_cdata.set('GDK_WINDOWING_WIN32', win32_enabled)
364 gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled)
365 gdkconfig_cdata.set('GDK_WINDOWING_QUARTZ', quartz_enabled)
366+gdkconfig_cdata.set('GDK_WITH_OPENGL', opengl_enabled)
367
368 gdkconfig = configure_file(
369 input : 'gdkconfig.h.meson',
370diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
371index 32b1f24434..d73eee604a 100644
372--- a/gdk/x11/Makefile.am
373+++ b/gdk/x11/Makefile.am
374@@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \
375 gdkeventtranslator.c \
376 gdkeventtranslator.h \
377 gdkgeometry-x11.c \
378- gdkglcontext-x11.c \
379- gdkglcontext-x11.h \
380 gdkkeys-x11.c \
381 gdkmain-x11.c \
382 gdkmonitor-x11.c \
383diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
384index 7e08f472cc..30fd7b6089 100644
385--- a/gdk/x11/gdkdisplay-x11.c
386+++ b/gdk/x11/gdkdisplay-x11.c
387@@ -37,7 +37,9 @@
388 #include "gdkdisplay-x11.h"
389 #include "gdkprivate-x11.h"
390 #include "gdkscreen-x11.h"
391+#ifdef HAVE_OPENGL
392 #include "gdkglcontext-x11.h"
393+#endif
394 #include "gdk-private.h"
395 #include "gdkprofilerprivate.h"
396
397@@ -3191,7 +3193,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
398 display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
399 display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
400
401- display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
402+#ifdef HAVE_OPENGL
403+ display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
404+#endif
405
406 display_class->get_default_seat = gdk_x11_display_get_default_seat;
407
408diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c
409index 81479d81f4..3c8c5c02ff 100644
410--- a/gdk/x11/gdkvisual-x11.c
411+++ b/gdk/x11/gdkvisual-x11.c
412@@ -306,7 +306,12 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
413 /* If GL is available we want to pick better default/rgba visuals,
414 as we care about glx details such as alpha/depth/stencil depth,
415 stereo and double buffering */
416+ /* update_visuals_for_gl() will end up calling epoxy GLX api which
417+ will exit if libgl is not there: so only do this if we know GL
418+ is available */
419+#ifdef HAVE_GLX
420 _gdk_x11_screen_update_visuals_for_gl (screen);
421+#endif
422 }
423
424 gint
425diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
426index 194bc82e29..0302bb68d4 100644
427--- a/gdk/x11/gdkwindow-x11.c
428+++ b/gdk/x11/gdkwindow-x11.c
429@@ -36,7 +36,9 @@
430 #include "gdkasync.h"
431 #include "gdkeventsource.h"
432 #include "gdkdisplay-x11.h"
433+#ifdef HAVE_OPENGL
434 #include "gdkglcontext-x11.h"
435+#endif
436 #include "gdkprivate-x11.h"
437 #include "gdk-private.h"
438
439@@ -5888,7 +5890,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
440 impl_class->set_opaque_region = gdk_x11_window_set_opaque_region;
441 impl_class->set_shadow_width = gdk_x11_window_set_shadow_width;
442 impl_class->show_window_menu = gdk_x11_window_show_window_menu;
443+#ifdef HAVE_OPENGL
444 impl_class->create_gl_context = gdk_x11_window_create_gl_context;
445 impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
446+#endif
447 impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
448 }
449diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h
450index edb0ea7dbf..a317d61cca 100644
451--- a/gdk/x11/gdkx-autocleanups.h
452+++ b/gdk/x11/gdkx-autocleanups.h
453@@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref)
454 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref)
455 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref)
456 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref)
457+#ifdef HAVE_OPENGL
458 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref)
459+#endif
460 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref)
461 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref)
462 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref)
463diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
464index 1f64bccb6d..4db6c18351 100644
465--- a/gdk/x11/gdkx.h
466+++ b/gdk/x11/gdkx.h
467@@ -43,7 +43,9 @@
468 #include <gdk/x11/gdkx11display.h>
469 #include <gdk/x11/gdkx11displaymanager.h>
470 #include <gdk/x11/gdkx11dnd.h>
471+#ifdef GDK_WITH_OPENGL
472 #include <gdk/x11/gdkx11glcontext.h>
473+#endif
474 #include <gdk/x11/gdkx11keys.h>
475 #include <gdk/x11/gdkx11monitor.h>
476 #include <gdk/x11/gdkx11property.h>
477diff --git a/gdk/x11/meson.build b/gdk/x11/meson.build
478index 754ae0a615..0318c83877 100644
479--- a/gdk/x11/meson.build
480+++ b/gdk/x11/meson.build
481@@ -14,7 +14,6 @@ gdk_x11_sources = files(
482 'gdkeventsource.c',
483 'gdkeventtranslator.c',
484 'gdkgeometry-x11.c',
485- 'gdkglcontext-x11.c',
486 'gdkkeys-x11.c',
487 'gdkmain-x11.c',
488 'gdkproperty-x11.c',
489@@ -42,7 +41,6 @@ gdk_x11_public_headers = files(
490 'gdkx11display.h',
491 'gdkx11displaymanager.h',
492 'gdkx11dnd.h',
493- 'gdkx11glcontext.h',
494 'gdkx11keys.h',
495 'gdkx11monitor.h',
496 'gdkx11property.h',
497@@ -53,6 +51,11 @@ gdk_x11_public_headers = files(
498 'gdkx11window.h',
499 )
500
501+if opengl_enabled
502+ gdk_x11_sources += files('gdkglcontext-x11.c')
503+ gdk_x11_public_headers += files('gdkx11glcontext.h')
504+endif
505+
506 install_headers(gdk_x11_public_headers, subdir: 'gtk-3.0/gdk/x11/')
507 install_headers('gdkx.h', subdir: 'gtk-3.0/gdk/')
508
509diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
510index 802303ea9f..6439d7745d 100644
511--- a/gtk/gtkglarea.c
512+++ b/gtk/gtkglarea.c
513@@ -29,7 +29,9 @@
514 #include "gtkprivate.h"
515 #include "gtkrender.h"
516
517+#ifdef HAVE_OPENGL
518 #include <epoxy/gl.h>
519+#endif
520
521 /**
522 * SECTION:gtkglarea
523@@ -369,9 +371,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
524 static void
525 gtk_gl_area_resize (GtkGLArea *area, int width, int height)
526 {
527+#ifdef HAVE_OPENGL
528 glViewport (0, 0, width, height);
529+#endif
530 }
531
532+#ifdef HAVE_OPENGL
533 /*
534 * Creates all the buffer objects needed for rendering the scene
535 */
536@@ -483,6 +488,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
537
538 priv->needs_render = TRUE;
539 }
540+#endif
541
542 /**
543 * gtk_gl_area_attach_buffers:
544@@ -501,6 +507,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area)
545 void
546 gtk_gl_area_attach_buffers (GtkGLArea *area)
547 {
548+#ifdef HAVE_OPENGL
549 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
550
551 g_return_if_fail (GTK_IS_GL_AREA (area));
552@@ -533,11 +540,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area)
553 glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
554 GL_RENDERBUFFER, priv->depth_stencil_buffer);
555 }
556+#endif
557 }
558
559 static void
560 gtk_gl_area_delete_buffers (GtkGLArea *area)
561 {
562+#ifdef HAVE_OPENGL
563 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
564
565 if (priv->context == NULL)
566@@ -569,6 +578,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
567 glDeleteFramebuffers (1, &priv->frame_buffer);
568 priv->frame_buffer = 0;
569 }
570+#endif
571 }
572
573 static void
574@@ -679,6 +689,7 @@ gtk_gl_area_draw (GtkWidget *widget,
575 GtkGLArea *area = GTK_GL_AREA (widget);
576 GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
577 gboolean unused;
578+#ifdef HAVE_OPENGL
579 int w, h, scale;
580 GLenum status;
581
582@@ -736,6 +747,14 @@ gtk_gl_area_draw (GtkWidget *widget,
583 }
584
585 return TRUE;
586+#else
587+ if (priv->error != NULL)
588+ gtk_gl_area_draw_error_screen (area,
589+ cr,
590+ gtk_widget_get_allocated_width (widget),
591+ gtk_widget_get_allocated_height (widget));
592+ return FALSE;
593+#endif
594 }
595
596 static gboolean
597diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
598index 4fd0c3039c..a8e59ed077 100644
599--- a/gtk/inspector/general.c
600+++ b/gtk/inspector/general.c
601@@ -33,8 +33,10 @@
602
603 #ifdef GDK_WINDOWING_X11
604 #include "x11/gdkx.h"
605+#ifdef HAVE_OPENGL
606 #include <epoxy/glx.h>
607 #endif
608+#endif
609
610 #ifdef GDK_WINDOWING_WIN32
611 #include "win32/gdkwin32.h"
612@@ -217,6 +219,7 @@ add_label_row (GtkInspectorGeneral *gen,
613 gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label);
614 }
615
616+#ifdef HAVE_OPENGL
617 #ifdef GDK_WINDOWING_X11
618 static void
619 append_glx_extension_row (GtkInspectorGeneral *gen,
620@@ -226,6 +229,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen,
621 add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0);
622 }
623 #endif
624+#endif
625
626 #ifdef GDK_WINDOWING_WAYLAND
627 static void
628@@ -275,6 +279,7 @@ wayland_get_display (struct wl_display *wl_display)
629 static void
630 init_gl (GtkInspectorGeneral *gen)
631 {
632+#ifdef HAVE_OPENGL
633 #ifdef GDK_WINDOWING_X11
634 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
635 {
636@@ -301,6 +306,7 @@ init_gl (GtkInspectorGeneral *gen)
637 }
638 else
639 #endif
640+#endif
641 #ifdef GDK_WINDOWING_WAYLAND
642 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
643 {
644diff --git a/meson.build b/meson.build
645index f2e63a8655..eea5347930 100644
646--- a/meson.build
647+++ b/meson.build
648@@ -136,6 +136,7 @@ wayland_enabled = get_option('wayland_backend')
649 broadway_enabled = get_option('broadway_backend')
650 quartz_enabled = get_option('quartz_backend')
651 win32_enabled = get_option('win32_backend')
652+opengl_enabled = get_option('opengl')
653
654 os_unix = false
655 os_linux = false
656@@ -450,7 +451,7 @@ pangocairo_dep = dependency('pangocairo', version: cairo_req,
657 fallback : ['pango', 'libpangocairo_dep'])
658 pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
659 fallback : ['gdk-pixbuf', 'gdkpixbuf_dep'])
660-epoxy_dep = dependency('epoxy', version: epoxy_req,
661+epoxy_dep = dependency('epoxy', version: epoxy_req, required: opengl_enabled,
662 fallback: ['libepoxy', 'libepoxy_dep'])
663 atk_dep = dependency('atk', version: atk_req,
664 fallback : ['atk', 'libatk_dep'])
665@@ -496,6 +497,10 @@ if tracker3_enabled
666 endif
667 endif
668
669+if opengl_enabled
670+ cdata.set('HAVE_OPENGL', 1)
671+endif
672+
673 if iso_codes_dep.found()
674 cdata.set_quoted('ISO_CODES_PREFIX', iso_codes_dep.get_pkgconfig_variable('prefix'))
675 else
676@@ -926,9 +931,15 @@ else
677 gio_packages = ['gio-2.0', glib_req]
678 endif
679
680+if opengl_enabled
681+ epoxy_packages = ['epoxy', epoxy_req]
682+else
683+ epoxy_packages = []
684+endif
685+
686 pkgconf.set('GDK_PRIVATE_PACKAGES',
687 ' '.join(gio_packages + x11_pkgs + wayland_pkgs + cairo_backends +
688- ['epoxy', epoxy_req] + cloudproviders_packages +
689+ epoxy_packages + cloudproviders_packages +
690 ['fribidi', fribidi_req]))
691
692 gtk_packages = ' '.join([
693@@ -942,7 +953,7 @@ pkgconf.set('GTK_PACKAGES', gtk_packages)
694 # Requires.private
695 pc_gdk_extra_libs += cairo_libs
696
697-gtk_private_packages = atk_pkgs + wayland_pkgs + ['epoxy', epoxy_req, 'fribidi', fribidi_req]
698+gtk_private_packages = atk_pkgs + wayland_pkgs + epoxy_packages + ['fribidi', fribidi_req]
699 if wayland_enabled or x11_enabled
700 gtk_private_packages += ['pangoft2']
701 endif
702diff --git a/meson_options.txt b/meson_options.txt
703index 94099aa01e..8bd096896d 100644
704--- a/meson_options.txt
705+++ b/meson_options.txt
706@@ -19,6 +19,8 @@ option('profiler', type: 'boolean', value: false,
707 description : 'Enable profiler support')
708 option('tracker3', type: 'boolean', value: false,
709 description : 'Enable Tracker3 filechooser search')
710+option('opengl', type: 'boolean', value: true,
711+ description : 'Enable use of GL')
712
713 # Print backends
714 option('print_backends', type : 'string', value : 'auto',
715diff --git a/tests/meson.build b/tests/meson.build
716index 586fe2f45e..6ecf317dde 100644
717--- a/tests/meson.build
718+++ b/tests/meson.build
719@@ -5,7 +5,6 @@ gtk_tests = [
720 ['scrolling-performance', ['frame-stats.c', 'variable.c']],
721 ['blur-performance', ['../gtk/gtkcairoblur.c']],
722 ['flicker'],
723- ['gdkgears', ['gtkgears.c']],
724 ['listmodel'],
725 ['motion-compression'],
726 ['styleexamples'],
727@@ -54,7 +53,6 @@ gtk_tests = [
728 ['testfullscreen'],
729 ['testgeometry'],
730 ['testgiconpixbuf'],
731- ['testglblending', ['gtkgears.c']],
732 ['testgmenu'],
733 ['testgrid'],
734 ['testgrouping'],
735@@ -137,6 +135,13 @@ if x11_enabled
736 ]
737 endif
738
739+if opengl_enabled
740+ gtk_tests += [
741+ ['gdkgears', ['gtkgears.c']],
742+ ['testglblending', ['gtkgears.c']],
743+ ]
744+endif
745+
746 if os_linux
747 gtk_tests += [['testfontchooserdialog']]
748 endif
749diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
750index 24540e313f..e0f863ab6a 100644
751--- a/testsuite/gtk/objects-finalize.c
752+++ b/testsuite/gtk/objects-finalize.c
753@@ -116,7 +116,9 @@ main (int argc, char **argv)
754 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE &&
755 all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 &&
756 all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER &&
757+#ifdef HAVE_OPENGL
758 all_types[i] != GDK_TYPE_X11_GL_CONTEXT &&
759+#endif
760 #endif
761 /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */
762 all_types[i] != GDK_TYPE_PIXBUF_LOADER &&
763--
7642.34.1
765
diff --git a/meta/recipes-gnome/gtk+/gtk+3_3.24.35.bb b/meta/recipes-gnome/gtk+/gtk+3_3.24.35.bb
index 3a63ef57fc..7c6ea104c7 100644
--- a/meta/recipes-gnome/gtk+/gtk+3_3.24.35.bb
+++ b/meta/recipes-gnome/gtk+/gtk+3_3.24.35.bb
@@ -3,9 +3,9 @@ require gtk+3.inc
3MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}" 3MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}"
4 4
5SRC_URI = "http://ftp.gnome.org/pub/gnome/sources/gtk+/${MAJ_VER}/gtk+-${PV}.tar.xz \ 5SRC_URI = "http://ftp.gnome.org/pub/gnome/sources/gtk+/${MAJ_VER}/gtk+-${PV}.tar.xz \
6 file://0002-Do-not-try-to-initialize-GL-without-libGL.patch \ 6 file://meson.build;subdir=${S}/gdk/wayland/cursor \
7 file://0003-Add-disable-opengl-configure-option.patch \ 7 file://buildpaths.patch \
8 file://link_fribidi.patch \ 8 file://opengl.patch \
9 " 9 "
10SRC_URI[sha256sum] = "ec10fe6d712ef0b3c63b5f932639c9d1ae99fce94f500f6f06965629fef60bd1" 10SRC_URI[sha256sum] = "ec10fe6d712ef0b3c63b5f932639c9d1ae99fce94f500f6f06965629fef60bd1"
11 11