Re: X11 vs. Windows and pointer motion hints




Tor Lillqvist <tml@hemuli.tte.vtt.fi> writes:

> Am I confused, or is there something strange in
> gtk_list_motion_notify? gdk_window_get_pointer(widget->window, &x, &y,
> NULL) is called only if (event->is_hint || event->window !=
> widget->window), but still x and y are used without any checking
> later.

This sounds like a bug in the handler.

Because you want the button state to correspond to the button
press/release events one gets, and the coordinates to correspond with
the button state, very frequently the right thing to do when dealing
with is_hint, is to:

 - Always use the x and y from the event.
 - Call gdk_window_get_pointer() at the _end_ of the button press
   handler to allow X to send another motion event if is_hint
   is set.

For this case (autoscrolling), getting the coordinates exactly
right isn't that important, so it doesn't really matter much
what is done. However, I think the routine should not count
on is_hint always being sent use x and y from the event if
it doesn't call get_pointer().
 
> As you might guess my problems appears in the Windows port, where
> there is no concept of pointer motion hints. Until now I have set the
> is_hint member always to zero (= NotifyNormal). This caused lists to
> misbehave. x and y had random values, and if you tried to drag-select,
> the list always scrolled to the bottom.
> 
> Basically what I mean is that I am a bit confused about whether we
> really can be sure (on X11) that always either
> event->is_hint==NotifyHint or event->window!=widget->window here? (I
> guess yes, as the code works OK on X11...) The X11 documentation on
> when the is_hint is set in the pointer motion notify events is not
> that awfully clear.

The Xlib documentation clearly says that the Xserver is free
to send events without is_hint sent when you Specify PointerMotioNHintMask.
(Section 10.5.2 in my copy). Now that doesn't mean any server
does that, but GTK+ should not make the assumption that is_hint
will always be set.

  Might there be any harm to GTK if I always set the
> is_hint member in GDK_MOTION_NOTIFY events to nonzero (NotifyHint)?
> Or should I set it to nonzero only if the window (or the grabbing
> window) is interested in motion hints?

That would probably not be a good idea, since it could cause code to 
to make excessive calls to gtk_.._pointer_get()
 
Regards,
                                        Owen



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