Re: [gtk-list] Re: problem with grabbing pointer



Paul Barton-Davis <pbd@op.net> writes:

> >I have a button drawn on the screen.  I would like for the user to be able
> >to click and drag the button around the window using the left mouse button.
> >
> >So, what I do is I connect signals to button pushes, and motion, etc.  All
> >is well as long as the user doesn't move the mouse too fast.  If they do,
> >then the button no longer gets the mouse events (b/c the mouse moved off the
> >button before it could catch up).  With Tcl/Tk and Java, the pointer is
> >grabbed by the button and so if I move off the upper left edge, the button
> >still gets the mouse events, with coordinates of -1,-1 (for example).
> >
> >I'd like for the same thing to happen with Gtk+.
> 
> it does. you must have a mistake in your code. take a look at the
> example code in testgtk.c covering shaped windows. you'll find stuff
> that does this for shaped windows that you can drag around the screen
> at will.

No, he's right. testgtk.c does an explicit gdk_pointer_grab().

> Pointer grabs are not a feature of GTK, but of the X Window
> system. There is (almost) no way to avoid them regardless of the
> widget toolkit one uses or the language its written in.

The reason for the effect Martin described is that gdk sets the
OwnerGrabButtonMask flag in gdkwindow.c . Without this flag, X does an
automatic pointer grab and motion events and the final button release
event are sent to the window where the button press occurred and mouse
positions are reported relative to the origin of that window. When the
flag is set there's no automatic pointer grab and the events go to
whatever window is under the cursor and the positions are relative to
that window. (this is a bit simplified).

I have no idea why gdk sets that flag, though.

-- 
Bernhard Herzog	  | Sketch, a drawing program for Unix
herzog@online.de  | http://www.online.de/home/sketch/



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