/* gcc -o motion-events `pkg-config --cflags --libs gtk+-2.0` motion-events.c */

#include <gtk/gtk.h>

static gboolean
event_grabber(GtkWidget *widget, GdkEventMotion *event)
{
  g_print("Motion: %.1f,%.1f\n", event->x, event->y);
  return FALSE;
}

int
main(gint argc, gchar **argv)
{
    GtkWidget *window;
    GtkWidget *widget;

    gtk_init(&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    widget = gtk_drawing_area_new ();
    gtk_widget_add_events(widget,
			  GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
			  GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK);
    g_signal_connect(widget, "motion-notify-event",
		     G_CALLBACK(event_grabber), NULL);
    gtk_container_add(GTK_CONTAINER(window), widget);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
