Possible bug in gdk_window_get_device_position ?



Hi,
with gtk 3.4.4 I get a crash with code like:

gboolean button_callback (GtkWidget *widget, GdkEventButton *event,
gpointer user_data) {
  gint x,y;
  GdkWindow *xwin=gtk_widget_get_window(widget);
  GdkDevice *device=gdk_event_get_source_device((GdkEvent *)event);
  gdk_window_get_device_position (xwin,device,&x,&y,NULL);  // crash !!

}

There is not even a stack trace, it just instantly quits the app.


However, if I replace:

GdkDevice *device=gdk_event_get_source_device((GdkEvent *)event);

with:

GdkDeviceManager *device_manager =
gdk_display_get_device_manager(gdk_window_get_display(xwin));
GdkDevice *device = gdk_device_manager_get_client_pointer (device_manager);

then there is no crash. Is this a bug ?

In the documentation for gdk_device_manager_get_client_pointer(), it says:
"You should use this function sheldomly (sic), only in code that isn't
triggered by a GdkEvent..."

http://developer.gnome.org/gdk3/stable/GdkDeviceManager.html#gdk-device-manager-get-client-pointer


If it is not a bug then the documentation is somewhat misleading.



Regards,
Salsaman.


http://lives.sourceforge.net
https://www.ohloh.net/accounts/salsaman


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]