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 679795 - Unclear "event" argument on Gtk.Widget "motion-nofity-event" signal
Unclear "event" argument on Gtk.Widget "motion-nofity-event" signal
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-07-12 12:30 UTC by Manuel Kaufmann
Modified: 2017-08-14 23:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Manuel Kaufmann 2012-07-12 12:30:11 UTC
Hello,

I'm reading this page[1] and I noticed the argument "event" in the definition says:

GdkEvent  *event

but in the description it says:

event: the GdkEventMotion which triggered this signal. [type Gdk.EventMotion]

So, I think it is unclear because I'm not sure if I should pass a Gdk.EventMotion or a Gdk.Event

Thanks,

[1] http://developer.gnome.org/gtk3/3.5/GtkWidget.html#GtkWidget-motion-notify-event
Comment 1 Daniel Boles 2017-08-14 23:21:05 UTC
This is done in various places, not just the one you quoted. GdkEvent is a union that contains all the different possible types of GdkEvent[Derived], as well as a way to determine which is really present:
https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkEvent

You can trust the parameter type given against the parameter name in the documentation; it is explicitly specified, by authors who know what they're doing. :)

The more basal type in the example function declaration has a long and boring reason for existing, involve GType...

Anyway, should you have a rationale for manually passing something to a handler, it should be a GtkEventMotion.

Moreover, your handler itself can declare itself as taking a GtkEventMotion, if you like; see gtkwidget.c:gtk_widget_real_motion_event(), which does just that, and even drops the user_data argument. Read up on GCallback to understand how this all works. :)
Comment 2 Daniel Boles 2017-08-14 23:21:58 UTC
...and, of course, the fact that GdkEvent is a union containing all the other types, means you can safely cast between them - if your passing them to a function that can't (or you don't want to make it) receive a 'derived' event type directly.