Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 1 | From d11b41a7ff0234f3832d6aabdf498807d1463c18 Mon Sep 17 00:00:00 2001 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2 | From: Jussi Kukkonen <jussi.kukkonen@intel.com> |
| 3 | Date: Tue, 21 Jun 2016 15:11:39 +0300 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 4 | Subject: [PATCH] Add --disable-opengl configure option |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | |
| 6 | --disable-opengl will remove the dependency on libepoxy and on the |
| 7 | OpenGL APIs. This is useful for those who want to keep using gtk+3 |
| 8 | without the "opengl" distro feature. |
| 9 | |
| 10 | GtkGLArea is still part of the API (it just doesn't work) even when |
| 11 | OpenGL is disabled. GdkX11GLContext was removed from the Gtk API |
| 12 | completely: that object exposes GL API elements so it had to be at |
| 13 | the very least modified. |
| 14 | |
| 15 | The patch is _not_ great from a maintenance point of view and |
| 16 | modifying the library API is also a fairly nasty thing to do. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | Next long term release (4.0) will require alternative solutions |
| 18 | as it actually will depend on OpenGL. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | |
| 20 | Upstream-Status: Inappropriate [Evil eye expected from upstream] |
| 21 | Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 23 | --- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | configure.ac | 13 ++++- |
| 25 | demos/gtk-demo/glarea.c | 14 ++++++ |
| 26 | docs/tools/Makefile.am | 9 +++- |
| 27 | docs/tools/widgets.c | 4 +- |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 28 | gdk/Makefile.am | 8 ++- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | gdk/gdkdisplay.c | 4 +- |
| 30 | gdk/gdkgl.c | 10 ++++ |
| 31 | gdk/gdkglcontext.c | 6 +++ |
| 32 | gdk/gdkwindow.c | 13 +++++ |
| 33 | gdk/x11/Makefile.am | 30 +++++++++-- |
| 34 | gdk/x11/gdkdisplay-x11.c | 6 ++- |
| 35 | gdk/x11/gdkscreen-x11.c | 5 ++ |
| 36 | gdk/x11/gdkwindow-x11.c | 4 ++ |
| 37 | gdk/x11/gdkx-autocleanups.h | 2 + |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | gdk/x11/{gdkx.h => gdkx-with-gl-context.h} | 1 - |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 39 | gdk/x11/gdkx-without-gl-context.h | 58 ++++++++++++++++++++++ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | gtk/Makefile.am | 3 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | gtk/gtkglarea.c | 20 +++++++- |
| 42 | gtk/inspector/general.c | 6 +++ |
| 43 | tests/Makefile.am | 10 ++-- |
| 44 | testsuite/gtk/objects-finalize.c | 2 + |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 45 | 21 files changed, 208 insertions(+), 20 deletions(-) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 46 | rename gdk/x11/{gdkx.h => gdkx-with-gl-context.h} (98%) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | create mode 100644 gdk/x11/gdkx-without-gl-context.h |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 48 | |
| 49 | diff --git a/configure.ac b/configure.ac |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 50 | index 2c4733b..18ae66c 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | --- a/configure.ac |
| 52 | +++ b/configure.ac |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 53 | @@ -352,6 +352,15 @@ AC_ARG_ENABLE(cloudproviders, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | [AS_HELP_STRING([--enable-cloudproviders], |
| 55 | [enable libcloudproviders integration])], |
| 56 | [cloudproviders_set=yes]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 57 | +AC_ARG_ENABLE(opengl, |
| 58 | + [AS_HELP_STRING([--enable-opengl], |
| 59 | + [When enabled, Gtk+ will use libepoxy and exposes GtkGLArea widget ])]) |
| 60 | +AS_IF([test "x$enable_opengl" != "xno"], [ |
| 61 | + AC_DEFINE([HAVE_OPENGL], [1], [libepoxy and opengl APIs are available at buildtime]) |
| 62 | + EPOXY_PACKAGES="epoxy >= epoxy_required_version" |
| 63 | +]) |
| 64 | +AM_CONDITIONAL([HAVE_OPENGL],[test "x$enable_opengl" != "xno"]) |
| 65 | + |
| 66 | AC_ARG_ENABLE(glx, |
| 67 | [AS_HELP_STRING([--enable-glx], |
| 68 | [When enabled Gdk will try to initialize GLX])]) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 69 | @@ -1370,7 +1379,7 @@ CFLAGS="$saved_cflags" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 70 | LDFLAGS="$saved_ldflags" |
| 71 | |
| 72 | GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 73 | -GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES fribidi >= fribidi_required_version" |
| 74 | +GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends $EPOXY_PACKAGES $CLOUDPROVIDER_PACKAGES fribidi >= fribidi_required_version" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 75 | |
| 76 | PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES) |
| 77 | GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 78 | @@ -1404,7 +1413,7 @@ fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 79 | PKG_CHECK_MODULES(ATK, $ATK_PACKAGES) |
| 80 | |
| 81 | GTK_PACKAGES="atk >= atk_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version gdk-pixbuf-2.0 >= gdk_pixbuf_required_version gio-2.0 >= glib_required_version" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 82 | -GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version" |
| 83 | +GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $EPOXY_PACKAGES fribidi >= fribidi_required_version" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 84 | if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then |
| 85 | GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2" |
| 86 | fi |
| 87 | diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 88 | index b51e4ae..82409c7 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 89 | --- a/demos/gtk-demo/glarea.c |
| 90 | +++ b/demos/gtk-demo/glarea.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 91 | @@ -3,9 +3,12 @@ |
| 92 | * GtkGLArea is a widget that allows custom drawing using OpenGL calls. |
| 93 | */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 94 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 95 | +#include "config.h" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 96 | #include <math.h> |
| 97 | #include <gtk/gtk.h> |
| 98 | +#if HAVE_OPENGL |
| 99 | #include <epoxy/gl.h> |
| 100 | +#endif |
| 101 | |
| 102 | static GtkWidget *demo_window = NULL; |
| 103 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 104 | @@ -23,6 +26,8 @@ enum { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 105 | /* Rotation angles on each axis */ |
| 106 | static float rotation_angles[N_AXIS] = { 0.0 }; |
| 107 | |
| 108 | +#ifdef HAVE_OPENGL |
| 109 | + |
| 110 | /* The object we are drawing */ |
| 111 | static const GLfloat vertex_data[] = { |
| 112 | 0.f, 0.5f, 0.f, 1.f, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 113 | @@ -215,6 +220,7 @@ compute_mvp (float *res, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 114 | static GLuint position_buffer; |
| 115 | static GLuint program; |
| 116 | static GLuint mvp_location; |
| 117 | +#endif |
| 118 | |
| 119 | /* We need to set up our state when we realize the GtkGLArea widget */ |
| 120 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | @@ -241,8 +247,10 @@ realize (GtkWidget *widget) |
| 122 | fragment_path = "/glarea/glarea-gl.fs.glsl"; |
| 123 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 124 | |
| 125 | +#ifdef HAVE_OPENGL |
| 126 | init_buffers (&position_buffer, NULL); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 127 | init_shaders (vertex_path, fragment_path, &program, &mvp_location); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 128 | +#endif |
| 129 | } |
| 130 | |
| 131 | /* We should tear down the state when unrealizing */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 132 | @@ -254,10 +262,13 @@ unrealize (GtkWidget *widget) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 133 | if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL) |
| 134 | return; |
| 135 | |
| 136 | +#ifdef HAVE_OPENGL |
| 137 | glDeleteBuffers (1, &position_buffer); |
| 138 | glDeleteProgram (program); |
| 139 | +#endif |
| 140 | } |
| 141 | |
| 142 | +#ifdef HAVE_OPENGL |
| 143 | static void |
| 144 | draw_triangle (void) |
| 145 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 146 | @@ -290,6 +301,7 @@ draw_triangle (void) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 147 | glBindBuffer (GL_ARRAY_BUFFER, 0); |
| 148 | glUseProgram (0); |
| 149 | } |
| 150 | +#endif |
| 151 | |
| 152 | static gboolean |
| 153 | render (GtkGLArea *area, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 154 | @@ -298,6 +310,7 @@ render (GtkGLArea *area, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 155 | if (gtk_gl_area_get_error (area) != NULL) |
| 156 | return FALSE; |
| 157 | |
| 158 | +#ifdef HAVE_OPENGL |
| 159 | /* Clear the viewport */ |
| 160 | glClearColor (0.5, 0.5, 0.5, 1.0); |
| 161 | glClear (GL_COLOR_BUFFER_BIT); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 162 | @@ -307,6 +320,7 @@ render (GtkGLArea *area, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 163 | |
| 164 | /* Flush the contents of the pipeline */ |
| 165 | glFlush (); |
| 166 | +#endif |
| 167 | |
| 168 | return TRUE; |
| 169 | } |
| 170 | diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am |
| 171 | index 6a6d70f..5cdf312 100644 |
| 172 | --- a/docs/tools/Makefile.am |
| 173 | +++ b/docs/tools/Makefile.am |
| 174 | @@ -9,13 +9,18 @@ AM_CPPFLAGS = \ |
| 175 | $(GTK_DEBUG_FLAGS) \ |
| 176 | $(GTK_DEP_CFLAGS) |
| 177 | |
| 178 | +if HAVE_OPENGL |
| 179 | +GEARS_LDADD = $(top_builddir)/tests/gtkgears.o |
| 180 | +endif |
| 181 | + |
| 182 | DEPS = \ |
| 183 | - $(top_builddir)/gtk/libgtk-3.la |
| 184 | + $(top_builddir)/gtk/libgtk-3.la \ |
| 185 | + $(GEARS_LDADD) |
| 186 | |
| 187 | LDADDS = \ |
| 188 | $(top_builddir)/gtk/libgtk-3.la \ |
| 189 | $(top_builddir)/gdk/libgdk-3.la \ |
| 190 | - $(top_builddir)/tests/gtkgears.o \ |
| 191 | + $(GEARS_LDADD) \ |
| 192 | $(GTK_DEP_LIBS) \ |
| 193 | $(GDK_DEP_LIBS) \ |
| 194 | -lm |
| 195 | diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c |
| 196 | index 932daf1..54239d6 100644 |
| 197 | --- a/docs/tools/widgets.c |
| 198 | +++ b/docs/tools/widgets.c |
| 199 | @@ -1526,9 +1526,11 @@ create_gl_area (void) |
| 200 | widget = gtk_frame_new (NULL); |
| 201 | gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN); |
| 202 | |
| 203 | +#ifdef HAVE_OPENGL |
| 204 | gears = gtk_gears_new (); |
| 205 | gtk_container_add (GTK_CONTAINER (widget), gears); |
| 206 | - |
| 207 | +#endif |
| 208 | + |
| 209 | info = new_widget_info ("glarea", widget, MEDIUM); |
| 210 | |
| 211 | return info; |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 212 | diff --git a/gdk/Makefile.am b/gdk/Makefile.am |
| 213 | index 689ee52..d6b4e70 100644 |
| 214 | --- a/gdk/Makefile.am |
| 215 | +++ b/gdk/Makefile.am |
| 216 | @@ -274,7 +274,6 @@ x11_introspection_files = \ |
| 217 | x11/gdkeventsource.c \ |
| 218 | x11/gdkeventtranslator.c \ |
| 219 | x11/gdkgeometry-x11.c \ |
| 220 | - x11/gdkglcontext-x11.c \ |
| 221 | x11/gdkkeys-x11.c \ |
| 222 | x11/gdkmain-x11.c \ |
| 223 | x11/gdkmonitor-x11.c \ |
| 224 | @@ -300,7 +299,6 @@ x11_introspection_files = \ |
| 225 | x11/gdkx11display.h \ |
| 226 | x11/gdkx11displaymanager.h \ |
| 227 | x11/gdkx11dnd.h \ |
| 228 | - x11/gdkx11glcontext.h \ |
| 229 | x11/gdkx11keys.h \ |
| 230 | x11/gdkx11monitor.h \ |
| 231 | x11/gdkx11property.h \ |
| 232 | @@ -310,6 +308,12 @@ x11_introspection_files = \ |
| 233 | x11/gdkx11visual.h \ |
| 234 | x11/gdkx11window.h |
| 235 | |
| 236 | +if HAVE_OPENGL |
| 237 | +x11_introspection_files += \ |
| 238 | + x11/gdkglcontext-x11.c \ |
| 239 | + x11/gdkx11glcontext.h |
| 240 | +endif |
| 241 | + |
| 242 | GdkX11-3.0.gir: libgdk-3.la Gdk-3.0.gir Makefile |
| 243 | GdkX11_3_0_gir_SCANNERFLAGS = \ |
| 244 | --identifier-prefix=Gdk \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 245 | diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 246 | index 06d4187..832711c 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 247 | --- a/gdk/gdkdisplay.c |
| 248 | +++ b/gdk/gdkdisplay.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 249 | @@ -2416,7 +2416,9 @@ gboolean |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 250 | gdk_display_make_gl_context_current (GdkDisplay *display, |
| 251 | GdkGLContext *context) |
| 252 | { |
| 253 | - return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 254 | + if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current) |
| 255 | + return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 256 | + return FALSE; |
| 257 | } |
| 258 | |
| 259 | GdkRenderingMode |
| 260 | diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 261 | index 933e204..1767508 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 262 | --- a/gdk/gdkgl.c |
| 263 | +++ b/gdk/gdkgl.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 264 | @@ -26,7 +26,9 @@ |
| 265 | # include "win32/gdkwin32.h" |
| 266 | #endif |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 267 | |
| 268 | +#ifdef HAVE_OPENGL |
| 269 | #include <epoxy/gl.h> |
| 270 | +#endif |
| 271 | #include <math.h> |
| 272 | #include <string.h> |
| 273 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 274 | @@ -40,6 +42,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 275 | g_object_ref (window), g_object_unref); |
| 276 | } |
| 277 | |
| 278 | +#ifdef HAVE_OPENGL |
| 279 | static const char * |
| 280 | get_vertex_type_name (int type) |
| 281 | { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 282 | @@ -212,6 +215,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 283 | glUseProgram (paint_data->current_program->program); |
| 284 | } |
| 285 | } |
| 286 | +#endif |
| 287 | |
| 288 | void |
| 289 | gdk_gl_texture_quads (GdkGLContext *paint_context, |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 290 | @@ -220,6 +224,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 291 | GdkTexturedQuad *quads, |
| 292 | gboolean flip_colors) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 293 | { |
| 294 | +#ifdef HAVE_OPENGL |
| 295 | GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context); |
| 296 | GdkGLContextProgram *program; |
| 297 | GdkWindow *window = gdk_gl_context_get_window (paint_context); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 298 | @@ -293,6 +298,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 299 | |
| 300 | glDisableVertexAttribArray (program->position_location); |
| 301 | glDisableVertexAttribArray (program->uv_location); |
| 302 | +#endif |
| 303 | } |
| 304 | |
| 305 | /* x,y,width,height describes a rectangle in the gl render buffer |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 306 | @@ -341,6 +347,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 307 | int width, |
| 308 | int height) |
| 309 | { |
| 310 | +#ifdef HAVE_OPENGL |
| 311 | GdkGLContext *paint_context; |
| 312 | cairo_surface_t *image; |
| 313 | cairo_matrix_t matrix; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 314 | @@ -718,6 +725,7 @@ out: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 315 | if (clip_region) |
| 316 | cairo_region_destroy (clip_region); |
| 317 | |
| 318 | +#endif |
| 319 | } |
| 320 | |
| 321 | /* This is always called with the paint context current */ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 322 | @@ -725,6 +733,7 @@ void |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 323 | gdk_gl_texture_from_surface (cairo_surface_t *surface, |
| 324 | cairo_region_t *region) |
| 325 | { |
| 326 | +#ifdef HAVE_OPENGL |
| 327 | GdkGLContext *paint_context; |
| 328 | cairo_surface_t *image; |
| 329 | double device_x_offset, device_y_offset; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 330 | @@ -825,4 +834,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 331 | |
| 332 | glDisable (GL_SCISSOR_TEST); |
| 333 | glDeleteTextures (1, &texture_id); |
| 334 | +#endif |
| 335 | } |
| 336 | diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 337 | index dfbed63..556f0a3 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 338 | --- a/gdk/gdkglcontext.c |
| 339 | +++ b/gdk/gdkglcontext.c |
| 340 | @@ -85,7 +85,9 @@ |
| 341 | #include "gdkintl.h" |
| 342 | #include "gdk-private.h" |
| 343 | |
| 344 | +#ifdef HAVE_OPENGL |
| 345 | #include <epoxy/gl.h> |
| 346 | +#endif |
| 347 | |
| 348 | typedef struct { |
| 349 | GdkDisplay *display; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 350 | @@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 351 | int height, |
| 352 | guint texture_target) |
| 353 | { |
| 354 | +#ifdef HAVE_OPENGL |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 355 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 356 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 357 | g_return_if_fail (GDK_IS_GL_CONTEXT (context)); |
| 358 | @@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
| 359 | glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride)); |
| 360 | } |
| 361 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 362 | +#endif |
| 363 | } |
| 364 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 365 | static gboolean |
| 366 | @@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 367 | static void |
| 368 | gdk_gl_context_check_extensions (GdkGLContext *context) |
| 369 | { |
| 370 | +#ifdef HAVE_OPENGL |
| 371 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
| 372 | gboolean has_npot, has_texture_rectangle; |
| 373 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 374 | @@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 375 | priv->use_texture_rectangle ? "yes" : "no")); |
| 376 | |
| 377 | priv->extensions_checked = TRUE; |
| 378 | +#endif |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 383 | index 1416409..e3b5630 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 384 | --- a/gdk/gdkwindow.c |
| 385 | +++ b/gdk/gdkwindow.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 386 | @@ -45,7 +45,9 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 387 | |
| 388 | #include <math.h> |
| 389 | |
| 390 | +#ifdef HAVE_OPENGL |
| 391 | #include <epoxy/gl.h> |
| 392 | +#endif |
| 393 | |
| 394 | /* for the use of round() */ |
| 395 | #include "fallback-c89.c" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 396 | @@ -2822,6 +2824,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 397 | { |
| 398 | GError *internal_error = NULL; |
| 399 | |
| 400 | +#ifndef HAVE_OPENGL |
| 401 | + g_set_error_literal (error, GDK_GL_ERROR, |
| 402 | + GDK_GL_ERROR_NOT_AVAILABLE, |
| 403 | + _("GL support disabled with --disable-opengl")); |
| 404 | + return NULL; |
| 405 | +#endif |
| 406 | + |
| 407 | if (_gdk_gl_flags & GDK_GL_DISABLE) |
| 408 | { |
| 409 | g_set_error_literal (error, GDK_GL_ERROR, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 410 | @@ -2957,6 +2966,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 411 | } |
| 412 | else |
| 413 | { |
| 414 | +#ifdef HAVE_OPENGL |
| 415 | gdk_gl_context_make_current (context); |
| 416 | /* With gl we always need a surface to combine the gl |
| 417 | drawing with the native drawing. */ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 418 | @@ -2971,6 +2981,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 419 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 420 | |
| 421 | glViewport (0, 0, ww, wh); |
| 422 | +#endif |
| 423 | } |
| 424 | } |
| 425 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 426 | @@ -3034,6 +3045,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 427 | |
| 428 | gdk_gl_context_make_current (window->gl_paint_context); |
| 429 | |
| 430 | +#ifdef HAVE_OPENGL |
| 431 | if (!cairo_region_is_empty (opaque_region)) |
| 432 | gdk_gl_texture_from_surface (window->current_paint.surface, |
| 433 | opaque_region); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 434 | @@ -3044,6 +3056,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 435 | window->current_paint.need_blend_region); |
| 436 | glDisable(GL_BLEND); |
| 437 | } |
| 438 | +#endif |
| 439 | |
| 440 | cairo_region_destroy (opaque_region); |
| 441 | |
| 442 | diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 443 | index 6289f3a..cbbac79 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 444 | --- a/gdk/x11/Makefile.am |
| 445 | +++ b/gdk/x11/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 446 | @@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 447 | gdkeventtranslator.c \ |
| 448 | gdkeventtranslator.h \ |
| 449 | gdkgeometry-x11.c \ |
| 450 | - gdkglcontext-x11.c \ |
| 451 | - gdkglcontext-x11.h \ |
| 452 | gdkkeys-x11.c \ |
| 453 | gdkmain-x11.c \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 454 | gdkmonitor-x11.c \ |
| 455 | @@ -56,14 +54,32 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 456 | gdkwindow-x11.h \ |
| 457 | gdkxftdefaults.c \ |
| 458 | gdkxid.c \ |
| 459 | - gdkx.h \ |
| 460 | gdkprivate-x11.h \ |
| 461 | xsettings-client.h \ |
| 462 | xsettings-client.c |
| 463 | |
| 464 | +if HAVE_OPENGL |
| 465 | +libgdk_x11_la_SOURCES += \ |
| 466 | + gdkglcontext-x11.c \ |
| 467 | + gdkglcontext-x11.h |
| 468 | +endif |
| 469 | + |
| 470 | libgdkinclude_HEADERS = \ |
| 471 | gdkx.h |
| 472 | |
| 473 | +if HAVE_OPENGL |
| 474 | +GDKX_HEADER = gdkx-with-gl-context.h |
| 475 | +else |
| 476 | +GDKX_HEADER = gdkx-without-gl-context.h |
| 477 | +endif |
| 478 | + |
| 479 | +BUILT_SOURCES = gdkx.h |
| 480 | + |
| 481 | +.PHONY: gdkx.h |
| 482 | +gdkx.h: |
| 483 | + $(AM_V_GEN) cd $(srcdir) \ |
| 484 | + && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h ) |
| 485 | + |
| 486 | libgdkx11include_HEADERS = \ |
| 487 | gdkx-autocleanups.h \ |
| 488 | gdkx11applaunchcontext.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 489 | @@ -77,7 +93,6 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 490 | gdkx11display.h \ |
| 491 | gdkx11displaymanager.h \ |
| 492 | gdkx11dnd.h \ |
| 493 | - gdkx11glcontext.h \ |
| 494 | gdkx11keys.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 495 | gdkx11monitor.h \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 496 | gdkx11property.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 497 | @@ -87,9 +102,16 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 498 | gdkx11visual.h \ |
| 499 | gdkx11window.h |
| 500 | |
| 501 | +if HAVE_OPENGL |
| 502 | +libgdkx11include_HEADERS += gdkx11glcontext.h |
| 503 | +endif |
| 504 | + |
| 505 | # We need to include all these C files here since the conditionals |
| 506 | # don't seem to be correctly expanded for the dist files. |
| 507 | EXTRA_DIST += \ |
| 508 | + gdkx.h \ |
| 509 | gdksettings.c |
| 510 | |
| 511 | +MAINTAINERCLEANFILES = gdkx.h |
| 512 | + |
| 513 | -include $(top_srcdir)/git.mk |
| 514 | diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 515 | index 5b95196..9a2f2a2 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 | |
| 527 | #include <glib.h> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 528 | @@ -3184,7 +3186,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 | |
| 539 | diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 540 | index 272cecd..2bb34ac 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 541 | --- a/gdk/x11/gdkscreen-x11.c |
| 542 | +++ b/gdk/x11/gdkscreen-x11.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 543 | @@ -1675,3 +1675,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 |
| 552 | diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 553 | index f92a146..89f900a 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 566 | @@ -5839,7 +5841,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 | } |
| 576 | diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h |
| 577 | index edb0ea7..a317d61 100644 |
| 578 | --- a/gdk/x11/gdkx-autocleanups.h |
| 579 | +++ b/gdk/x11/gdkx-autocleanups.h |
| 580 | @@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref) |
| 581 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref) |
| 582 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref) |
| 583 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref) |
| 584 | +#ifdef HAVE_OPENGL |
| 585 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref) |
| 586 | +#endif |
| 587 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref) |
| 588 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref) |
| 589 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 590 | diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx-with-gl-context.h |
| 591 | similarity index 98% |
| 592 | rename from gdk/x11/gdkx.h |
| 593 | rename to gdk/x11/gdkx-with-gl-context.h |
| 594 | index 1f64bcc..ae05fa6 100644 |
| 595 | --- a/gdk/x11/gdkx.h |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 596 | +++ b/gdk/x11/gdkx-with-gl-context.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 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> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 605 | diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h |
| 606 | new file mode 100644 |
| 607 | index 0000000..c9e2617 |
| 608 | --- /dev/null |
| 609 | +++ b/gdk/x11/gdkx-without-gl-context.h |
| 610 | @@ -0,0 +1,58 @@ |
| 611 | +/* GDK - The GIMP Drawing Kit |
| 612 | + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 613 | + * |
| 614 | + * This library is free software; you can redistribute it and/or |
| 615 | + * modify it under the terms of the GNU Lesser General Public |
| 616 | + * License as published by the Free Software Foundation; either |
| 617 | + * version 2 of the License, or (at your option) any later version. |
| 618 | + * |
| 619 | + * This library is distributed in the hope that it will be useful, |
| 620 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 621 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 622 | + * Lesser General Public License for more details. |
| 623 | + * |
| 624 | + * You should have received a copy of the GNU Lesser General Public |
| 625 | + * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 626 | + */ |
| 627 | + |
| 628 | +/* |
| 629 | + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 630 | + * file for a list of people on the GTK+ Team. See the ChangeLog |
| 631 | + * files for a list of changes. These files are distributed with |
| 632 | + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 633 | + */ |
| 634 | + |
| 635 | +#ifndef __GDK_X_H__ |
| 636 | +#define __GDK_X_H__ |
| 637 | + |
| 638 | +#include <gdk/gdk.h> |
| 639 | + |
| 640 | +#include <X11/Xlib.h> |
| 641 | +#include <X11/Xutil.h> |
| 642 | + |
| 643 | +#define __GDKX_H_INSIDE__ |
| 644 | + |
| 645 | +#include <gdk/x11/gdkx11applaunchcontext.h> |
| 646 | +#include <gdk/x11/gdkx11cursor.h> |
| 647 | +#include <gdk/x11/gdkx11device.h> |
| 648 | +#include <gdk/x11/gdkx11device-core.h> |
| 649 | +#include <gdk/x11/gdkx11device-xi2.h> |
| 650 | +#include <gdk/x11/gdkx11devicemanager.h> |
| 651 | +#include <gdk/x11/gdkx11devicemanager-core.h> |
| 652 | +#include <gdk/x11/gdkx11devicemanager-xi2.h> |
| 653 | +#include <gdk/x11/gdkx11display.h> |
| 654 | +#include <gdk/x11/gdkx11displaymanager.h> |
| 655 | +#include <gdk/x11/gdkx11dnd.h> |
| 656 | +#include <gdk/x11/gdkx11keys.h> |
| 657 | +#include <gdk/x11/gdkx11property.h> |
| 658 | +#include <gdk/x11/gdkx11screen.h> |
| 659 | +#include <gdk/x11/gdkx11selection.h> |
| 660 | +#include <gdk/x11/gdkx11utils.h> |
| 661 | +#include <gdk/x11/gdkx11visual.h> |
| 662 | +#include <gdk/x11/gdkx11window.h> |
| 663 | + |
| 664 | +#include <gdk/x11/gdkx-autocleanups.h> |
| 665 | + |
| 666 | +#undef __GDKX_H_INSIDE__ |
| 667 | + |
| 668 | +#endif /* __GDK_X_H__ */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 669 | diff --git a/gtk/Makefile.am b/gtk/Makefile.am |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 670 | index e556e9d..ce912d7 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 671 | --- a/gtk/Makefile.am |
| 672 | +++ b/gtk/Makefile.am |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 673 | @@ -1441,7 +1441,6 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 674 | && cp xgen-gptbc gtkprivatetypebuiltins.c \ |
| 675 | && rm -f xgen-gptbc |
| 676 | |
| 677 | - |
| 678 | gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gtk/deprecated/*.h $(top_srcdir)/gdk/*.h Makefile |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 679 | $(AM_V_GEN) export LC_ALL=C ; \ |
| 680 | (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtkx.h>') > xgen-gtfsrc.c && \ |
| 681 | @@ -1449,7 +1448,7 @@ gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_src |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 682 | ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \ |
| 683 | $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \ |
| 684 | sort | uniq | \ |
| 685 | - $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \ |
| 686 | + $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; s/^.*gdk_x11_gl.*$$/#ifdef HAVE_OPENGL\n&\n#endif/; }' >> xgen-gtf \ |
| 687 | && cp xgen-gtf $@ && rm -f xgen-gtf |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 688 | $(srcdir)/gtktestutils.c: gtktypefuncs.c |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 689 | |
| 690 | diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 691 | index ea383c0..bb4eb64 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 692 | --- a/gtk/gtkglarea.c |
| 693 | +++ b/gtk/gtkglarea.c |
| 694 | @@ -28,7 +28,9 @@ |
| 695 | #include "gtkprivate.h" |
| 696 | #include "gtkrender.h" |
| 697 | |
| 698 | +#ifdef HAVE_OPENGL |
| 699 | #include <epoxy/gl.h> |
| 700 | +#endif |
| 701 | |
| 702 | /** |
| 703 | * SECTION:gtkglarea |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 704 | @@ -368,9 +370,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 705 | static void |
| 706 | gtk_gl_area_resize (GtkGLArea *area, int width, int height) |
| 707 | { |
| 708 | +#ifdef HAVE_OPENGL |
| 709 | glViewport (0, 0, width, height); |
| 710 | +#endif |
| 711 | } |
| 712 | |
| 713 | +#ifdef HAVE_OPENGL |
| 714 | /* |
| 715 | * Creates all the buffer objects needed for rendering the scene |
| 716 | */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 717 | @@ -482,6 +487,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 718 | |
| 719 | priv->needs_render = TRUE; |
| 720 | } |
| 721 | +#endif |
| 722 | |
| 723 | /** |
| 724 | * gtk_gl_area_attach_buffers: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 725 | @@ -500,6 +506,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 726 | void |
| 727 | gtk_gl_area_attach_buffers (GtkGLArea *area) |
| 728 | { |
| 729 | +#ifdef HAVE_OPENGL |
| 730 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 731 | |
| 732 | g_return_if_fail (GTK_IS_GL_AREA (area)); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 733 | @@ -532,11 +539,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 734 | glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, |
| 735 | GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer); |
| 736 | } |
| 737 | +#endif |
| 738 | } |
| 739 | |
| 740 | static void |
| 741 | gtk_gl_area_delete_buffers (GtkGLArea *area) |
| 742 | { |
| 743 | +#ifdef HAVE_OPENGL |
| 744 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 745 | |
| 746 | if (priv->context == NULL) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 747 | @@ -568,6 +577,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 748 | glDeleteFramebuffersEXT (1, &priv->frame_buffer); |
| 749 | priv->frame_buffer = 0; |
| 750 | } |
| 751 | +#endif |
| 752 | } |
| 753 | |
| 754 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 755 | @@ -678,6 +688,7 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 756 | GtkGLArea *area = GTK_GL_AREA (widget); |
| 757 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 758 | gboolean unused; |
| 759 | +#ifdef HAVE_OPENGL |
| 760 | int w, h, scale; |
| 761 | GLenum status; |
| 762 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 763 | @@ -689,7 +700,6 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 764 | gtk_widget_get_allocated_height (widget)); |
| 765 | return FALSE; |
| 766 | } |
| 767 | - |
| 768 | if (priv->context == NULL) |
| 769 | return FALSE; |
| 770 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 771 | @@ -735,6 +745,14 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | return TRUE; |
| 775 | +#else |
| 776 | + if (priv->error != NULL) |
| 777 | + gtk_gl_area_draw_error_screen (area, |
| 778 | + cr, |
| 779 | + gtk_widget_get_allocated_width (widget), |
| 780 | + gtk_widget_get_allocated_height (widget)); |
| 781 | + return FALSE; |
| 782 | +#endif |
| 783 | } |
| 784 | |
| 785 | static gboolean |
| 786 | diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 787 | index c241ec8..24576dd 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 788 | --- a/gtk/inspector/general.c |
| 789 | +++ b/gtk/inspector/general.c |
| 790 | @@ -33,8 +33,10 @@ |
| 791 | |
| 792 | #ifdef GDK_WINDOWING_X11 |
| 793 | #include "x11/gdkx.h" |
| 794 | +#ifdef HAVE_OPENGL |
| 795 | #include <epoxy/glx.h> |
| 796 | #endif |
| 797 | +#endif |
| 798 | |
| 799 | #ifdef GDK_WINDOWING_WIN32 |
| 800 | #include "win32/gdkwin32.h" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 801 | @@ -196,6 +198,7 @@ add_label_row (GtkInspectorGeneral *gen, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 802 | gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label); |
| 803 | } |
| 804 | |
| 805 | +#ifdef HAVE_OPENGL |
| 806 | #ifdef GDK_WINDOWING_X11 |
| 807 | static void |
| 808 | append_glx_extension_row (GtkInspectorGeneral *gen, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 809 | @@ -205,6 +208,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen, |
| 810 | add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 811 | } |
| 812 | #endif |
| 813 | +#endif |
| 814 | |
| 815 | #ifdef GDK_WINDOWING_WAYLAND |
| 816 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 817 | @@ -254,6 +258,7 @@ wayland_get_display (struct wl_display *wl_display) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 818 | static void |
| 819 | init_gl (GtkInspectorGeneral *gen) |
| 820 | { |
| 821 | +#ifdef HAVE_OPENGL |
| 822 | #ifdef GDK_WINDOWING_X11 |
| 823 | if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) |
| 824 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 825 | @@ -280,6 +285,7 @@ init_gl (GtkInspectorGeneral *gen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 826 | } |
| 827 | else |
| 828 | #endif |
| 829 | +#endif |
| 830 | #ifdef GDK_WINDOWING_WAYLAND |
| 831 | if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) |
| 832 | { |
| 833 | diff --git a/tests/Makefile.am b/tests/Makefile.am |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 834 | index 7c5ca99..e4a4546 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 835 | --- a/tests/Makefile.am |
| 836 | +++ b/tests/Makefile.am |
| 837 | @@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
| 838 | testfullscreen \ |
| 839 | testgeometry \ |
| 840 | testgiconpixbuf \ |
| 841 | - testglarea \ |
| 842 | - testglblending \ |
| 843 | testgrid \ |
| 844 | testgtk \ |
| 845 | testheaderbar \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 846 | @@ -172,12 +170,18 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 847 | testactionbar \ |
| 848 | testwindowsize \ |
| 849 | testpopover \ |
| 850 | - gdkgears \ |
| 851 | listmodel \ |
| 852 | testpopup \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 853 | testpopupat \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 854 | $(NULL) |
| 855 | |
| 856 | +if HAVE_OPENGL |
| 857 | +noinst_PROGRAMS += |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 858 | + testglarea \ |
| 859 | + testglblending \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 860 | + gdkgears |
| 861 | +endif |
| 862 | + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 863 | if USE_WAYLAND |
| 864 | noinst_PROGRAMS += testforeign |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 865 | endif |
| 866 | diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 867 | index 0b3a519..07b096f 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 868 | --- a/testsuite/gtk/objects-finalize.c |
| 869 | +++ b/testsuite/gtk/objects-finalize.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 870 | @@ -115,7 +115,9 @@ main (int argc, char **argv) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 871 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE && |
| 872 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 && |
| 873 | all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER && |
| 874 | +#ifdef HAVE_OPENGL |
| 875 | all_types[i] != GDK_TYPE_X11_GL_CONTEXT && |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 876 | +#endif |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 877 | #endif |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 878 | /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */ |
| 879 | all_types[i] != GDK_TYPE_PIXBUF_LOADER && |