Commit b27345fe authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Cal gdk_window_invalidate_maybe_recurse() for recursion. (Soeren Sandmann)

Thu Nov 15 14:19:34 2001  Owen Taylor  <otaylor@redhat.com>

 	* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
 	gdk_window_invalidate_maybe_recurse() for recursion.
 	(Soeren Sandmann)

 	* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)

	* gtk/gtkcontainer.c (gtk_container_expose): Call
	gtk_container_forall() not _foreach() to propagate,
	since we need to propagate exposes to internal children
	as well.

	* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
	Remove the restriction of only being able to call these
	on window widgets, since we have lots of NO_WINDOW widgets
	with windows now; for add events, recurse over the children
	of widget->window to find one owned by the widget.

	* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
	window to catch events.

	* gtk/gtktogglebutton.[ch]: Remove the code for switching
	between NO_WINDOW and WINDOW widgets based on the mode.

	* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
	gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.

	* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.

	* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
	change for range.

	* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.

	* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
parent 41f14d35
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal
gdk_window_invalidate_maybe_recurse() for recursion.
(Soeren Sandmann)
* gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann)
* gtk/gtkcontainer.c (gtk_container_expose): Call
gtk_container_forall() not _foreach() to propagate,
since we need to propagate exposes to internal children
as well.
* gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events):
Remove the restriction of only being able to call these
on window widgets, since we have lots of NO_WINDOW widgets
with windows now; for add events, recurse over the children
of widget->window to find one owned by the widget.
* gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only
window to catch events.
* gtk/gtktogglebutton.[ch]: Remove the code for switching
between NO_WINDOW and WINDOW widgets based on the mode.
* gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c
gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton.
* gtk/gtkrange.[ch]: Make into a NO_WINDOW widget.
* gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW
change for range.
* gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget.
* docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Thu Nov 15 11:59:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c: Patch from Murray Cumming to add
......
......@@ -514,3 +514,17 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
If you want to actually draw contents in a widget derived from
one of these widgets, you'll probably want to change this
in your init() function.
* A number of widgets are now NO_WINDOW widgets (most importantly
GtkButton, but also GtkRange and GtkNotebook)
This has a couple of effects:
- If you are deriving from one of these widgets, you need to
adapt your code appropriately -- for instance, drawing coordinates
start from widget->allocation.x, widget->allocation.y.
- If you are embedding one of these widgets in a custom widget,
you must make sure you call gtk_container_propagate_expose()
correctly, as you must for any NO_WINDOW widgets.
......@@ -76,6 +76,8 @@ static void gtk_button_get_property (GObject *object,
GParamSpec *pspec);
static void gtk_button_realize (GtkWidget *widget);
static void gtk_button_unrealize (GtkWidget *widget);
static void gtk_button_map (GtkWidget *widget);
static void gtk_button_unmap (GtkWidget *widget);
static void gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_button_size_allocate (GtkWidget *widget,
......@@ -159,6 +161,8 @@ gtk_button_class_init (GtkButtonClass *klass)
widget_class->realize = gtk_button_realize;
widget_class->unrealize = gtk_button_unrealize;
widget_class->map = gtk_button_map;
widget_class->unmap = gtk_button_unmap;
widget_class->size_request = gtk_button_size_request;
widget_class->size_allocate = gtk_button_size_allocate;
widget_class->expose_event = gtk_button_expose;
......@@ -289,7 +293,7 @@ static void
gtk_button_init (GtkButton *button)
{
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT);
GTK_WIDGET_UNSET_FLAGS (button, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);
button->label_text = NULL;
......@@ -582,9 +586,7 @@ gtk_button_realize (GtkWidget *widget)
attributes.y = widget->allocation.y + border_width;
attributes.width = widget->allocation.width - border_width * 2;
attributes.height = widget->allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
......@@ -592,13 +594,16 @@ gtk_button_realize (GtkWidget *widget)
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes_mask = GDK_WA_X | GDK_WA_Y;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, button);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
button->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (button->event_window, button);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
}
static void
......@@ -608,10 +613,43 @@ gtk_button_unrealize (GtkWidget *widget)
if (button->activate_timeout)
gtk_button_finish_activate (button, FALSE);
if (button->event_window)
{
gdk_window_set_user_data (button->event_window, NULL);
gdk_window_destroy (button->event_window);
button->event_window = NULL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
gtk_button_map (GtkWidget *widget)
{
GtkButton *button = GTK_BUTTON (widget);
g_return_if_fail (GTK_IS_BUTTON (widget));
if (button->event_window)
gdk_window_show (button->event_window);
GTK_WIDGET_CLASS (parent_class)->map (widget);
}
static void
gtk_button_unmap (GtkWidget *widget)
{
GtkButton *button = GTK_BUTTON (widget);
g_return_if_fail (GTK_IS_BUTTON (widget));
if (button->event_window)
gdk_window_hide (button->event_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
gtk_button_get_props (GtkButton *button,
GtkBorder *default_border,
......@@ -706,7 +744,7 @@ gtk_button_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
gdk_window_move_resize (button->event_window,
widget->allocation.x + border_width,
widget->allocation.y + border_width,
widget->allocation.width - border_width * 2,
......@@ -714,12 +752,12 @@ gtk_button_size_allocate (GtkWidget *widget,
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (CHILD_SPACING + xthickness);
child_allocation.y = (CHILD_SPACING + ythickness);
child_allocation.x = widget->allocation.x + border_width + (CHILD_SPACING + xthickness);
child_allocation.y = widget->allocation.y + border_width + (CHILD_SPACING + ythickness);
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
child_allocation.width = MAX (1, (gint)widget->allocation.width - (CHILD_SPACING + xthickness) * 2 -
border_width * 2);
child_allocation.height = MAX (1, (gint)widget->allocation.height - child_allocation.y * 2 -
child_allocation.height = MAX (1, (gint)widget->allocation.height - (CHILD_SPACING + ythickness) * 2 -
border_width * 2);
if (GTK_WIDGET_CAN_DEFAULT (button))
......@@ -781,23 +819,22 @@ gtk_button_paint (GtkWidget *widget,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
gint border_width;
GtkBorder default_border;
GtkBorder default_outside_border;
gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget))
{
border_width = GTK_CONTAINER (widget)->border_width;
button = GTK_BUTTON (widget);
gtk_button_get_props (button, &default_border, &default_outside_border, &interior_focus);
x = 0;
y = 0;
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2;
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
x = widget->allocation.x + border_width;
y = widget->allocation.y + border_width;
width = widget->allocation.width - border_width * 2;
height = widget->allocation.height - border_width * 2;
if (GTK_WIDGET_HAS_DEFAULT (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
......@@ -1040,7 +1077,7 @@ gtk_real_button_activate (GtkButton *button)
if (GTK_WIDGET_REALIZED (button) && !button->activate_timeout)
{
if (gdk_keyboard_grab (widget->window, TRUE,
if (gdk_keyboard_grab (button->event_window, TRUE,
gtk_get_current_event_time ()) == 0)
{
gtk_grab_add (widget);
......
......@@ -52,6 +52,8 @@ struct _GtkButton
{
GtkBin bin;
GdkWindow *event_window;
gchar *label_text;
guint activate_timeout;
......
......@@ -261,6 +261,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
g_return_if_fail (allocation != NULL);
button = GTK_BUTTON (widget);
check_button = GTK_CHECK_BUTTON (widget);
toggle_button = GTK_TOGGLE_BUTTON (widget);
......@@ -273,12 +274,10 @@ gtk_check_button_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (toggle_button->event_window,
gdk_window_move_resize (button->event_window,
allocation->x, allocation->y,
allocation->width, allocation->height);
button = GTK_BUTTON (widget);
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
gint border_width = GTK_CONTAINER (widget)->border_width;
......
......@@ -4806,6 +4806,19 @@ gtk_clist_expose (GtkWidget *widget,
(clist, g_list_nth (clist->row_list,
clist->drag_highlight_row)->data,
clist->drag_highlight_row, clist->drag_highlight_pos);
if (event->window == clist->title_window)
{
gint i;
for (i = 0; i < clist->columns; i++)
{
if (clist->column[i].button)
gtk_container_propagate_expose (GTK_CONTAINER (clist),
clist->column[i].button,
event);
}
}
}
return FALSE;
......
......@@ -2159,9 +2159,9 @@ gtk_container_expose (GtkWidget *widget,
data.container = widget;
data.event = event;
gtk_container_foreach (GTK_CONTAINER (widget),
gtk_container_expose_child,
&data);
gtk_container_forall (GTK_CONTAINER (widget),
gtk_container_expose_child,
&data);
}
return TRUE;
......
......@@ -211,6 +211,9 @@ gtk_hscale_expose (GtkWidget *widget,
y = 0;
break;
}
x += widget->allocation.x;
y += widget->allocation.y;
state_type = GTK_STATE_NORMAL;
if (!GTK_WIDGET_IS_SENSITIVE (scale))
......
This diff is collapsed.
......@@ -65,7 +65,7 @@ struct _GtkNotebook
GList *focus_tab;
GtkWidget *menu;
GdkWindow *panel;
GdkWindow *event_window;
guint32 timer;
......
......@@ -464,6 +464,7 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWidget *child;
GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
GtkOptionMenuProps props;
gint border_width;
......@@ -473,19 +474,21 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
gdk_window_move_resize (button->event_window,
allocation->x + border_width, allocation->y + border_width,
allocation->width - border_width * 2, allocation->height - border_width * 2);
child = GTK_BIN (widget)->child;
if (child && GTK_WIDGET_VISIBLE (child))
{
child_allocation.x = GTK_WIDGET (widget)->style->xthickness + 1;
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1;
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2 - border_width * 2 -
gint xthickness = GTK_WIDGET (widget)->style->xthickness;
child_allocation.x = widget->allocation.x + border_width + xthickness + 1;
child_allocation.y = widget->allocation.y + 2 * border_width + 1;
child_allocation.width = MAX (1, (gint)allocation->width - (xthickness + 1) * 2 - border_width * 2 -
props.indicator_size.width - props.indicator_spacing.left - props.indicator_spacing.right -
CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING - 2);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2 - border_width * 2 -
child_allocation.height = MAX (1, (gint)allocation->height - (border_width + 1) * 2 - border_width * 2 -
CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING - 2);
child_allocation.x += CHILD_LEFT_SPACING;
child_allocation.y += CHILD_TOP_SPACING;
......@@ -510,8 +513,8 @@ gtk_option_menu_paint (GtkWidget *widget,
border_width = GTK_CONTAINER (widget)->border_width;
gtk_option_menu_get_props (GTK_OPTION_MENU (widget), &props);
button_area.x = 0;
button_area.y = 0;
button_area.x = widget->allocation.x + border_width;
button_area.y = widget->allocation.y + border_width;
button_area.width = widget->allocation.width - 2 * border_width;
button_area.height = widget->allocation.height - 2 * border_width;
......@@ -521,13 +524,6 @@ gtk_option_menu_paint (GtkWidget *widget,
button_area.y += 1;
button_area.width -= 2;
button_area.height -= 2;
/* This is evil, and should be elimated here and in the button
* code. The point is to clear the focus, and make it
* sort of transparent if it isn't there.
*/
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
}
gtk_paint_box (widget->style, widget->window,
......@@ -873,6 +869,7 @@ gtk_option_menu_position (GtkMenu *menu,
GtkOptionMenu *option_menu;
GtkWidget *active;
GtkWidget *child;
GtkWidget *widget;
GtkRequisition requisition;
GList *children;
gint screen_width;
......@@ -883,14 +880,16 @@ gtk_option_menu_position (GtkMenu *menu,
g_return_if_fail (GTK_IS_OPTION_MENU (user_data));
option_menu = GTK_OPTION_MENU (user_data);
widget = GTK_WIDGET (option_menu);
gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
menu_width = requisition.width;
active = gtk_menu_get_active (GTK_MENU (option_menu->menu));
gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
menu_ypos += GTK_WIDGET (option_menu)->allocation.height / 2 - 2;
menu_xpos += widget->allocation.x;
menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2;
if (active != NULL)
{
......
......@@ -103,6 +103,8 @@ static void gtk_range_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_range_realize (GtkWidget *widget);
static void gtk_range_unrealize (GtkWidget *widget);
static void gtk_range_map (GtkWidget *widget);
static void gtk_range_unmap (GtkWidget *widget);
static gint gtk_range_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint gtk_range_button_press (GtkWidget *widget,
......@@ -216,6 +218,8 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->size_allocate = gtk_range_size_allocate;
widget_class->realize = gtk_range_realize;
widget_class->unrealize = gtk_range_unrealize;
widget_class->map = gtk_range_map;
widget_class->unmap = gtk_range_unmap;
widget_class->expose_event = gtk_range_expose;
widget_class->button_press_event = gtk_range_button_press;
widget_class->button_release_event = gtk_range_button_release;
......@@ -366,6 +370,8 @@ gtk_range_get_property (GObject *object,
static void
gtk_range_init (GtkRange *range)
{
GTK_WIDGET_SET_FLAGS (range, GTK_NO_WINDOW);
range->adjustment = NULL;
range->update_policy = GTK_UPDATE_CONTINUOUS;
range->inverted = FALSE;
......@@ -719,10 +725,17 @@ gtk_range_size_allocate (GtkWidget *widget,
range = GTK_RANGE (widget);
widget->allocation = *allocation;
range->need_recalc = TRUE;
gtk_range_calc_layout (range, range->adjustment->value);
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
if (GTK_WIDGET_REALIZED (range))
gdk_window_move_resize (range->event_window,
widget->allocation.x,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height);
}
static void
......@@ -738,14 +751,15 @@ gtk_range_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
......@@ -755,13 +769,13 @@ gtk_range_realize (GtkWidget *widget)
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes_mask = GDK_WA_X | GDK_WA_Y;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, range);
range->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (range->event_window, range);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, widget->state);
}
static void
......@@ -776,10 +790,38 @@ gtk_range_unrealize (GtkWidget *widget)
gtk_range_remove_step_timer (range);
gtk_range_remove_update_timer (range);
gdk_window_set_user_data (range->event_window, NULL);
gdk_window_destroy (range->event_window);
range->event_window = NULL;
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
static void
gtk_range_map (GtkWidget *widget)
{
GtkRange *range = GTK_RANGE (widget);
g_return_if_fail (GTK_IS_RANGE (widget));
gdk_window_show (range->event_window);