Add _gtk_window_unset_focus_and_default(), use to clear the focus and

Tue Nov 12 15:13:58 2002  Owen Taylor  <otaylor@redhat.com>

        * 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.
This commit is contained in:
Owen Taylor 2002-11-12 21:08:29 +00:00 committed by Owen Taylor
parent 3b5d33adc7
commit ff9c2c5669
10 changed files with 178 additions and 39 deletions

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

@ -1,3 +1,21 @@
Tue Nov 12 15:13:58 2002 Owen Taylor <otaylor@redhat.com>
* 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 <sandmann@daimi.au.dk>
* gtk/gtkmenu.c (gtk_menu_enter_notify): Do not return when

View File

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

View File

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

View File

@ -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 *
*********************************/

View File

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