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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed May 12 15:38:44 UTC 2021


 vcl/inc/unx/gtk/gtkdata.hxx |    6 ++++++
 vcl/unx/gtk3/gtkframe.cxx   |    5 ++++-
 vcl/unx/gtk3/gtkinst.cxx    |   25 +++++++------------------
 vcl/unx/gtk3/gtkobject.cxx  |    2 +-
 vcl/unx/gtk3/gtksalmenu.cxx |    6 +-----
 5 files changed, 19 insertions(+), 25 deletions(-)

New commits:
commit aaeb94cb055d5daad9bd98c5ec435d1234c75eb7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed May 12 14:45:22 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed May 12 17:38:03 2021 +0200

    gtk4: add a typedef for different gtk_widget_translate_coordinates arg type
    
    Change-Id: I07c514309d1c687361609818d1d16e808e8b4a56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115487
    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 92f8f28c0b6d..7dbc350353e4 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -101,6 +101,12 @@ inline GtkWidget* widget_get_first_child(GtkWidget *pWidget)
 #endif
 }
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+typedef double gtk_coord;
+#else
+typedef int gtk_coord;
+#endif
+
 class GtkSalTimer final : public SalTimer
 {
     struct SalGtkTimeoutSource *m_pTimeout;
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index cb5d57dde23a..938ff3a61ab3 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -2844,7 +2844,10 @@ namespace
         GtkWidget* pRealEventWidget = static_cast<GtkWidget*>(user_data);
         if (pRealEventWidget)
         {
-            gtk_widget_translate_coordinates(pRealEventWidget, pTargetWidget, rEventX, rEventY, &rEventX, &rEventY);
+            gtk_coord fX(0.0), fY(0.0);
+            gtk_widget_translate_coordinates(pRealEventWidget, pTargetWidget, rEventX, rEventY, &fX, &fY);
+            rEventX = fX;
+            rEventY = fY;
         }
     }
 }
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 67d8e2a897be..d76344d7c64d 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -3138,18 +3138,12 @@ public:
     {
         //for toplevel windows this is sadly futile under wayland, so we can't tell where a dialog is in order to allow
         //the document underneath to auto-scroll to place content in a visible location
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        bool ret = gtk_widget_translate_coordinates(m_pWidget,
-                                                    dynamic_cast<const GtkInstanceWidget&>(rRelative).getWidget(),
-                                                    0, 0, &x, &y);
-#else
-        double fX(0.0), fY(0.0);
+        gtk_coord fX(0.0), fY(0.0);
         bool ret = gtk_widget_translate_coordinates(m_pWidget,
                                                     dynamic_cast<const GtkInstanceWidget&>(rRelative).getWidget(),
                                                     0, 0, &fX, &fY);
         x = fX;
         y = fY;
-#endif
         width = gtk_widget_get_allocated_width(m_pWidget);
         height = gtk_widget_get_allocated_height(m_pWidget);
         return ret;
@@ -4419,7 +4413,7 @@ namespace
         // try and omit drawing CSD under wayland
         GtkWidget* pChild = widget_get_first_child(pTopLevel);
 
-        int x, y;
+        gtk_coord x, y;
         gtk_widget_translate_coordinates(pChild, pTopLevel, 0, 0, &x, &y);
 
         int innerborder = gtk_container_get_border_width(GTK_CONTAINER(pChild));
@@ -4441,13 +4435,8 @@ namespace
     {
         GtkWidget* pTopLevel = widget_get_root(pItem);
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        int x, y;
-        gtk_widget_translate_coordinates(pItem, pTopLevel, 0, 0, &x, &y);
-#else
-        double x, y;
+        gtk_coord x, y;
         gtk_widget_translate_coordinates(pItem, pTopLevel, 0, 0, &x, &y);
-#endif
 
         Point aOffset = get_csd_offset(pTopLevel);
 
@@ -5586,7 +5575,7 @@ private:
 
             gtk_widget_get_allocation(pWidget, &allocation);
 
-            gint dest_x1, dest_y1;
+            gtk_coord dest_x1, dest_y1;
             gtk_widget_translate_coordinates(pWidget,
                                              m_pSidebarEventBox,
                                              0,
@@ -5594,7 +5583,7 @@ private:
                                              &dest_x1,
                                              &dest_y1);
 
-            gint dest_x2, dest_y2;
+            gtk_coord dest_x2, dest_y2;
             gtk_widget_translate_coordinates(pWidget,
                                              m_pSidebarEventBox,
                                              allocation.width,
@@ -8043,7 +8032,7 @@ GtkPositionType show_menu_older_gtk(GtkWidget* pMenuButton, GtkWindow* pMenu)
 {
     //place the toplevel just below its launcher button
     GtkWidget* pToplevel = widget_get_root(pMenuButton);
-    gint x, y, absx, absy;
+    gtk_coord x, y, absx, absy;
     gtk_widget_translate_coordinates(pMenuButton, pToplevel, 0, 0, &x, &y);
     GdkWindow *pWindow = gtk_widget_get_window(pToplevel);
     gdk_window_get_position(pWindow, &absx, &absy);
@@ -8142,7 +8131,7 @@ bool show_menu_newer_gtk(GtkWidget* pComboBox, GtkWindow* pMenu)
 
     //place the toplevel just below its launcher button
     GtkWidget* pToplevel = widget_get_root(pComboBox);
-    gint x, y;
+    gtk_coord x, y;
     gtk_widget_translate_coordinates(pComboBox, pToplevel, 0, 0, &x, &y);
 
     gtk_widget_realize(GTK_WIDGET(pMenu));
diff --git a/vcl/unx/gtk3/gtkobject.cxx b/vcl/unx/gtk3/gtkobject.cxx
index a0fdbd4b4f35..2d58b67b2a70 100644
--- a/vcl/unx/gtk3/gtkobject.cxx
+++ b/vcl/unx/gtk3/gtkobject.cxx
@@ -538,7 +538,7 @@ bool GtkSalObjectWidgetClip::signal_scroll(GtkWidget*, GdkEvent* pEvent)
 
     GtkWidget* pMouseEventWidget = m_pParent->getMouseEventWidget();
 
-    gint dest_x, dest_y;
+    gtk_coord dest_x, dest_y;
     gtk_widget_translate_coordinates(pEventWidget,
                                      pMouseEventWidget,
                                      pEvent->scroll.x,
diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx
index 24cc6a300eea..aeac0637024e 100644
--- a/vcl/unx/gtk3/gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtksalmenu.cxx
@@ -884,11 +884,7 @@ tools::Rectangle GtkSalMenu::GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame*
 
     GtkSalFrame* pFrame = static_cast<GtkSalFrame*>(pReferenceFrame);
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
-    int x, y;
-#else
-    double x, y;
-#endif
+    gtk_coord x, y;
     if (!gtk_widget_translate_coordinates(pButton, GTK_WIDGET(pFrame->getMouseEventWidget()), 0, 0, &x, &y))
         return tools::Rectangle();
 


More information about the Libreoffice-commits mailing list