]> Pileus Git - ~andy/gtk/commitdiff
More extensive debugging output
authorOwen Taylor <owt1@cornell.edu>
Fri, 3 Apr 1998 23:17:16 +0000 (23:17 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 3 Apr 1998 23:17:16 +0000 (23:17 +0000)
Fri Apr  3 17:14:55 1998  Owen Taylor  <owt1@cornell.edu>

* gdk/gdk.c: More extensive debugging output

* gtk/gtkalignment.c gtk/gtkbutton.c gtk/gtkcheckbutton.c
  gtk/gtkclist.c gtk/gtkeventbox.c gtk/gtkhandlebox.c
  gtk/gtk[hv]box.c gtk/gtk[hv]paned.c gtk/gtklist.c
  gtk/gtkmenu.c gtk/gtkmenubar.c gtk/gtkmenuitem.c
  gtk/gtknotebook.c gtk/gtktable.c gtk/gtktree.c
  gtk/gtktreeitem.c gtk/gtkviewport.c

Avoid assigning negative values to unsigned allocation.width and
height

* gtk/gtkwindow.c:

Instead of realizing the widget, then size allocating, (resulting
in XMoveResizeWindows for all children, do the size allocation
first, then realize.

In gtk_real_window_move_resize, combine move and resize
into a single GDK/X call when possible.

* gtk/gtkclist.c gtk/gtkdrawingarea.c:

Remove assumption that the widget will be size allocated _after_
it is realized.

* gtk/gtklist.c (gtk_list_motion_notify): Removed useless
debugging message.

24 files changed:
gtk/gtkalignment.c
gtk/gtkbutton.c
gtk/gtkcheckbutton.c
gtk/gtkclist.c
gtk/gtkdrawingarea.c
gtk/gtkentry.c
gtk/gtkeventbox.c
gtk/gtkhandlebox.c
gtk/gtkhbox.c
gtk/gtkhpaned.c
gtk/gtklist.c
gtk/gtkmain.c
gtk/gtkmenu.c
gtk/gtkmenubar.c
gtk/gtkmenuitem.c
gtk/gtknotebook.c
gtk/gtkscrolledwindow.c
gtk/gtktable.c
gtk/gtktree.c
gtk/gtktreeitem.c
gtk/gtkvbox.c
gtk/gtkviewport.c
gtk/gtkvpaned.c
gtk/gtkwindow.c

index 2ea50ed587104b301d7a63ad37e7c62651bca5dd..f5100ac8c2db9e58469cd51decd6d5eab98f2c85 100644 (file)
@@ -169,8 +169,8 @@ gtk_alignment_size_allocate (GtkWidget     *widget,
     {
       x = GTK_CONTAINER (alignment)->border_width;
       y = GTK_CONTAINER (alignment)->border_width;
-      width = allocation->width - 2 * x;
-      height = allocation->height - 2 * y;
+      width = MAX (allocation->width - 2 * x, 0);
+      height = MAX (allocation->height - 2 * y, 0);
 
       if (width > bin->child->requisition.width)
        child_allocation.width = (bin->child->requisition.width *
index baf65e399056246ab27aa0bc4a253d795f7c8b95..bdb64bdc77afe707733bcd3cf9dc57274d78ab29 100644 (file)
@@ -421,10 +421,10 @@ gtk_button_size_allocate (GtkWidget     *widget,
       child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->xthickness);
       child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->ythickness);
 
-      child_allocation.width = widget->allocation.width - child_allocation.x * 2 -
-                                border_width * 2;
-      child_allocation.height = widget->allocation.height - child_allocation.y * 2 -
-                                 border_width * 2;
+      child_allocation.width = MAX (0, widget->allocation.width - child_allocation.x * 2 -
+                                border_width * 2);
+      child_allocation.height = MAX (0, widget->allocation.height - child_allocation.y * 2 -
+                                 border_width * 2);
 
       if (GTK_WIDGET_CAN_DEFAULT (button))
        {
@@ -432,10 +432,10 @@ gtk_button_size_allocate (GtkWidget     *widget,
                                 DEFAULT_LEFT_POS);
          child_allocation.y += (GTK_WIDGET (widget)->style->klass->ythickness +
                                 DEFAULT_TOP_POS);
-         child_allocation.width -= (GTK_WIDGET (widget)->style->klass->xthickness * 2 +
-                                    DEFAULT_SPACING);
-         child_allocation.height -= (GTK_WIDGET (widget)->style->klass->xthickness * 2 +
-                                     DEFAULT_SPACING);
+         child_allocation.width =  MAX (0, child_allocation.width - 
+                                       (GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
+         child_allocation.height = MAX (0, child_allocation.height - 
+                                        (GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
        }
 
       gtk_widget_size_allocate (button->child, &child_allocation);
index 30a181aab2d8e694c46ee1fb16f8e234bc62f3fa..239d0252e53153ef0322afd17ec8e71994b951ec 100644 (file)
@@ -249,9 +249,9 @@ gtk_check_button_size_allocate (GtkWidget     *widget,
                                CHECK_BUTTON_CLASS (widget)->indicator_size +
                                CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1);
          child_allocation.y = GTK_CONTAINER (widget)->border_width + 1;
-         child_allocation.width = (allocation->width - child_allocation.x  -
+         child_allocation.width = MAX (0, allocation->width - child_allocation.x  -
                                    GTK_CONTAINER (widget)->border_width - 1);
-         child_allocation.height = allocation->height - child_allocation.y * 2;
+         child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
 
          gtk_widget_size_allocate (button->child, &child_allocation);
        }
index ff9ce626e31f00341d9757ce3f4ab9895b9a496f..ddcbc423507faef7677ddccd2b2b48b8e1cf59ad 100644 (file)
@@ -418,12 +418,12 @@ gtk_clist_init (GtkCList * clist)
   clist->title_window = NULL;
   clist->column_title_area.x = 0;
   clist->column_title_area.y = 0;
-  clist->column_title_area.width = 0;
-  clist->column_title_area.height = 0;
+  clist->column_title_area.width = 1;
+  clist->column_title_area.height = 1;
 
   clist->clist_window = NULL;
-  clist->clist_window_width = 0;
-  clist->clist_window_height = 0;
+  clist->clist_window_width = 1;
+  clist->clist_window_height = 1;
 
   clist->hoffset = 0;
   clist->voffset = 0;
@@ -1765,6 +1765,12 @@ gtk_clist_realize (GtkWidget * widget)
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
 
   /* column-title window */
+
+  attributes.x = clist->column_title_area.x;
+  attributes.y = clist->column_title_area.y;
+  attributes.width = clist->column_title_area.width;
+  attributes.height = clist->column_title_area.height;
+  
   clist->title_window = gdk_window_new (widget->window, &attributes, attributes_mask);
   gdk_window_set_user_data (clist->title_window, clist);
 
@@ -1777,6 +1783,12 @@ gtk_clist_realize (GtkWidget * widget)
       gtk_widget_set_parent_window (clist->column[i].button, clist->title_window);
 
   /* clist-window */
+  attributes.x = clist->internal_allocation.x + widget->style->klass->xthickness;
+  attributes.y = clist->internal_allocation.y + widget->style->klass->ythickness +
+    clist->column_title_area.height;
+  attributes.width = clist->internal_allocation.width;
+  attributes.height = clist->internal_allocation.height;
+  
   clist->clist_window = gdk_window_new (widget->window, &attributes, attributes_mask);
   gdk_window_set_user_data (clist->clist_window, clist);
 
@@ -1798,9 +1810,13 @@ gtk_clist_realize (GtkWidget * widget)
     {
       clist->column[i].window = gdk_window_new (clist->title_window, &attributes, attributes_mask);
       gdk_window_set_user_data (clist->column[i].window, clist);
-      gdk_window_show (clist->column[i].window);
     }
 
+  /* This is slightly less efficient than creating them with the
+   * right size to begin with, but easier
+   */
+  size_allocate_title_buttons (clist);
+
   /* GCs */
   clist->fg_gc = gdk_gc_new (widget->window);
   clist->bg_gc = gdk_gc_new (widget->window);
@@ -2219,133 +2235,144 @@ gtk_clist_size_allocate (GtkWidget * widget,
                              allocation->y + GTK_CONTAINER (widget)->border_width,
                              allocation->width - GTK_CONTAINER (widget)->border_width * 2,
                              allocation->height - GTK_CONTAINER (widget)->border_width * 2);
+    }
 
-      /* use internal allocation structure for all the math
-       * because it's easier than always subtracting the container
-       * border width */
-      clist->internal_allocation.x = 0;
-      clist->internal_allocation.y = 0;
-      clist->internal_allocation.width = allocation->width -
-       GTK_CONTAINER (widget)->border_width * 2;
-      clist->internal_allocation.height = allocation->height -
-       GTK_CONTAINER (widget)->border_width * 2;
+  /* use internal allocation structure for all the math
+   * because it's easier than always subtracting the container
+   * border width */
+  clist->internal_allocation.x = 0;
+  clist->internal_allocation.y = 0;
+  clist->internal_allocation.width = MAX (0, allocation->width -
+    GTK_CONTAINER (widget)->border_width * 2);
+  clist->internal_allocation.height = MAX (0, allocation->height -
+    GTK_CONTAINER (widget)->border_width * 2);
        
-      /* allocate clist window assuming no scrollbars */
-      clist_allocation.x = clist->internal_allocation.x + widget->style->klass->xthickness;
-      clist_allocation.y = clist->internal_allocation.y + widget->style->klass->ythickness +
-       clist->column_title_area.height;
-      clist_allocation.width = clist->internal_allocation.width - 
-       (2 * widget->style->klass->xthickness);
-      clist_allocation.height = clist->internal_allocation.height -
-       (2 * widget->style->klass->ythickness) -
-       clist->column_title_area.height;
-
-      /* 
-       * here's where we decide to show/not show the scrollbars
-       */
-      vscrollbar_vis = 0;
-      hscrollbar_vis = 0;
-
-      for (i = 0; i <= 1; i++)
+  /* allocate clist window assuming no scrollbars */
+  clist_allocation.x = clist->internal_allocation.x + widget->style->klass->xthickness;
+  clist_allocation.y = clist->internal_allocation.y + widget->style->klass->ythickness +
+    clist->column_title_area.height;
+  clist_allocation.width = MAX (0, clist->internal_allocation.width - 
+    (2 * widget->style->klass->xthickness));
+  clist_allocation.height = MAX (0, clist->internal_allocation.height -
+    (2 * widget->style->klass->ythickness) -
+    clist->column_title_area.height);
+  
+  /* 
+   * here's where we decide to show/not show the scrollbars
+   */
+  vscrollbar_vis = 0;
+  hscrollbar_vis = 0;
+  
+  for (i = 0; i <= 1; i++)
+    {
+      if (LIST_HEIGHT (clist) <= clist_allocation.height &&
+         clist->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
        {
-         if (LIST_HEIGHT (clist) <= clist_allocation.height &&
-             clist->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
-           {
-             vscrollbar_vis = 0;
-           }
-         else
-           {
-             if (!vscrollbar_vis)
-               {
-                 vscrollbar_vis = 1;
-                 clist_allocation.width -= clist->vscrollbar->requisition.width +
-                   SCROLLBAR_SPACING (clist);
-               }  
-           }
-         
-         if (LIST_WIDTH (clist) <= clist_allocation.width &&
-             clist->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+         vscrollbar_vis = 0;
+       }
+      else
+       {
+         if (!vscrollbar_vis)
            {
-             hscrollbar_vis = 0;
-           }
-         else
+             vscrollbar_vis = 1;
+             clist_allocation.width = MAX (0, 
+               clist_allocation.width - clist->vscrollbar->requisition.width +
+                 SCROLLBAR_SPACING (clist));
+           }  
+       }
+      
+      if (LIST_WIDTH (clist) <= clist_allocation.width &&
+         clist->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+       {
+         hscrollbar_vis = 0;
+       }
+      else
+       {
+         if (!hscrollbar_vis)
            {
-             if (!hscrollbar_vis)
-               {
-                 hscrollbar_vis = 1;
-                 clist_allocation.height -= clist->hscrollbar->requisition.height + 
-                   SCROLLBAR_SPACING (clist);  
-               }  
-           }
+             hscrollbar_vis = 1;
+             clist_allocation.height = MAX (0,
+               clist_allocation.height - clist->hscrollbar->requisition.height + 
+                 SCROLLBAR_SPACING (clist));   
+           }  
        }
-
-      clist->clist_window_width = clist_allocation.width;
-      clist->clist_window_height = clist_allocation.height;
-
+    }
+  
+  clist->clist_window_width = clist_allocation.width;
+  clist->clist_window_height = clist_allocation.height;
+  
+  if (GTK_WIDGET_REALIZED (widget))
+    {
       gdk_window_move_resize (clist->clist_window,
                              clist_allocation.x,
                              clist_allocation.y,
                              clist_allocation.width,
                              clist_allocation.height);
-
-      /* position the window which holds the column title buttons */
-      clist->column_title_area.x = widget->style->klass->xthickness;
-      clist->column_title_area.y = widget->style->klass->ythickness;
-      clist->column_title_area.width = clist_allocation.width;
-
+    }
+  
+  /* position the window which holds the column title buttons */
+  clist->column_title_area.x = widget->style->klass->xthickness;
+  clist->column_title_area.y = widget->style->klass->ythickness;
+  clist->column_title_area.width = clist_allocation.width;
+  
+  if (GTK_WIDGET_REALIZED (widget))
+    {
       gdk_window_move_resize (clist->title_window,
                              clist->column_title_area.x,
                              clist->column_title_area.y,
                              clist->column_title_area.width,
                              clist->column_title_area.height);
+    }
+  
+  /* column button allocation */
+  size_allocate_columns (clist);
 
-      /* column button allocation */
-      size_allocate_columns (clist);
-      size_allocate_title_buttons (clist);
-      adjust_scrollbars (clist);
-
-      /* allocate the vscrollbar */
-      if (vscrollbar_vis)
-       {
-         if (!GTK_WIDGET_VISIBLE (clist->vscrollbar))
-           gtk_widget_show (clist->vscrollbar);
-             
-         child_allocation.x = clist->internal_allocation.x + 
-           clist->internal_allocation.width -
-           clist->vscrollbar->requisition.width;
-         child_allocation.y = clist->internal_allocation.y;
-         child_allocation.width = clist->vscrollbar->requisition.width;
-         child_allocation.height = clist->internal_allocation.height -
-           (hscrollbar_vis ? (clist->hscrollbar->requisition.height + SCROLLBAR_SPACING (clist)) : 0);
-
-         gtk_widget_size_allocate (clist->vscrollbar, &child_allocation);
-       }
-      else
-       {
-          if (GTK_WIDGET_VISIBLE (clist->vscrollbar))
-               gtk_widget_hide (clist->vscrollbar);
-       }
+  if (GTK_WIDGET_REALIZED (widget))
+    size_allocate_title_buttons (clist);
 
-      if (hscrollbar_vis)
-       {
-         if (!GTK_WIDGET_VISIBLE (clist->hscrollbar))
-           gtk_widget_show (clist->hscrollbar);
+  adjust_scrollbars (clist);
+  
+  /* allocate the vscrollbar */
+  if (vscrollbar_vis)
+    {
+      if (!GTK_WIDGET_VISIBLE (clist->vscrollbar))
+       gtk_widget_show (clist->vscrollbar);
       
-         child_allocation.x = clist->internal_allocation.x;
-         child_allocation.y = clist->internal_allocation.y +
-           clist->internal_allocation.height -
-           clist->hscrollbar->requisition.height;
-         child_allocation.width = clist->internal_allocation.width -
-           (vscrollbar_vis ? (clist->vscrollbar->requisition.width + SCROLLBAR_SPACING (clist)) : 0);
-         child_allocation.height = clist->hscrollbar->requisition.height;
-
-         gtk_widget_size_allocate (clist->hscrollbar, &child_allocation);
-       }
-      else
-       {
-         if (GTK_WIDGET_VISIBLE (clist->hscrollbar))
-               gtk_widget_hide (clist->hscrollbar);
-       }
+      child_allocation.x = clist->internal_allocation.x + 
+       clist->internal_allocation.width -
+       clist->vscrollbar->requisition.width;
+      child_allocation.y = clist->internal_allocation.y;
+      child_allocation.width = clist->vscrollbar->requisition.width;
+      child_allocation.height = MAX (0, clist->internal_allocation.height -
+       (hscrollbar_vis ? (clist->hscrollbar->requisition.height + SCROLLBAR_SPACING (clist)) : 0));
+      
+      gtk_widget_size_allocate (clist->vscrollbar, &child_allocation);
+    }
+  else
+    {
+      if (GTK_WIDGET_VISIBLE (clist->vscrollbar))
+       gtk_widget_hide (clist->vscrollbar);
+    }
+  
+  if (hscrollbar_vis)
+    {
+      if (!GTK_WIDGET_VISIBLE (clist->hscrollbar))
+       gtk_widget_show (clist->hscrollbar);
+      
+      child_allocation.x = clist->internal_allocation.x;
+      child_allocation.y = clist->internal_allocation.y +
+       clist->internal_allocation.height -
+       clist->hscrollbar->requisition.height;
+      child_allocation.width = MAX (0, clist->internal_allocation.width -
+       (vscrollbar_vis ? (clist->vscrollbar->requisition.width + SCROLLBAR_SPACING (clist)) : 0));
+      child_allocation.height = clist->hscrollbar->requisition.height;
+      
+      gtk_widget_size_allocate (clist->hscrollbar, &child_allocation);
+    }
+  else
+    {
+      if (GTK_WIDGET_VISIBLE (clist->hscrollbar))
+       gtk_widget_hide (clist->hscrollbar);
     }
 
   /* set the vscrollbar adjustments */
index 8fdb23b0f7b1d662c5e19f9e25c2a5ae7a27fe07..70a9770ffe607ff4a3482a172830100fc4926acf 100644 (file)
@@ -23,6 +23,7 @@ static void gtk_drawing_area_init          (GtkDrawingArea      *darea);
 static void gtk_drawing_area_realize       (GtkWidget           *widget);
 static void gtk_drawing_area_size_allocate (GtkWidget           *widget,
                                            GtkAllocation       *allocation);
+static void gtk_drawing_area_send_configure (GtkDrawingArea     *darea);
 
 
 guint
@@ -117,14 +118,14 @@ gtk_drawing_area_realize (GtkWidget *widget)
 
   widget->style = gtk_style_attach (widget->style, widget->window);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+  gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
 }
 
 static void
 gtk_drawing_area_size_allocate (GtkWidget     *widget,
                                GtkAllocation *allocation)
 {
-  GdkEventConfigure event;
-
   g_return_if_fail (widget != NULL);
   g_return_if_fail (GTK_IS_DRAWING_AREA (widget));
   g_return_if_fail (allocation != NULL);
@@ -137,13 +138,24 @@ gtk_drawing_area_size_allocate (GtkWidget     *widget,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);
 
-      event.type = GDK_CONFIGURE;
-      event.window = widget->window;
-      event.x = allocation->x;
-      event.y = allocation->y;
-      event.width = allocation->width;
-      event.height = allocation->height;
-
-      gtk_widget_event (widget, (GdkEvent*) &event);
+      gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
     }
 }
+
+static void
+gtk_drawing_area_send_configure (GtkDrawingArea *darea)
+{
+  GtkWidget *widget;
+  GdkEventConfigure event;
+
+  widget = GTK_WIDGET (darea);
+
+  event.type = GDK_CONFIGURE;
+  event.window = widget->window;
+  event.x = widget->allocation.x;
+  event.y = widget->allocation.y;
+  event.width = widget->allocation.width;
+  event.height = widget->allocation.height;
+  
+  gtk_widget_event (widget, (GdkEvent*) &event);
+}
index 866456e2a0dbd76fc9dfe5fbb49349c92c52b360..934c8a3f92d62241c6ffb9d54d981e6dc643db8e 100644 (file)
@@ -637,6 +637,7 @@ gtk_entry_size_allocate (GtkWidget     *widget,
 {
   GtkEntry *entry;
   GtkEditable *editable;
+  gint offset;
 
   g_return_if_fail (widget != NULL);
   g_return_if_fail (GTK_IS_ENTRY (widget));
@@ -658,8 +659,17 @@ gtk_entry_size_allocate (GtkWidget     *widget,
                              allocation->width - (widget->style->klass->xthickness + INNER_BORDER) * 2,
                              widget->requisition.height - (widget->style->klass->ythickness + INNER_BORDER) * 2);
 
-      entry->scroll_offset = 0;
+      /* Display as much text as we can */
+      offset = MAX(0, entry->char_offset[entry->nchars] - 
+                  (allocation->width -
+                      (widget->style->klass->xthickness + INNER_BORDER) * 2));
+
+      if (entry->scroll_offset > offset)
+       entry->scroll_offset = offset;
+
+      /* And make sure the cursor is on screen */
       gtk_entry_adjust_scroll (entry);
+      
 #ifdef USE_XIM
       if (editable->ic && (gdk_ic_get_style (editable->ic) & GdkIMPreeditPosition))
        {
index b18e1646ae721e5d60b2c9d3d9f43c950625b431..4fb341d3145595944ca37e58bafc69953a37d776 100644 (file)
@@ -162,8 +162,8 @@ gtk_event_box_size_allocate (GtkWidget     *widget,
 
   child_allocation.x = 0;
   child_allocation.y = 0;
-  child_allocation.width = allocation->width - GTK_CONTAINER (widget)->border_width * 2;
-  child_allocation.height = allocation->height - GTK_CONTAINER (widget)->border_width * 2;
+  child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0);
+  child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0);
 
   if (GTK_WIDGET_REALIZED (widget))
     {
index e0f44ceaea786c2f15b7e3de4d8fad7f94001ffd..a577441888f0d1716eb588321020e976e9206d52 100644 (file)
@@ -514,8 +514,8 @@ gtk_handle_box_size_allocate (GtkWidget     *widget,
        }
       else
        {
-         child_allocation.width = widget->allocation.width - 2 * border_width;
-         child_allocation.height = widget->allocation.height - 2 * border_width;
+         child_allocation.width = MAX (0, widget->allocation.width - 2 * border_width);
+         child_allocation.height = MAX (0, widget->allocation.height - 2 * border_width);
 
          if (hb->handle_position == GTK_POS_LEFT ||
              hb->handle_position == GTK_POS_RIGHT)
index f8f8848acff29f626fe9e011b529d0e756fa5476..eb46104d65900d8efad0170eb3ab499e226619e1 100644 (file)
@@ -187,7 +187,7 @@ gtk_hbox_size_allocate (GtkWidget     *widget,
        }
       else if (nexpand_children > 0)
        {
-         width = allocation->width - widget->requisition.width;
+         width = (gint)allocation->width - (gint)widget->requisition.width;
          extra = width / nexpand_children;
        }
       else
@@ -198,7 +198,7 @@ gtk_hbox_size_allocate (GtkWidget     *widget,
 
       x = allocation->x + GTK_CONTAINER (box)->border_width;
       child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width;
-      child_allocation.height = allocation->height - GTK_CONTAINER (box)->border_width * 2;
+      child_allocation.height = MAX (0, allocation->height - GTK_CONTAINER (box)->border_width * 2);
 
       children = box->children;
       while (children)
@@ -236,7 +236,7 @@ gtk_hbox_size_allocate (GtkWidget     *widget,
 
              if (child->fill)
                {
-                 child_allocation.width = child_width - child->padding * 2;
+                 child_allocation.width = MAX (0, child_width - child->padding * 2);
                  child_allocation.x = x + child->padding;
                }
              else
@@ -289,7 +289,7 @@ gtk_hbox_size_allocate (GtkWidget     *widget,
 
               if (child->fill)
                 {
-                  child_allocation.width = child_width - child->padding * 2;
+                  child_allocation.width = MAX (0, child_width - child->padding * 2);
                   child_allocation.x = x + child->padding - child_width;
                 }
               else
index 9ef2ff0952aeb3148c582dc4662a4f5f2c640d11..07bff9e6a15456e27091cc0f309843fdd8989d22 100644 (file)
@@ -177,7 +177,7 @@ gtk_hpaned_size_allocate (GtkWidget     *widget,
                             paned->groove_rectangle.height);
     }
   
-  child1_allocation.height = child2_allocation.height = allocation->height - border_width * 2;
+  child1_allocation.height = child2_allocation.height = MAX (0, allocation->height - border_width * 2);
   child1_allocation.width = paned->child1_size;
   child1_allocation.x = border_width;
   child1_allocation.y = child2_allocation.y = border_width;
@@ -189,8 +189,8 @@ gtk_hpaned_size_allocate (GtkWidget     *widget,
   paned->groove_rectangle.height = allocation->height;
       
   child2_allocation.x = paned->groove_rectangle.x + paned->gutter_size / 2 + 1;
-  child2_allocation.width = allocation->width
-    - child2_allocation.x - border_width;
+  child2_allocation.width = MAX (0, allocation->width
+    - child2_allocation.x - border_width);
   
   /* Now allocate the childen, making sure, when resizing not to
    * overlap the windows */
index ead9f98a9747a3d93f853d9ea3a5687f9c8f4d13..076777be815b9070c8cff0bbe6e44be7543acbb8 100644 (file)
@@ -679,7 +679,7 @@ gtk_list_motion_notify (GtkWidget      *widget,
   g_return_val_if_fail (GTK_IS_LIST (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
 
-  g_print ("gtk_list_motion_notify\n");
+  /* g_print ("gtk_list_motion_notify\n"); */
 
   return FALSE;
 }
@@ -789,7 +789,7 @@ gtk_list_size_allocate (GtkWidget     *widget,
     {
       child_allocation.x = GTK_CONTAINER (list)->border_width;
       child_allocation.y = GTK_CONTAINER (list)->border_width;
-      child_allocation.width = allocation->width - child_allocation.x * 2;
+      child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
 
       children = list->children;
 
index b5b6dea791e2aa54baaf0b0806d53fd7714fb319..a48a714d01037500ad8eecd284e49c4ad832e51c 100644 (file)
@@ -1253,7 +1253,7 @@ gtk_get_event_widget (GdkEvent *event)
   GtkWidget *widget;
 
   widget = NULL;
-  if (event->any.window)
+  if (event && event->any.window)
     gdk_window_get_user_data (event->any.window, (void**) &widget);
   
   return widget;
index cf83d262b7dce2c3dbd02bee624ca6849b6c7f83..6dc66c55c95e383df5df9fb79eee90767beea6f5 100644 (file)
@@ -641,7 +641,7 @@ gtk_menu_size_allocate (GtkWidget     *widget,
                            widget->style->klass->xthickness);
       child_allocation.y = (GTK_CONTAINER (menu)->border_width +
                            widget->style->klass->ythickness);
-      child_allocation.width = allocation->width - child_allocation.x * 2;
+      child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
 
       children = menu_shell->children;
       while (children)
index 49c7ec6284188221b70a84132725e6270e248bc9..8bd5e8221dcadfdc356978061942b397849b2d01 100644 (file)
@@ -200,7 +200,7 @@ gtk_menu_bar_size_allocate (GtkWidget     *widget,
       child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
                            widget->style->klass->ythickness +
                            BORDER_SPACING);
-      child_allocation.height = allocation->height - child_allocation.y * 2;
+      child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
 
       children = menu_shell->children;
       while (children)
index 3d228d8648ad1b33818ae0a834ba456949ef0431..152d427575eb7b11552fee14a3d019a31aa30fbb 100644 (file)
@@ -395,8 +395,8 @@ gtk_menu_item_size_allocate (GtkWidget     *widget,
                             widget->style->klass->xthickness +
                            BORDER_SPACING);
       child_allocation.y = GTK_CONTAINER (widget)->border_width;
-      child_allocation.width = allocation->width - child_allocation.x * 2;
-      child_allocation.height = allocation->height - child_allocation.y * 2;
+      child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
+      child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
       child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size;
       child_allocation.width -= (GTK_MENU_ITEM (widget)->toggle_size +
                                 GTK_MENU_ITEM (widget)->accelerator_size);
index bce592bd4555d74fde55a18b6cf33e84eb37bc50..a3f5bdcba7c30e33c389a25fe6e7f3831d2b5bd7 100644 (file)
@@ -1162,15 +1162,17 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
     {
       child_allocation.x = GTK_CONTAINER (widget)->border_width;
       child_allocation.y = GTK_CONTAINER (widget)->border_width;
-      child_allocation.width = allocation->width - child_allocation.x * 2;
-      child_allocation.height = allocation->height - child_allocation.y * 2;
+      child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
+      child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
 
       if (notebook->show_tabs || notebook->show_border)
        {
          child_allocation.x += widget->style->klass->xthickness;
          child_allocation.y += widget->style->klass->ythickness;
-         child_allocation.width -= widget->style->klass->xthickness * 2;
-         child_allocation.height -= widget->style->klass->ythickness * 2;
+         child_allocation.width = MAX (0, 
+             child_allocation.width - widget->style->klass->xthickness * 2);
+         child_allocation.height = MAX (0, 
+              child_allocation.height - widget->style->klass->ythickness * 2);
 
          if (notebook->show_tabs && notebook->children)
            {
@@ -1179,12 +1181,14 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
                case GTK_POS_TOP:
                  child_allocation.y += notebook->cur_page->requisition.height;
                case GTK_POS_BOTTOM:
-                 child_allocation.height -= notebook->cur_page->requisition.height;
+                 child_allocation.height = MAX (0, 
+                   child_allocation.height - notebook->cur_page->requisition.height);
                  break;
                case GTK_POS_LEFT:
                  child_allocation.x += notebook->cur_page->requisition.width;
                case GTK_POS_RIGHT:
-                 child_allocation.width -= notebook->cur_page->requisition.width;
+                 child_allocation.width = MAX (0, 
+                   child_allocation.width - notebook->cur_page->requisition.width);
                  break;
                }
            }
index c840fe03ad5aec32cc8760b19f42931f740a9ff7..f69c7f70e5a4af4464f18ea1bda986b8925c5b4e 100644 (file)
@@ -493,13 +493,15 @@ gtk_scrolled_window_viewport_allocate (GtkWidget     *widget,
 
   allocation->x = GTK_CONTAINER (widget)->border_width;
   allocation->y = GTK_CONTAINER (widget)->border_width;
-  allocation->width = widget->allocation.width - allocation->x * 2;
-  allocation->height = widget->allocation.height - allocation->y * 2;
+  allocation->width = MAX (0, widget->allocation.width - allocation->x * 2);
+  allocation->height = MAX (0, widget->allocation.height - allocation->y * 2);
 
   if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
-    allocation->width -= scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window);
+    allocation->width = MAX (0,
+      allocation->width - (scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window)));
   if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
-    allocation->height -= scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window);
+    allocation->height = MAX (0, 
+      allocation->height - (scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window)));
 }
 
 static void
index 0f5959f749c487f9ba7108ad819f64ac5ac99001..3f92608e2adab69b5d164436bfcf1c2ab1e2baef 100644 (file)
@@ -964,7 +964,7 @@ gtk_table_size_allocate_pass1 (GtkTable *table)
           for (col = 0; col < table->ncols; col++)
             {
               extra = width / (table->ncols - col);
-             table->cols[col].allocation = extra;
+             table->cols[col].allocation = MAX (0, extra);
               width -= extra;
             }
         }
@@ -1013,7 +1013,7 @@ gtk_table_size_allocate_pass1 (GtkTable *table)
             if (table->cols[col].shrink)
               {
                 extra = width / nshrink;
-               table->cols[col].allocation -= extra;
+               table->cols[col].allocation = MAX (0, table->cols[col].allocation - extra);
 
                 width -= extra;
                 nshrink -= 1;
@@ -1042,7 +1042,7 @@ gtk_table_size_allocate_pass1 (GtkTable *table)
           for (row = 0; row < table->nrows; row++)
             {
               extra = height / (table->nrows - row);
-             table->rows[row].allocation = extra;
+             table->rows[row].allocation = MAX (0, extra);
               height -= extra;
             }
         }
@@ -1091,7 +1091,7 @@ gtk_table_size_allocate_pass1 (GtkTable *table)
             if (table->rows[row].shrink)
               {
                 extra = height / nshrink;
-               table->rows[row].allocation -= extra;
+               table->rows[row].allocation = MAX (0, table->rows[row].allocation - extra);
 
                 height -= extra;
                 nshrink -= 1;
@@ -1152,7 +1152,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
 
           if (child->xfill)
             {
-              allocation.width = max_width - child->xpadding * 2;
+              allocation.width = MAX (0, max_width - child->xpadding * 2);
               allocation.x = x + (max_width - allocation.width) / 2;
             }
           else
@@ -1163,7 +1163,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
 
           if (child->yfill)
             {
-              allocation.height = max_height - child->ypadding * 2;
+              allocation.height = MAX (0, max_height - child->ypadding * 2);
               allocation.y = y + (max_height - allocation.height) / 2;
             }
           else
index f4c9e78608ef05b10530cbaeb268a2a8b04b56e1..8b35c554dc87dda4f0d54ea666ef3be63161850b 100644 (file)
@@ -928,7 +928,7 @@ gtk_tree_size_allocate (GtkWidget     *widget,
     {
       child_allocation.x = GTK_CONTAINER (tree)->border_width;
       child_allocation.y = GTK_CONTAINER (tree)->border_width;
-      child_allocation.width = allocation->width - child_allocation.x * 2;
+      child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2);
 
       children = tree->children;
 
index f2241b6e4734dc5d646545baa6cb18bc7512d971..daf4e85e6935508f84a9cb4b3983d94d33f9b71e 100644 (file)
@@ -551,11 +551,11 @@ gtk_tree_item_size_allocate (GtkWidget     *widget,
       gtk_widget_size_allocate (item->pixmaps_box, &child_allocation);
 
       child_allocation.y = GTK_CONTAINER (widget)->border_width;
-      child_allocation.height = allocation->height - child_allocation.y * 2;
+      child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2);
       child_allocation.x += item->pixmaps_box->requisition.width+DEFAULT_DELTA;
 
       child_allocation.width = 
-       allocation->width - (child_allocation.x + border_width);
+       MAX (0, allocation->width - (child_allocation.x + border_width));
 
       gtk_widget_size_allocate (bin->child, &child_allocation);
     }
index a26f33ebc185d79efa9fd6127cf599504d527d0a..46993902dd33123671703f5fe44b945820809ef4 100644 (file)
@@ -187,7 +187,7 @@ gtk_vbox_size_allocate (GtkWidget     *widget,
        }
       else if (nexpand_children > 0)
        {
-         height = allocation->height - widget->requisition.height;
+         height = (gint)allocation->height - (gint)widget->requisition.height;
          extra = height / nexpand_children;
        }
       else
@@ -198,7 +198,7 @@ gtk_vbox_size_allocate (GtkWidget     *widget,
 
       y = allocation->y + GTK_CONTAINER (box)->border_width;
       child_allocation.x = allocation->x + GTK_CONTAINER (box)->border_width;
-      child_allocation.width = allocation->width - GTK_CONTAINER (box)->border_width * 2;
+      child_allocation.width = MAX (0, allocation->width - GTK_CONTAINER (box)->border_width * 2);
 
       children = box->children;
       while (children)
@@ -236,7 +236,7 @@ gtk_vbox_size_allocate (GtkWidget     *widget,
 
              if (child->fill)
                {
-                 child_allocation.height = child_height - child->padding * 2;
+                 child_allocation.height = MAX (0, child_height - child->padding * 2);
                  child_allocation.y = y + child->padding;
                }
              else
@@ -289,7 +289,7 @@ gtk_vbox_size_allocate (GtkWidget     *widget,
 
               if (child->fill)
                 {
-                  child_allocation.height = child_height - child->padding * 2;
+                  child_allocation.height = MAX (0, child_height - child->padding * 2);
                   child_allocation.y = y + child->padding - child_height;
                 }
               else
index ed8c202b2f2402856d2d8ea6f71ce82023ac74d5..a139267667362981703d3310f5255b6a7e1dc22e 100644 (file)
@@ -535,8 +535,8 @@ gtk_viewport_size_allocate (GtkWidget     *widget,
       child_allocation.y = GTK_WIDGET (viewport)->style->klass->ythickness;
     }
 
-  child_allocation.width = allocation->width - child_allocation.x * 2 - border_width * 2;
-  child_allocation.height = allocation->height - child_allocation.y * 2 - border_width * 2;
+  child_allocation.width = MAX (0, allocation->width - child_allocation.x * 2 - border_width * 2);
+  child_allocation.height = MAX (0, allocation->height - child_allocation.y * 2 - border_width * 2);
 
   if (GTK_WIDGET_REALIZED (widget))
     {
index 3672b670443025c58104f740e855297bd75cf7db..9828324d22e627903ce5ebf5e091522063f9fd9e 100644 (file)
@@ -177,7 +177,7 @@ gtk_vpaned_size_allocate (GtkWidget     *widget,
                             paned->groove_rectangle.height);
     }
   
-  child1_allocation.width = child2_allocation.width = allocation->width - border_width * 2;
+  child1_allocation.width = child2_allocation.width = MAX (0, allocation->width - border_width * 2);
   child1_allocation.height = paned->child1_size;
   child1_allocation.x = child2_allocation.x = border_width;
   child1_allocation.y = border_width;
@@ -189,8 +189,8 @@ gtk_vpaned_size_allocate (GtkWidget     *widget,
   paned->groove_rectangle.width = allocation->width;
   
   child2_allocation.y = paned->groove_rectangle.y + paned->gutter_size / 2 + 1;
-  child2_allocation.height = allocation->height 
-    - child2_allocation.y - border_width;
+  child2_allocation.height = MAX (0, allocation->height 
+    - child2_allocation.y - border_width);
   
   /* Now allocate the childen, making sure, when resizing not to
    * overlap the windows */
index b839c580ce5c55c91447c87bbdf895d88664986e..ae444d8e17adc6348a648463fe74ccf636d50b84 100644 (file)
@@ -561,7 +561,6 @@ gtk_window_map (GtkWidget *widget)
 
   GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
 
-  gtk_window_move_resize (widget);
   window = GTK_WINDOW (widget);
 
   if (window->bin.child &&
@@ -569,7 +568,6 @@ gtk_window_map (GtkWidget *widget)
       !GTK_WIDGET_MAPPED (window->bin.child))
     gtk_widget_map (window->bin.child);
 
-  gtk_window_set_hints (widget, &widget->requisition);
   gdk_window_show (widget->window);
 }
 
@@ -639,6 +637,8 @@ gtk_window_realize (GtkWidget *widget)
 
   widget->style = gtk_style_attach (widget->style, widget->window);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+  gtk_window_set_hints (widget, &widget->requisition);
 }
 
 static void
@@ -744,7 +744,7 @@ gtk_window_configure_event (GtkWidget         *widget,
     gtk_widget_map (window->bin.child);
   
   if (window->resize_count > 0)
-    window->resize_count -= 1;
+      window->resize_count -= 1;
   
   window->handling_resize = FALSE;
   
@@ -1044,10 +1044,7 @@ gtk_real_window_move_resize (GtkWindow *window,
   g_return_val_if_fail ((x != NULL) || (y != NULL), FALSE);
   
   widget = GTK_WIDGET (window);
-  
-  if ((*x != -1) && (*y != -1))
-    gdk_window_move (widget->window, *x, *y);
-  
+
   if ((widget->requisition.width == 0) ||
       (widget->requisition.height == 0))
     {
@@ -1055,6 +1052,20 @@ gtk_real_window_move_resize (GtkWindow *window,
       widget->requisition.height = 200;
     }
   
+  if (!GTK_WIDGET_REALIZED (window))
+    {
+      GtkAllocation allocation;
+
+      allocation.x = 0;
+      allocation.y = 0;
+      allocation.width = widget->requisition.width;
+      allocation.height = widget->requisition.height;
+      
+      gtk_widget_size_allocate (widget, &allocation);
+
+      return FALSE;
+    }
+  
   gdk_window_get_geometry (widget->window, NULL, NULL, &width, &height, NULL);
   
   if ((window->auto_shrink &&
@@ -1064,9 +1075,14 @@ gtk_real_window_move_resize (GtkWindow *window,
       (height < widget->requisition.height))
     {
       window->resize_count += 1;
-      gdk_window_resize (widget->window,
-                        widget->requisition.width,
-                        widget->requisition.height);
+      if ((*x != -1) && (*y != -1))
+       gdk_window_move_resize (widget->window, *x, *y,
+                               widget->requisition.width,
+                               widget->requisition.height);
+      else
+        gdk_window_resize (widget->window,
+                          widget->requisition.width,
+                          widget->requisition.height);
     }
   else
     {
@@ -1085,6 +1101,9 @@ gtk_real_window_move_resize (GtkWindow *window,
       GSList *resize_containers;
       GSList *node;
       
+      if ((*x != -1) && (*y != -1))
+       gdk_window_move (widget->window, *x, *y);
+
       resize_widgets = GTK_CONTAINER (window)->resize_widgets;
       GTK_CONTAINER (window)->resize_widgets = NULL;
       
@@ -1167,61 +1186,56 @@ gtk_window_move_resize (GtkWidget *widget)
   g_return_val_if_fail (widget != NULL, FALSE);
   g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
 
+  window = GTK_WINDOW (widget);
   return_val = FALSE;
 
-  if (GTK_WIDGET_REALIZED (widget))
-    {
-      window = GTK_WINDOW (widget);
-
-      /* Remember old size, to know if we have to reset hints */
-      width = widget->requisition.width;
-      height = widget->requisition.height;
-      gtk_widget_size_request (widget, &widget->requisition);
-
-      if (GTK_WIDGET_MAPPED (widget) &&
-         (width != widget->requisition.width ||
-          height != widget->requisition.height))
-       gtk_window_set_hints (widget, &widget->requisition);
-
-      x = -1;
-      y = -1;
-      width = widget->requisition.width;
-      height = widget->requisition.height;
-
-      if (window->use_uposition)
-       switch (window->position)
-         {
-         case GTK_WIN_POS_CENTER:
-           x = (gdk_screen_width () - width) / 2;
-           y = (gdk_screen_height () - height) / 2;
-           gtk_widget_set_uposition (widget, x, y);
-           break;
-         case GTK_WIN_POS_MOUSE:
-           gdk_window_get_pointer (NULL, &x, &y, NULL);
-
-           x -= width / 2;
-           y -= height / 2;
-
-           screen_width = gdk_screen_width ();
-           screen_height = gdk_screen_height ();
-
-           if (x < 0)
-             x = 0;
-           else if (x > (screen_width - width))
-             x = screen_width - width;
-
-           if (y < 0)
-             y = 0;
-           else if (y > (screen_height - height))
-             y = screen_height - height;
-
-           gtk_widget_set_uposition (widget, x, y);
-           break;
-         }
-
-      gtk_signal_emit (GTK_OBJECT (widget), window_signals[MOVE_RESIZE],
-                       &x, &y, width, height, &return_val);
-    }
+  /* Remember old size, to know if we have to reset hints */
+  width = widget->requisition.width;
+  height = widget->requisition.height;
+  gtk_widget_size_request (widget, &widget->requisition);
+  
+  if ((width != widget->requisition.width ||
+       height != widget->requisition.height))
+    gtk_window_set_hints (widget, &widget->requisition);
+  
+  x = -1;
+  y = -1;
+  width = widget->requisition.width;
+  height = widget->requisition.height;
+  
+  if (window->use_uposition)
+    switch (window->position)
+      {
+      case GTK_WIN_POS_CENTER:
+       x = (gdk_screen_width () - width) / 2;
+       y = (gdk_screen_height () - height) / 2;
+       gtk_widget_set_uposition (widget, x, y);
+       break;
+      case GTK_WIN_POS_MOUSE:
+       gdk_window_get_pointer (NULL, &x, &y, NULL);
+       
+       x -= width / 2;
+       y -= height / 2;
+       
+       screen_width = gdk_screen_width ();
+       screen_height = gdk_screen_height ();
+       
+       if (x < 0)
+         x = 0;
+       else if (x > (screen_width - width))
+         x = screen_width - width;
+       
+       if (y < 0)
+         y = 0;
+       else if (y > (screen_height - height))
+         y = screen_height - height;
+       
+       gtk_widget_set_uposition (widget, x, y);
+       break;
+      }
+  
+  gtk_signal_emit (GTK_OBJECT (widget), window_signals[MOVE_RESIZE],
+                  &x, &y, width, height, &return_val);
 
   return return_val;
 }