diff --git a/ChangeLog b/ChangeLog index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e2c72e9340..3f698b05ca 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +Tue Nov 12 15:13:58 2002 Owen Taylor + + * gtk/gtkwidget.c gtk/gtkwindow.[ch]: Add + _gtk_window_unset_focus_and_default(), use to clear + the focus and default out of parts of the widget + heirarchy that we are hiding. + + * gtk/gtkwidget.c (gtk_widget_propagate_screen_changed_recurse): + Fix typo that was resulting in missed screen-change + notifies. + + * gtk/gtkwindow.c (do_focus_change): Allow for + widget->window == NULL. + + * gtk/gtklabel.c (gtk_label_screen_changed): Clear the + layout here not in hierarchy changed to handle the case + where the toplevel was moved between screens. + Tue Nov 12 14:20:53 2002 Soeren Sandmann * gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index f063f1c6b8..2129b50e66 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -130,6 +130,8 @@ static void set_markup (GtkLabel *label, static void gtk_label_recalculate (GtkLabel *label); static void gtk_label_hierarchy_changed (GtkWidget *widget, GtkWidget *old_toplevel); +static void gtk_label_screen_changed (GtkWidget *widget, + GdkScreen *old_screen); static void gtk_label_create_window (GtkLabel *label); static void gtk_label_destroy_window (GtkLabel *label); @@ -244,6 +246,7 @@ gtk_label_class_init (GtkLabelClass *class) widget_class->button_release_event = gtk_label_button_release; widget_class->motion_notify_event = gtk_label_motion; widget_class->hierarchy_changed = gtk_label_hierarchy_changed; + widget_class->screen_changed = gtk_label_screen_changed; widget_class->mnemonic_activate = gtk_label_mnemonic_activate; widget_class->focus = gtk_label_focus; @@ -719,12 +722,16 @@ gtk_label_hierarchy_changed (GtkWidget *widget, { GtkLabel *label = GTK_LABEL (widget); - /* in case the label has been reparented to another screen */ - gtk_label_clear_layout (label); - gtk_label_setup_mnemonic (label, label->mnemonic_keyval); } +static void +gtk_label_screen_changed (GtkWidget *widget, + GdkScreen *old_screen) +{ + gtk_label_clear_layout (GTK_LABEL (widget)); +} + static void label_mnemonic_widget_weak_notify (gpointer data, GObject *where_the_object_was) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index b5a32fae33..da4df7f4dc 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1522,41 +1522,12 @@ gtk_widget_unparent (GtkWidget *widget) g_object_freeze_notify (G_OBJECT (widget)); nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context); - /* unset focused and default children properly, this code - * should eventually move into some gtk_window_unparent_branch() or - * similar function. - */ - toplevel = gtk_widget_get_toplevel (widget); - if (GTK_CONTAINER (widget->parent)->focus_child == widget) - { - gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL); - - if (GTK_WIDGET_TOPLEVEL (toplevel)) - { - GtkWidget *child; - - child = GTK_WINDOW (toplevel)->focus_widget; - - while (child && child != widget) - child = child->parent; - - if (child == widget) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); - } - } if (GTK_WIDGET_TOPLEVEL (toplevel)) - { - GtkWidget *child; - - child = GTK_WINDOW (toplevel)->default_widget; - - while (child && child != widget) - child = child->parent; - - if (child == widget) - gtk_window_set_default (GTK_WINDOW (toplevel), NULL); - } + _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget); + + if (GTK_CONTAINER (widget->parent)->focus_child == widget) + gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL); /* If we are unanchoring the child, we save around the toplevel * to emit hierarchy changed @@ -1762,6 +1733,10 @@ gtk_widget_hide (GtkWidget *widget) if (GTK_WIDGET_VISIBLE (widget)) { + GtkWidget *toplevel = gtk_widget_get_toplevel (widget); + if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel)) + _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget); + g_object_ref (widget); g_signal_emit (widget, widget_signals[HIDE], 0); if (!GTK_WIDGET_TOPLEVEL (widget)) @@ -4405,7 +4380,7 @@ gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget, if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), - gtk_widget_propagate_hierarchy_changed_recurse, + gtk_widget_propagate_screen_changed_recurse, client_data); g_object_unref (widget); @@ -4709,7 +4684,16 @@ gtk_widget_set_child_visible (GtkWidget *widget, if (is_visible) GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE); else - GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE); + { + GtkWidget *toplevel; + + GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE); + + toplevel = gtk_widget_get_toplevel (widget); + if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel)) + _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget); + } + if (widget->parent && GTK_WIDGET_REALIZED (widget->parent)) { if (GTK_WIDGET_MAPPED (widget->parent) && diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index a4193e4400..bee766c3b3 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4116,7 +4116,9 @@ do_focus_change (GtkWidget *widget, GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); fevent->focus_change.type = GDK_FOCUS_CHANGE; - fevent->focus_change.window = g_object_ref (widget->window); + fevent->focus_change.window = widget->window; + if (widget->window) + g_object_ref (widget->window); fevent->focus_change.in = in; gtk_widget_event (widget, fevent); @@ -4336,6 +4338,41 @@ gtk_window_real_set_focus (GtkWindow *window, } } +/** + * _gtk_window_unset_focus_and_default: + * @window: a #GtkWindow + * @widget: a widget inside of @window + * + * Checks whether the focus and default widgets of @window are + * @widget or a descendent of @widget, and if so, unset them. + **/ +void +_gtk_window_unset_focus_and_default (GtkWindow *window, + GtkWidget *widget) + +{ + GtkWidget *child; + + if (GTK_CONTAINER (widget->parent)->focus_child == widget) + { + child = window->focus_widget; + + while (child && child != widget) + child = child->parent; + + if (child == widget) + gtk_window_set_focus (GTK_WINDOW (window), NULL); + } + + child = window->default_widget; + + while (child && child != widget) + child = child->parent; + + if (child == widget) + gtk_window_set_default (window, NULL); +} + /********************************* * Functions related to resizing * *********************************/ diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index 1bd48843c2..60d43b3d46 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -364,6 +364,9 @@ gboolean _gtk_window_activate_key (GtkWindow *window, void _gtk_window_set_has_toplevel_focus (GtkWindow *window, gboolean has_toplevel_focus); +void _gtk_window_unset_focus_and_default (GtkWindow *window, + GtkWidget *widget); + void _gtk_window_set_is_active (GtkWindow *window, gboolean is_active);