RE: GDK_POINTER_MOTION_HINT_MASK has no effect



Thanks for the code, BUT... when I run it exactly as you
typed it below, I get NO output lines that say
seen a hint!
no matter how I move the mouse and press the buttons.
I get all other outputs: all button down and release and
motion at r x c type messages. No hints.

I am running this on a Windows box with gtk+ 2.12 installed.


Stewart


> -----Original Message-----
> From: jcupitt gmail com [mailto:jcupitt gmail com]
> Sent: Tuesday, November 27, 2007 9:30 AM
> To: stewart weiss acm org
> Cc: gtk-list gnome org
> Subject: Re: GDK_POINTER_MOTION_HINT_MASK has no effect
> 
> 
> On Nov 27, 2007 2:27 AM, Stewart Weiss <stewart weiss acm org> wrote:
> > Does anyone know what the real semantics are, and when is_hint is true?
> 
> Here's a complete small program that shows mouse events (with hints)
> for a drawing area.
> 
> --------------
> /* compile with
>  *      gcc -g -Wall try32.c `pkg-config gtk+-2.0 --cflags --libs`
>  */
> 
> #include <stdio.h>
> #include <gtk/gtk.h>
> 
> static gboolean
> event_cb (GtkWidget * widget, GdkEvent * ev)
> {
>   gboolean handled;
> 
>   handled = FALSE;
> 
>   switch (ev->type)
>     {
>     case GDK_BUTTON_PRESS:
>       printf ("button %d press\n", ev->button.button);
>       handled = TRUE;
>       break;
> 
>     case GDK_BUTTON_RELEASE:
>       printf ("button %d release\n", ev->button.button);
>       handled = TRUE;
>       break;
> 
>     case GDK_MOTION_NOTIFY:
>       /* A hint? Read the position to get the latest value.
>        */
>       if (ev->motion.is_hint)
>         {
>           GdkDisplay *display = gtk_widget_get_display (widget);
>           GdkScreen *screen;
>           int x_root, y_root;
> 
>           printf ("seen a hint!\n");
> 
>           gdk_display_get_pointer (display, &screen, &x_root, 
> &y_root, NULL);
>           ev->motion.x_root = x_root;
>           ev->motion.y_root = y_root;
>         }
> 
>       printf ("motion at %g x %g\n", ev->motion.x_root, 
> ev->motion.y_root);
> 
>       if (ev->motion.state & GDK_BUTTON1_MASK)
>         printf ("(and btn1 held down)\n");
>       if (ev->motion.state & GDK_BUTTON2_MASK)
>         printf ("(and btn2 held down)\n");
> 
>       handled = TRUE;
> 
>       break;
> 
>     default:
>       break;
>     }
> 
>   return (handled);
> }
> 
> int
> main (int argc, char **argv)
> {
>   GtkWidget *win;
>   GtkWidget *area;
> 
>   gtk_init (&argc, &argv);
>   win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>   g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
> 
>   area = gtk_drawing_area_new ();
>   gtk_widget_add_events (GTK_WIDGET (area),
>                          GDK_POINTER_MOTION_MASK |
>                          GDK_POINTER_MOTION_HINT_MASK |
>                          GDK_BUTTON_PRESS_MASK |
>                          GDK_BUTTON_RELEASE_MASK);
> 
>   gtk_signal_connect_after (GTK_OBJECT (area), "event",
>                             GTK_SIGNAL_FUNC (event_cb), NULL);
> 
>   gtk_container_add (GTK_CONTAINER (win), area);
> 
>   gtk_window_set_default_size (GTK_WINDOW (win), 250, 250);
>   gtk_widget_show_all (win);
> 
>   gtk_main ();
> 
>   return (0);
> }
> ------------------------
> 
> You get output like:
> 
> seen a hint!
> motion at 1367 x 446
> seen a hint!
> motion at 1368 x 446
> button 1 press
> seen a hint!
> motion at 1368 x 447
> (and btn1 held down)
> button 2 press
> seen a hint!
> motion at 1368 x 448
> (and btn1 held down)
> (and btn2 held down)
> 
> John


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