GNOME Bugzilla – Bug 674549
widget receives leave event when button released
Last modified: 2012-05-05 18:38:56 UTC
Recently, with Gtk+3, a widget may receive a "leave" event when a button is pressed on it. It doesn't happen with gtk2. This behaviour is weird and I hope it can be fixed to not have to work around it. The test case I used: #include <gtk/gtk.h> gboolean event_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_message("%s", user_data); return FALSE; } int main(int argc, char *argv[]) { GtkWidget *draw, *win; gtk_init(&argc, &argv); win = gtk_window_new(GTK_WINDOW_TOPLEVEL); draw = gtk_drawing_area_new(); gtk_widget_add_events(draw, GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_container_add(GTK_CONTAINER(win), draw); gtk_widget_add_events(draw, GDK_SCROLL_MASK); g_signal_connect(draw, "enter-notify-event", G_CALLBACK(event_cb), "enter"); g_signal_connect(draw, "leave-notify-event", G_CALLBACK(event_cb), "leave"); gtk_widget_show_all(win); gtk_main(); return 0; }
With your testcase, I'm not getting any extra leave events in either the master or gtk-3.4 branches. Maybe this got fixed recently ?
After git bisect, this is the guilty commit 8689921b90556008da9ba34326346fd6856c9d47 is the first bad commit commit 8689921b90556008da9ba34326346fd6856c9d47 Author: Carlos Garnacho <carlosg@gnome.org> Date: Sat Dec 3 15:11:08 2011 +0100 gdk: Generate crossing events around touch devices' press/release
Are you using a touch device ?
(In reply to comment #3) > Are you using a touch device ? Sort-of, I use the lenovo t410 touchpad.
so your finger does leave the screen when you release the button - kinda makes sense to get a leave event for that, no ?
(In reply to comment #5) > so your finger does leave the screen when you release the button - kinda makes > sense to get a leave event for that, no ? I leave my finger on the touchpad when I click on the button bellow. There is no "release" of fingers from the touchpad.
Created attachment 213390 [details] [review] gdk: do not send leave event on touchpad button release This is along the changes introduced in bd55519f7e6bb5da2fdf6f5e99bd79213059f81b, A TOUCHPAD device behaves like a mouse"
The patch looks good to me, the machinery behind need_touch_press_enter should only trigger on touchscreens ,where the pointer cursor is likely to be hidden, and crossing events are synthesized so the invisible cursor leaves no trace on widgets. On touchpads (and seeing the partial fix in bd55519f7e), setting that to TRUE likely bring things to a sort of inconsistent state.
The following fix has been pushed: 4884a7c gdk: do not send leave event on touchpad button release
Created attachment 213507 [details] [review] gdk: do not send leave event on touchpad button release This is along the changes introduced in bd55519f7e6bb5da2fdf6f5e99bd79213059f81b, A TOUCHPAD device behaves like a mouse"