summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkalignment.c4
-rw-r--r--gtk/gtkbutton.c16
-rw-r--r--gtk/gtkcheckbutton.c4
-rw-r--r--gtk/gtkclist.c253
-rw-r--r--gtk/gtkdrawingarea.c32
-rw-r--r--gtk/gtkentry.c12
-rw-r--r--gtk/gtkeventbox.c4
-rw-r--r--gtk/gtkhandlebox.c4
-rw-r--r--gtk/gtkhbox.c8
-rw-r--r--gtk/gtkhpaned.c6
-rw-r--r--gtk/gtklist.c4
-rw-r--r--gtk/gtkmain.c2
-rw-r--r--gtk/gtkmenu.c2
-rw-r--r--gtk/gtkmenubar.c2
-rw-r--r--gtk/gtkmenuitem.c4
-rw-r--r--gtk/gtknotebook.c16
-rw-r--r--gtk/gtkscrolledwindow.c10
-rw-r--r--gtk/gtktable.c12
-rw-r--r--gtk/gtktree.c2
-rw-r--r--gtk/gtktreeitem.c4
-rw-r--r--gtk/gtkvbox.c8
-rw-r--r--gtk/gtkviewport.c4
-rw-r--r--gtk/gtkvpaned.c6
-rw-r--r--gtk/gtkwindow.c140
24 files changed, 314 insertions, 245 deletions
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index 2ea50ed587..f5100ac8c2 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -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 *
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index baf65e3990..bdb64bdc77 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -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);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 30a181aab2..239d0252e5 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -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);
}
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index ff9ce626e3..ddcbc42350 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -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 */
diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c
index 8fdb23b0f7..70a9770ffe 100644
--- a/gtk/gtkdrawingarea.c
+++ b/gtk/gtkdrawingarea.c
@@ -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);
+}
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 866456e2a0..934c8a3f92 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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))
{
diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c
index b18e1646ae..4fb341d314 100644
--- a/gtk/gtkeventbox.c
+++ b/gtk/gtkeventbox.c
@@ -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))
{
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index e0f44ceaea..a577441888 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -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)
diff --git a/gtk/gtkhbox.c b/gtk/gtkhbox.c
index f8f8848acf..eb46104d65 100644
--- a/gtk/gtkhbox.c
+++ b/gtk/gtkhbox.c
@@ -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
diff --git a/gtk/gtkhpaned.c b/gtk/gtkhpaned.c
index 9ef2ff0952..07bff9e6a1 100644
--- a/gtk/gtkhpaned.c
+++ b/gtk/gtkhpaned.c
@@ -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 */
diff --git a/gtk/gtklist.c b/gtk/gtklist.c
index ead9f98a97..076777be81 100644
--- a/gtk/gtklist.c
+++ b/gtk/gtklist.c
@@ -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;
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index b5b6dea791..a48a714d01 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -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;
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index cf83d262b7..6dc66c55c9 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -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)
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 49c7ec6284..8bd5e8221d 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -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)
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 3d228d8648..152d427575 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -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);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index bce592bd45..a3f5bdcba7 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -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;
}
}
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index c840fe03ad..f69c7f70e5 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -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
diff --git a/gtk/gtktable.c b/gtk/gtktable.c
index 0f5959f749..3f92608e2a 100644
--- a/gtk/gtktable.c
+++ b/gtk/gtktable.c
@@ -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
diff --git a/gtk/gtktree.c b/gtk/gtktree.c
index f4c9e78608..8b35c554dc 100644
--- a/gtk/gtktree.c
+++ b/gtk/gtktree.c
@@ -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;
diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c
index f2241b6e47..daf4e85e69 100644
--- a/gtk/gtktreeitem.c
+++ b/gtk/gtktreeitem.c
@@ -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);
}
diff --git a/gtk/gtkvbox.c b/gtk/gtkvbox.c
index a26f33ebc1..46993902dd 100644
--- a/gtk/gtkvbox.c
+++ b/gtk/gtkvbox.c
@@ -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
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index ed8c202b2f..a139267667 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -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))
{
diff --git a/gtk/gtkvpaned.c b/gtk/gtkvpaned.c
index 3672b67044..9828324d22 100644
--- a/gtk/gtkvpaned.c
+++ b/gtk/gtkvpaned.c
@@ -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 */
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b839c580ce..ae444d8e17 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -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;
}