--- configure.ac	2014-04-30 22:15:36.309059583 +0200
+++ configure.ac	2014-04-30 22:18:33.353062271 +0200
@@ -88,10 +88,11 @@
 dnl
 dnl  Check for GL/MesaGL libraries
 dnl
-AC_ARG_WITH(GL-prefix,  [  --with-GL-prefix=DIR    Prefix where GL/MesaGL is installed])
-AC_ARG_WITH(lib-GL,     [  --with-lib-GL           use '-lGL'])
-AC_ARG_WITH(lib-MesaGL, [  --with-lib-MesaGL       use '-lMesaGL'])
-AC_ARG_WITH(lib-opengl32,[ --with-lib-opengl32     use '-lopengl32'])
+AC_ARG_WITH(GL-prefix,   [  --with-GL-prefix=DIR    Prefix where GL/MesaGL is installed])
+AC_ARG_WITH(lib-GL,      [  --with-lib-GL           use '-lGL'])
+AC_ARG_WITH(lib-MesaGL,  [  --with-lib-MesaGL       use '-lMesaGL'])
+AC_ARG_WITH(lib-opengl32,[  --with-lib-opengl32     use '-lopengl32'])
+AC_ARG_WITH(wayland-egl, [  --with-wayland-egl      use '-lwayland-egl' (requires GTK+ 3.8.0 and GLESv1)])
 
 if test "x$with_GL_prefix" = "x" ; then
  GL_LDOPTS=""
@@ -131,6 +132,35 @@
  AC_MSG_RESULT($have_MesaGL_pthread)
 fi
 
+AM_CONDITIONAL(HAVE_GL, test "$have_GL" = "yes" -o "$have_MesaGL" = "yes" -o "$have_MesaGL_pthread" = "yes")
+
+if test "x$with_wayland_egl" = "xyes"; then
+ if test "x$with_gtk" = "x3"; then
+  PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.8.0)
+ else
+  AC_MSG_ERROR([Wayland-EGL requires GTK+3 (--with-gtk=3)])
+ fi
+ AC_MSG_CHECKING([Wayland-EGL])
+ LIBS="$saved_LIBS $GTK_LIBS $GL_LDOPTS -lwayland-egl -lwayland-client -lEGL"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
+                                 [[ struct wl_surface *surf; wl_egl_window_create(surf, 1, 1); ]])],
+                [have_wayland_EGL=yes], [have_wayland_EGL=no])
+ AC_MSG_RESULT($have_wayland_EGL)
+
+ if test "x$have_wayland_EGL" = "xyes"; then
+  AC_MSG_CHECKING([GLESv1])
+  LIBS="$saved_LIBS $GTK_LIBS $GL_LDOPTS -lGLESv1_CM"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
+                                  [[ glEnableClientState (); ]])],
+                 [have_GLESv1=yes], [have_GLESv1=no])
+  AC_MSG_RESULT($have_GLESv1)
+ fi
+else
+ have_wayland_EGL=no
+ have_GLESv1=no
+fi
+AM_CONDITIONAL(HAVE_WAYLAND_EGL, test "$have_wayland_EGL" = "yes")
+
 LIBS="$saved_LIBS"
 
 if test "x$with_lib_GL" = "xyes"; then
@@ -169,6 +199,8 @@
   GL_LIBS="$GL_LDOPTS -lMesaGL"
  elif test "x$have_MesaGL_pthread" = "xyes"; then
   GL_LIBS="$GL_LDOPTS -lMesaGL -lpthread"
+ elif test "x$have_wayland_EGL" = "xyes" -a "x$have_GLESv1" = "xyes"; then
+  GL_LIBS="$GL_LDOPTS -lwayland-egl -lwayland-client -lEGL -lGLESv1_CM"
  else
   AC_MSG_ERROR([You need GL or MesaGL libraries])
  fi
@@ -206,5 +238,7 @@
 echo "   * Installation prefix: $prefix"
 echo "   * Win32:               $native_win32"
 echo "   * OpenGL:              $have_GL"
+echo "   * GLESv1:              $have_GLESv1"
+echo "   * Wayland-EGL:         $have_wayland_EGL"
 echo ""
 echo "---"
--- examples/Makefile.am	2014-04-30 09:54:35.752566712 -0700
+++ examples/Makefile.am	2014-04-30 10:09:23.257130386 -0700
@@ -6,13 +6,22 @@
 shader_programs = shaders
 endif
 
-noinst_PROGRAMS = simple zktor viewlw glpixmap gdkfont $(shader_programs) gtkglarea_demo
+if HAVE_GL
+gl_programs = simple zktor viewlw glpixmap gdkfont $(shader_programs) gtkglarea_demo
+endif
+
+if HAVE_WAYLAND_EGL
+wayland_egl_programs = simple_wl
+endif
+
+noinst_PROGRAMS = $(gl_programs) $(wayland_egl_programs)
 
 AM_CPPFLAGS = -I$(top_srcdir)
 AM_CFLAGS = $(GTK_CFLAGS) $(GL_CFLAGS)
 LDADD = $(top_builddir)/gtkgl/libgtkgl-2.0.la $(GTK_LIBS) $(GL_LIBS) $(LIBM)
 
 simple_SOURCES   = simple.c
+simple_wl_SOURCES= simple_wl.c
 zktor_SOURCES    = zktor.c
 glpixmap_SOURCES = glpixmap.c
 viewlw_SOURCES   = viewlw.c lw.h lw.c trackball.h trackball.c
--- /dev/null	2014-04-30 07:14:18.697400853 -0700
+++ examples/simple_wl.c	2014-04-30 09:53:32.185568103 -0700
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 1998 Janne Löf <jlof@mail.student.oulu.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <math.h>
+#include <gtk/gtk.h>
+#include <gtkgl/gtkglarea.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+gint init(GtkWidget *widget)
+{
+  g_print ("GTK+ version : %d.%d.%d\n", GTK_MAJOR_VERSION,
+                                        GTK_MINOR_VERSION,
+                                        GTK_MICRO_VERSION);
+
+  /* OpenGL functions can be called only if make_current returns true */
+  if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
+    {
+      GtkAllocation allocation;
+      gtk_widget_get_allocation (widget, &allocation);
+      glViewport(0, 0, allocation.width, allocation.height);
+    }
+
+  return TRUE;
+}
+
+
+/* When widget is exposed it's contents are redrawn. */
+gboolean draw(GtkWidget *widget, cairo_t *cr)
+{
+  /* OpenGL functions can be called only if make_current returns true */
+  if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
+    {
+      GtkAllocation allocation;
+      gtk_widget_get_allocation (widget, &allocation);
+      glViewport(0, 0, allocation.width, allocation.height);
+
+      /* Draw simple triangle */
+      GLfloat triangle_vertices[] = {
+         0.0,  0.5, 0.0,
+        -0.5, -0.5, 0.0,
+         0.5, -0.5, 0.0,
+      };
+
+      glClearColor (0.0, 0.0, 1.0, 1.0);
+      glClear (GL_COLOR_BUFFER_BIT);
+
+      glEnableClientState (GL_VERTEX_ARRAY);
+      glVertexPointer (3, GL_FLOAT, 0, triangle_vertices);
+      glDrawArrays (GL_TRIANGLES, 0, 3);
+      glDisableClientState (GL_VERTEX_ARRAY);
+
+      /* Swap backbuffer to front */
+      gtk_gl_area_swap_buffers(GTK_GL_AREA(widget));
+    }
+
+  return TRUE;
+}
+
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+
+
+int main(int argc, char **argv)
+{
+  GtkWidget *window,*box,*glarea,*button;
+  gchar *info_str;
+
+  /* Attribute list for gtkglarea widget. Specifies a
+     list of Boolean attributes and enum/integer
+     attribute/value pairs. The last attribute must be
+     GDK_GL_NONE. See glXChooseVisual manpage for further
+     explanation.
+  */
+  int attrlist[] = {
+    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+    EGL_RED_SIZE, 1,
+    EGL_GREEN_SIZE, 1,
+    EGL_BLUE_SIZE, 1,
+    EGL_DEPTH_SIZE, 1,
+    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
+    EGL_NONE
+  };
+
+  /* initialize gtk */
+  gtk_init(&argc, &argv);
+
+  /* Check if OpenGL is supported. */
+  if (gdk_gl_query() == FALSE) {
+    g_print("OpenGL not supported\n");
+    return 0;
+  }
+
+
+  /* Create new top level window. */
+  window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(window), "Simple EGL");
+  gtk_container_set_border_width(GTK_CONTAINER(window), 10);
+
+  /* Quit form main if got delete event */
+  g_signal_connect(G_OBJECT(window), "delete-event",
+                   G_CALLBACK(delete), NULL);
+  g_signal_connect(G_OBJECT(window), "destroy",
+                   G_CALLBACK(gtk_main_quit), NULL);
+
+
+  /* Create box widget. */
+  box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
+
+  /* Create new OpenGL widget. */
+  glarea = GTK_WIDGET(gtk_gl_area_new(attrlist));
+  /* Events for widget must be set before window is created */
+  gtk_widget_set_events(GTK_WIDGET(glarea),
+			GDK_EXPOSURE_MASK|
+			GDK_BUTTON_PRESS_MASK);
+
+  /* Create button widget. */
+  button = gtk_button_new_with_label("Quit");
+
+  /* Quit form main if got clicked event */
+  g_signal_connect(G_OBJECT(button), "clicked",
+                   G_CALLBACK(gtk_main_quit), NULL);
+
+  /* Connect signal handlers */
+  /* Redraw image when exposed. */
+  g_signal_connect(G_OBJECT(glarea), "draw",
+                   G_CALLBACK(draw), NULL);
+
+  /* Do initialization when widget has been realized. */
+  g_signal_connect(G_OBJECT(glarea), "realize",
+                   G_CALLBACK(init), NULL);
+
+  /* set minimum size */
+  gtk_widget_set_size_request(GTK_WIDGET(glarea), 100,100);
+
+  /* put glarea into window and show it all */
+  gtk_container_add(GTK_CONTAINER(window), box);
+  gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(glarea));
+  gtk_container_add(GTK_CONTAINER(box), button);
+  gtk_widget_show_all(GTK_WIDGET(window));
+
+  /* vendor dependent version info string */
+  info_str = gdk_gl_get_info();
+  g_print(info_str);
+  g_free(info_str);
+
+  gtk_main();
+
+  return 0;
+}
--- gtkgl/gtkglarea.c	2014-04-29 02:38:58.888271392 -0700
+++ gtkgl/gtkglarea.c	2014-04-30 09:09:18.076614124 -0700
@@ -158,5 +158,6 @@
   GtkWidget *widget = GTK_WIDGET (gl_area);
   g_return_if_fail(gtk_widget_get_realized(widget));
 
-  gdk_gl_swap_buffers(gtk_widget_get_window (widget));
+  gdk_gl_swap_buffers(gtk_widget_get_window (widget),
+                      gl_area->glcontext);
 }
--- gtkgl/gdkgl.h	2014-04-30 09:11:36.235611100 -0700
+++ gtkgl/gdkgl.h	2014-04-29 05:39:03.563348755 -0700
@@ -108,7 +108,7 @@
 GdkGLContext *gdk_gl_context_attrlist_share_new(int *attrlist, GdkGLContext *sharelist, gint direct);
 
 gint          gdk_gl_make_current(GdkGLDrawable *drawable, GdkGLContext *context);
-void          gdk_gl_swap_buffers(GdkGLDrawable *drawable);
+void          gdk_gl_swap_buffers(GdkGLDrawable *drawable, GdkGLContext *context);
 
 
 void          gdk_gl_wait_gdk(void);
--- gtkgl/gdkgl.c	2014-04-29 02:39:40.103274208 -0700
+++ gtkgl/gdkgl.c	2014-04-30 10:59:12.530558341 -0700
@@ -20,21 +20,29 @@
 #include "config.h"
 
 #include <string.h>
+#include <stdlib.h>
 
 #include "gdkgl.h"
 
-#include <GL/gl.h>
 #if defined GDK_WINDOWING_WIN32
 #   include <gdk/gdkwin32.h>
+#   include <GL/gl.h>
 #   define PLATFORM "GDK_WINDOWING_WIN32"
 #elif defined GDK_WINDOWING_X11
 #   include <gdk/gdkx.h>
 #   include <GL/glx.h>
+#   include <GL/gl.h>
 #   ifdef __GTK3__
 #      include <cairo.h>
 #      include <cairo-xlib.h>
 #   endif
 #   define PLATFORM "GDK_WINDOWING_X11"
+#elif defined GDK_WINDOWING_WAYLAND
+#   include <gdk/gdkwayland.h>
+#   include <wayland-client.h>
+#   include <wayland-egl.h>
+#   include <EGL/egl.h>
+#   define PLATFORM "GDK_WINDOWING_WAYLAND"
 #elif defined GDK_WINDOWING_FB
 #   define PLATFORM "GDK_WINDOWING_FB"
 #elif defined GDK_WINDOWING_QUARTZ
@@ -58,6 +66,13 @@
 #elif defined GDK_WINDOWING_X11
   Display    *xdisplay;
   GLXContext  glxcontext;
+#elif defined GDK_WINDOWING_WAYLAND
+  EGLDisplay edpy;
+  EGLConfig ecfg;
+  EGLContext ectx;
+  EGLSurface esrf;
+  struct wl_egl_window *ewin;
+  EGLint *attrlist;
 #endif
 };
 
@@ -109,6 +124,8 @@
 {
 #if defined GDK_WINDOWING_WIN32
   return TRUE;
+#elif defined GDK_WINDOWING_WAYLAND
+  return TRUE;
 #elif defined GDK_WINDOWING_X11
   return (glXQueryExtension(gdk_x11_get_default_xdisplay(),NULL,NULL) == True) ? TRUE : FALSE;
 #else
@@ -124,6 +141,12 @@
   vendor = glGetString (GL_VENDOR);
   version = glGetString (GL_VERSION);
   extensions = glGetString (GL_EXTENSIONS);
+#elif defined GDK_WINDOWING_WAYLAND
+  GdkDisplay *gdkdisplay = gdk_display_get_default ();
+  struct wl_display *display = gdk_wayland_display_get_wl_display (gdkdisplay);
+  vendor = eglQueryString (eglGetDisplay((EGLNativeDisplayType)display), EGL_VENDOR);
+  version = eglQueryString (eglGetDisplay((EGLNativeDisplayType)display), EGL_VERSION);
+  extensions = eglQueryString (eglGetDisplay((EGLNativeDisplayType)display), EGL_EXTENSIONS);
 #elif defined GDK_WINDOWING_X11
   vendor = glXGetClientString(gdk_x11_get_default_xdisplay(), GLX_VENDOR);
   version = glXGetClientString(gdk_x11_get_default_xdisplay(), GLX_VERSION);
@@ -215,6 +238,19 @@
     ReleaseDC (context->hwnd, context->hdc);
   else
     DeleteDC (context->hdc);
+#elif defined GDK_WINDOWING_WAYLAND
+  if (context->esrf)
+    eglDestroySurface (context->edpy, context->esrf);
+  if (context->ewin)
+    wl_egl_window_destroy (context->ewin);
+  if (context->ectx) {
+    eglMakeCurrent (context->edpy,
+                    EGL_NO_SURFACE, EGL_NO_SURFACE,
+                    EGL_NO_CONTEXT);
+    eglDestroyContext (context->edpy, context->ectx);
+  }
+  if (context->ecfg)
+    context->ecfg = NULL;
 #elif defined GDK_WINDOWING_X11
   if (context->glxcontext) {
     if (context->glxcontext == glXGetCurrentContext())
@@ -249,7 +285,7 @@
 GdkGLContext *
 gdk_gl_context_new(GdkVisual *visual)
 {
-#if defined GDK_WINDOWING_WIN32 || defined GDK_WINDOWING_X11
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_WAYLAND )|| defined (GDK_WINDOWING_X11)
   return gdk_gl_context_share_new(visual, NULL, FALSE);
 #else
   g_warning ("gdk_gl_context_new not implemented on " PLATFORM);
@@ -261,7 +297,7 @@
 GdkGLContext *
 gdk_gl_context_share_new(GdkVisual *visual, GdkGLContext *sharelist, gint direct)
 {
-#if defined GDK_WINDOWING_WIN32
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_WAYLAND)
   GdkGLContext *context;
 #elif defined GDK_WINDOWING_X11
   Display *dpy;
@@ -300,6 +336,18 @@
   context->pfd.cColorBits = 24;
   context->pfd.cDepthBits = 32;
   context->pfd.iLayerType = PFD_MAIN_PLANE;
+#elif defined GDK_WINDOWING_WAYLAND
+  int attrlist[] = {
+    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+    EGL_RED_SIZE, 1, EGL_GREEN_SIZE, 1,  EGL_BLUE_SIZE, 1, EGL_DEPTH_SIZE, 1,
+    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
+    EGL_NONE
+  };
+  context->edpy     = NULL;
+  context->ecfg     = NULL;
+  context->esrf     = NULL;
+  context->ewin     = NULL;
+  context->attrlist = attrlist;
 #elif defined GDK_WINDOWING_X11
   dpy = gdk_x11_get_default_xdisplay();
 
@@ -323,7 +371,7 @@
 
 GdkGLContext *gdk_gl_context_attrlist_share_new(int *attrlist, GdkGLContext *sharelist, gint direct)
 {
-#if defined GDK_WINDOWING_WIN32
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_WAYLAND)
   GdkGLContext *context;
 #elif defined GDK_WINDOWING_X11
   GdkVisual *visual;
@@ -334,11 +382,12 @@
 
   g_return_val_if_fail(attrlist != NULL, NULL);
 
-#if defined GDK_WINDOWING_WIN32
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_WAYLAND)
   context = g_object_new(GDK_TYPE_GL_CONTEXT, NULL);
   if (!context)
     return NULL;
 
+# if defined GDK_WINDOWING_WIN32
   context->initialised = FALSE;
   context->hglrc    = NULL;
   context->hdc      = NULL;
@@ -346,6 +395,14 @@
   context->share    = sharelist ? g_object_ref(sharelist) : NULL;
   fill_pfd(&context->pfd, attrlist);
 
+# elif defined GDK_WINDOWING_WAYLAND
+  context->edpy     = NULL;
+  context->ecfg     = NULL;
+  context->esrf     = NULL;
+  context->ewin     = NULL;
+  context->attrlist = attrlist;
+# endif
+
   return context;
 #elif defined GDK_WINDOWING_X11
   visual = gdk_gl_choose_visual(attrlist);
@@ -401,6 +458,69 @@
   wglMakeCurrent (context->hdc, context->hglrc);
 
   return TRUE;
+
+#elif defined GDK_WINDOWING_WAYLAND
+  GdkDisplay *gdkdisplay = gdk_window_get_display (GDK_WINDOW (drawable));
+  struct wl_display *display = gdk_wayland_display_get_wl_display (gdkdisplay);
+
+  if (!context->edpy)
+    {
+      context->edpy = eglGetDisplay ((EGLNativeDisplayType) display);
+      eglInitialize (context->edpy, NULL, NULL);
+      eglBindAPI (EGL_OPENGL_ES_API);
+    }
+
+  if (!context->ecfg)
+    {
+      EGLint count;
+      eglGetConfigs (context->edpy, NULL, 0, &count);
+
+      EGLConfig *configs = calloc (count, sizeof *configs);
+      EGLint num_configs;
+      eglChooseConfig (context->edpy, context->attrlist, configs, count, &num_configs);
+
+      int i; EGLint size;
+      for (i = 0; i < num_configs; i++) {
+        eglGetConfigAttrib (context->edpy, configs[i], EGL_BUFFER_SIZE, &size);
+        if (size == 32) /* 32-bit rendering */
+          context->ecfg = configs[i];
+      }
+      free (configs);
+    }
+
+  if (!context->ectx)
+    {
+      static const EGLint ectx_attrlist[] = {
+        EGL_CONTEXT_CLIENT_VERSION, 1,
+        EGL_NONE
+      };
+      context->ectx = eglCreateContext (context->edpy, context->ecfg, EGL_NO_CONTEXT, ectx_attrlist);
+    }
+
+  if (!context->ewin)
+    {
+       /* get the widget allocation here, under Wayland we must add the title bar height */
+      int x, y;
+      gdk_window_get_position (GDK_WINDOW(drawable), &x, &y); y += 30;
+      gdk_wayland_window_set_use_custom_subsurface (GDK_WINDOW (drawable),
+                                                    x, y);
+      struct wl_surface *surface = gdk_wayland_window_get_subsurface (GDK_WINDOW (drawable));
+
+      context->ewin = wl_egl_window_create (surface,
+                                            gdk_window_get_width(GDK_WINDOW (drawable)),	
+                                            gdk_window_get_height(GDK_WINDOW (drawable)));
+    }
+
+  if (!context->esrf)
+    {
+      context->esrf = eglCreateWindowSurface (context->edpy, context->ecfg, (EGLNativeWindowType)context->ewin, NULL);
+
+      eglSwapInterval(context->edpy, 0);
+    }
+
+  eglMakeCurrent (context->edpy, context->esrf, context->esrf, context->ectx);
+  return TRUE;
+
 #elif defined GDK_WINDOWING_X11
   return (glXMakeCurrent(context->xdisplay, gdk_x11_window_get_xid(drawable),
 			 context->glxcontext) == True) ? TRUE : FALSE;
@@ -421,7 +541,7 @@
 #endif
 }
 
-void gdk_gl_swap_buffers(GdkGLDrawable *drawable)
+void gdk_gl_swap_buffers(GdkGLDrawable *drawable, GdkGLContext *context)
 {
 #if defined GDK_WINDOWING_WIN32
   HDC   hdc;
@@ -444,6 +564,24 @@
   }
   SwapBuffers (hdc);
   ReleaseDC (hwnd, hdc);
+
+#elif defined GDK_WINDOWING_WAYLAND
+  GdkDisplay *gdkdisplay = gdk_window_get_display (GDK_WINDOW (drawable));
+  struct wl_display *display = gdk_wayland_display_get_wl_display (gdkdisplay);
+
+  eglSwapBuffers (context->edpy, context->esrf);
+
+  while (wl_display_prepare_read (display) != 0)
+    wl_display_dispatch_pending (display);
+  wl_display_flush (display);
+  wl_display_read_events (display);
+  wl_display_dispatch_pending (display);
+
+  if (gdk_window_is_visible (GDK_WINDOW (drawable)))
+    gdk_window_hide (GDK_WINDOW (drawable));
+  else
+    gdk_window_show (GDK_WINDOW (drawable));
+
 #elif defined GDK_WINDOWING_X11
   GdkDisplay *gdkdisplay = gdk_window_get_display (GDK_WINDOW (drawable));
   glXSwapBuffers(gdk_x11_display_get_xdisplay (gdkdisplay),
@@ -457,6 +595,8 @@
 {
 #if defined GDK_WINDOWING_WIN32
   GdiFlush();
+#elif defined GDK_WINDOWING_WAYLAND
+  eglWaitGL();
 #elif defined GDK_WINDOWING_X11
   glXWaitX();
 #endif
@@ -466,6 +606,8 @@
 {
 #if defined GDK_WINDOWING_WIN32
   glFinish();
+#elif defined GDK_WINDOWING_WAYLAND
+  eglWaitGL();
 #elif defined GDK_WINDOWING_X11
   glXWaitGL();
 #endif
@@ -553,7 +695,7 @@
 gdk_gl_pixmap_new(GdkVisual *visual, GdkGLPixmapSource *pixmap)
 {
   GdkGLPixmap *glpixmap;
-#ifndef GDK_WINDOWING_WIN32
+#if defined GDK_WINDOWING_X11
   Display *dpy;
   XVisualInfo *vi;
   Pixmap xpixmap;
@@ -561,7 +703,7 @@
   Window root_return;
   unsigned int w_ret, h_ret, bw_ret, depth_ret;
   int x_ret, y_ret;
-#elif defined GDK_WINDOWING_X11
+#elif defined GDK_WINDOWING_WIN32
 #else
   g_warning ("gdk_gl_pixmap_new not implemented on " PLATFORM);
   return NULL;
@@ -583,8 +725,8 @@
 #  elif defined __GTK2__
   glpixmap->pixmap = gdk_pixmap_ref (pixmap);
 #  endif
-#elif defined GDK_WINDOWING_X11
 
+#elif defined GDK_WINDOWING_X11
 #  if defined __GTK2__
   dpy = gdk_x11_get_default_xdisplay();
   xpixmap = (Pixmap)GDK_DRAWABLE_XID(pixmap);
@@ -632,11 +774,11 @@
 
 gint gdk_gl_pixmap_make_current(GdkGLPixmap *glpixmap, GdkGLContext *context)
 {
-#ifndef GDK_WINDOWING_WIN32
+#if defined GDK_WINDOWING_X11
   Display  *dpy;
   GLXPixmap glxpixmap;
   GLXContext glxcontext;
-#elif defined GDK_WINDOWING_X11
+#elif defined GDK_WINDOWING_WIN32
 #else
   g_warning ("gdk_gl_pixmap_make_current not implemented on " PLATFORM);
   return 0;
