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.
This commit is contained in:
Owen Taylor 2001-11-15 21:04:51 +00:00 committed by Owen Taylor
parent 41f14d3597
commit b27345fe2c
25 changed files with 822 additions and 630 deletions

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -1,3 +1,40 @@
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

View File

@ -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.

View File

@ -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);

View File

@ -52,6 +52,8 @@ struct _GtkButton
{
GtkBin bin;
GdkWindow *event_window;
gchar *label_text;
guint activate_timeout;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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))

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ struct _GtkNotebook
GList *focus_tab;
GtkWidget *menu;
GdkWindow *panel;
GdkWindow *event_window;
guint32 timer;

View File

@ -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)
{

View File

@ -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);
GTK_WIDGET_CLASS (parent_class)->map (widget);
}
static void
gtk_range_unmap (GtkWidget *widget)
{
GtkRange *range = GTK_RANGE (widget);
g_return_if_fail (GTK_IS_RANGE (widget));
gdk_window_hide (range->event_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
draw_stepper (GtkRange *range,
GdkRectangle *rect,
@ -791,10 +833,14 @@ draw_stepper (GtkRange *range,
GtkStateType state_type;
GtkShadowType shadow_type;
GdkRectangle intersection;
GtkWidget *widget = GTK_WIDGET (range);
/* More to get the right clip region than for efficiency */
if (!gdk_rectangle_intersect (area, rect, &intersection))
return;
intersection.x += widget->allocation.x;
intersection.y += widget->allocation.y;
if (!GTK_WIDGET_IS_SENSITIVE (range))
state_type = GTK_STATE_INSENSITIVE;
@ -816,7 +862,10 @@ draw_stepper (GtkRange *range,
&intersection, GTK_WIDGET (range),
GTK_RANGE_GET_CLASS (range)->stepper_detail,
arrow_type,
TRUE, rect->x, rect->y, rect->width, rect->height);
TRUE,
widget->allocation.x + rect->x,
widget->allocation.y + rect->y,
rect->width, rect->height);
}
static gint
@ -826,6 +875,7 @@ gtk_range_expose (GtkWidget *widget,
GtkRange *range;
gboolean sensitive;
GtkStateType state;
GdkRectangle expose_area; /* Relative to widget->allocation */
GdkRectangle area;
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
@ -833,10 +883,14 @@ gtk_range_expose (GtkWidget *widget,
range = GTK_RANGE (widget);
expose_area = event->area;
expose_area.x -= widget->allocation.x;
expose_area.y -= widget->allocation.y;
gtk_range_calc_layout (range, range->adjustment->value);
sensitive = GTK_WIDGET_IS_SENSITIVE (widget);
/* Just to be confusing, we draw the trough for the whole
* range rectangle, not the trough rectangle (the trough
* rectangle is just for hit detection)
@ -844,16 +898,19 @@ gtk_range_expose (GtkWidget *widget,
/* The gdk_rectangle_intersect is more to get the right
* clip region (limited to range_rect) than for efficiency
*/
if (gdk_rectangle_intersect (&event->area, &range->range_rect,
if (gdk_rectangle_intersect (&expose_area, &range->range_rect,
&area))
{
area.x += widget->allocation.x;
area.y += widget->allocation.y;
gtk_paint_box (widget->style,
widget->window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN,
&area, GTK_WIDGET(range), "trough",
range->range_rect.x,
range->range_rect.y,
widget->allocation.x + range->range_rect.x,
widget->allocation.y + range->range_rect.y,
range->range_rect.width,
range->range_rect.height);
@ -863,8 +920,8 @@ gtk_range_expose (GtkWidget *widget,
gtk_paint_focus (widget->style,
widget->window,
&area, widget, "trough",
range->range_rect.x,
range->range_rect.y,
widget->allocation.x + range->range_rect.x,
widget->allocation.y + range->range_rect.y,
range->range_rect.width,
range->range_rect.height);
}
@ -876,19 +933,22 @@ gtk_range_expose (GtkWidget *widget,
else
state = GTK_STATE_NORMAL;
if (gdk_rectangle_intersect (&event->area,
if (gdk_rectangle_intersect (&expose_area,
&range->layout->slider,
&area))
{
area.x += widget->allocation.x;
area.y += widget->allocation.y;
gtk_paint_slider (widget->style,
widget->window,
state,
GTK_SHADOW_OUT,
&event->area,
&area,
widget,
GTK_RANGE_GET_CLASS (range)->slider_detail,
range->layout->slider.x,
range->layout->slider.y,
widget->allocation.x + range->layout->slider.x,
widget->allocation.y + range->layout->slider.y,
range->layout->slider.width,
range->layout->slider.height,
range->orientation);
@ -899,28 +959,28 @@ gtk_range_expose (GtkWidget *widget,
range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT,
range->layout->grab_location == MOUSE_STEPPER_A,
range->layout->mouse_location == MOUSE_STEPPER_A,
&event->area);
&expose_area);
if (range->has_stepper_b)
draw_stepper (range, &range->layout->stepper_b,
range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT,
range->layout->grab_location == MOUSE_STEPPER_B,
range->layout->mouse_location == MOUSE_STEPPER_B,
&event->area);
&expose_area);
if (range->has_stepper_c)
draw_stepper (range, &range->layout->stepper_c,
range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT,
range->layout->grab_location == MOUSE_STEPPER_C,
range->layout->mouse_location == MOUSE_STEPPER_C,
&event->area);
&expose_area);
if (range->has_stepper_d)
draw_stepper (range, &range->layout->stepper_d,
range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT,
range->layout->grab_location == MOUSE_STEPPER_D,
range->layout->mouse_location == MOUSE_STEPPER_D,
&event->area);
&expose_area);
return FALSE;
}
@ -1291,7 +1351,7 @@ gtk_range_motion_notify (GtkWidget *widget,
range = GTK_RANGE (widget);
gdk_window_get_pointer (widget->window, &x, &y, NULL);
gdk_window_get_pointer (range->event_window, &x, &y, NULL);
range->layout->mouse_x = x;
range->layout->mouse_y = y;

View File

@ -97,6 +97,7 @@ struct _GtkRange
gint slide_initial_slider_position;
gint slide_initial_coordinate;
guint update_timeout_id;
GdkWindow *event_window;
};
struct _GtkRangeClass

View File

@ -51,8 +51,6 @@ static void gtk_toggle_button_class_init (GtkToggleButtonClass *klass);
static void gtk_toggle_button_init (GtkToggleButton *toggle_button);
static void gtk_toggle_button_paint (GtkWidget *widget,
GdkRectangle *area);
static void gtk_toggle_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_toggle_button_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toggle_button_pressed (GtkButton *button);
@ -66,10 +64,6 @@ static void gtk_toggle_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_toggle_button_realize (GtkWidget *widget);
static void gtk_toggle_button_unrealize (GtkWidget *widget);
static void gtk_toggle_button_map (GtkWidget *widget);
static void gtk_toggle_button_unmap (GtkWidget *widget);
static void gtk_toggle_button_update_state (GtkButton *button);
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
@ -121,12 +115,7 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
gobject_class->set_property = gtk_toggle_button_set_property;
gobject_class->get_property = gtk_toggle_button_get_property;
widget_class->size_allocate = gtk_toggle_button_size_allocate;
widget_class->expose_event = gtk_toggle_button_expose;
widget_class->realize = gtk_toggle_button_realize;
widget_class->unrealize = gtk_toggle_button_unrealize;
widget_class->map = gtk_toggle_button_map;
widget_class->unmap = gtk_toggle_button_unmap;
button_class->pressed = gtk_toggle_button_pressed;
button_class->released = gtk_toggle_button_released;
@ -174,7 +163,6 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
{
toggle_button->active = FALSE;
toggle_button->draw_indicator = FALSE;
GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
}
@ -273,35 +261,7 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
if (toggle_button->draw_indicator != draw_indicator)
{
if (GTK_WIDGET_REALIZED (toggle_button))
{
gboolean visible = GTK_WIDGET_VISIBLE (toggle_button);
if (visible)
gtk_widget_hide (widget);
gtk_widget_unrealize (widget);
toggle_button->draw_indicator = draw_indicator;
if (toggle_button->draw_indicator)
GTK_WIDGET_SET_FLAGS (toggle_button, GTK_NO_WINDOW);
else
GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
gtk_widget_realize (widget);
if (visible)
gtk_widget_show (widget);
}
else
{
toggle_button->draw_indicator = draw_indicator;
if (toggle_button->draw_indicator)
GTK_WIDGET_SET_FLAGS (toggle_button, GTK_NO_WINDOW);
else
GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
}
toggle_button->draw_indicator = draw_indicator;
if (GTK_WIDGET_VISIBLE (toggle_button))
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
@ -418,6 +378,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
GtkStateType state_type;
gint width, height;
gboolean interior_focus;
gint border_width;
gint x, y;
button = GTK_BUTTON (widget);
@ -425,15 +386,14 @@ gtk_toggle_button_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
border_width = GTK_CONTAINER (widget)->border_width;
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
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)
@ -505,15 +465,6 @@ gtk_toggle_button_paint (GtkWidget *widget,
}
}
static void
gtk_toggle_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
if (!GTK_WIDGET_NO_WINDOW (widget) &&
GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
}
static gint
gtk_toggle_button_expose (GtkWidget *widget,
GdkEventExpose *event)
@ -566,104 +517,6 @@ gtk_toggle_button_clicked (GtkButton *button)
g_object_notify (G_OBJECT (toggle_button), "active");
}
static void
gtk_toggle_button_realize (GtkWidget *widget)
{
GtkToggleButton *toggle_button;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
toggle_button = GTK_TOGGLE_BUTTON (widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
border_width = GTK_CONTAINER (widget)->border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x + border_width;
attributes.y = widget->allocation.y + border_width;
attributes.width = widget->allocation.width - border_width * 2;
attributes.height = widget->allocation.height - border_width * 2;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
if (GTK_WIDGET_NO_WINDOW (widget))
{
attributes.wclass = GDK_INPUT_ONLY;
attributes_mask = GDK_WA_X | GDK_WA_Y;
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
toggle_button->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (toggle_button->event_window, toggle_button);
}
else
{
attributes.wclass = GDK_INPUT_OUTPUT;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, toggle_button);
}
widget->style = gtk_style_attach (widget->style, widget->window);
if (!GTK_WIDGET_NO_WINDOW (widget))
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
}
static void
gtk_toggle_button_unrealize (GtkWidget *widget)
{
GtkToggleButton *toggle_button;
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
toggle_button = GTK_TOGGLE_BUTTON (widget);
if (GTK_WIDGET_NO_WINDOW (widget))
{
gdk_window_set_user_data (toggle_button->event_window, NULL);
gdk_window_destroy (toggle_button->event_window);
toggle_button->event_window = NULL;
}
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
static void
gtk_toggle_button_map (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
if (GTK_WIDGET_NO_WINDOW (widget))
gdk_window_show (GTK_TOGGLE_BUTTON (widget)->event_window);
GTK_WIDGET_CLASS (parent_class)->map (widget);
}
static void
gtk_toggle_button_unmap (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
if (GTK_WIDGET_NO_WINDOW (widget))
gdk_window_hide (GTK_TOGGLE_BUTTON (widget)->event_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
gtk_toggle_button_update_state (GtkButton *button)
{

View File

@ -55,8 +55,6 @@ struct _GtkToggleButton
guint active : 1;
guint draw_indicator : 1;
guint inconsistent : 1;
GdkWindow *event_window;
};
struct _GtkToggleButtonClass

View File

@ -2498,6 +2498,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_TREE_VIEW (widget), FALSE);
tree_view = GTK_TREE_VIEW (widget);
gtk_widget_style_get (widget,
"horizontal_separator", &horizontal_separator,
"vertical_separator", &vertical_separator,
@ -2871,6 +2872,20 @@ gtk_tree_view_expose (GtkWidget *widget,
if (event->window == tree_view->priv->bin_window)
return gtk_tree_view_bin_expose (widget, event);
else if (event->window == tree_view->priv->header_window)
{
GList *list;
for (list = tree_view->priv->columns; list != NULL; list = list->next)
{
GtkTreeViewColumn *column = list->data;
if (column->visible)
gtk_container_propagate_expose (GTK_CONTAINER (tree_view),
column->button,
event);
}
}
return TRUE;
}

View File

@ -218,6 +218,7 @@ gtk_viewport_init (GtkViewport *viewport)
{
GTK_WIDGET_UNSET_FLAGS (viewport, GTK_NO_WINDOW);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (viewport), FALSE);
gtk_container_set_resize_mode (GTK_CONTAINER (viewport), GTK_RESIZE_QUEUE);
viewport->shadow_type = GTK_SHADOW_IN;
@ -619,18 +620,11 @@ static void
gtk_viewport_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkViewport *viewport;
GtkBin *bin;
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkBin *bin = GTK_BIN (widget);
GtkAllocation child_allocation;
gint hval, vval;
gint border_width;
g_return_if_fail (GTK_IS_VIEWPORT (widget));
g_return_if_fail (allocation != NULL);
widget->allocation = *allocation;
viewport = GTK_VIEWPORT (widget);
bin = GTK_BIN (widget);
gint border_width = GTK_CONTAINER (widget)->border_width;
/* demand creation */
if (!viewport->hadjustment)
@ -638,15 +632,24 @@ gtk_viewport_size_allocate (GtkWidget *widget,
if (!viewport->vadjustment)
gtk_viewport_set_hadjustment (viewport, NULL);
border_width = GTK_CONTAINER (widget)->border_width;
/* If our size changed, and we have a shadow, queue a redraw on widget->window to
* redraw the shadow correctly.
*/
if (GTK_WIDGET_MAPPED (widget) &&
viewport->shadow_type != GTK_SHADOW_NONE &&
(widget->allocation.width != allocation->width ||
widget->allocation.height != allocation->height))
gdk_window_invalidate_rect (widget->window, NULL, FALSE);
widget->allocation = *allocation;
child_allocation.x = 0;
child_allocation.y = 0;
if (viewport->shadow_type != GTK_SHADOW_NONE)
{
child_allocation.x = GTK_WIDGET (viewport)->style->xthickness;
child_allocation.y = GTK_WIDGET (viewport)->style->ythickness;
child_allocation.x = widget->style->xthickness;
child_allocation.y = widget->style->ythickness;
}
child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2 - border_width * 2);

View File

@ -212,6 +212,9 @@ gtk_vscale_expose (GtkWidget *widget,
break;
}
x += widget->allocation.x;
y += widget->allocation.y;
state_type = GTK_STATE_NORMAL;
if (!GTK_WIDGET_IS_SENSITIVE (scale))
state_type = GTK_STATE_INSENSITIVE;

View File

@ -4857,7 +4857,6 @@ gtk_widget_set_events (GtkWidget *widget,
gint *eventp;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
@ -4895,8 +4894,7 @@ gtk_widget_add_events (GtkWidget *widget,
gint *eventp;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (events)
@ -4918,8 +4916,25 @@ gtk_widget_add_events (GtkWidget *widget,
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_set_events (widget->window,
gdk_window_get_events (widget->window) | events);
if (GTK_WIDGET_NO_WINDOW (widget))
{
GList *children = gdk_window_get_children (widget->window);
GList *tmp_list = children;
while (tmp_list)
{
GdkWindow *window = tmp_list->data;
gpointer user_data;
gdk_window_get_user_data (window, &user_data);
if (user_data == widget)
gdk_window_set_events (window, gdk_window_get_events (window) | events);
}
}
else
{
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | events);
}
}
g_object_notify (G_OBJECT (widget), "events");