After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674549 - widget receives leave event when button released
widget receives leave event when button released
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-04-22 00:46 UTC by Marc-Andre Lureau
Modified: 2012-05-05 18:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdk: do not send leave event on touchpad button release (1.11 KB, patch)
2012-05-03 16:17 UTC, Marc-Andre Lureau
none Details | Review
gdk: do not send leave event on touchpad button release (1.11 KB, patch)
2012-05-05 18:38 UTC, Matthias Clasen
committed Details | Review

Description Marc-Andre Lureau 2012-04-22 00:46:58 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;
}
Comment 1 Matthias Clasen 2012-04-23 02:52:44 UTC
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 ?
Comment 2 Marc-Andre Lureau 2012-04-23 13:08:20 UTC
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
Comment 3 Matthias Clasen 2012-04-23 14:58:13 UTC
Are you using a touch device ?
Comment 4 Marc-Andre Lureau 2012-04-23 15:03:49 UTC
(In reply to comment #3)
> Are you using a touch device ?

Sort-of, I use the lenovo t410 touchpad.
Comment 5 Matthias Clasen 2012-04-26 19:24:59 UTC
so your finger does leave the screen when you release the button - kinda makes sense to get a leave event for that, no ?
Comment 6 Marc-Andre Lureau 2012-05-02 17:33:20 UTC
(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.
Comment 7 Marc-Andre Lureau 2012-05-03 16:17:15 UTC
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"
Comment 8 Carlos Garnacho 2012-05-04 11:57:19 UTC
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.
Comment 9 Matthias Clasen 2012-05-05 18:38:52 UTC
The following fix has been pushed:
4884a7c gdk: do not send leave event on touchpad button release
Comment 10 Matthias Clasen 2012-05-05 18:38:56 UTC
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"