]> Pileus Git - ~andy/gtk/commitdiff
don't switch submenu opening direction for overlapping reasons if there is
authorMichael Natterer <mitch@imendio.com>
Fri, 1 Jun 2007 11:02:11 +0000 (11:02 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Fri, 1 Jun 2007 11:02:11 +0000 (11:02 +0000)
2007-06-01  Michael Natterer  <mitch@imendio.com>

* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): don't switch
submenu opening direction for overlapping reasons if there is even
less space on the other side (bug #441863, Tommi Komulainen).

svn path=/trunk/; revision=18002

ChangeLog
gtk/gtkmenuitem.c

index 8f47061429c2b08664b679be3701add75b24fd48..7e1d588700c943869ea0284e118d9e0d04ea8220 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-01  Michael Natterer  <mitch@imendio.com>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): don't switch
+       submenu opening direction for overlapping reasons if there is even
+       less space on the other side (bug #441863, Tommi Komulainen).
+
 2007-06-01  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtkfilechooserdialog.c (response_cb): change fix for #347883
index 7d9a7e963e98282a0e26c078dcfe3e134be16e53..11c5b34d5572177011ca305130f48bbaffb5a138 100644 (file)
@@ -1174,6 +1174,7 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   gint horizontal_offset;
   gint vertical_offset;
   gint parent_xthickness;
+  gint available_left, available_right;
 
   g_return_if_fail (menu != NULL);
   g_return_if_fail (x != NULL);
@@ -1207,6 +1208,9 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
 
   get_offsets (menu, &horizontal_offset, &vertical_offset);
 
+  available_left = tx - monitor.x;
+  available_right = monitor.x + monitor.width - (tx + widget->allocation.width);
+
   if (GTK_IS_MENU_BAR (widget->parent))
     {
       menu_item->from_menubar = TRUE;
@@ -1266,7 +1270,8 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
       switch (menu_item->submenu_direction)
        {
        case GTK_DIRECTION_LEFT:
-         if ((tx - twidth - parent_xthickness - horizontal_offset) >= monitor.x)
+         if (tx - twidth - parent_xthickness - horizontal_offset >= monitor.x ||
+             available_left >= available_right)
            tx -= twidth + parent_xthickness + horizontal_offset;
          else
            {
@@ -1276,7 +1281,8 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
          break;
 
        case GTK_DIRECTION_RIGHT:
-         if ((tx + widget->allocation.width + parent_xthickness + horizontal_offset + twidth) <= monitor.x + monitor.width)
+         if (tx + widget->allocation.width + parent_xthickness + horizontal_offset + twidth <= monitor.x + monitor.width ||
+             available_right >= available_left)
            tx += widget->allocation.width + parent_xthickness + horizontal_offset;
          else
            {