[maemo-commits] [maemo-commits] r11994 - in projects/haf/trunk/gtk+: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu May 31 12:05:48 EEST 2007
Author: tko
Date: 2007-05-31 12:05:26 +0300 (Thu, 31 May 2007)
New Revision: 11994

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkmenuitem.c
Log:
Improve submenu placement on small displays

	* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Switch submenu
	opening direction only if there's more space in the new direction to
	reduce overlapping. (#441863, NB#50636)


Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2007-05-30 20:13:13 UTC (rev 11993)
+++ projects/haf/trunk/gtk+/ChangeLog	2007-05-31 09:05:26 UTC (rev 11994)
@@ -1,3 +1,9 @@
+2007-05-31  Tommi Komulainen  <tommi.komulainen at nokia.com>
+
+	* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Switch submenu
+	opening direction only if there's more space in the new direction to
+	reduce overlapping. (#441863, NB#50636)
+
 2007-05-29  Xan Lopez  <xan.lopez at nokia.com>
 
 	* gtk/gtkenums.h (enum): remove extra new lines to shut up

Modified: projects/haf/trunk/gtk+/gtk/gtkmenuitem.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkmenuitem.c	2007-05-30 20:13:13 UTC (rev 11993)
+++ projects/haf/trunk/gtk+/gtk/gtkmenuitem.c	2007-05-31 09:05:26 UTC (rev 11994)
@@ -1192,6 +1192,7 @@
   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);
@@ -1225,6 +1226,9 @@
 
   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;
@@ -1284,7 +1288,8 @@
       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
 	    {
@@ -1294,7 +1299,8 @@
 	  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
 	    {


More information about the maemo-commits mailing list