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 565405 - gtk.gdk.POINTER_MOTION_HINT_MASK behaves incorrectly
gtk.gdk.POINTER_MOTION_HINT_MASK behaves incorrectly
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
2.18.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 572986 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-12-23 00:35 UTC by Pietro Battiston
Modified: 2018-02-10 03:44 UTC
See Also:
GNOME target: ---
GNOME version: 2.27/2.28


Attachments
This is a minimal script to show things don't happen as documentation states (308 bytes, text/plain)
2008-12-23 00:36 UTC, Pietro Battiston
Details

Description Pietro Battiston 2008-12-23 00:35:15 UTC
Please describe the problem:
gtk.gdk.POINTER_MOTION_HINT_MASK doesn't behave as described in documentation:

"When using the gtk.gdk.POINTER_MOTION_HINT_MASK the server will only send a single gtk.gdk.MOTION_NOTIFY event (which is marked as a hint) until the application asks for more, by calling the gtk.gdk.Window.get_pointer() method." (taken from http://www.pygtk.org/docs/pygtk/class-gdkevent.html#description-gdkevent).

Instead, the attached small program shows that:
- if gtk.gdk.POINTER_MOTION_HINT_MASK is used alone (comment line 6), just no gtk.gdk.MOTION_NOTIFY events are sent
- if it is used in conjunction with gtk.gdk.POINTER_MOTION_MASK, then lots of events are sent, even in presence of no "get_pointer" calls. In the end, the only difference that can be noticed is that those events have the "is_hint" attribute set

Steps to reproduce:
1. run the attachted script
2. move the pointer over the window popping up
3. notice the flow of event calls
4. now comment out line 6 (and eventually uncomment line 12)
5. rerun
6. notice that now there is not a single event call


Actual results:
Too much or none event calls happen; in either case, not what the documentation says (and what would make sense to make gtk.gdk.POINTER_MOTION_HINT_MASK of some utility).

Expected results:
Actually, I'm not 100% sure of what I would expect just because the documentation isn't 100% complete: it doesn't specify if gtk.gdk.POINTER_MOTION_HINT_MASK is meant to be used in conjunction with gtk.gdk.POINTER_MOTION_MASK or alone.

Anyway, in one way or the other I would expect to be effectively able to use it and get only motion events when I ask for them.

Does this happen every time?
yes

Other information:
I'm not 100% this is a gtk problem: it may be a gdk one or (though I really can't see how) a documentation one; sorry if I picked the wrong section.
Comment 1 Pietro Battiston 2008-12-23 00:36:19 UTC
Created attachment 125165 [details]
This is a minimal script to show things don't happen as documentation states
Comment 2 Pietro Battiston 2008-12-23 00:42:52 UTC
Notice that the C documentation (http://library.gnome.org/devel/gdk/stable/gdk-Events.html#GdkEventMask) is in one sense more complete (pygtk's one doesn't mention gdk_event_request_motions), but in another more vague, because it just says "fewer GDK_MOTION_NOTIFY events will be sent". So while this could suggest that pygtk documentation's precision ("there will be _one_ event if no more are asked") is just erroneous (and hence this is just a documentation bug), I hope this is not the case, because this "fewer" is so vague that the mask becomes quite useless/unreliable.

Notice anyway that for me a point in favour of the non-documentation bug is that the custom widget coded at http://www.pygtk.org/articles/writing-a-custom-widget-using-pygtk/writing-a-custom-widget-using-pygtk.htm doesn't work on modern pygtk (tested on Ubuntu Intrepid and Hardy and on OpenSolaris), so apparently something changed from the time it was written.
Comment 3 Guillaume Bouchard 2009-02-24 14:50:14 UTC
*** Bug 572986 has been marked as a duplicate of this bug. ***
Comment 4 Guillaume Bouchard 2009-02-24 14:58:33 UTC
Please, take a look on the bug #572986 that I open and close (sorry for duplication).

There is a C program that show exacly what the C documentation said about "fewer". When you launch it, there is "fewer" call to the signal handler.

So there is two problems :

1) Pygtk does not behave as "Cgtk"
2) what "fewer" mean ? because in the actual state, it's quite useless !

Comment 5 Pietro Battiston 2009-03-16 21:13:43 UTC
The bug is confirmed in 2.15.5 (well, at least part of it: the linked widget doesn't show up).

I think there is _another_ problem:
3) the C documentation says
"fewer GDK_MOTION_NOTIFY events will be sent, some of which are marked as a hint (the is_hint member is TRUE)"
, while this is not true: _all_ of them are marked.

While as a documentation bug it would really not be serious, probably it isn't a documentation bug; in other words, I think the problem lies (also?) in C code.
Comment 6 Pietro Battiston 2009-12-11 09:27:02 UTC
Guillaume, only now I did test your C example, and I'm not able to see any real difference between pygtk and C: though it was hard to me to provide an accurate estimate, I would say that in both languages, adding POINTER_MOTION_HINT_MASK to POINTER_MOTION_MASK suppresses around 20% of motion-notify-event emitted.

Were you able to get more precise numbers, possibly showing clearly a difference between the two languages?

Anyway, even in that case I would say that the issue is _first of all_ a base gtk one (or documentation, but I don't think), hence I'm moving the bug (which, by the way, is still confirmed in 2.18).
Comment 7 Pietro Battiston 2009-12-11 09:29:36 UTC
As a sidenote, the reference to the linked pygtk custom widget didn't make much sense because it didn't work for a completely different reason: it _is_ also affected by this bug, but in a much less macroscopic way.
Comment 8 Guillaume Bouchard 2009-12-16 18:25:46 UTC
Hello Pietro.

Sorry but I don't really remember the differences between the C and pygtk code. The more I remember is that on pygtk it looks like there was less "fewer" notification than in C code.

I run the code I wrote, and It is really not a scentific fact, but it really seam that there is fewer hint in C code. In fact it is more like there is more event without hint in C than in pygtk but the same amount of event with hint. Perhaps it is because of python layer that slow the processing of event, so C and Python does the same for hint, but C is able to do more "event without hint". (Sorry this is a little bit confusing)

So problem that stay is:

1) The documentation writes about "fewer". What does that mean ?
2) I think the "correct" way of using MOTION_HINT is to disallow events until the last motion event is handled. I don't know how it work inside gtk, but if gtk still receive all motion event, perhaps it can remove the "hint" part (As far as I test and understand, the hint means that the information of pointer position may be wrong)
Comment 9 Matthias Clasen 2018-02-10 03:44:04 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.