[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 22 02:24:24 UTC 2020


 vcl/unx/gtk3/gtk3gtkinst.cxx |   24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

New commits:
commit 4ec79a49b2885d4d5074c87cbb15f2d3c207ccf4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Aug 14 20:05:06 2020 +0100
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Sat Aug 22 04:23:52 2020 +0200

    Related: tdf#135743 position combobox dropdowns correctly for RTL
    
    Change-Id: I4f8e70e128fd8506e7f95291226fc52599f15896
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100706
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 5ac1ec88fc10..986cf4d23bc1 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1700,7 +1700,6 @@ static MouseEventModifiers ImplGetMouseMoveMode(sal_uInt16 nCode)
 
 namespace
 {
-#if GTK_CHECK_VERSION(3,22,0)
     bool SwapForRTL(GtkWidget* pWidget)
     {
         GtkTextDirection eDir = gtk_widget_get_direction(pWidget);
@@ -1710,7 +1709,6 @@ namespace
             return false;
         return AllSettings::GetLayoutRTL();
     }
-#endif
 
     void replaceWidget(GtkWidget* pWidget, GtkWidget* pReplacement)
     {
@@ -1968,12 +1966,7 @@ protected:
 
     bool SwapForRTL() const
     {
-        GtkTextDirection eDir = gtk_widget_get_direction(m_pWidget);
-        if (eDir == GTK_TEXT_DIR_RTL)
-            return true;
-        if (eDir == GTK_TEXT_DIR_LTR)
-            return false;
-        return AllSettings::GetLayoutRTL();
+        return ::SwapForRTL(m_pWidget);
     }
 
     void do_enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants)
@@ -7056,17 +7049,14 @@ bool show_menu_newer_gtk(GtkWidget* pComboBox, GtkWindow* pMenu)
     gtk_window_group_add_window(gtk_window_get_group(GTK_WINDOW(pToplevel)), pMenu);
     gtk_window_set_transient_for(pMenu, GTK_WINDOW(pToplevel));
 
-    GtkRequisition req;
-    gtk_widget_get_preferred_size(GTK_WIDGET(pMenu), nullptr, &req);
-    gint nMenuWidth = req.width;
+    gint nComboWidth = gtk_widget_get_allocated_width(pComboBox);
+    gint nComboHeight = gtk_widget_get_allocated_height(pComboBox);
 
-    gint nButtonHeight = gtk_widget_get_allocated_height(pComboBox);
+    bool bSwapForRTL = SwapForRTL(GTK_WIDGET(pComboBox));
 
-    GdkGravity rect_anchor = GDK_GRAVITY_SOUTH, menu_anchor = GDK_GRAVITY_NORTH;
-    GdkRectangle rect {static_cast<int>(x),
-                       static_cast<int>(y),
-                       static_cast<int>(nMenuWidth),
-                       static_cast<int>(nButtonHeight) };
+    GdkGravity rect_anchor = !bSwapForRTL ? GDK_GRAVITY_SOUTH_WEST : GDK_GRAVITY_SOUTH_EAST;
+    GdkGravity menu_anchor = !bSwapForRTL ? GDK_GRAVITY_NORTH_WEST : GDK_GRAVITY_NORTH_EAST;
+    GdkRectangle rect {x, y, nComboWidth, nComboHeight };
     GdkWindow* toplevel = gtk_widget_get_window(GTK_WIDGET(pMenu));
 
     window_move_to_rect(toplevel, &rect, rect_anchor, menu_anchor,


More information about the Libreoffice-commits mailing list