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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 11 15:38:58 UTC 2021


 vcl/inc/unx/gtk/gtkdata.hxx  |    7 -------
 vcl/inc/unx/gtk/gtkframe.hxx |    2 +-
 vcl/unx/gtk3/gtkframe.cxx    |   28 ++++++++++++++++------------
 3 files changed, 17 insertions(+), 20 deletions(-)

New commits:
commit 07d235414f95a74561204a3643975590cde89299
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 11 15:04:51 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 11 17:38:02 2021 +0200

    gtk4: tidy up messy xid/native handle behind GtkSalFrame::GetNativeWindowHandle
    
    Change-Id: Icefbfe3922b46de8da54a8117709e3a01b4b21db
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115430
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index 85db523c2caf..747ad505abb5 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -46,13 +46,6 @@ namespace com::sun::star::accessibility { class XAccessibleEventListener; }
 class GtkSalDisplay;
 class DocumentFocusListener;
 
-#if !GTK_CHECK_VERSION(4,0,0)
-inline ::Window widget_get_xid(GtkWidget *widget)
-{
-    return GDK_WINDOW_XID(gtk_widget_get_window(widget));
-}
-#endif
-
 inline void main_loop_run(GMainLoop* pLoop)
 {
 #if !GTK_CHECK_VERSION(4, 0, 0)
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 0f74ca131e3d..189a097fd40e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -583,7 +583,7 @@ public:
 
     static GtkSalFrame         *getFromWindow( GtkWidget *pWindow );
 
-    sal_uIntPtr                 GetNativeWindowHandle(GtkWidget *pWidget) const;
+    static sal_uIntPtr          GetNativeWindowHandle(GtkWidget *pWidget);
 
     //Call the usual SalFrame Callback, but catch uno exceptions and delegate
     //to GtkSalData to rethrow them after the gsignal is processed when its safe
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 6a5df5eafb20..45df011039ef 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -65,6 +65,8 @@
 #   define GDK_ALT_MASK GDK_MOD1_MASK
 #   define GDK_TOPLEVEL_STATE_MAXIMIZED GDK_WINDOW_STATE_MAXIMIZED
 #   define GDK_TOPLEVEL_STATE_MINIMIZED GDK_WINDOW_STATE_ICONIFIED
+#   define gdk_wayland_surface_get_wl_surface gdk_wayland_window_get_wl_surface
+#   define gdk_x11_surface_get_xid gdk_x11_window_get_xid
 #endif
 
 using namespace com::sun::star;
@@ -541,7 +543,7 @@ static void attach_menu_model(GtkSalFrame* pSalFrame)
             return;
 
         // Generate menu paths.
-        sal_uIntPtr windowId = pSalFrame->GetNativeWindowHandle(pWidget);
+        sal_uIntPtr windowId = GtkSalFrame::GetNativeWindowHandle(pWidget);
         gchar* aDBusWindowPath = g_strdup_printf( "/org/libreoffice/window/%lu", windowId );
         gchar* aDBusMenubarPath = g_strdup_printf( "/org/libreoffice/window/%lu/menus/menubar", windowId );
 
@@ -2149,7 +2151,7 @@ void GtkSalFrame::updateWMClass()
         pClass->res_name  = const_cast<char*>(aResName.getStr());
         pClass->res_class = const_cast<char*>(pResClass);
         XSetClassHint( display,
-                       widget_get_xid(m_pWindow),
+                       GtkSalFrame::GetNativeWindowHandle(m_pWindow),
                        pClass );
         XFree( pClass );
     }
@@ -2195,7 +2197,7 @@ void GtkSalFrame::StartPresentation( bool bStart )
 #if !GTK_CHECK_VERSION(4, 0, 0)
     if( getDisplay()->IsX11Display() )
     {
-        aWindow = widget_get_xid(m_pWindow);
+        aWindow = GtkSalFrame::GetNativeWindowHandle(m_pWindow);
         aDisplay = GDK_DISPLAY_XDISPLAY( getGdkDisplay() );
     }
 #endif
@@ -5232,28 +5234,30 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
     return Size( aRect.GetWidth(), aRect.GetHeight() );
 }
 
-sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) const
+sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget)
 {
-#if !GTK_CHECK_VERSION(4, 0, 0)
-    (void) this;                // Silence loplugin:staticmethods
+#if !GTK_CHECK_VERSION(4,0,0)
+    GdkSurface* pSurface = gtk_widget_get_window(pWidget);
+#else
+    GdkSurface* pSurface = gtk_native_get_surface(gtk_widget_get_native(pWidget));
+#endif
+
     GdkDisplay *pDisplay = getGdkDisplay();
-    GdkWindow *pWindow = gtk_widget_get_window(pWidget);
 
 #if defined(GDK_WINDOWING_X11)
     if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
     {
-        return GDK_WINDOW_XID(pWindow);
+        return gdk_x11_surface_get_xid(pSurface);
     }
 #endif
+
 #if defined(GDK_WINDOWING_WAYLAND)
     if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
     {
-        return reinterpret_cast<sal_uIntPtr>(gdk_wayland_window_get_wl_surface(pWindow));
+        return reinterpret_cast<sal_uIntPtr>(gdk_wayland_surface_get_wl_surface(pSurface));
     }
 #endif
-#else
-    (void)pWidget;
-#endif
+
     return 0;
 }
 


More information about the Libreoffice-commits mailing list