diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-02-18 20:03:34 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-02-18 20:03:34 +0000 |
commit | 211c4696463a5f3162bb6a19a421c70143b22be5 (patch) | |
tree | 4a43d1751ab9bf91f3e03d4737458ee925c7ed5f /gtk/gtkcombo.c | |
parent | b2b29ea184f60ecbc1c175689bc421b357770953 (diff) | |
download | gdk-pixbuf-211c4696463a5f3162bb6a19a421c70143b22be5.tar.gz |
Fix problems with stuck grab (#60132, reported by Nicolas Setton) and
Mon Feb 18 14:40:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
with stuck grab (#60132, reported by Nicolas Setton) and
stuck prelighting. Combine duplicated code in three
places for popping down the list.
Diffstat (limited to 'gtk/gtkcombo.c')
-rw-r--r-- | gtk/gtkcombo.c | 77 |
1 files changed, 33 insertions, 44 deletions
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c index ab6d29b41..d236801b6 100644 --- a/gtk/gtkcombo.c +++ b/gtk/gtkcombo.c @@ -24,6 +24,10 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ +/* Do NOT, I repeat, NOT, copy any of the code in this file. + * The code here relies on all sorts of internal details of GTK+ + */ + #include <string.h> #include "gtkarrow.h" @@ -493,6 +497,26 @@ gtk_combo_popup_list (GtkCombo * combo) gtk_widget_grab_focus (combo->popwin); } +static void +gtk_combo_popdown_list (GtkCombo *combo) +{ + combo->current_button = 0; + + if (GTK_BUTTON (combo->button)->in_button) + { + GTK_BUTTON (combo->button)->in_button = FALSE; + gtk_button_released (GTK_BUTTON (combo->button)); + } + + if (GTK_WIDGET_HAS_GRAB (combo->popwin)) + { + gtk_grab_remove (combo->popwin); + gdk_pointer_ungrab (GDK_CURRENT_TIME); + } + + gtk_widget_hide (combo->popwin); +} + static void gtk_combo_activate (GtkWidget *widget, GtkCombo *combo) @@ -544,10 +568,12 @@ gtk_combo_popup_button_leave (GtkWidget *button, GdkEventCrossing *event, GtkCombo *combo) { + /* The idea here is that we want to keep the button down if the + * popup is popped up. + */ return combo->current_button != 0; } - static void gtk_combo_update_entry (GtkList * list, GtkCombo * combo) { @@ -607,9 +633,7 @@ gtk_combo_button_press (GtkWidget * widget, GdkEvent * event, GtkCombo * combo) } } - gtk_widget_hide (combo->popwin); - gtk_grab_remove (combo->popwin); - gdk_pointer_ungrab (event->button.time); + gtk_combo_popdown_list (combo); return TRUE; } @@ -628,23 +652,8 @@ gtk_combo_button_event_after (GtkWidget *widget, { /* This was the initial button press */ - GdkEventCrossing tmp_event; - combo->current_button = 0; - if (widget != combo->button) - gtk_widget_event (combo->button, event); - - /* Un-pre-highlight */ - - tmp_event.type = GDK_LEAVE_NOTIFY; - tmp_event.window = combo->button->window; - tmp_event.send_event = TRUE; - tmp_event.subwindow = NULL; - tmp_event.detail = GDK_NOTIFY_ANCESTOR; - - gtk_widget_event (combo->button, (GdkEvent *)&tmp_event); - /* Check to see if we released inside the button */ child = gtk_get_event_widget ((GdkEvent*) event); @@ -662,18 +671,8 @@ gtk_combo_button_event_after (GtkWidget *widget, return; } } - else - { - /* The user has clicked inside the popwin and released */ - if (GTK_WIDGET_HAS_GRAB (combo->popwin)) - { - gtk_grab_remove (combo->popwin); - gdk_pointer_ungrab (event->button.time); - } - } - - gtk_widget_hide (combo->popwin); + gtk_combo_popdown_list (combo); } static gint @@ -723,21 +722,11 @@ gtk_combo_list_key_press (GtkWidget * widget, GdkEventKey * event, GtkCombo * co { if (event->keyval == GDK_Escape) { - if (GTK_WIDGET_HAS_GRAB (combo->popwin)) - { - gtk_grab_remove (combo->popwin); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } - else if (GTK_WIDGET_HAS_GRAB (combo->list)) + if (GTK_WIDGET_HAS_GRAB (combo->list)) gtk_list_end_drag_selection (GTK_LIST (combo->list)); - gtk_widget_hide (combo->popwin); - if (GTK_WIDGET_HAS_GRAB (combo->button)) - { - combo->current_button = 0; - GTK_BUTTON (combo->button)->in_button = FALSE; - gtk_button_released (GTK_BUTTON (combo->button)); - gtk_grab_remove (combo->button); - } + + gtk_combo_popdown_list (combo); + return TRUE; } return FALSE; |