Index: gtkmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.128.2.1
diff -u -p -r1.128.2.1 gtkmenu.c
--- gtkmenu.c	28 Feb 2003 02:03:50 -0000	1.128.2.1
+++ gtkmenu.c	21 Aug 2003 18:48:22 -0000
@@ -2811,7 +2811,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
   if (!menu->tearoff_active)
     {
       last_visible = menu->upper_arrow_visible;
-      menu->upper_arrow_visible = (view_height < menu_height && offset > 0);
+      menu->upper_arrow_visible = offset > 0;
       
       if (menu->upper_arrow_visible)
 	view_height -= MENU_SCROLL_ARROW_HEIGHT;
@@ -2827,7 +2827,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
 	}
 
       last_visible = menu->lower_arrow_visible;
-      menu->lower_arrow_visible = (view_height < menu_height && offset < menu_height - view_height);
+      menu->lower_arrow_visible = offset < menu_height - view_height;
       
       if (menu->lower_arrow_visible)
 	view_height -= MENU_SCROLL_ARROW_HEIGHT;
@@ -2846,8 +2846,6 @@ gtk_menu_scroll_to (GtkMenu *menu,
 	y += MENU_SCROLL_ARROW_HEIGHT;
     }
 
-  offset = CLAMP (offset, 0, menu_height - view_height);
-
   /* Scroll the menu: */
   if (GTK_WIDGET_REALIZED (menu))
     gdk_window_move (menu->bin_window, 0, -offset);
@@ -3165,6 +3163,24 @@ child_at (GtkMenu *menu,
   return child;
 }
 
+static gint
+get_menu_height (GtkMenu *menu)
+{
+  gint height;
+  GtkWidget *widget = GTK_WIDGET (menu);
+
+  height = widget->requisition.height;
+  height -= (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2;
+
+  if (menu->upper_arrow_visible && !menu->tearoff_active)
+    height -= MENU_SCROLL_ARROW_HEIGHT;
+
+  if (menu->lower_arrow_visible && !menu->tearoff_active)
+    height -= MENU_SCROLL_ARROW_HEIGHT;
+
+  return height;
+}
+
 static void
 gtk_menu_real_move_scroll (GtkMenu       *menu,
 			   GtkScrollType  type)
@@ -3178,6 +3194,7 @@ gtk_menu_real_move_scroll (GtkMenu      
       {
 	gint page_size = get_visible_size (menu);
 	gint old_offset;
+        gint new_offset;
 	gint child_offset = 0;
 	gboolean old_upper_arrow_visible;
 	gint step;
@@ -3199,7 +3216,11 @@ gtk_menu_real_move_scroll (GtkMenu      
 	menu_shell->ignore_enter = TRUE;
 	old_upper_arrow_visible = menu->upper_arrow_visible && !menu->tearoff_active;
 	old_offset = menu->scroll_offset;
-	gtk_menu_scroll_to (menu, menu->scroll_offset + step);
+
+        new_offset = menu->scroll_offset + step;
+        new_offset = CLAMP (new_offset, 0, get_menu_height (menu) - page_size);
+
+        gtk_menu_scroll_to (menu, new_offset);
 	
 	if (menu_shell->active_menu_item)
 	  {
