diff --git a/widget/gtk/mozgtk/moz.build b/widget/gtk/mozgtk/moz.build index f860f8217879..d5e78d00323b 100644 --- a/widget/gtk/mozgtk/moz.build +++ b/widget/gtk/mozgtk/moz.build @@ -11,6 +11,7 @@ SOURCES += [ ] CFLAGS += CONFIG["MOZ_X11_CFLAGS"] +CFLAGS += CONFIG["MOZ_GTK3_CFLAGS"] # If LDFLAGS contains -Wl,--as-needed or if it's the default for the toolchain, # we need to add -Wl,--no-as-needed before the gtk libraries, otherwise the diff --git a/widget/gtk/mozgtk/mozgtk.c b/widget/gtk/mozgtk/mozgtk.c index d7dbbc6fd9e3..d95746fc0bf5 100644 --- a/widget/gtk/mozgtk/mozgtk.c +++ b/widget/gtk/mozgtk/mozgtk.c @@ -6,6 +6,13 @@ #include "mozilla/Types.h" +#include + +// Dummy call to gtk3 library to prevent the linker from removing +// the gtk3 dependency with --as-needed. +// see toolkit/library/moz.build for details. +MOZ_EXPORT void mozgtk_linker_holder() { gdk_display_get_default(); } + #ifdef MOZ_X11 # include // Bug 1271100 diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index e9b825bafccc..5528d2d49bb8 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -268,6 +268,9 @@ static SystemTimeConverter& TimeConverter() { bool nsWindow::sTransparentMainWindow = false; +// forward declare from mozgtk +extern "C" MOZ_EXPORT void mozgtk_linker_holder(); + namespace mozilla { #ifdef MOZ_X11 @@ -428,6 +431,10 @@ nsWindow::nsWindow() } #endif } + // Dummy call to mozgtk to prevent the linker from removing + // the dependency with --as-needed. + // see toolkit/library/moz.build for details. + mozgtk_linker_holder(); } nsWindow::~nsWindow() { @@ -5311,10 +5318,6 @@ void nsWindow::ConfigureGdkWindow() { // tearing because Gecko does not align its framebuffer updates with // vblank. SetCompositorHint(GTK_WIDGET_COMPOSIDED_ENABLED); - - // Dummy call to a function in mozgtk to prevent the linker from removing - // the dependency with --as-needed. - XShmQueryExtension(DefaultXDisplay()); } #endif #ifdef MOZ_WAYLAND