On Wed, Jun 27, 2007 at 05:46:57PM +0200, Jerome Blondel wrote:
> I've set up a motion-notify-event handler in a GtkDrawingArea, adding 
> the POINTER_MOTION and POINTER_MOTION_HINT event masks to the widget. 
> The event is triggered only when the pointer moves into the window. I'd 
> like to receive an event for each movement of the pointer. Is there 
> something I might have missed,

Yes, the fact that no one knows what your code really does
if you don't post it.

Anyway, this works:

====================================================
#include <gtk/gtk.h>

static gboolean
motion(GtkWidget *area,
       GdkEventMotion *event)
{
    if (event->is_hint) {
        gint x, y;

        gdk_window_get_pointer(area->window, &x, &y, NULL);
        g_print("Motion (hint): %d %d\n", x, y);
    }
    else
        g_print("Motion: %g %g\n", event->x, event->y);

    return FALSE;
}

int
main(int argc, char *argv[])
{
    GtkWidget *window, *area;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    area = gtk_drawing_area_new();
    gtk_widget_add_events(area,
                          GDK_POINTER_MOTION_MASK
                          | GDK_POINTER_MOTION_HINT_MASK);
    gtk_container_add(GTK_CONTAINER(window), area);
    g_signal_connect(area, "motion-notify-event", G_CALLBACK(motion), NULL);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
====================================================

The thing you *possibly* forgot is to call
gdk_window_get_pointer() which you have to as you explicitly
asked -- by using GDK_POINTER_MOTION_HINT_MASK -- not to get
any further events until you call gdk_window_get_pointer().

Yeti

--
http://gwyddion.net/
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to