Bug 1430018 - dlsym gdk_wayland_* routines as those are available at Gtk+ > 3.8, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Fri, 12 Jan 2018 13:22:48 +0100
changeset 451145 40a2e98240cff8b9db471c2005dac54017369314
parent 451144 e432cc393634cdb6ac5a85030dc7fb518f5bfbe6
child 451146 b88adc63e02f99d12614dbf87244647a8e935c29
push id8543
push userryanvm@gmail.com
push dateTue, 16 Jan 2018 14:33:22 +0000
treeherdermozilla-beta@a6525ed16a32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1430018
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1430018 - dlsym gdk_wayland_* routines as those are available at Gtk+ > 3.8, r=jhorak MozReview-Commit-ID: EUgmc9QNeoI
widget/gtk/mozcontainer.cpp
widget/gtk/nsWindow.cpp
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -7,16 +7,17 @@
 
 #include "mozcontainer.h"
 #include <gtk/gtk.h>
 #ifdef MOZ_WAYLAND
 #include <gdk/gdkx.h>
 #include <gdk/gdkwayland.h>
 #endif
 #include <stdio.h>
+#include <dlfcn.h>
 
 #ifdef ACCESSIBILITY
 #include <atk/atk.h>
 #include "maiRedundantObjectFactory.h"
 #endif
 
 /* init methods */
 static void moz_container_class_init          (MozContainerClass *klass);
@@ -203,17 +204,22 @@ moz_container_init (MozContainer *contai
     gtk_widget_set_can_focus(GTK_WIDGET(container), TRUE);
     gtk_container_set_resize_mode(GTK_CONTAINER(container), GTK_RESIZE_IMMEDIATE);
     gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container), FALSE);
 
 #if defined(MOZ_WAYLAND)
     {
       GdkDisplay *gdk_display = gtk_widget_get_display(GTK_WIDGET(container));
       if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) {
-          wl_display* display = gdk_wayland_display_get_wl_display(gdk_display);
+          // Available as of GTK 3.8+
+          static auto sGdkWaylandDisplayGetWlDisplay =
+              (wl_display *(*)(GdkDisplay *))
+              dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_display");
+
+          wl_display* display = sGdkWaylandDisplayGetWlDisplay(gdk_display);
           wl_registry* registry = wl_display_get_registry(display);
           wl_registry_add_listener(registry, &registry_listener, container);
           wl_display_dispatch(display);
           wl_display_roundtrip(display);
         }
     }
 #endif
 }
@@ -224,32 +230,40 @@ moz_container_init (MozContainer *contai
  * and attach it as an overlay to GdkWindow.
  *
  * see gtk_clutter_embed_ensure_subsurface() at gtk-clutter-embed.c
 *  for reference.
  */
 static gboolean
 moz_container_map_surface(MozContainer *container)
 {
+    // Available as of GTK 3.8+
+    static auto sGdkWaylandDisplayGetWlCompositor =
+        (wl_compositor *(*)(GdkDisplay *))
+        dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_compositor");
+    static auto sGdkWaylandWindowGetWlSurface =
+        (wl_surface *(*)(GdkWindow *))
+        dlsym(RTLD_DEFAULT, "gdk_wayland_window_get_wl_surface");
+
     GdkDisplay *display = gtk_widget_get_display(GTK_WIDGET(container));
     if (GDK_IS_X11_DISPLAY(display))
         return false;
 
     if (container->subsurface && container->surface)
         return true;
 
     if (!container->surface) {
         struct wl_compositor *compositor;
-        compositor = gdk_wayland_display_get_wl_compositor(display);
+        compositor = sGdkWaylandDisplayGetWlCompositor(display);
         container->surface = wl_compositor_create_surface(compositor);
     }
 
     if (!container->subsurface) {
         GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(container));
-        wl_surface* gtk_surface = gdk_wayland_window_get_wl_surface(window);
+        wl_surface* gtk_surface = sGdkWaylandWindowGetWlSurface(window);
         if (!gtk_surface) {
           // We requested the underlying wl_surface too early when container
           // is not realized yet. We'll try again before first rendering
           // to mContainer.
           return false;
         }
 
         container->subsurface =
@@ -259,17 +273,17 @@ moz_container_map_surface(MozContainer *
         gint x, y;
         gdk_window_get_position(window, &x, &y);
         wl_subsurface_set_position(container->subsurface, x, y);
         wl_subsurface_set_desync(container->subsurface);
 
         // Route input to parent wl_surface owned by Gtk+ so we get input
         // events from Gtk+.
         GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET (container));
-        wl_compositor* compositor = gdk_wayland_display_get_wl_compositor(display);
+        wl_compositor* compositor = sGdkWaylandDisplayGetWlCompositor(display);
         wl_region* region = wl_compositor_create_region(compositor);
         wl_surface_set_input_region(container->surface, region);
         wl_region_destroy(region);
     }
     return true;
 }
 
 static void
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -6931,19 +6931,24 @@ nsWindow::IsComposited() const
          (gdk_window_get_visual(mGdkWindow)
             == gdk_screen_get_rgba_visual(gdkScreen));
 }
 
 #ifdef MOZ_WAYLAND
 wl_display*
 nsWindow::GetWaylandDisplay()
 {
+  // Available as of GTK 3.8+
+  static auto sGdkWaylandDisplayGetWlDisplay =
+      (wl_display *(*)(GdkDisplay *))
+      dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_display");
+
   GdkDisplay* gdkDisplay = gdk_display_get_default();
   return mIsX11Display ? nullptr :
-                         gdk_wayland_display_get_wl_display(gdkDisplay);
+                         sGdkWaylandDisplayGetWlDisplay(gdkDisplay);
 }
 
 wl_surface*
 nsWindow::GetWaylandSurface()
 {
   return moz_container_get_wl_surface(MOZ_CONTAINER(mContainer));
 }
 #endif