Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 1 | From a2e6b7cbbd6d741fed38d91b3742aa4a08395aba 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 |
| 4 | Subject: [PATCH 3/4] Add --disable-opengl configure option |
| 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> |
| 22 | --- |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 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/gdkdisplay.c | 4 ++- |
| 28 | gdk/gdkgl.c | 10 +++++++ |
| 29 | gdk/gdkglcontext.c | 6 ++++ |
| 30 | gdk/gdkwindow.c | 13 +++++++++ |
| 31 | gdk/x11/Makefile.am | 30 +++++++++++++++++--- |
| 32 | gdk/x11/gdkdisplay-x11.c | 6 +++- |
| 33 | gdk/x11/gdkscreen-x11.c | 5 ++++ |
| 34 | gdk/x11/gdkwindow-x11.c | 4 +++ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 35 | gdk/x11/gdkx-autocleanups.h | 2 ++ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 36 | gdk/x11/gdkx-with-gl-context.h | 59 ++++++++++++++++++++++++++++++++++++++ |
| 37 | gdk/x11/gdkx-without-gl-context.h | 58 +++++++++++++++++++++++++++++++++++++ |
| 38 | gdk/x11/gdkx.h | 60 --------------------------------------- |
| 39 | gtk/Makefile.am | 3 +- |
| 40 | gtk/gtkglarea.c | 20 ++++++++++++- |
| 41 | gtk/inspector/general.c | 6 ++++ |
| 42 | tests/Makefile.am | 10 +++++-- |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | testsuite/gtk/objects-finalize.c | 2 ++ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 44 | 21 files changed, 261 insertions(+), 77 deletions(-) |
| 45 | create mode 100644 gdk/x11/gdkx-with-gl-context.h |
| 46 | create mode 100644 gdk/x11/gdkx-without-gl-context.h |
| 47 | delete mode 100644 gdk/x11/gdkx.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 | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 50 | index 965eec9..00bf544 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | --- a/configure.ac |
| 52 | +++ b/configure.ac |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 53 | @@ -346,6 +346,15 @@ AC_ARG_ENABLE(mir-backend, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 54 | [enable the Mir gdk backend])], |
| 55 | [backend_set=yes]) |
| 56 | |
| 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 | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 69 | @@ -1352,7 +1361,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" |
| 73 | -GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends epoxy >= epoxy_required_version" |
| 74 | +GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends $EPOXY_PACKAGES" |
| 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 | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 78 | @@ -1386,7 +1395,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" |
| 82 | -GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES epoxy >= epoxy_required_version" |
| 83 | +GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $EPOXY_PACKAGES" |
| 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; |
| 212 | diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 213 | index 6b012ca..311c7f7 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 214 | --- a/gdk/gdkdisplay.c |
| 215 | +++ b/gdk/gdkdisplay.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 216 | @@ -2409,7 +2409,9 @@ gboolean |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 217 | gdk_display_make_gl_context_current (GdkDisplay *display, |
| 218 | GdkGLContext *context) |
| 219 | { |
| 220 | - return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 221 | + if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current) |
| 222 | + return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 223 | + return FALSE; |
| 224 | } |
| 225 | |
| 226 | GdkRenderingMode |
| 227 | diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 228 | index 8e7b8c2..b579b22 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 229 | --- a/gdk/gdkgl.c |
| 230 | +++ b/gdk/gdkgl.c |
| 231 | @@ -22,7 +22,9 @@ |
| 232 | |
| 233 | #include "gdkinternals.h" |
| 234 | |
| 235 | +#ifdef HAVE_OPENGL |
| 236 | #include <epoxy/gl.h> |
| 237 | +#endif |
| 238 | #include <math.h> |
| 239 | #include <string.h> |
| 240 | |
| 241 | @@ -36,6 +38,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface, |
| 242 | g_object_ref (window), g_object_unref); |
| 243 | } |
| 244 | |
| 245 | +#ifdef HAVE_OPENGL |
| 246 | static const char * |
| 247 | get_vertex_type_name (int type) |
| 248 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 249 | @@ -208,6 +211,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 250 | glUseProgram (paint_data->current_program->program); |
| 251 | } |
| 252 | } |
| 253 | +#endif |
| 254 | |
| 255 | void |
| 256 | gdk_gl_texture_quads (GdkGLContext *paint_context, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 257 | @@ -216,6 +220,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
| 258 | GdkTexturedQuad *quads, |
| 259 | gboolean flip_colors) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 260 | { |
| 261 | +#ifdef HAVE_OPENGL |
| 262 | GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context); |
| 263 | GdkGLContextProgram *program; |
| 264 | GdkWindow *window = gdk_gl_context_get_window (paint_context); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 265 | @@ -289,6 +294,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 266 | |
| 267 | glDisableVertexAttribArray (program->position_location); |
| 268 | glDisableVertexAttribArray (program->uv_location); |
| 269 | +#endif |
| 270 | } |
| 271 | |
| 272 | /* x,y,width,height describes a rectangle in the gl render buffer |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 273 | @@ -337,6 +343,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 274 | int width, |
| 275 | int height) |
| 276 | { |
| 277 | +#ifdef HAVE_OPENGL |
| 278 | GdkGLContext *paint_context; |
| 279 | cairo_surface_t *image; |
| 280 | cairo_matrix_t matrix; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 281 | @@ -707,6 +714,7 @@ out: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 282 | if (clip_region) |
| 283 | cairo_region_destroy (clip_region); |
| 284 | |
| 285 | +#endif |
| 286 | } |
| 287 | |
| 288 | /* This is always called with the paint context current */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 289 | @@ -714,6 +722,7 @@ void |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 290 | gdk_gl_texture_from_surface (cairo_surface_t *surface, |
| 291 | cairo_region_t *region) |
| 292 | { |
| 293 | +#ifdef HAVE_OPENGL |
| 294 | GdkGLContext *paint_context; |
| 295 | cairo_surface_t *image; |
| 296 | double device_x_offset, device_y_offset; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 297 | @@ -814,4 +823,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 298 | |
| 299 | glDisable (GL_SCISSOR_TEST); |
| 300 | glDeleteTextures (1, &texture_id); |
| 301 | +#endif |
| 302 | } |
| 303 | diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 304 | index c79dca0..8a7bec2 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 305 | --- a/gdk/gdkglcontext.c |
| 306 | +++ b/gdk/gdkglcontext.c |
| 307 | @@ -85,7 +85,9 @@ |
| 308 | #include "gdkintl.h" |
| 309 | #include "gdk-private.h" |
| 310 | |
| 311 | +#ifdef HAVE_OPENGL |
| 312 | #include <epoxy/gl.h> |
| 313 | +#endif |
| 314 | |
| 315 | typedef struct { |
| 316 | GdkDisplay *display; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 317 | @@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 318 | int height, |
| 319 | guint texture_target) |
| 320 | { |
| 321 | +#ifdef HAVE_OPENGL |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 322 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 323 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 324 | g_return_if_fail (GDK_IS_GL_CONTEXT (context)); |
| 325 | @@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
| 326 | glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride)); |
| 327 | } |
| 328 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 329 | +#endif |
| 330 | } |
| 331 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 332 | static gboolean |
| 333 | @@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 334 | static void |
| 335 | gdk_gl_context_check_extensions (GdkGLContext *context) |
| 336 | { |
| 337 | +#ifdef HAVE_OPENGL |
| 338 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
| 339 | gboolean has_npot, has_texture_rectangle; |
| 340 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 341 | @@ -847,6 +852,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 342 | priv->use_texture_rectangle ? "yes" : "no")); |
| 343 | |
| 344 | priv->extensions_checked = TRUE; |
| 345 | +#endif |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 350 | index 689d666..fb84256 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 351 | --- a/gdk/gdkwindow.c |
| 352 | +++ b/gdk/gdkwindow.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 353 | @@ -45,7 +45,9 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 354 | |
| 355 | #include <math.h> |
| 356 | |
| 357 | +#ifdef HAVE_OPENGL |
| 358 | #include <epoxy/gl.h> |
| 359 | +#endif |
| 360 | |
| 361 | /* for the use of round() */ |
| 362 | #include "fallback-c89.c" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 363 | @@ -2819,6 +2821,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 364 | { |
| 365 | GError *internal_error = NULL; |
| 366 | |
| 367 | +#ifndef HAVE_OPENGL |
| 368 | + g_set_error_literal (error, GDK_GL_ERROR, |
| 369 | + GDK_GL_ERROR_NOT_AVAILABLE, |
| 370 | + _("GL support disabled with --disable-opengl")); |
| 371 | + return NULL; |
| 372 | +#endif |
| 373 | + |
| 374 | if (_gdk_gl_flags & GDK_GL_DISABLE) |
| 375 | { |
| 376 | g_set_error_literal (error, GDK_GL_ERROR, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 377 | @@ -2954,6 +2963,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 378 | } |
| 379 | else |
| 380 | { |
| 381 | +#ifdef HAVE_OPENGL |
| 382 | gdk_gl_context_make_current (context); |
| 383 | /* With gl we always need a surface to combine the gl |
| 384 | drawing with the native drawing. */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 385 | @@ -2968,6 +2978,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 386 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 387 | |
| 388 | glViewport (0, 0, ww, wh); |
| 389 | +#endif |
| 390 | } |
| 391 | } |
| 392 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 393 | @@ -3031,6 +3042,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 394 | |
| 395 | gdk_gl_context_make_current (window->gl_paint_context); |
| 396 | |
| 397 | +#ifdef HAVE_OPENGL |
| 398 | if (!cairo_region_is_empty (opaque_region)) |
| 399 | gdk_gl_texture_from_surface (window->current_paint.surface, |
| 400 | opaque_region); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 401 | @@ -3041,6 +3053,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 402 | window->current_paint.need_blend_region); |
| 403 | glDisable(GL_BLEND); |
| 404 | } |
| 405 | +#endif |
| 406 | |
| 407 | cairo_region_destroy (opaque_region); |
| 408 | |
| 409 | diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 410 | index 6289f3a..cbbac79 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 411 | --- a/gdk/x11/Makefile.am |
| 412 | +++ b/gdk/x11/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 413 | @@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 414 | gdkeventtranslator.c \ |
| 415 | gdkeventtranslator.h \ |
| 416 | gdkgeometry-x11.c \ |
| 417 | - gdkglcontext-x11.c \ |
| 418 | - gdkglcontext-x11.h \ |
| 419 | gdkkeys-x11.c \ |
| 420 | gdkmain-x11.c \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 421 | gdkmonitor-x11.c \ |
| 422 | @@ -56,14 +54,32 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 423 | gdkwindow-x11.h \ |
| 424 | gdkxftdefaults.c \ |
| 425 | gdkxid.c \ |
| 426 | - gdkx.h \ |
| 427 | gdkprivate-x11.h \ |
| 428 | xsettings-client.h \ |
| 429 | xsettings-client.c |
| 430 | |
| 431 | +if HAVE_OPENGL |
| 432 | +libgdk_x11_la_SOURCES += \ |
| 433 | + gdkglcontext-x11.c \ |
| 434 | + gdkglcontext-x11.h |
| 435 | +endif |
| 436 | + |
| 437 | libgdkinclude_HEADERS = \ |
| 438 | gdkx.h |
| 439 | |
| 440 | +if HAVE_OPENGL |
| 441 | +GDKX_HEADER = gdkx-with-gl-context.h |
| 442 | +else |
| 443 | +GDKX_HEADER = gdkx-without-gl-context.h |
| 444 | +endif |
| 445 | + |
| 446 | +BUILT_SOURCES = gdkx.h |
| 447 | + |
| 448 | +.PHONY: gdkx.h |
| 449 | +gdkx.h: |
| 450 | + $(AM_V_GEN) cd $(srcdir) \ |
| 451 | + && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h ) |
| 452 | + |
| 453 | libgdkx11include_HEADERS = \ |
| 454 | gdkx-autocleanups.h \ |
| 455 | gdkx11applaunchcontext.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 456 | @@ -77,7 +93,6 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 457 | gdkx11display.h \ |
| 458 | gdkx11displaymanager.h \ |
| 459 | gdkx11dnd.h \ |
| 460 | - gdkx11glcontext.h \ |
| 461 | gdkx11keys.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 462 | gdkx11monitor.h \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 463 | gdkx11property.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 464 | @@ -87,9 +102,16 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 465 | gdkx11visual.h \ |
| 466 | gdkx11window.h |
| 467 | |
| 468 | +if HAVE_OPENGL |
| 469 | +libgdkx11include_HEADERS += gdkx11glcontext.h |
| 470 | +endif |
| 471 | + |
| 472 | # We need to include all these C files here since the conditionals |
| 473 | # don't seem to be correctly expanded for the dist files. |
| 474 | EXTRA_DIST += \ |
| 475 | + gdkx.h \ |
| 476 | gdksettings.c |
| 477 | |
| 478 | +MAINTAINERCLEANFILES = gdkx.h |
| 479 | + |
| 480 | -include $(top_srcdir)/git.mk |
| 481 | diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 482 | index ad65e29..91345ee 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 483 | --- a/gdk/x11/gdkdisplay-x11.c |
| 484 | +++ b/gdk/x11/gdkdisplay-x11.c |
| 485 | @@ -37,7 +37,9 @@ |
| 486 | #include "gdkdisplay-x11.h" |
| 487 | #include "gdkprivate-x11.h" |
| 488 | #include "gdkscreen-x11.h" |
| 489 | +#ifdef HAVE_OPENGL |
| 490 | #include "gdkglcontext-x11.h" |
| 491 | +#endif |
| 492 | #include "gdk-private.h" |
| 493 | |
| 494 | #include <glib.h> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 495 | @@ -2994,7 +2996,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 496 | display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list; |
| 497 | display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target; |
| 498 | |
| 499 | - display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; |
| 500 | +#ifdef HAVE_OPENGL |
| 501 | + display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; |
| 502 | +#endif |
| 503 | |
| 504 | display_class->get_default_seat = gdk_x11_display_get_default_seat; |
| 505 | |
| 506 | diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 507 | index 7bf9979..cd1cc9d 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 508 | --- a/gdk/x11/gdkscreen-x11.c |
| 509 | +++ b/gdk/x11/gdkscreen-x11.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 510 | @@ -1643,3 +1643,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 511 | { |
| 512 | return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP"); |
| 513 | } |
| 514 | + |
| 515 | +#ifndef HAVE_OPENGL |
| 516 | +/* Function from in gdk/x11/gdkglcontext-x11.c */ |
| 517 | +void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen) {} |
| 518 | +#endif |
| 519 | diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 520 | index 3d6fd3b..2bd5c87 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 521 | --- a/gdk/x11/gdkwindow-x11.c |
| 522 | +++ b/gdk/x11/gdkwindow-x11.c |
| 523 | @@ -36,7 +36,9 @@ |
| 524 | #include "gdkasync.h" |
| 525 | #include "gdkeventsource.h" |
| 526 | #include "gdkdisplay-x11.h" |
| 527 | +#ifdef HAVE_OPENGL |
| 528 | #include "gdkglcontext-x11.h" |
| 529 | +#endif |
| 530 | #include "gdkprivate-x11.h" |
| 531 | #include "gdk-private.h" |
| 532 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 533 | @@ -5801,7 +5803,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 534 | impl_class->set_opaque_region = gdk_x11_window_set_opaque_region; |
| 535 | impl_class->set_shadow_width = gdk_x11_window_set_shadow_width; |
| 536 | impl_class->show_window_menu = gdk_x11_window_show_window_menu; |
| 537 | +#ifdef HAVE_OPENGL |
| 538 | impl_class->create_gl_context = gdk_x11_window_create_gl_context; |
| 539 | impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame; |
| 540 | +#endif |
| 541 | impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size; |
| 542 | } |
| 543 | diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h |
| 544 | index edb0ea7..a317d61 100644 |
| 545 | --- a/gdk/x11/gdkx-autocleanups.h |
| 546 | +++ b/gdk/x11/gdkx-autocleanups.h |
| 547 | @@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref) |
| 548 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref) |
| 549 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref) |
| 550 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref) |
| 551 | +#ifdef HAVE_OPENGL |
| 552 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref) |
| 553 | +#endif |
| 554 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref) |
| 555 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref) |
| 556 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref) |
| 557 | diff --git a/gdk/x11/gdkx-with-gl-context.h b/gdk/x11/gdkx-with-gl-context.h |
| 558 | new file mode 100644 |
| 559 | index 0000000..ae05fa6 |
| 560 | --- /dev/null |
| 561 | +++ b/gdk/x11/gdkx-with-gl-context.h |
| 562 | @@ -0,0 +1,59 @@ |
| 563 | +/* GDK - The GIMP Drawing Kit |
| 564 | + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 565 | + * |
| 566 | + * This library is free software; you can redistribute it and/or |
| 567 | + * modify it under the terms of the GNU Lesser General Public |
| 568 | + * License as published by the Free Software Foundation; either |
| 569 | + * version 2 of the License, or (at your option) any later version. |
| 570 | + * |
| 571 | + * This library is distributed in the hope that it will be useful, |
| 572 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 573 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 574 | + * Lesser General Public License for more details. |
| 575 | + * |
| 576 | + * You should have received a copy of the GNU Lesser General Public |
| 577 | + * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 578 | + */ |
| 579 | + |
| 580 | +/* |
| 581 | + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 582 | + * file for a list of people on the GTK+ Team. See the ChangeLog |
| 583 | + * files for a list of changes. These files are distributed with |
| 584 | + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 585 | + */ |
| 586 | + |
| 587 | +#ifndef __GDK_X_H__ |
| 588 | +#define __GDK_X_H__ |
| 589 | + |
| 590 | +#include <gdk/gdk.h> |
| 591 | + |
| 592 | +#include <X11/Xlib.h> |
| 593 | +#include <X11/Xutil.h> |
| 594 | + |
| 595 | +#define __GDKX_H_INSIDE__ |
| 596 | + |
| 597 | +#include <gdk/x11/gdkx11applaunchcontext.h> |
| 598 | +#include <gdk/x11/gdkx11cursor.h> |
| 599 | +#include <gdk/x11/gdkx11device.h> |
| 600 | +#include <gdk/x11/gdkx11device-core.h> |
| 601 | +#include <gdk/x11/gdkx11device-xi2.h> |
| 602 | +#include <gdk/x11/gdkx11devicemanager.h> |
| 603 | +#include <gdk/x11/gdkx11devicemanager-core.h> |
| 604 | +#include <gdk/x11/gdkx11devicemanager-xi2.h> |
| 605 | +#include <gdk/x11/gdkx11display.h> |
| 606 | +#include <gdk/x11/gdkx11displaymanager.h> |
| 607 | +#include <gdk/x11/gdkx11dnd.h> |
| 608 | +#include <gdk/x11/gdkx11glcontext.h> |
| 609 | +#include <gdk/x11/gdkx11keys.h> |
| 610 | +#include <gdk/x11/gdkx11property.h> |
| 611 | +#include <gdk/x11/gdkx11screen.h> |
| 612 | +#include <gdk/x11/gdkx11selection.h> |
| 613 | +#include <gdk/x11/gdkx11utils.h> |
| 614 | +#include <gdk/x11/gdkx11visual.h> |
| 615 | +#include <gdk/x11/gdkx11window.h> |
| 616 | + |
| 617 | +#include <gdk/x11/gdkx-autocleanups.h> |
| 618 | + |
| 619 | +#undef __GDKX_H_INSIDE__ |
| 620 | + |
| 621 | +#endif /* __GDK_X_H__ */ |
| 622 | diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h |
| 623 | new file mode 100644 |
| 624 | index 0000000..c9e2617 |
| 625 | --- /dev/null |
| 626 | +++ b/gdk/x11/gdkx-without-gl-context.h |
| 627 | @@ -0,0 +1,58 @@ |
| 628 | +/* GDK - The GIMP Drawing Kit |
| 629 | + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 630 | + * |
| 631 | + * This library is free software; you can redistribute it and/or |
| 632 | + * modify it under the terms of the GNU Lesser General Public |
| 633 | + * License as published by the Free Software Foundation; either |
| 634 | + * version 2 of the License, or (at your option) any later version. |
| 635 | + * |
| 636 | + * This library is distributed in the hope that it will be useful, |
| 637 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 638 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 639 | + * Lesser General Public License for more details. |
| 640 | + * |
| 641 | + * You should have received a copy of the GNU Lesser General Public |
| 642 | + * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 643 | + */ |
| 644 | + |
| 645 | +/* |
| 646 | + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 647 | + * file for a list of people on the GTK+ Team. See the ChangeLog |
| 648 | + * files for a list of changes. These files are distributed with |
| 649 | + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 650 | + */ |
| 651 | + |
| 652 | +#ifndef __GDK_X_H__ |
| 653 | +#define __GDK_X_H__ |
| 654 | + |
| 655 | +#include <gdk/gdk.h> |
| 656 | + |
| 657 | +#include <X11/Xlib.h> |
| 658 | +#include <X11/Xutil.h> |
| 659 | + |
| 660 | +#define __GDKX_H_INSIDE__ |
| 661 | + |
| 662 | +#include <gdk/x11/gdkx11applaunchcontext.h> |
| 663 | +#include <gdk/x11/gdkx11cursor.h> |
| 664 | +#include <gdk/x11/gdkx11device.h> |
| 665 | +#include <gdk/x11/gdkx11device-core.h> |
| 666 | +#include <gdk/x11/gdkx11device-xi2.h> |
| 667 | +#include <gdk/x11/gdkx11devicemanager.h> |
| 668 | +#include <gdk/x11/gdkx11devicemanager-core.h> |
| 669 | +#include <gdk/x11/gdkx11devicemanager-xi2.h> |
| 670 | +#include <gdk/x11/gdkx11display.h> |
| 671 | +#include <gdk/x11/gdkx11displaymanager.h> |
| 672 | +#include <gdk/x11/gdkx11dnd.h> |
| 673 | +#include <gdk/x11/gdkx11keys.h> |
| 674 | +#include <gdk/x11/gdkx11property.h> |
| 675 | +#include <gdk/x11/gdkx11screen.h> |
| 676 | +#include <gdk/x11/gdkx11selection.h> |
| 677 | +#include <gdk/x11/gdkx11utils.h> |
| 678 | +#include <gdk/x11/gdkx11visual.h> |
| 679 | +#include <gdk/x11/gdkx11window.h> |
| 680 | + |
| 681 | +#include <gdk/x11/gdkx-autocleanups.h> |
| 682 | + |
| 683 | +#undef __GDKX_H_INSIDE__ |
| 684 | + |
| 685 | +#endif /* __GDK_X_H__ */ |
| 686 | diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h |
| 687 | deleted file mode 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 688 | index 1f64bcc..0000000 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 689 | --- a/gdk/x11/gdkx.h |
| 690 | +++ /dev/null |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 691 | @@ -1,60 +0,0 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 692 | -/* GDK - The GIMP Drawing Kit |
| 693 | - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 694 | - * |
| 695 | - * This library is free software; you can redistribute it and/or |
| 696 | - * modify it under the terms of the GNU Lesser General Public |
| 697 | - * License as published by the Free Software Foundation; either |
| 698 | - * version 2 of the License, or (at your option) any later version. |
| 699 | - * |
| 700 | - * This library is distributed in the hope that it will be useful, |
| 701 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 702 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 703 | - * Lesser General Public License for more details. |
| 704 | - * |
| 705 | - * You should have received a copy of the GNU Lesser General Public |
| 706 | - * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 707 | - */ |
| 708 | - |
| 709 | -/* |
| 710 | - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 711 | - * file for a list of people on the GTK+ Team. See the ChangeLog |
| 712 | - * files for a list of changes. These files are distributed with |
| 713 | - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 714 | - */ |
| 715 | - |
| 716 | -#ifndef __GDK_X_H__ |
| 717 | -#define __GDK_X_H__ |
| 718 | - |
| 719 | -#include <gdk/gdk.h> |
| 720 | - |
| 721 | -#include <X11/Xlib.h> |
| 722 | -#include <X11/Xutil.h> |
| 723 | - |
| 724 | -#define __GDKX_H_INSIDE__ |
| 725 | - |
| 726 | -#include <gdk/x11/gdkx11applaunchcontext.h> |
| 727 | -#include <gdk/x11/gdkx11cursor.h> |
| 728 | -#include <gdk/x11/gdkx11device.h> |
| 729 | -#include <gdk/x11/gdkx11device-core.h> |
| 730 | -#include <gdk/x11/gdkx11device-xi2.h> |
| 731 | -#include <gdk/x11/gdkx11devicemanager.h> |
| 732 | -#include <gdk/x11/gdkx11devicemanager-core.h> |
| 733 | -#include <gdk/x11/gdkx11devicemanager-xi2.h> |
| 734 | -#include <gdk/x11/gdkx11display.h> |
| 735 | -#include <gdk/x11/gdkx11displaymanager.h> |
| 736 | -#include <gdk/x11/gdkx11dnd.h> |
| 737 | -#include <gdk/x11/gdkx11glcontext.h> |
| 738 | -#include <gdk/x11/gdkx11keys.h> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 739 | -#include <gdk/x11/gdkx11monitor.h> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 740 | -#include <gdk/x11/gdkx11property.h> |
| 741 | -#include <gdk/x11/gdkx11screen.h> |
| 742 | -#include <gdk/x11/gdkx11selection.h> |
| 743 | -#include <gdk/x11/gdkx11utils.h> |
| 744 | -#include <gdk/x11/gdkx11visual.h> |
| 745 | -#include <gdk/x11/gdkx11window.h> |
| 746 | - |
| 747 | -#include <gdk/x11/gdkx-autocleanups.h> |
| 748 | - |
| 749 | -#undef __GDKX_H_INSIDE__ |
| 750 | - |
| 751 | -#endif /* __GDK_X_H__ */ |
| 752 | diff --git a/gtk/Makefile.am b/gtk/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 753 | index 45fb7c2..ce81011 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 754 | --- a/gtk/Makefile.am |
| 755 | +++ b/gtk/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 756 | @@ -1411,14 +1411,13 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 757 | && cp xgen-gptbc gtkprivatetypebuiltins.c \ |
| 758 | && rm -f xgen-gptbc |
| 759 | |
| 760 | - |
| 761 | 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 |
| 762 | $(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtkx.h>') > xgen-gtfsrc.c && \ |
| 763 | echo 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS' > xgen-gtf && \ |
| 764 | ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \ |
| 765 | $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \ |
| 766 | sort | uniq | \ |
| 767 | - $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \ |
| 768 | + $(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 \ |
| 769 | && cp xgen-gtf $@ && rm -f xgen-gtf |
| 770 | gtktestutils.c: gtktypefuncs.c |
| 771 | |
| 772 | diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 773 | index 094378e..f7c7f47 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 774 | --- a/gtk/gtkglarea.c |
| 775 | +++ b/gtk/gtkglarea.c |
| 776 | @@ -28,7 +28,9 @@ |
| 777 | #include "gtkprivate.h" |
| 778 | #include "gtkrender.h" |
| 779 | |
| 780 | +#ifdef HAVE_OPENGL |
| 781 | #include <epoxy/gl.h> |
| 782 | +#endif |
| 783 | |
| 784 | /** |
| 785 | * SECTION:gtkglarea |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 786 | @@ -368,9 +370,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 787 | static void |
| 788 | gtk_gl_area_resize (GtkGLArea *area, int width, int height) |
| 789 | { |
| 790 | +#ifdef HAVE_OPENGL |
| 791 | glViewport (0, 0, width, height); |
| 792 | +#endif |
| 793 | } |
| 794 | |
| 795 | +#ifdef HAVE_OPENGL |
| 796 | /* |
| 797 | * Creates all the buffer objects needed for rendering the scene |
| 798 | */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 799 | @@ -482,6 +487,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 800 | |
| 801 | priv->needs_render = TRUE; |
| 802 | } |
| 803 | +#endif |
| 804 | |
| 805 | /** |
| 806 | * gtk_gl_area_attach_buffers: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 807 | @@ -500,6 +506,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 808 | void |
| 809 | gtk_gl_area_attach_buffers (GtkGLArea *area) |
| 810 | { |
| 811 | +#ifdef HAVE_OPENGL |
| 812 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 813 | |
| 814 | g_return_if_fail (GTK_IS_GL_AREA (area)); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 815 | @@ -532,11 +539,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 816 | glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, |
| 817 | GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer); |
| 818 | } |
| 819 | +#endif |
| 820 | } |
| 821 | |
| 822 | static void |
| 823 | gtk_gl_area_delete_buffers (GtkGLArea *area) |
| 824 | { |
| 825 | +#ifdef HAVE_OPENGL |
| 826 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 827 | |
| 828 | if (priv->context == NULL) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 829 | @@ -568,6 +577,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 830 | glDeleteFramebuffersEXT (1, &priv->frame_buffer); |
| 831 | priv->frame_buffer = 0; |
| 832 | } |
| 833 | +#endif |
| 834 | } |
| 835 | |
| 836 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 837 | @@ -678,6 +688,7 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 838 | GtkGLArea *area = GTK_GL_AREA (widget); |
| 839 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 840 | gboolean unused; |
| 841 | +#ifdef HAVE_OPENGL |
| 842 | int w, h, scale; |
| 843 | GLenum status; |
| 844 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 845 | @@ -689,7 +700,6 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 846 | gtk_widget_get_allocated_height (widget)); |
| 847 | return FALSE; |
| 848 | } |
| 849 | - |
| 850 | if (priv->context == NULL) |
| 851 | return FALSE; |
| 852 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 853 | @@ -735,6 +745,14 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | return TRUE; |
| 857 | +#else |
| 858 | + if (priv->error != NULL) |
| 859 | + gtk_gl_area_draw_error_screen (area, |
| 860 | + cr, |
| 861 | + gtk_widget_get_allocated_width (widget), |
| 862 | + gtk_widget_get_allocated_height (widget)); |
| 863 | + return FALSE; |
| 864 | +#endif |
| 865 | } |
| 866 | |
| 867 | static gboolean |
| 868 | diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 869 | index c241ec8..24576dd 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 870 | --- a/gtk/inspector/general.c |
| 871 | +++ b/gtk/inspector/general.c |
| 872 | @@ -33,8 +33,10 @@ |
| 873 | |
| 874 | #ifdef GDK_WINDOWING_X11 |
| 875 | #include "x11/gdkx.h" |
| 876 | +#ifdef HAVE_OPENGL |
| 877 | #include <epoxy/glx.h> |
| 878 | #endif |
| 879 | +#endif |
| 880 | |
| 881 | #ifdef GDK_WINDOWING_WIN32 |
| 882 | #include "win32/gdkwin32.h" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 883 | @@ -196,6 +198,7 @@ add_label_row (GtkInspectorGeneral *gen, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 884 | gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label); |
| 885 | } |
| 886 | |
| 887 | +#ifdef HAVE_OPENGL |
| 888 | #ifdef GDK_WINDOWING_X11 |
| 889 | static void |
| 890 | append_glx_extension_row (GtkInspectorGeneral *gen, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 891 | @@ -205,6 +208,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen, |
| 892 | 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] | 893 | } |
| 894 | #endif |
| 895 | +#endif |
| 896 | |
| 897 | #ifdef GDK_WINDOWING_WAYLAND |
| 898 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 899 | @@ -254,6 +258,7 @@ wayland_get_display (struct wl_display *wl_display) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 900 | static void |
| 901 | init_gl (GtkInspectorGeneral *gen) |
| 902 | { |
| 903 | +#ifdef HAVE_OPENGL |
| 904 | #ifdef GDK_WINDOWING_X11 |
| 905 | if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) |
| 906 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 907 | @@ -280,6 +285,7 @@ init_gl (GtkInspectorGeneral *gen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 908 | } |
| 909 | else |
| 910 | #endif |
| 911 | +#endif |
| 912 | #ifdef GDK_WINDOWING_WAYLAND |
| 913 | if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) |
| 914 | { |
| 915 | diff --git a/tests/Makefile.am b/tests/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 916 | index f86c166..ba1acad 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 917 | --- a/tests/Makefile.am |
| 918 | +++ b/tests/Makefile.am |
| 919 | @@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
| 920 | testfullscreen \ |
| 921 | testgeometry \ |
| 922 | testgiconpixbuf \ |
| 923 | - testglarea \ |
| 924 | - testglblending \ |
| 925 | testgrid \ |
| 926 | testgtk \ |
| 927 | testheaderbar \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 928 | @@ -170,12 +168,18 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 929 | testactionbar \ |
| 930 | testwindowsize \ |
| 931 | testpopover \ |
| 932 | - gdkgears \ |
| 933 | listmodel \ |
| 934 | testpopup \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 935 | testpopupat \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 936 | $(NULL) |
| 937 | |
| 938 | +if HAVE_OPENGL |
| 939 | +noinst_PROGRAMS += |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 940 | + testglarea \ |
| 941 | + testglblending \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 942 | + gdkgears |
| 943 | +endif |
| 944 | + |
| 945 | if USE_X11 |
| 946 | noinst_PROGRAMS += testerrors |
| 947 | endif |
| 948 | 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^] | 949 | index 0b3a519..07b096f 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 950 | --- a/testsuite/gtk/objects-finalize.c |
| 951 | +++ b/testsuite/gtk/objects-finalize.c |
| 952 | @@ -115,8 +115,10 @@ main (int argc, char **argv) |
| 953 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE && |
| 954 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 && |
| 955 | all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER && |
| 956 | +#ifdef HAVE_OPENGL |
| 957 | all_types[i] != GDK_TYPE_X11_GL_CONTEXT && |
| 958 | #endif |
| 959 | +#endif |
| 960 | /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */ |
| 961 | all_types[i] != GDK_TYPE_PIXBUF_LOADER && |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 962 | all_types[i] != GDK_TYPE_DRAWING_CONTEXT && |
| 963 | -- |
| 964 | 2.12.0 |
| 965 | |