Re: [gtk-list] Getting mouse motion events for child windows ofwidgets



On Sun, 9 Aug 1998, Damon Chaplin wrote:

> 
> I need to get motion_notify events for all windows/widgets so I can
> change the mouse cursor to show resizing handles.
> 
> If I simply connect to the widgets' motion_notify signals I don't
> always get the event (e.g. I don't get motion_notify events inside
> the text window of an entry or spinbutton).
> 
> I've tried using gdk_window_set_events() on all of the windows but
> that doesn't work. I've even tried gdk_window_add_filter() to see all
> events for all windows, but I never see any motion_notify events for
> these windows (I see them for everything else).
> 
> Any ideas?

yep, you need to grab the pointer on the button press.
[code snippets are from gleselector.c]
do that with something like
      while (gdk_pointer_grab (GTK_WIDGET (selector)->window,
                               TRUE,
                               GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                               GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
                               NULL,
                               selector->query_cursor,
                               GDK_CURRENT_TIME));
then in the event handling routine you need to react on
event->type==GDK_MOTION_NOTIFY. you can see what whether you got a usual motion
notify event or a hint by examining event->motion.is_hint.
if you want to track further movement within the xwindow the cursor is
currently in (which is probably the case), you need to invoke either of
gdk_window_get_pointer() or gdk_window_at_pointer() within the event
handler.

[both functions call XQueryPointer(), and the xlib docu on this says:
    PointerMotionHintMask

     If PointerMotionHintMask is selected in combination
     with one or more of the above masks, the X server is
     free to send only one MotionNotify event (with the
     is_hint member  of the XPointerMovedEvent structure set
     to NotifyHint) to the client for the event window,
     until either the key or button state changes, the
     pointer leaves the event window, or the client calls
     XQueryPointer or XGetMotionEvents.  The server still
     may send MotionNotify events without is_hint set to
     NotifyHint.
]

> 
> Damon
> 
> 

---
ciaoTJ



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