diff --git a/ChangeLog b/ChangeLog index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e4a196088c..0cc77b39ab 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Tue Nov 12 17:10:10 2002 Owen Taylor + + * gtk/gtkcombo.c: Fix up grabs to be robust; grab + the keyboard as well as the pointer so we won't + leave the window behind if the user switches desktops + with a keyboard combination. (Based on a patch + from Matthias Clasen, #82525) + Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c index 11424632ae..4cdecc0a71 100644 --- a/gtk/gtkcombo.c +++ b/gtk/gtkcombo.c @@ -297,6 +297,8 @@ gtk_combo_window_key_press (GtkWidget *window, gtk_grab_remove (combo->popwin); gdk_display_pointer_ungrab (gtk_widget_get_display (window), event->time); + gdk_display_keyboard_ungrab (gtk_widget_get_display (window), + event->time); } } @@ -561,27 +563,56 @@ gtk_combo_popdown_list (GtkCombo *combo) { gtk_grab_remove (combo->popwin); gdk_display_pointer_ungrab (gtk_widget_get_display (GTK_WIDGET (combo)), - GDK_CURRENT_TIME); + gtk_get_current_event_time ()); + gdk_display_keyboard_ungrab (gtk_widget_get_display (GTK_WIDGET (combo)), + gtk_get_current_event_time ()); } gtk_widget_hide (combo->popwin); } +static gboolean +popup_grab_on_window (GdkWindow *window, + guint32 activate_time) +{ + if ((gdk_pointer_grab (window, TRUE, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, NULL, activate_time) == 0)) + { + if (gdk_keyboard_grab (window, TRUE, + activate_time) == 0) + return TRUE; + else + { + gdk_display_pointer_ungrab (gdk_drawable_get_display (window), + activate_time); + return FALSE; + } + } + + return FALSE; +} + static void gtk_combo_activate (GtkWidget *widget, GtkCombo *combo) { + if (!combo->button->window || + !popup_grab_on_window (combo->button->window, + gtk_get_current_event_time ())) + return FALSE; + gtk_combo_popup_list (combo); + /* This must succeed since we already have the grab */ + popup_grab_on_window (combo->popwin->window, + gtk_get_current_event_time ()); + if (!GTK_WIDGET_HAS_FOCUS (combo->entry)) gtk_widget_grab_focus (combo->entry); gtk_grab_add (combo->popwin); - gdk_pointer_grab (combo->popwin->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); } static gboolean @@ -595,18 +626,21 @@ gtk_combo_popup_button_press (GtkWidget *button, if (event->button != 1) return FALSE; + if (!popup_grab_on_window (combo->button->window, + gtk_get_current_event_time ())) + return FALSE; + combo->current_button = event->button; gtk_combo_popup_list (combo); + + /* This must succeed since we already have the grab */ + popup_grab_on_window (combo->popwin->window, + gtk_get_current_event_time ()); + gtk_button_pressed (GTK_BUTTON (button)); gtk_grab_add (combo->popwin); - gdk_pointer_grab (combo->popwin->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); - GTK_LIST (combo->list)->drag_selection = TRUE; gtk_grab_add (combo->list);