summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-11-15 21:04:51 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-11-15 21:04:51 +0000
commitb27345fe2cf7277bb3483d06651c8bb6820003ec (patch)
tree5d692b7598d24fb038d1c02b9304cb9b68e4a236
parent41f14d359739ba21d0725d7025885da880100f33 (diff)
downloadgtk+-b27345fe2cf7277bb3483d06651c8bb6820003ec.tar.gz
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.
-rw-r--r--ChangeLog37
-rw-r--r--ChangeLog.pre-2-037
-rw-r--r--ChangeLog.pre-2-1037
-rw-r--r--ChangeLog.pre-2-237
-rw-r--r--ChangeLog.pre-2-437
-rw-r--r--ChangeLog.pre-2-637
-rw-r--r--ChangeLog.pre-2-837
-rw-r--r--docs/Changes-2.0.txt14
-rw-r--r--gtk/gtkbutton.c81
-rw-r--r--gtk/gtkbutton.h2
-rw-r--r--gtk/gtkcheckbutton.c5
-rw-r--r--gtk/gtkclist.c13
-rw-r--r--gtk/gtkcontainer.c6
-rw-r--r--gtk/gtkhscale.c3
-rw-r--r--gtk/gtknotebook.c680
-rw-r--r--gtk/gtknotebook.h2
-rw-r--r--gtk/gtkoptionmenu.c31
-rw-r--r--gtk/gtkrange.c108
-rw-r--r--gtk/gtkrange.h1
-rw-r--r--gtk/gtktogglebutton.c163
-rw-r--r--gtk/gtktogglebutton.h2
-rw-r--r--gtk/gtktreeview.c15
-rw-r--r--gtk/gtkviewport.c29
-rw-r--r--gtk/gtkvscale.c3
-rw-r--r--gtk/gtkwidget.c25
25 files changed, 817 insertions, 625 deletions
diff --git a/ChangeLog b/ChangeLog
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -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
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index c107dec4ab..91e0160dd6 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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
diff --git a/docs/Changes-2.0.txt b/docs/Changes-2.0.txt
index a5953d5235..6c2ceac78a 100644
--- a/docs/Changes-2.0.txt
+++ b/docs/Changes-2.0.txt
@@ -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.
+
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 32199e7fc5..0e805768dc 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -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,11 +613,44 @@ 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,
GtkBorder *default_outside_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);
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index 3f40d54d3b..c0caa19e2e 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -52,6 +52,8 @@ struct _GtkButton
{
GtkBin bin;
+ GdkWindow *event_window;
+
gchar *label_text;
guint activate_timeout;
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 8616180a59..3d2fff01ad 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -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;
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index 602850186f..856eb3172e 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -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;
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 279ff7bc1f..613eb4a4d3 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -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;
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c
index e940d50428..a85b6b9755 100644
--- a/gtk/gtkhscale.c
+++ b/gtk/gtkhscale.c
@@ -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))
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 87f114138d..bac4ff9ee2 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -180,7 +180,6 @@ static void gtk_notebook_forall (GtkContainer *container,
gpointer callback_data);
/*** GtkNotebook Private Functions ***/
-static void gtk_notebook_panel_realize (GtkNotebook *notebook);
static void gtk_notebook_redraw_tabs (GtkNotebook *notebook);
static void gtk_notebook_redraw_arrows (GtkNotebook *notebook);
static void gtk_notebook_focus_changed (GtkNotebook *notebook,
@@ -209,7 +208,6 @@ static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GdkRectangle *area);
static void gtk_notebook_draw_arrow (GtkNotebook *notebook,
guint arrow);
-static void gtk_notebook_set_shape (GtkNotebook *notebook);
/*** GtkNotebook Size Allocate Functions ***/
static void gtk_notebook_pages_allocate (GtkNotebook *notebook);
@@ -497,13 +495,13 @@ static void
gtk_notebook_init (GtkNotebook *notebook)
{
GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT);
- GTK_WIDGET_UNSET_FLAGS (notebook, GTK_NO_WINDOW);
+ GTK_WIDGET_SET_FLAGS (notebook, GTK_NO_WINDOW);
notebook->cur_page = NULL;
notebook->children = NULL;
notebook->first_tab = NULL;
notebook->focus_tab = NULL;
- notebook->panel = NULL;
+ notebook->event_window = NULL;
notebook->menu = NULL;
notebook->tab_hborder = 2;
@@ -696,6 +694,54 @@ gtk_notebook_get_property (GObject *object,
* gtk_notebook_draw_focus
* gtk_notebook_style_set
*/
+static gboolean
+gtk_notebook_get_event_window_position (GtkNotebook *notebook,
+ GdkRectangle *rectangle)
+{
+ GtkWidget *widget = GTK_WIDGET (notebook);
+
+ if (notebook->show_tabs && notebook->children)
+ {
+ if (rectangle)
+ {
+ GtkNotebookPage *page = notebook->children->data;
+
+ rectangle->x = widget->allocation.x;
+ rectangle->y = widget->allocation.y;
+
+ switch (notebook->tab_pos)
+ {
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ rectangle->width = widget->allocation.width;
+ rectangle->height = page->requisition.height;
+ if (notebook->tab_pos == GTK_POS_BOTTOM)
+ rectangle->y += widget->allocation.height - rectangle->height;
+ break;
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ rectangle->width = page->requisition.width;
+ rectangle->height = widget->allocation.height;
+ if (notebook->tab_pos == GTK_POS_RIGHT)
+ rectangle->x += widget->allocation.width - rectangle->width;
+ break;
+ }
+ }
+
+ return TRUE;
+ }
+ else
+ {
+ if (rectangle)
+ {
+ rectangle->x = rectangle->y = 0;
+ rectangle->width = rectangle->height = 10;
+ }
+ }
+
+ return FALSE;
+}
+
static void
gtk_notebook_map (GtkWidget *widget)
{
@@ -732,10 +778,8 @@ gtk_notebook_map (GtkWidget *widget)
}
}
- if (notebook->scrollable)
- gdk_window_show (notebook->panel);
-
- gdk_window_show (widget->window);
+ if (gtk_notebook_get_event_window_position (notebook, NULL))
+ gdk_window_show (notebook->event_window);
}
static void
@@ -744,9 +788,8 @@ gtk_notebook_unmap (GtkWidget *widget)
g_return_if_fail (GTK_IS_NOTEBOOK (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
- gdk_window_hide (widget->window);
- if (GTK_NOTEBOOK (widget)->panel)
- gdk_window_hide (GTK_NOTEBOOK (widget)->panel);
+
+ gdk_window_hide (GTK_NOTEBOOK (widget)->event_window);
}
static void
@@ -755,35 +798,35 @@ gtk_notebook_realize (GtkWidget *widget)
GtkNotebook *notebook;
GdkWindowAttr attributes;
gint attributes_mask;
+ GdkRectangle event_window_pos;
g_return_if_fail (GTK_IS_NOTEBOOK (widget));
notebook = GTK_NOTEBOOK (widget);
GTK_WIDGET_SET_FLAGS (notebook, GTK_REALIZED);
+ gtk_notebook_get_event_window_position (notebook, &event_window_pos);
+
+ 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.x = event_window_pos.x;
+ attributes.y = event_window_pos.y;
+ attributes.width = event_window_pos.width;
+ attributes.height = event_window_pos.height;
+ attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_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, notebook);
+ notebook->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (notebook->event_window, notebook);
widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
- if (notebook->scrollable)
- gtk_notebook_panel_realize (notebook);
}
static void
@@ -795,12 +838,9 @@ gtk_notebook_unrealize (GtkWidget *widget)
notebook = GTK_NOTEBOOK (widget);
- if (notebook->panel)
- {
- gdk_window_set_user_data (notebook->panel, NULL);
- gdk_window_destroy (notebook->panel);
- notebook->panel = NULL;
- }
+ gdk_window_set_user_data (notebook->event_window, NULL);
+ gdk_window_destroy (notebook->event_window);
+ notebook->event_window = NULL;
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
@@ -1071,28 +1111,34 @@ gtk_notebook_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_NOTEBOOK (widget));
g_return_if_fail (allocation != NULL);
+ notebook = GTK_NOTEBOOK (widget);
+
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
+ {
+ GdkRectangle position;
+
+ if (gtk_notebook_get_event_window_position (notebook, &position))
+ gdk_window_move_resize (notebook->event_window,
+ position.x, position.y,
+ position.width, position.height);
+ }
- notebook = GTK_NOTEBOOK (widget);
if (notebook->children)
{
child_allocation.x = GTK_CONTAINER (widget)->border_width;
child_allocation.y = GTK_CONTAINER (widget)->border_width;
- child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
- child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
+ child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2);
+ child_allocation.height = MAX (1, allocation->height - child_allocation.y * 2);
if (notebook->show_tabs || notebook->show_border)
{
child_allocation.x += widget->style->xthickness;
child_allocation.y += widget->style->ythickness;
- child_allocation.width = MAX (1, (gint)child_allocation.width -
- (gint) widget->style->xthickness * 2);
- child_allocation.height = MAX (1, (gint)child_allocation.height -
- (gint) widget->style->ythickness * 2);
+ child_allocation.width = MAX (1, child_allocation.width -
+ widget->style->xthickness * 2);
+ child_allocation.height = MAX (1, child_allocation.height -
+ widget->style->ythickness * 2);
if (notebook->show_tabs && notebook->children && notebook->cur_page)
{
@@ -1102,15 +1148,15 @@ gtk_notebook_size_allocate (GtkWidget *widget,
child_allocation.y += notebook->cur_page->requisition.height;
case GTK_POS_BOTTOM:
child_allocation.height =
- MAX (1, (gint)child_allocation.height -
- (gint)notebook->cur_page->requisition.height);
+ MAX (1, 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 =
- MAX (1, (gint)child_allocation.width -
- (gint)notebook->cur_page->requisition.width);
+ MAX (1, child_allocation.width -
+ notebook->cur_page->requisition.width);
break;
}
}
@@ -1128,7 +1174,6 @@ gtk_notebook_size_allocate (GtkWidget *widget,
gtk_notebook_pages_allocate (notebook);
}
- gtk_notebook_set_shape (notebook);
}
static gint
@@ -1165,13 +1210,104 @@ gtk_notebook_expose (GtkWidget *widget,
}
static gboolean
+gtk_notebook_show_arrows (GtkNotebook *notebook)
+{
+ gboolean show_arrow = FALSE;
+ GList *children;
+
+ if (!notebook->scrollable)
+ return FALSE;
+
+ children = notebook->children;
+ while (children)
+ {
+ GtkNotebookPage *page = children->data;
+
+ if (page->tab_label && !gtk_widget_get_child_visible (page->tab_label))
+ show_arrow = TRUE;
+
+ children = children->next;
+ }
+
+ return show_arrow;
+}
+
+static void
+gtk_notebook_get_arrow_rect (GtkNotebook *notebook,
+ GdkRectangle *rectangle)
+{
+ GdkRectangle event_window_pos;
+
+ if (gtk_notebook_get_event_window_position (notebook, &event_window_pos))
+ {
+ rectangle->width = 2 * ARROW_SIZE + ARROW_SPACING;
+ rectangle->height = ARROW_SIZE;
+
+ switch (notebook->tab_pos)
+ {
+ case GTK_POS_LEFT:
+ rectangle->x = event_window_pos.x + (event_window_pos.width - rectangle->width) / 2;
+ break;
+ case GTK_POS_RIGHT:
+ rectangle->x = event_window_pos.x + event_window_pos.width - (event_window_pos.width - rectangle->width) / 2;
+ break;
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ rectangle->x = event_window_pos.x + event_window_pos.width - rectangle->width;
+ break;
+ }
+
+ switch (notebook->tab_pos)
+ {
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ rectangle->y = event_window_pos.y + event_window_pos.height - rectangle->height;
+ break;
+ case GTK_POS_TOP:
+ rectangle->y = event_window_pos.y + (event_window_pos.height - rectangle->height) / 2;
+ break;
+ case GTK_POS_BOTTOM:
+ rectangle->y = event_window_pos.y + event_window_pos.height - (event_window_pos.height - rectangle->height) / 2;
+ break;
+ }
+ }
+}
+
+static GtkArrowType
+gtk_notebook_get_arrow (GtkNotebook *notebook,
+ gint x,
+ gint y)
+{
+ GdkRectangle arrow_rect;
+ GdkRectangle event_window_pos;
+
+ if (gtk_notebook_show_arrows (notebook))
+ {
+ gtk_notebook_get_event_window_position (notebook, &event_window_pos);
+ gtk_notebook_get_arrow_rect (notebook, &arrow_rect);
+
+ x -= arrow_rect.x - event_window_pos.x;
+ y -= arrow_rect.y - event_window_pos.y;
+
+ if (y >= 0 && y < arrow_rect.height)
+ {
+ if (x >= 0 && x < ARROW_SIZE + ARROW_SPACING / 2)
+ return GTK_ARROW_LEFT;
+ else if (x >= ARROW_SIZE + ARROW_SPACING / 2 && x < arrow_rect.width)
+ return GTK_ARROW_RIGHT;
+ }
+ }
+
+ return 0;
+}
+
+static gboolean
gtk_notebook_arrow_button_press (GtkNotebook *notebook,
+ GtkArrowType arrow,
GdkEventButton *event)
{
GtkWidget *widget = GTK_WIDGET (notebook);
- GtkArrowType arrow = event->x <= ARROW_SIZE + ARROW_SPACING / 2 ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT;
-
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
@@ -1219,75 +1355,75 @@ static gboolean
gtk_notebook_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- GtkNotebook *notebook;
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPage *page;
GList *children;
+ GtkArrowType arrow;
+ GdkRectangle event_window_pos;
gint num;
-
- g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- notebook = GTK_NOTEBOOK (widget);
+ gint x, y;
if (event->type != GDK_BUTTON_PRESS || !notebook->children ||
notebook->button)
return FALSE;
- if (event->window == notebook->panel)
+ arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+ if (arrow)
+ return gtk_notebook_arrow_button_press (notebook, arrow, event);
+
+ if (event->button == 3 && notebook->menu)
{
- return gtk_notebook_arrow_button_press (notebook, event);
+ gtk_menu_popup (GTK_MENU (notebook->menu), NULL, NULL,
+ NULL, NULL, 3, event->time);
+ return TRUE;
}
- else if (event->window == widget->window)
- {
- if (event->button == 3 && notebook->menu)
- {
- gtk_menu_popup (GTK_MENU (notebook->menu), NULL, NULL,
- NULL, NULL, 3, event->time);
- return TRUE;
- }
- num = 0;
- children = notebook->children;
- while (children)
+ /* Translate coordinates from event_window to widget->window
+ */
+ gtk_notebook_get_event_window_position (notebook, &event_window_pos);
+ x = event->x + event_window_pos.x;
+ y = event->y + event_window_pos.y;
+
+ num = 0;
+ children = notebook->children;
+ while (children)
+ {
+ page = children->data;
+
+ if (GTK_WIDGET_VISIBLE (page->child) &&
+ page->tab_label && GTK_WIDGET_MAPPED (page->tab_label) &&
+ (x >= page->allocation.x) &&
+ (y >= page->allocation.y) &&
+ (x <= (page->allocation.x + page->allocation.width)) &&
+ (y <= (page->allocation.y + page->allocation.height)))
{
- page = children->data;
-
- if (GTK_WIDGET_VISIBLE (page->child) &&
- page->tab_label && GTK_WIDGET_MAPPED (page->tab_label) &&
- (event->x >= page->allocation.x) &&
- (event->y >= page->allocation.y) &&
- (event->x <= (page->allocation.x + page->allocation.width)) &&
- (event->y <= (page->allocation.y + page->allocation.height)))
+ if (page == notebook->cur_page && notebook->focus_tab &&
+ notebook->focus_tab != children &&
+ GTK_WIDGET_HAS_FOCUS (notebook))
{
- if (page == notebook->cur_page && notebook->focus_tab &&
- notebook->focus_tab != children &&
- GTK_WIDGET_HAS_FOCUS (notebook))
- {
- GtkNotebookPage *old_page;
-
- notebook->child_has_focus = FALSE;
- old_page = (GtkNotebookPage *)
- (notebook->focus_tab->data);
- gtk_notebook_switch_focus_tab (notebook, children);
- gtk_notebook_focus_changed (notebook, old_page);
- }
- else
- {
- gtk_notebook_switch_focus_tab (notebook, children);
- gtk_widget_grab_focus (widget);
- gtk_notebook_switch_page (notebook, page, num);
- }
- break;
+ GtkNotebookPage *old_page;
+
+ notebook->child_has_focus = FALSE;
+ old_page = (GtkNotebookPage *)
+ (notebook->focus_tab->data);
+ gtk_notebook_switch_focus_tab (notebook, children);
+ gtk_notebook_focus_changed (notebook, old_page);
}
- children = children->next;
- num++;
+ else
+ {
+ gtk_notebook_switch_focus_tab (notebook, children);
+ gtk_widget_grab_focus (widget);
+ gtk_notebook_switch_page (notebook, page, num);
+ }
+ break;
}
- if (!children && !GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
- return TRUE;
+ children = children->next;
+ num++;
}
-
- return FALSE;
+ if (!children && !GTK_WIDGET_HAS_FOCUS (widget))
+ gtk_widget_grab_focus (widget);
+
+ return TRUE;
}
static gint
@@ -1330,89 +1466,69 @@ gtk_notebook_enter_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkNotebook *notebook;
+ GtkArrowType arrow;
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
notebook = GTK_NOTEBOOK (widget);
- if (event->window == notebook->panel)
- {
- gint x;
- gint y;
-
- gdk_window_get_pointer (notebook->panel, &x, &y, NULL);
-
- if (x <= ARROW_SIZE + ARROW_SPACING / 2)
- notebook->in_child = GTK_ARROW_LEFT;
- else
- notebook->in_child = GTK_ARROW_RIGHT;
+ arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+ if (arrow != notebook->in_child)
+ {
+ notebook->in_child = arrow;
gtk_notebook_redraw_arrows (notebook);
+
+ return TRUE;
}
- return FALSE;
+ return TRUE;
}
static gint
gtk_notebook_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
- GtkNotebook *notebook;
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkArrowType arrow;
- g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- notebook = GTK_NOTEBOOK (widget);
+ arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
- if (event->window == notebook->panel)
- gtk_notebook_redraw_arrows (notebook);
+ if (notebook->in_child)
+ {
+ notebook->in_child = 0;
+ gtk_notebook_redraw_arrows (notebook);
+ }
- return FALSE;
+ return TRUE;
}
static gint
gtk_notebook_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkNotebook *notebook;
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkArrowType arrow;
- g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- notebook = GTK_NOTEBOOK (widget);
-
if (notebook->button)
return FALSE;
- if (event->window == notebook->panel)
- {
- gint x;
- GtkArrowType old_child = notebook->in_child;
-
- x = event->x;
- if (event->is_hint)
- gdk_window_get_pointer (notebook->panel, &x, NULL, NULL);
-
- if (x <= ARROW_SIZE + ARROW_SPACING / 2)
- notebook->in_child = GTK_ARROW_LEFT;
- else
- notebook->in_child = GTK_ARROW_RIGHT;
+ arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
- if (old_child != notebook->in_child)
- gtk_notebook_redraw_arrows (notebook);
+ if (arrow != notebook->in_child)
+ {
+ notebook->in_child = arrow;
+ gtk_notebook_redraw_arrows (notebook);
}
- return FALSE;
+ return TRUE;
}
static gint
gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event)
{
- g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
GTK_NOTEBOOK (widget)->child_has_focus = FALSE;
return (* GTK_WIDGET_CLASS (parent_class)->focus_in_event) (widget, event);
@@ -1421,11 +1537,7 @@ gtk_notebook_focus_in (GtkWidget *widget,
static void
gtk_notebook_draw_focus (GtkWidget *widget)
{
- GtkNotebook *notebook;
-
- g_return_if_fail (GTK_IS_NOTEBOOK (widget));
-
- notebook = GTK_NOTEBOOK (widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs &&
notebook->focus_tab)
@@ -1840,7 +1952,6 @@ gtk_notebook_child_type (GtkContainer *container)
/* Private GtkNotebook Functions:
*
- * gtk_notebook_panel_realize
* gtk_notebook_redraw_tabs
* gtk_notebook_focus_changed
* gtk_notebook_real_remove
@@ -1851,49 +1962,6 @@ gtk_notebook_child_type (GtkContainer *container)
* gtk_notebook_search_page
*/
static void
-gtk_notebook_panel_realize (GtkNotebook *notebook)
-{
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
-
- widget = GTK_WIDGET (notebook);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK
- | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- attributes.width = 2 * ARROW_SIZE + ARROW_SPACING;
- attributes.height = ARROW_SIZE;
-
- attributes.x = (widget->allocation.width - attributes.width -
- GTK_CONTAINER (notebook)->border_width);
- attributes.y = (widget->allocation.height - ARROW_SIZE -
- GTK_CONTAINER (notebook)->border_width);
- if (notebook->tab_pos == GTK_POS_TOP)
- attributes.y = GTK_CONTAINER (notebook)->border_width;
- else if (notebook->tab_pos == GTK_POS_LEFT)
- attributes.x = (widget->allocation.x +
- GTK_CONTAINER (notebook)->border_width);
-
- notebook->panel = gdk_window_new (widget->window, &attributes,
- attributes_mask);
- gtk_style_set_background (widget->style, notebook->panel,
- GTK_STATE_NORMAL);
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
- gdk_window_set_user_data (notebook->panel, widget);
-}
-
-static void
gtk_notebook_redraw_tabs (GtkNotebook *notebook)
{
GtkWidget *widget;
@@ -1950,8 +2018,13 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook)
static void
gtk_notebook_redraw_arrows (GtkNotebook *notebook)
{
- if (GTK_WIDGET_MAPPED (notebook) && notebook->panel)
- gdk_window_invalidate_rect (notebook->panel, NULL, FALSE);
+ if (GTK_WIDGET_MAPPED (notebook) && gtk_notebook_show_arrows (notebook))
+ {
+ GdkRectangle rect;
+
+ gtk_notebook_get_arrow_rect (notebook, &rect);
+ gdk_window_invalidate_rect (GTK_WIDGET (notebook)->window, &rect, FALSE);
+ }
}
static void
@@ -2113,6 +2186,10 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
g_list_free (list);
g_free (page);
+ if (!notebook->children && notebook->show_tabs &&
+ GTK_WIDGET_MAPPED (notebook))
+ gdk_window_hide (notebook->event_window);
+
gtk_notebook_update_labels (notebook);
if (need_resize)
gtk_widget_queue_resize (GTK_WIDGET (notebook));
@@ -2257,7 +2334,6 @@ gtk_notebook_search_page (GtkNotebook *notebook,
* gtk_notebook_paint
* gtk_notebook_draw_tab
* gtk_notebook_draw_arrow
- * gtk_notebook_set_shape
*/
static void
gtk_notebook_paint (GtkWidget *widget,
@@ -2269,6 +2345,7 @@ gtk_notebook_paint (GtkWidget *widget,
gboolean showarrow;
gint width, height;
gint x, y;
+ gint border_width = GTK_CONTAINER (widget)->border_width;
gint gap_x = 0, gap_width = 0;
g_return_if_fail (GTK_IS_NOTEBOOK (widget));
@@ -2281,15 +2358,10 @@ gtk_notebook_paint (GtkWidget *widget,
if ((!notebook->show_tabs && !notebook->show_border) ||
!notebook->cur_page || !GTK_WIDGET_VISIBLE (notebook->cur_page->child))
- {
- gdk_window_clear_area (widget->window,
- area->x, area->y,
- area->width, area->height);
- return;
- }
+ return;
- x = GTK_CONTAINER (widget)->border_width;
- y = GTK_CONTAINER (widget)->border_width;
+ x = widget->allocation.x + border_width;
+ y = widget->allocation.y + border_width;
width = widget->allocation.width - x * 2;
height = widget->allocation.height - y * 2;
@@ -2344,23 +2416,19 @@ gtk_notebook_paint (GtkWidget *widget,
switch (notebook->tab_pos)
{
case GTK_POS_TOP:
- gap_x = (notebook->cur_page->allocation.x -
- GTK_CONTAINER(notebook)->border_width);
+ gap_x = (notebook->cur_page->allocation.x - border_width);
gap_width = notebook->cur_page->allocation.width;
break;
case GTK_POS_BOTTOM:
- gap_x = (notebook->cur_page->allocation.x -
- GTK_CONTAINER(notebook)->border_width);
+ gap_x = (notebook->cur_page->allocation.x - border_width);
gap_width = notebook->cur_page->allocation.width;
break;
case GTK_POS_LEFT:
- gap_x = (notebook->cur_page->allocation.y -
- GTK_CONTAINER(notebook)->border_width);
+ gap_x = (notebook->cur_page->allocation.y - border_width);
gap_width = notebook->cur_page->allocation.height;
break;
case GTK_POS_RIGHT:
- gap_x = (notebook->cur_page->allocation.y -
- GTK_CONTAINER(notebook)->border_width);
+ gap_x = (notebook->cur_page->allocation.y - border_width);
gap_width = notebook->cur_page->allocation.height;
break;
}
@@ -2487,6 +2555,9 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook,
GtkStateType state_type;
GtkShadowType shadow_type;
GtkWidget *widget;
+ GdkRectangle arrow_rect;
+
+ gtk_notebook_get_arrow_rect (notebook, &arrow_rect);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
@@ -2523,11 +2594,10 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook,
notebook->tab_pos == GTK_POS_RIGHT)
arrow = GTK_ARROW_UP;
- gdk_window_clear_area (notebook->panel, 0, 0, ARROW_SIZE, ARROW_SIZE);
- gtk_paint_arrow (widget->style, notebook->panel, state_type,
+ gtk_paint_arrow (widget->style, widget->window, state_type,
shadow_type, NULL, GTK_WIDGET(notebook), "notebook",
arrow, TRUE,
- 0, 0, ARROW_SIZE, ARROW_SIZE);
+ arrow_rect.x, arrow_rect.y, ARROW_SIZE, ARROW_SIZE);
}
else
{
@@ -2543,141 +2613,14 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook,
notebook->tab_pos == GTK_POS_RIGHT)
arrow = GTK_ARROW_DOWN;
- gdk_window_clear_area(notebook->panel, ARROW_SIZE + ARROW_SPACING,
- 0, ARROW_SIZE, ARROW_SIZE);
- gtk_paint_arrow (widget->style, notebook->panel, state_type,
+ gtk_paint_arrow (widget->style, widget->window, state_type,
shadow_type, NULL, GTK_WIDGET(notebook), "notebook",
- arrow, TRUE, ARROW_SIZE + ARROW_SPACING,
- 0, ARROW_SIZE, ARROW_SIZE);
+ arrow, TRUE, arrow_rect.x + ARROW_SIZE + ARROW_SPACING,
+ arrow_rect.y, ARROW_SIZE, ARROW_SIZE);
}
}
}
-static void
-gtk_notebook_set_shape (GtkNotebook *notebook)
-{
- GtkWidget *widget = NULL;
- GdkPixmap *pm = NULL;
- GdkGC *pmgc = NULL;
- GdkColor col;
- gint x, y, width, height, w, h, depth;
- GtkNotebookPage *page;
- GList *children;
-
- if (!GTK_WIDGET(notebook)->window)
- return;
-
- widget = GTK_WIDGET(notebook);
-
- w = widget->allocation.width;
- h = widget->allocation.height;
-
- pm = gdk_pixmap_new (widget->window, w, h, 1);
- pmgc = gdk_gc_new (pm);
-
- /* clear the shape mask */
- col.pixel = 0;
- gdk_gc_set_foreground(pmgc, &col);
- gdk_draw_rectangle(pm, pmgc, TRUE, 0, 0, w, h);
-
- col.pixel = 1;
- gdk_gc_set_foreground(pmgc, &col);
-
- /* draw the shape for the notebook page itself */
- x = GTK_CONTAINER(notebook)->border_width;
- y = GTK_CONTAINER(notebook)->border_width;
- width = widget->allocation.width - x * 2;
- height = widget->allocation.height - y * 2;
-
- if (notebook->show_tabs && notebook->children)
- {
- if (!(notebook->show_tabs))
- {
- page = notebook->first_tab->data;
- switch (notebook->tab_pos)
- {
- case GTK_POS_TOP:
- y += page->allocation.height +
- widget->style->ythickness;
- case GTK_POS_BOTTOM:
- height -= page->allocation.height +
- widget->style->ythickness;
- break;
- case GTK_POS_LEFT:
- x += page->allocation.width +
- widget->style->xthickness;
- case GTK_POS_RIGHT:
- width -= page->allocation.width +
- widget->style->xthickness;
- break;
- }
- }
- else
- {
- if (notebook->cur_page)
- page = notebook->cur_page;
- else
- page = notebook->children->data;
-
- if (!GTK_WIDGET_MAPPED (page->tab_label))
- {
- if (notebook->tab_pos == GTK_POS_LEFT)
- {
- x -= widget->style->xthickness * 2;
- width += widget->style->xthickness * 2;
- }
- else if (notebook->tab_pos == GTK_POS_RIGHT)
- width += widget->style->xthickness * 2;
- }
- switch (notebook->tab_pos)
- {
- case GTK_POS_TOP:
- y += page->allocation.height;
- case GTK_POS_BOTTOM:
- height -= page->allocation.height;
- break;
- case GTK_POS_LEFT:
- x += page->allocation.width;
- case GTK_POS_RIGHT:
- width -= page->allocation.width;
- break;
- }
- }
- }
- gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height);
-
- /* if theres an area for scrolling arrows draw the shape for them */
- if (notebook->panel && gdk_window_is_visible (notebook->panel))
- {
- gdk_window_get_geometry(notebook->panel, &x, &y, &width, &height, &depth);
- gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height);
- }
-
- /* draw the shapes of all the children */
- if (notebook->show_tabs)
- {
- children = notebook->children;
- while (children)
- {
- page = children->data;
- if (gtk_widget_get_child_visible (page->tab_label))
- {
- x = page->allocation.x;
- y = page->allocation.y;
- width = page->allocation.width;
- height = page->allocation.height;
- gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height);
- }
- children = children->next;
- }
- }
-
- /* set the mask */
- gdk_window_shape_combine_mask(widget->window, pm, 0, 0);
- gdk_pixmap_unref(pm);
- gdk_gc_destroy(pmgc);
-}
-
/* Private GtkNotebook Size Allocate Functions:
*
* gtk_notebook_pages_allocate
@@ -2892,12 +2835,6 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
}
}
- if (GTK_WIDGET_REALIZED (notebook))
- {
- gdk_window_move (notebook->panel, x, y);
- gdk_window_show (notebook->panel);
- }
-
if (tab_space < 0)
{
tab_space = -tab_space;
@@ -2936,8 +2873,6 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
notebook->first_tab = gtk_notebook_search_page (notebook, NULL,
STEP_NEXT, TRUE);
tab_space = 0;
- if (GTK_WIDGET_REALIZED (notebook))
- gdk_window_hide (notebook->panel);
}
}
@@ -3115,7 +3050,6 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
}
done:
- gtk_notebook_set_shape (notebook);
gtk_notebook_redraw_tabs (notebook);
}
@@ -3216,7 +3150,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook,
{
child_allocation.x = (xthickness + FOCUS_WIDTH +
notebook->tab_hborder);
- child_allocation.width = MAX (1, (((gint) page->allocation.width) -
+ child_allocation.width = MAX (1, (page->allocation.width -
2 * child_allocation.x));
child_allocation.x += page->allocation.x;
}
@@ -3231,7 +3165,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook,
page->allocation.y);
if (notebook->tab_pos == GTK_POS_TOP)
child_allocation.y += ythickness;
- child_allocation.height = MAX (1, (((gint) page->allocation.height) - ythickness -
+ child_allocation.height = MAX (1, (page->allocation.height - ythickness -
2 * (notebook->tab_vborder + FOCUS_WIDTH)));
break;
case GTK_POS_LEFT:
@@ -3240,7 +3174,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook,
if (page->fill)
{
child_allocation.y = ythickness + padding;
- child_allocation.height = MAX (1, (((gint) page->allocation.height) -
+ child_allocation.height = MAX (1, (page->allocation.height -
2 * child_allocation.y));
child_allocation.y += page->allocation.y;
}
@@ -3253,7 +3187,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook,
child_allocation.x = page->allocation.x + notebook->tab_hborder + FOCUS_WIDTH;
if (notebook->tab_pos == GTK_POS_LEFT)
child_allocation.x += xthickness;
- child_allocation.width = MAX (1, (((gint) page->allocation.width) - xthickness -
+ child_allocation.width = MAX (1, (page->allocation.width - xthickness -
2 * (notebook->tab_hborder + FOCUS_WIDTH)));
break;
}
@@ -3466,7 +3400,7 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
old_child = notebook->focus_tab;
notebook->focus_tab = new_child;
- if (notebook->scrollable && GTK_WIDGET_DRAWABLE (notebook))
+ if (notebook->scrollable)
gtk_notebook_redraw_arrows (notebook);
if (!notebook->show_tabs || !notebook->focus_tab)
@@ -3480,8 +3414,6 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
gtk_notebook_focus_changed (notebook, old_page);
else
gtk_notebook_pages_allocate (notebook);
-
- gtk_notebook_set_shape (notebook);
}
static void
@@ -3847,6 +3779,9 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
(GtkSignalFunc) gtk_notebook_mnemonic_activate_switch_page,
notebook);
+ if (notebook->show_tabs && GTK_WIDGET_MAPPED (notebook))
+ gdk_window_show (notebook->event_window);
+
gtk_widget_child_notify (child, "tab_expand");
gtk_widget_child_notify (child, "tab_fill");
gtk_widget_child_notify (child, "tab_pack");
@@ -4150,9 +4085,6 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
else
gtk_widget_hide (page->tab_label);
}
-
- if (notebook->panel)
- gdk_window_hide (notebook->panel);
}
else
{
@@ -4335,20 +4267,6 @@ gtk_notebook_set_scrollable (GtkNotebook *notebook,
{
notebook->scrollable = scrollable;
- if (GTK_WIDGET_REALIZED (notebook))
- {
- if (scrollable)
- {
- gtk_notebook_panel_realize (notebook);
- }
- else if (notebook->panel)
- {
- gdk_window_set_user_data (notebook->panel, NULL);
- gdk_window_destroy (notebook->panel);
- notebook->panel = NULL;
- }
- }
-
if (GTK_WIDGET_VISIBLE (notebook))
gtk_widget_queue_resize (GTK_WIDGET (notebook));
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index 447b9b1e08..68ff3ad904 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -65,7 +65,7 @@ struct _GtkNotebook
GList *focus_tab;
GtkWidget *menu;
- GdkWindow *panel;
+ GdkWindow *event_window;
guint32 timer;
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c
index 2d311f5a38..830960eef8 100644
--- a/gtk/gtkoptionmenu.c
+++ b/gtk/gtkoptionmenu.c
@@ -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)
{
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index a453086ecf..7678159517 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -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,11 +790,39 @@ 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,
GtkArrowType arrow_type,
@@ -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;
diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h
index 2bddb475a0..1e2110d8fd 100644
--- a/gtk/gtkrange.h
+++ b/gtk/gtkrange.h
@@ -97,6 +97,7 @@ struct _GtkRange
gint slide_initial_slider_position;
gint slide_initial_coordinate;
guint update_timeout_id;
+ GdkWindow *event_window;
};
struct _GtkRangeClass
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 5d32d97306..dc3d8c90da 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -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)
@@ -567,104 +518,6 @@ gtk_toggle_button_clicked (GtkButton *button)
}
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)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
diff --git a/gtk/gtktogglebutton.h b/gtk/gtktogglebutton.h
index abc4e6f1fc..5ebb93c34e 100644
--- a/gtk/gtktogglebutton.h
+++ b/gtk/gtktogglebutton.h
@@ -55,8 +55,6 @@ struct _GtkToggleButton
guint active : 1;
guint draw_indicator : 1;
guint inconsistent : 1;
-
- GdkWindow *event_window;
};
struct _GtkToggleButtonClass
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 9347a98079..c36a7496d5 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -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;
}
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 8446beee4e..4ab5c7afb1 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -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);
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c
index ae18dfa025..861ba80e02 100644
--- a/gtk/gtkvscale.c
+++ b/gtk/gtkvscale.c
@@ -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;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 646ac49078..b8d4aab318 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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");