[gtk/new-style-menu: 4/6] popover: Respect alignment for positioning



commit 3f292c511aba09b0fe9e255ccda4ca4fea4ffadb
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]