diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-06-26 06:26:47 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-06-26 06:26:47 +0000 |
commit | d45263d5facd21ef43a2e75c8b525a4cf101450b (patch) | |
tree | a79ff9579ffdc9d9e975e7213c3e4d78b27d9dab /gtk/gtkcombobox.c | |
parent | 96cf099c4714584a18ca4a9dafa8aabdbc3cebe9 (diff) | |
download | gdk-pixbuf-d45263d5facd21ef43a2e75c8b525a4cf101450b.tar.gz |
Don't do explicitly ungrab pointer and keyboard. We're unmapping the grab
2005-06-26 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_popdown): Don't do
explicitly ungrab pointer and keyboard. We're unmapping
the grab window anyway.
(gtk_combo_box_popup): Handle grab failures.
Diffstat (limited to 'gtk/gtkcombobox.c')
-rw-r--r-- | gtk/gtkcombobox.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index e88dc485d..3147d7591 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -318,8 +318,6 @@ static void gtk_combo_box_list_position (GtkComboBox *combo_box, static void gtk_combo_box_list_setup (GtkComboBox *combo_box); static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); -static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); - static gboolean gtk_combo_box_list_button_released (GtkWidget *widget, GdkEventButton *event, gpointer data); @@ -1574,6 +1572,31 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box, button, activate_time); } +static gboolean +popup_grab_on_window (GdkWindow *window, + guint32 activate_time, + gboolean grab_keyboard) +{ + if ((gdk_pointer_grab (window, TRUE, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, NULL, activate_time) == 0)) + { + if (!grab_keyboard || + 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; +} + /** * gtk_combo_box_popup: * @combo_box: a #GtkComboBox @@ -1640,18 +1663,16 @@ gtk_combo_box_popup (GtkComboBox *combo_box) TRUE); if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view)) + gtk_widget_grab_focus (combo_box->priv->tree_view); + + if (!popup_grab_on_window (combo_box->priv->popup_window->window, + GDK_CURRENT_TIME, TRUE)) { - gdk_keyboard_grab (combo_box->priv->popup_window->window, - FALSE, GDK_CURRENT_TIME); - gtk_widget_grab_focus (combo_box->priv->tree_view); + gtk_widget_hide (combo_box->priv->popup_window); + return; } gtk_grab_add (combo_box->priv->popup_window); - gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); } /** @@ -1679,8 +1700,7 @@ gtk_combo_box_popdown (GtkComboBox *combo_box) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box))) return; - gtk_combo_box_list_remove_grabs (combo_box); - + gtk_grab_remove (combo_box->priv->popup_window); gtk_widget_hide_all (combo_box->priv->popup_window); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), FALSE); @@ -3338,17 +3358,6 @@ gtk_combo_box_list_destroy (GtkComboBox *combo_box) } /* callbacks */ -static void -gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box) -{ - if (combo_box->priv->popup_window && - GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window)) - { - gtk_grab_remove (combo_box->priv->popup_window); - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } -} static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget, |