[gtk/new-style-menu: 24/48] popover: Respect alignment for positioning



commit d736778c2ff7313dfc1de4805696e55d0811ec06
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 8 03:14:02 2019 +0000

    popover: Respect alignment for positioning
    
    We lost the code that takes the halign of
    the popover into account when positioning it.
    Bring it back, since we want to use it for
    popover menus.

 gtk/gtkpopover.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 25fdbf23b0..55db0e23cf 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -259,14 +259,50 @@ move_to_rect (GtkPopover *popover)
       break;
 
     case GTK_POS_TOP:
-      parent_anchor = GDK_GRAVITY_NORTH;
-      surface_anchor = GDK_GRAVITY_SOUTH;
+      switch (gtk_widget_get_halign (GTK_WIDGET (popover)))
+        {
+        case GTK_ALIGN_START:
+          parent_anchor = GDK_GRAVITY_NORTH_WEST;
+          surface_anchor = GDK_GRAVITY_SOUTH_WEST;
+          break;
+
+        case GTK_ALIGN_END:
+          parent_anchor = GDK_GRAVITY_NORTH_EAST;
+          surface_anchor = GDK_GRAVITY_SOUTH_EAST;
+          break;
+
+        case GTK_ALIGN_FILL:
+        case GTK_ALIGN_CENTER:
+        case GTK_ALIGN_BASELINE:
+        default:
+          parent_anchor = GDK_GRAVITY_NORTH;
+          surface_anchor = GDK_GRAVITY_SOUTH;
+          break;
+        }
       anchor_hints = GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE_X;
       break;
 
     case GTK_POS_BOTTOM:
-      parent_anchor = GDK_GRAVITY_SOUTH;
-      surface_anchor = GDK_GRAVITY_NORTH;
+      switch (gtk_widget_get_halign (GTK_WIDGET (popover)))
+        {
+        case GTK_ALIGN_START:
+          parent_anchor = GDK_GRAVITY_SOUTH_WEST;
+          surface_anchor = GDK_GRAVITY_NORTH_WEST;
+          break;
+
+        case GTK_ALIGN_END:
+          parent_anchor = GDK_GRAVITY_SOUTH_EAST;
+          surface_anchor = GDK_GRAVITY_NORTH_EAST;
+          break;
+
+        case GTK_ALIGN_FILL:
+        case GTK_ALIGN_CENTER:
+        case GTK_ALIGN_BASELINE:
+        default:
+          parent_anchor = GDK_GRAVITY_SOUTH;
+          surface_anchor = GDK_GRAVITY_NORTH;
+          break;
+        }
       anchor_hints = GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE_X;
       break;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]