Handle NO_WINDOW widgets with windows that are children of widget->window.

Sat Mar  2 20:58:30 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
	widgets with windows that are children of widget->window.
	(#50279)

	* tests/testgtk.c: Add eventboxes to the example so that
	we are reparenting between different GdkWindows.
This commit is contained in:
Owen Taylor 2002-03-03 02:52:56 +00:00 committed by Owen Taylor
parent 809a11fea0
commit 76cf3d95f6
9 changed files with 97 additions and 30 deletions

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -1,3 +1,9 @@
Sat Mar 2 20:58:30 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_reparent): Handle NO_WINDOW
widgets with windows that are children of widget->window.
(#50279)
Sat Mar 2 20:39:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_new_from_stock):

View File

@ -196,8 +196,6 @@ static gboolean gtk_widget_real_focus_out_event (GtkWidget *widget,
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data);
static void gtk_widget_reset_rc_style (GtkWidget *widget);
@ -3146,17 +3144,36 @@ gtk_widget_set_scroll_adjustments (GtkWidget *widget,
return FALSE;
}
/*****************************************
* gtk_widget_reparent_container_child:
* assistent function to gtk_widget_reparent
*
* arguments:
*
* results:
*****************************************/
static void
gtk_widget_reparent_subwindows (GtkWidget *widget,
GdkWindow *new_window)
{
if (GTK_WIDGET_NO_WINDOW (widget))
{
GList *children = gdk_window_get_children (widget->window);
GList *tmp_list;
for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
{
GtkWidget *child;
GdkWindow *window = tmp_list->data;
gdk_window_get_user_data (window, (void **)&child);
while (child && child != widget)
child = child->parent;
if (child)
gdk_window_reparent (window, new_window, 0, 0);
}
g_list_free (children);
}
else
gdk_window_reparent (widget->window, new_window, 0, 0);
}
static void
gtk_widget_reparent_container_child (GtkWidget *widget,
gtk_widget_reparent_fixup_child (GtkWidget *widget,
gpointer client_data)
{
g_return_if_fail (client_data != NULL);
@ -3171,12 +3188,9 @@ gtk_widget_reparent_container_child (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_reparent_container_child,
gtk_widget_reparent_fixup_child,
client_data);
}
else
gdk_window_reparent (widget->window,
(GdkWindow*) client_data, 0, 0);
}
/**
@ -3214,7 +3228,8 @@ gtk_widget_reparent (GtkWidget *widget,
{
GTK_PRIVATE_UNSET_FLAG (widget, GTK_IN_REPARENT);
gtk_widget_reparent_container_child (widget,
gtk_widget_reparent_subwindows (widget, gtk_widget_get_parent_window (widget));
gtk_widget_reparent_fixup_child (widget,
gtk_widget_get_parent_window (widget));
}

View File

@ -2469,6 +2469,7 @@ create_reparent (void)
GtkWidget *button;
GtkWidget *label;
GtkWidget *separator;
GtkWidget *event_box;
if (!window)
{
@ -2498,18 +2499,23 @@ create_reparent (void)
gtk_container_add (GTK_CONTAINER (frame), box3);
button = gtk_button_new_with_label ("switch");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(reparent_label),
box3);
gtk_object_set_user_data (GTK_OBJECT (button), label);
gtk_box_pack_start (GTK_BOX (box3), button, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box3), label, FALSE, TRUE, 0);
event_box = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (box3), event_box, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (event_box), label);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(reparent_label),
event_box);
gtk_signal_connect (GTK_OBJECT (label),
"parent_set",
GTK_SIGNAL_FUNC (set_parent_signal),
GINT_TO_POINTER (42));
frame = gtk_frame_new ("Frame 2");
gtk_box_pack_start (GTK_BOX (box2), frame, TRUE, TRUE, 0);
@ -2518,12 +2524,16 @@ create_reparent (void)
gtk_container_add (GTK_CONTAINER (frame), box3);
button = gtk_button_new_with_label ("switch");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(reparent_label),
box3);
gtk_object_set_user_data (GTK_OBJECT (button), label);
gtk_box_pack_start (GTK_BOX (box3), button, FALSE, TRUE, 0);
event_box = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (box3), event_box, FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(reparent_label),
event_box);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);