vcl/unx/gtk3/gtkinst.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 55e77a48fbafd47036d7bd3ba11579c5f15f2359
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Dec 5 11:38:52 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Dec 5 15:20:19 2024 +0100

    gtk4: GtkIconView doesn't have convert_widget_to_bin_window_coords
    
    but still has the same problem as the gtk3 iconview with reporting
    positions when scrolled
    
    a problem since:
    
    commit a36a58933a1e07d3f54bacd5c2fe8ca53063a63a
    CommitDate: Wed Dec 4 07:40:30 2024 +0100
    
        sd: convert sidebar masterpage panels from drawingview to iconview
    
    Change-Id: Ice549b40d88c5d2063e37ccb63490e3537736d39
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177855
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index c837bd6dbb54..92b281e8ee2d 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -2263,17 +2263,22 @@ namespace
             rOutRect = GdkRectangle{static_cast<int>(rInRect.Left()), 
static_cast<int>(rInRect.Top()),
                                  static_cast<int>(rInRect.GetWidth()), 
static_cast<int>(rInRect.GetHeight())};
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
             if (GTK_IS_ICON_VIEW(pWidget))
             {
                 // GtkIconView is a little weird in its positioning with 
scrolling, so adjust here to match what
                 // it expects
                 gint nOffsetX(0), nOffsetY(0);
+#if !GTK_CHECK_VERSION(4, 0, 0)
                 
gtk_icon_view_convert_widget_to_bin_window_coords(GTK_ICON_VIEW(pWidget), 0, 0, 
&nOffsetX, &nOffsetY);
+#else
+                GtkAdjustment* pVAdjustment = 
gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(pWidget));
+                nOffsetY = pVAdjustment ? 
gtk_adjustment_get_value(pVAdjustment) : 0;
+                GtkAdjustment* pHAdjustment = 
gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(pWidget));
+                nOffsetX = pHAdjustment ? 
gtk_adjustment_get_value(pHAdjustment) : 0;
+#endif
                 rOutRect.x -= nOffsetX;
                 rOutRect.y -= nOffsetY;
             }
-#endif
 
             if (SwapForRTL(pWidget))
                 rOutRect.x = gtk_widget_get_allocated_width(pWidget) - 
rOutRect.width - 1 - rOutRect.x;
@@ -17156,10 +17161,15 @@ private:
         gtk_icon_view_get_cell_rect(m_pIconView, path, nullptr, &aRect);
         gtk_tree_path_free(path);
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
         // GtkIconView is a little weird in its positioning with scrolling
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_icon_view_convert_widget_to_bin_window_coords(m_pIconView, 
aRect.x, aRect.y, &aRect.x,
                                                           &aRect.y);
+#else
+        GtkAdjustment* pVAdjustment = 
gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(m_pIconView));
+        aRect.y -= pVAdjustment ? gtk_adjustment_get_value(pVAdjustment) : 0;
+        GtkAdjustment* pHAdjustment = 
gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(m_pIconView));
+        aRect.x -= pHAdjustment ? gtk_adjustment_get_value(pHAdjustment) : 0;
 #endif
 
         return tools::Rectangle(aRect.x, aRect.y, aRect.x + aRect.width, 
aRect.y + aRect.height);

Reply via email to