mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
moved checks upon focus setting from gtk_window_real_set_focus to
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c: moved checks upon focus setting from gtk_window_real_set_focus to gtk_window_set_focus, so we don't emit the signal if unneccessary. * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus containers when grabbing focus on a new widget. this is based on a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998. * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS flag, so we take the buttons into consideration upon the next focus request. * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an assertment.
This commit is contained in:
parent
7cc3040412
commit
1ec6733573
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -1,3 +1,20 @@
|
||||
Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkwindow.c: moved checks upon focus setting from
|
||||
gtk_window_real_set_focus to gtk_window_set_focus, so we don't
|
||||
emit the signal if unneccessary.
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
|
||||
containers when grabbing focus on a new widget. this is based on
|
||||
a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
|
||||
|
||||
* gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
|
||||
flag, so we take the buttons into consideration upon the next focus
|
||||
request.
|
||||
|
||||
* gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
|
||||
assertment.
|
||||
|
||||
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
|
||||
|
@ -6517,6 +6517,8 @@ gtk_clist_focus_out (GtkWidget *widget,
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
|
||||
GTK_CLIST_SET_FLAG (widget, CLIST_CHILD_HAS_FOCUS);
|
||||
|
||||
gtk_widget_draw_focus (widget);
|
||||
|
||||
clist = GTK_CLIST (widget);
|
||||
@ -6537,7 +6539,7 @@ gtk_clist_set_focus_child (GtkContainer *container,
|
||||
if (child)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (child));
|
||||
GTK_CLIST_SET_FLAG (GTK_CLIST (container), CLIST_CHILD_HAS_FOCUS);
|
||||
GTK_CLIST_SET_FLAG (container, CLIST_CHILD_HAS_FOCUS);
|
||||
}
|
||||
|
||||
parent_class->set_focus_child (container, child);
|
||||
|
@ -1206,13 +1206,13 @@ gtk_container_focus (GtkContainer *container,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_container_set_focus_child (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
gtk_container_set_focus_child (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (container != NULL);
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
if (widget)
|
||||
g_return_if_fail (GTK_IS_WIDGET (container));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[SET_FOCUS_CHILD], widget);
|
||||
}
|
||||
|
@ -2833,34 +2833,77 @@ gtk_widget_intersect (GtkWidget *widget,
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_grab_focus (GtkWidget *widget)
|
||||
static void
|
||||
reset_focus_recurse (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
if (GTK_WIDGET_CAN_FOCUS (widget))
|
||||
if (GTK_IS_CONTAINER (widget))
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkWidget *child;
|
||||
GtkType window_type;
|
||||
GtkContainer *container;
|
||||
|
||||
container = GTK_CONTAINER (widget);
|
||||
gtk_container_set_focus_child (container, NULL);
|
||||
|
||||
gtk_container_foreach (container,
|
||||
reset_focus_recurse,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_widget_grab_focus (GtkWidget *focus_widget)
|
||||
{
|
||||
g_return_if_fail (focus_widget != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (focus_widget));
|
||||
|
||||
if (GTK_WIDGET_CAN_FOCUS (focus_widget))
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *widget;
|
||||
|
||||
window_type = gtk_window_get_type ();
|
||||
parent = widget->parent;
|
||||
child = widget;
|
||||
|
||||
while (parent && !gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
|
||||
/* clear the current focus setting, break if the current widget
|
||||
* is the focus widget's parent, since containers above that will
|
||||
* be set by the next loop.
|
||||
*/
|
||||
toplevel = gtk_widget_get_toplevel (focus_widget);
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
|
||||
child = parent;
|
||||
parent = parent->parent;
|
||||
widget = GTK_WINDOW (toplevel)->focus_widget;
|
||||
|
||||
if (widget == focus_widget)
|
||||
return;
|
||||
|
||||
if (widget)
|
||||
{
|
||||
while (widget->parent && widget->parent != focus_widget->parent)
|
||||
{
|
||||
widget = widget->parent;
|
||||
gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parent && gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
|
||||
else if (toplevel != focus_widget)
|
||||
{
|
||||
gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
|
||||
gtk_window_set_focus (GTK_WINDOW (parent), widget);
|
||||
/* gtk_widget_grab_focus() operates on a tree without window...
|
||||
* actually, this is very questionable behaviour.
|
||||
*/
|
||||
|
||||
gtk_container_foreach (GTK_CONTAINER (toplevel),
|
||||
reset_focus_recurse,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* now propagate the new focus up the widget tree and finally
|
||||
* set it on the window
|
||||
*/
|
||||
widget = focus_widget;
|
||||
while (widget->parent)
|
||||
{
|
||||
gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), widget);
|
||||
widget = widget->parent;
|
||||
}
|
||||
if (GTK_IS_WINDOW (widget))
|
||||
gtk_window_set_focus (GTK_WINDOW (widget), focus_widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ static gint gtk_window_focus_out_event (GtkWidget *widget,
|
||||
static gint gtk_window_client_event (GtkWidget *widget,
|
||||
GdkEventClient *event);
|
||||
static void gtk_window_check_resize (GtkContainer *container);
|
||||
static void gtk_real_window_set_focus (GtkWindow *window,
|
||||
static void gtk_window_real_set_focus (GtkWindow *window,
|
||||
GtkWidget *focus);
|
||||
static void gtk_window_move_resize (GtkWindow *window);
|
||||
static void gtk_window_set_hints (GtkWidget *widget,
|
||||
@ -184,7 +184,7 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
|
||||
container_class->check_resize = gtk_window_check_resize;
|
||||
|
||||
klass->set_focus = gtk_real_window_set_focus;
|
||||
klass->set_focus = gtk_window_real_set_focus;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -334,7 +334,16 @@ void
|
||||
gtk_window_set_focus (GtkWindow *window,
|
||||
GtkWidget *focus)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
if (focus)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (focus));
|
||||
g_return_if_fail (GTK_WIDGET_CAN_FOCUS (focus));
|
||||
}
|
||||
|
||||
if (window->focus_widget != focus)
|
||||
gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1225,7 +1234,7 @@ gtk_window_move_resize (GtkWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_real_window_set_focus (GtkWindow *window,
|
||||
gtk_window_real_set_focus (GtkWindow *window,
|
||||
GtkWidget *focus)
|
||||
{
|
||||
GdkEventFocus event;
|
||||
@ -1233,30 +1242,24 @@ gtk_real_window_set_focus (GtkWindow *window,
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
if (focus && !GTK_WIDGET_CAN_FOCUS (focus))
|
||||
return;
|
||||
|
||||
if (window->focus_widget != focus)
|
||||
if (window->focus_widget)
|
||||
{
|
||||
if (window->focus_widget)
|
||||
{
|
||||
event.type = GDK_FOCUS_CHANGE;
|
||||
event.window = window->focus_widget->window;
|
||||
event.in = FALSE;
|
||||
|
||||
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
|
||||
}
|
||||
|
||||
window->focus_widget = focus;
|
||||
|
||||
if (window->focus_widget)
|
||||
{
|
||||
event.type = GDK_FOCUS_CHANGE;
|
||||
event.window = window->focus_widget->window;
|
||||
event.in = TRUE;
|
||||
|
||||
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
|
||||
}
|
||||
event.type = GDK_FOCUS_CHANGE;
|
||||
event.window = window->focus_widget->window;
|
||||
event.in = FALSE;
|
||||
|
||||
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
|
||||
}
|
||||
|
||||
window->focus_widget = focus;
|
||||
|
||||
if (window->focus_widget)
|
||||
{
|
||||
event.type = GDK_FOCUS_CHANGE;
|
||||
event.window = window->focus_widget->window;
|
||||
event.in = TRUE;
|
||||
|
||||
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user