On Tue, May 12, 1998 at 12:08:35PM +0200, Johannes Keukelaar wrote:

> The short question: I want to use GTK_POINTER_MOTION_HINT_MASK, but I don't 
> know how.

I think there are several issues involved.

When the entry event is issued, you don't always get a motion event. One
can happen without the other. For example, the underlying window might have
'moved' to suddenly appear beneath the mouse cursor (when using keyboard
shortcuts to switch virtual desktops, for example).
You can always use gdk_window_get_pointer to get that information if you
need it.

On the other hand, using POINTER_MOTION_HINT_MASK should help you solve your
problem of getting too many events.
Once POINTER_MOTION_HINT_MASK it is set, you would only get motion events if
you queried for the pointer position since the last time the event was sent.
Note that these motion events are not standard motion events - their 'event'
pointer is rather dull, and doesn't contain the normal information. You'll
need to use gtk_window_get_pointer for that.

I'm using something like that, which was probably taken from one of gtk's
example files. This is located in the callback function, just after variable

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

This way, if an hint event was sent (recognized using 'event->is_hint'), it
is processed properly. Otherwise, if it was a normal event, it is normalized
to achieve the same result.
I don't know if you are allowed to get non-hint events when you've
specifically requested GTK_MOTION_HINT_MASK. This is the way the original
source looked like, and I assume it is good enough.

Note that event is a pointer to GtkEventMotion. Also note that the three
events you are catching are not of the same type (the entry and leave events
are of type GtkEventCrossing).

> My apologies if this is somewhere in the tutorial, but I didn't see it. (But 
> perhaps it would be useful to have this explanation somewhere? Seeing as how 
> the list archives don't seem to have any search functionality.)

I think it is covered somewhere in the drawing program example.

Hope this helped.


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