[Libreoffice-commits] core.git: vcl/inc vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Feb 11 17:42:02 UTC 2019


 vcl/inc/unx/gtk/gtkbackend.hxx            |   25 +++++++++++++++++++++++++
 vcl/inc/unx/gtk/gtkgdi.hxx                |    7 +------
 vcl/unx/gtk/gtkinst.cxx                   |    2 +-
 vcl/unx/gtk3/gtk3gtkdata.cxx              |    7 ++++---
 vcl/unx/gtk3/gtk3gtkframe.cxx             |   28 +++++++++-------------------
 vcl/unx/gtk3/gtk3gtkinst.cxx              |   23 ++++++++++++++++++++---
 vcl/unx/gtk3/gtk3gtkobject.cxx            |    2 +-
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx |    6 ++----
 8 files changed, 63 insertions(+), 37 deletions(-)

New commits:
commit b45debb0bcf051961abc7724472e2c55e4bd0a9c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 11 14:14:48 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Feb 11 18:37:40 2019 +0100

    Resolves: tdf#123080 don't require wayland at runtime
    
    if it existed at buildtime
    
    Change-Id: I8a3285b7ee3b0556605b0c3d4b1fef222eb62d1a
    Reviewed-on: https://gerrit.libreoffice.org/67691
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkbackend.hxx b/vcl/inc/unx/gtk/gtkbackend.hxx
new file mode 100644
index 000000000000..288311b41fca
--- /dev/null
+++ b/vcl/inc/unx/gtk/gtkbackend.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX
+#define INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX
+
+#include <gtk/gtk.h>
+#if defined(GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+bool DLSYM_GDK_IS_X11_DISPLAY(GdkDisplay* pDisplay);
+#endif
+#if defined(GDK_WINDOWING_WAYLAND)
+#include <gdk/gdkwayland.h>
+bool DLSYM_GDK_IS_WAYLAND_DISPLAY(GdkDisplay* pDisplay);
+#endif
+
+#endif // INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 074ce583dfb6..ee42a2baf433 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -23,12 +23,7 @@
 #include <config_cairo_canvas.h>
 
 #include <gtk/gtk.h>
-#if defined(GDK_WINDOWING_X11)
-#   include <gdk/gdkx.h>
-#endif
-#if defined(GDK_WINDOWING_WAYLAND)
-#   include <gdk/gdkwayland.h>
-#endif
+#include "gtkbackend.hxx"
 #include <gdk/gdkkeysyms.h>
 
 #include <unx/gtk/gtkframe.hxx>
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index f02ab9609014..64604ea3f92a 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -86,7 +86,7 @@ extern "C"
         // for gtk3 it is normally built with X and Wayland support, if
         // X is supported GDK_WINDOWING_X11 is defined and this is always
         // called, regardless of if we're running under X or Wayland.
-        // We can't use (GDK_IS_X11_DISPLAY(pDisplay)) to only do it under
+        // We can't use (DLSYM_GDK_IS_X11_DISPLAY(pDisplay)) to only do it under
         // X, because we need to do it earlier than we have a display
 #if !GTK_CHECK_VERSION(3,0,0) || defined(GDK_WINDOWING_X11)
         /* #i92121# workaround deadlocks in the X11 implementation
diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
index 617506c9e38b..c17303585f6a 100644
--- a/vcl/unx/gtk3/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #endif
+#include <unx/gtk/gtkbackend.hxx>
 #include <unx/gtk/gtkdata.hxx>
 #include <unx/gtk/gtkinst.hxx>
 #include <unx/gtk/gtkframe.hxx>
@@ -84,7 +85,7 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
     if ( getenv( "SAL_IGNOREXERRORS" ) )
         GetGenericUnixSalData()->ErrorTrapPush(); // and leak the trap
 
-    m_bX11Display = GDK_IS_X11_DISPLAY( m_pGdkDisplay );
+    m_bX11Display = DLSYM_GDK_IS_X11_DISPLAY( m_pGdkDisplay );
 
     gtk_widget_set_default_direction(AllSettings::GetLayoutRTL() ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
 }
@@ -424,7 +425,7 @@ GtkSalData::~GtkSalData()
         m_pUserEvent = nullptr;
     }
 #if defined(GDK_WINDOWING_X11)
-    if (GDK_IS_X11_DISPLAY(gdk_display_get_default()))
+    if (DLSYM_GDK_IS_X11_DISPLAY(gdk_display_get_default()))
         XSetIOErrorHandler(aOrigXIOErrorHandler);
 #endif
 }
@@ -572,7 +573,7 @@ void GtkSalData::Init()
     }
 
 #if defined(GDK_WINDOWING_X11)
-    if (GDK_IS_X11_DISPLAY(pGdkDisp))
+    if (DLSYM_GDK_IS_X11_DISPLAY(pGdkDisp))
         aOrigXIOErrorHandler = XSetIOErrorHandler(XIOErrorHdl);
 #endif
 
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index d437497227d4..a95f3886d679 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -51,12 +51,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
-#if defined(GDK_WINDOWING_X11)
-#   include <gdk/gdkx.h>
-#endif
-#if defined(GDK_WINDOWING_WAYLAND)
-#   include <gdk/gdkwayland.h>
-#endif
+#include <unx/gtk/gtkbackend.hxx>
 
 #include <dlfcn.h>
 #include <vcl/salbtype.hxx>
@@ -99,11 +94,6 @@
 #define IS_WIDGET_REALIZED gtk_widget_get_realized
 #define IS_WIDGET_MAPPED   gtk_widget_get_mapped
 
-#ifndef GDK_IS_X11_DISPLAY
-#define GDK_IS_X11_DISPLAY(foo) (true)
-#endif
-
-
 using namespace com::sun::star;
 
 int GtkSalFrame::m_nFloats = 0;
@@ -631,7 +621,7 @@ static gboolean ensure_dbus_setup( gpointer data )
         // fdo#70885 we don't want app menu under Unity
         const bool bDesktopIsUnity = (SalGetDesktopEnvironment() == "UNITY");
 #if defined(GDK_WINDOWING_X11)
-        if (GDK_IS_X11_DISPLAY(pDisplay))
+        if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
         {
             gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice" );
             if (!bDesktopIsUnity)
@@ -643,7 +633,7 @@ static gboolean ensure_dbus_setup( gpointer data )
         }
 #endif
 #if defined(GDK_WINDOWING_WAYLAND)
-        if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
+        if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
         {
             gdk_wayland_window_set_dbus_properties_libgtk_only(gdkWindow, "org.libreoffice",
                                                                "/org/libreoffice/menus/appmenu",
@@ -1017,7 +1007,7 @@ void GtkSalFrame::InitCommon()
     gtk_widget_set_app_paintable(GTK_WIDGET(m_pFixedContainer), true);
     /*non-X11 displays won't show anything at all without double-buffering
       enabled*/
-    if (GDK_IS_X11_DISPLAY(getGdkDisplay()))
+    if (DLSYM_GDK_IS_X11_DISPLAY(getGdkDisplay()))
         gtk_widget_set_double_buffered(GTK_WIDGET(m_pFixedContainer), false);
     gtk_widget_set_redraw_on_allocate(GTK_WIDGET(m_pFixedContainer), false);
 
@@ -1121,7 +1111,7 @@ void GtkSalFrame::InitCommon()
 
 #if defined(GDK_WINDOWING_X11)
     GdkDisplay *pDisplay = getGdkDisplay();
-    if (GDK_IS_X11_DISPLAY(pDisplay))
+    if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
     {
         m_aSystemData.pDisplay = gdk_x11_display_get_xdisplay(pDisplay);
         m_aSystemData.pVisual = gdk_x11_visual_get_xvisual(pVisual);
@@ -1260,7 +1250,7 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
         //built-in close button of the titlebar follows the overridden direction rather than continue in the same
         //direction as every other titlebar on the user's desktop. So if they don't match set an explicit
         //header bar with the desired 'outside' direction
-        if ((eType == GDK_WINDOW_TYPE_HINT_NORMAL || eType == GDK_WINDOW_TYPE_HINT_DIALOG) && GDK_IS_WAYLAND_DISPLAY(GtkSalFrame::getGdkDisplay()))
+        if ((eType == GDK_WINDOW_TYPE_HINT_NORMAL || eType == GDK_WINDOW_TYPE_HINT_DIALOG) && DLSYM_GDK_IS_WAYLAND_DISPLAY(GtkSalFrame::getGdkDisplay()))
         {
             const bool bDesktopIsRTL = MsLangId::isRightToLeft(MsLangId::getSystemUILanguage());
             const bool bAppIsRTL = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL;
@@ -1469,7 +1459,7 @@ void GtkSalFrame::Show( bool bVisible, bool /*bNoActivate*/ )
             //startcenter when initially shown to at least get
             //the default LibreOffice icon and not the broken
             //app icon
-            if (GDK_IS_WAYLAND_DISPLAY(getGdkDisplay()))
+            if (DLSYM_GDK_IS_WAYLAND_DISPLAY(getGdkDisplay()))
             {
                 OString sOrigName(g_get_prgname());
                 g_set_prgname("libreoffice-startcenter");
@@ -4321,13 +4311,13 @@ sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget)
     GdkWindow *pWindow = gtk_widget_get_window(pWidget);
 
 #if defined(GDK_WINDOWING_X11)
-    if (GDK_IS_X11_DISPLAY(pDisplay))
+    if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
     {
         return GDK_WINDOW_XID(pWindow);
     }
 #endif
 #if defined(GDK_WINDOWING_WAYLAND)
-    if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
+    if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
     {
         return reinterpret_cast<sal_uIntPtr>(gdk_wayland_window_get_wl_surface(pWindow));
     }
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 35fe3d03a0f7..7182deb54e30 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1172,6 +1172,23 @@ OpenGLContext* GtkInstance::CreateOpenGLContext()
     return new GtkOpenGLContext;
 }
 
+// tdf#123800 avoid requiring wayland at runtime just because it existed at buildtime
+bool DLSYM_GDK_IS_WAYLAND_DISPLAY(GdkDisplay* pDisplay)
+{
+    auto get_type = reinterpret_cast<GType (*) (void)>(dlsym(nullptr, "gdk_wayland_display_get_type"));
+    if (!get_type)
+        return false;
+    return G_TYPE_CHECK_INSTANCE_TYPE(pDisplay, get_type());
+}
+
+bool DLSYM_GDK_IS_X11_DISPLAY(GdkDisplay* pDisplay)
+{
+    auto get_type = reinterpret_cast<GType (*) (void)>(dlsym(nullptr, "gdk_x11_display_get_type"));
+    if (!get_type)
+        return false;
+    return G_TYPE_CHECK_INSTANCE_TYPE(pDisplay, get_type());
+}
+
 class GtkInstanceBuilder;
 
 namespace
@@ -2153,7 +2170,7 @@ public:
 #if defined(GDK_WINDOWING_WAYLAND)
         // drop x/y when under wayland
         GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
-        bPositioningAllowed = !GDK_IS_WAYLAND_DISPLAY(pDisplay);
+        bPositioningAllowed = !DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay);
 #endif
 
         WindowStateData aData;
@@ -4202,7 +4219,7 @@ public:
             //under wayland a Popover will work to "escape" the parent dialog, not
             //so under X, so come up with this hack to use a raw GtkWindow
             GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
-            if (GDK_IS_X11_DISPLAY(pDisplay))
+            if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
             {
                 m_pMenuHack = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP));
                 gtk_window_set_type_hint(m_pMenuHack, GDK_WINDOW_TYPE_HINT_COMBO);
@@ -7281,7 +7298,7 @@ public:
             return;
 #if defined(GDK_WINDOWING_WAYLAND)
         GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
-        if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
+        if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
         {
             gtk_combo_box_set_wrap_width(m_pComboBox, get_count() > 30 ? 1 : 0);
         }
diff --git a/vcl/unx/gtk3/gtk3gtkobject.cxx b/vcl/unx/gtk3/gtk3gtkobject.cxx
index 48e2436e67bf..33fd6d037981 100644
--- a/vcl/unx/gtk3/gtk3gtkobject.cxx
+++ b/vcl/unx/gtk3/gtk3gtkobject.cxx
@@ -60,7 +60,7 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
 
 #if defined(GDK_WINDOWING_X11)
     GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay();
-    if (GDK_IS_X11_DISPLAY(pDisplay))
+    if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
     {
         m_aSystemData.pDisplay = gdk_x11_display_get_xdisplay(pDisplay);
         m_aSystemData.pVisual = gdk_x11_visual_get_xvisual(pVisual);
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 1c3fa5aab7d4..51a83dd7705b 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -17,15 +17,13 @@
 #include <unx/gtk/gtkdata.hxx>
 #include <unx/gtk/gtkinst.hxx>
 #include <unx/gtk/gtkgdi.hxx>
+#include <unx/gtk/gtkbackend.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/settings.hxx>
 #include <unx/fontmanager.hxx>
 #include <headless/CustomWidgetDraw.hxx>
 
 #include "cairo_gtk3_cairo.hxx"
-#if defined(GDK_WINDOWING_WAYLAND)
-#   include <gdk/gdkwayland.h>
-#endif
 #include <boost/optional.hpp>
 
 GtkStyleContext* GtkSalGraphics::mpWindowStyle = nullptr;
@@ -3460,7 +3458,7 @@ void GtkSalData::initNWF()
     //gnome#768128 for the car crash that is wayland
     //and floating dockable toolbars
     GdkDisplay *pDisplay = gdk_display_get_default();
-    if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
+    if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
         pSVData->maNWFData.mbCanDetermineWindowPosition = false;
 #endif
 }


More information about the Libreoffice-commits mailing list