Bug 1430018 - dlsym gdk_wayland_* routines as those are available at Gtk+ > 3.8, r?jhorak
MozReview-Commit-ID: EUgmc9QNeoI
--- 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, ®istry_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
@@ -7123,19 +7123,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