diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-02-27 23:41:09 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-02-27 23:41:09 +0000 |
commit | 51454e8ac664e4098605791af644928dfe920b6f (patch) | |
tree | d8c1b47cf46ce4fd72286b932001a86836162ea4 | |
parent | 9cad1a8a546430311c3c8d265acb49cc6f402b4c (diff) | |
download | gdk-pixbuf-51454e8ac664e4098605791af644928dfe920b6f.tar.gz |
Redo the focus stuff once more. Keep track of the focus status via an
Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff
once more. Keep track of the focus status via an event
filter, so we can keep track of whether the window
or any child has the focus; something that requires
fields from the XEvent not in the GdkEvent.
Install this event filter in gtk_window_map() before mapping
the window, on the guess that this is unlikely to be overriden
without the overrider chaining up. (fingers crossed)
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 12 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 55 | ||||
-rw-r--r-- | gtk/gtkwindow.h | 4 |
9 files changed, 138 insertions, 5 deletions
@@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ab3fbc816..fdfd4207e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Tue Feb 27 18:38:27 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_map): Redo the focus stuff + once more. Keep track of the focus status via an event + filter, so we can keep track of whether the window + or any child has the focus; something that requires + fields from the XEvent not in the GdkEvent. + + Install this event filter in gtk_window_map() before mapping + the window, on the guess that this is unlikely to be overriden + without the overrider chaining up. (fingers crossed) + Tue Feb 27 04:14:21 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_propagate_event): Remove diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index d6e29ea14..8f73fb709 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -926,6 +926,52 @@ gtk_window_hide (GtkWidget *widget) gtk_grab_remove (widget); } +static GdkFilterReturn +gtk_window_focus_filter (GdkXEvent *xevent, + GdkEvent *event, + gpointer data) +{ + GtkWindow *window = GTK_WINDOW (data); + XEvent *xev = (XEvent *)xevent; + + if (xev->xany.type == FocusIn) + { + switch (xev->xfocus.detail) + { + case NotifyAncestor: + case NotifyNonlinear: + case NotifyVirtual: + case NotifyNonlinearVirtual: + window->window_has_focus = TRUE; + break; + case NotifyInferior: + case NotifyPointer: + case NotifyPointerRoot: + case NotifyDetailNone: + break; + } + } + else if (xev->xany.type == FocusOut) + { + switch (xev->xfocus.detail) + { + case NotifyAncestor: + case NotifyNonlinear: + case NotifyVirtual: + case NotifyNonlinearVirtual: + window->window_has_focus = FALSE; + break; + case NotifyInferior: + case NotifyPointer: + case NotifyPointerRoot: + case NotifyDetailNone: + break; + } + } + + return GDK_FILTER_CONTINUE; +} + static void gtk_window_map (GtkWidget *widget) { @@ -943,6 +989,8 @@ gtk_window_map (GtkWidget *widget) !GTK_WIDGET_MAPPED (window->bin.child)) gtk_widget_map (window->bin.child); + gdk_window_add_filter (widget->window, gtk_window_focus_filter, widget); + gdk_window_show (widget->window); } @@ -1325,7 +1373,6 @@ gtk_window_focus_in_event (GtkWidget *widget, */ if (GTK_WIDGET_VISIBLE (widget)) { - GTK_OBJECT_SET_FLAGS (widget, GTK_HAS_FOCUS); window = GTK_WINDOW (widget); if (window->focus_widget && window->focus_widget != widget && @@ -1355,8 +1402,6 @@ gtk_window_focus_out_event (GtkWidget *widget, window = GTK_WINDOW (widget); - GTK_OBJECT_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - if (window->focus_widget && window->focus_widget != widget && GTK_WIDGET_HAS_FOCUS (window->focus_widget)) @@ -1472,7 +1517,7 @@ gtk_window_real_set_focus (GtkWindow *window, GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT); } - if (GTK_WIDGET_HAS_FOCUS (window)) + if (window->window_has_focus) { event.type = GDK_FOCUS_CHANGE; event.window = window->focus_widget->window; @@ -1496,7 +1541,7 @@ gtk_window_real_set_focus (GtkWindow *window, GTK_WIDGET_UNSET_FLAGS (window->default_widget, GTK_HAS_DEFAULT); } - if (GTK_WIDGET_HAS_FOCUS (window)) + if (window->window_has_focus) { event.type = GDK_FOCUS_CHANGE; event.window = window->focus_widget->window; diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index 53d22948a..bd4492cef 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -77,6 +77,10 @@ struct _GtkWindow */ guint use_uposition : 1; guint modal : 1; + + /* Set if the window, or any descendent of it, has the focus + */ + guint window_has_focus : 1; }; struct _GtkWindowClass |