Re: drawing area and motion hint mask



Emmanuel Touzery wrote:
Hello,

I'm trying to detect mouse moves in a drawing area. The default behaviour without the GDK_POINTER_MOTION_HINT_MASK is as expected flooding me with events which I can't handle.
Perhaps you could have something as the code below (it works for me. It is based in GtkGlArea / GtkGLExt examples and discussions in this list with Havoc Pennington years ago)

I strongly suggest you to have a look in the examples coming with GtkGlExt,

Carlos Pereira
---------------------------------------------------------
g_signal_connect (area, "motion_notify_event",
G_CALLBACK (callback_area_notify), window);

int callback_area_notify (GtkWidget *widget,
GdkEventMotion *event, void *data)
{
my_structure *structure = (my_structure *) data;
GdkModifierType state;
int width = widget->allocation.width;
int height = widget->allocation.height;
int x, y;

if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state);
else
 {
 x = event->x;
 y = event->y;
 state = event->state;
 }

if (state & structure->mask_button1)
 {
 }

else if (state & structure->mask_button2)
 {
 }

else if (state & structure->mask_button3)
 {
 }

/* save x,y as initial values, preparing to next scan:
difference between initial and current x, y values control speed */

structure->begin_x = x;
structure->begin_y = y;

return TRUE;
}




    So I added that flag, but I still get way too many events.

    In my handler I put this at the top:

    printf ("got mouse move (%d)!\n", event->is_hint);

And when I don't set the HINT_MASK then is_hint is 0, if I set the HINT_MASK then it's 1.
    So it seems I'm setting the hint properly.

That I'm getting more events (not just one, because I never call gdk_event_request_motions() or gdk_window_get_pointer() anywhere in my code) it seems somehow someone else is calling gdk_event_request_motions() or gdk_window_get_pointer() (the examples on internet are not really clear on which one to call, or both, maybe this changed in the past?).

So I put a breakpoint on both those methods in GDB. And indeed I'm hitting very often this call:

#0 IA__gdk_window_get_pointer (window=0x88bdde8, x=0xbff3aef8, y=0xbff3aef4,
    mask=0x0) at /build/buildd/gtk+2.0-2.16.1/gdk/gdkwindow.c:3315
#1  0xb7c300f0 in IA__gdk_device_get_state (device=0x849c840,
    window=0x88bdde8, axes=0x0, mask=0x0)
    at /build/buildd/gtk+2.0-2.16.1/gdk/x11/gdkinput-x11.c:788
#2  0xb7be5db4 in IA__gdk_event_request_motions (event=0x849c840)
    at /build/buildd/gtk+2.0-2.16.1/gdk/gdkevents.c:889
#3  0xb7e657d0 in _gtk_tooltip_handle_event (event=0x887b0c0)
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtktooltip.c:1287
#4  0xb7d8720d in IA__gtk_main_do_event (event=0x887b0c0)
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c:1643
#5  0xb7c1434a in gdk_event_dispatch (source=0x849c358, callback=0,
user_data=0x0) at /build/buildd/gtk+2.0-2.16.1/gdk/x11/gdkevents-x11.c:2364
#6  0xb78a7b88 in IA__g_main_context_dispatch (context=0x849c3a0)
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c:1814
#7  0xb78ab0eb in g_main_context_iterate (context=0x849c3a0, block=1,
    dispatch=1, self=0x8483b80)
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c:2448
#8  0xb78ab5ba in IA__g_main_loop_run (loop=0x8611fb0)
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c:2656
#9  0xb7d877d9 in IA__gtk_main ()
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c:1205

Something about tooltips. I don't have any tooltips for now in the application and certainly not in this drawing area... So I don't understand how come that tooltip code is getting called. It prevents me from completely controlling when I'm getting mouse move events. That said, I'm surely getting much less events than before and maybe it's "expected". It does complicate my life though. Is there a way to avoid this? What am I doing wrong?

I can't send the complete source of that program for now, it's already bigger. I'm hoping that it's obvious enough that someone can answer it without me having to extract the problem in a test program.

    Thank you!

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





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