diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2010-01-06 14:58:29 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2010-01-06 14:58:29 (GMT) |
commit | 1a6ac30b077e52ba1da9ac22a8d38356ece00cec (patch) | |
tree | 26bd34fc1fc835f2a79bdefdc48e6aff6bbd207f /carbon | |
parent | ef7b2a248d85365c8bfc78d1ef62475638b1a6bc (diff) | |
download | tk-1a6ac30b077e52ba1da9ac22a8d38356ece00cec.zip tk-1a6ac30b077e52ba1da9ac22a8d38356ece00cec.tar.gz tk-1a6ac30b077e52ba1da9ac22a8d38356ece00cec.tar.bz2 |
[Bug 2926819]: Factor out the pointer warping code a bit better and extend it
to work on OSX too.
Diffstat (limited to 'carbon')
-rw-r--r-- | carbon/tkMacOSXMouseEvent.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/carbon/tkMacOSXMouseEvent.c b/carbon/tkMacOSXMouseEvent.c index b9e54f5..a653073 100644 --- a/carbon/tkMacOSXMouseEvent.c +++ b/carbon/tkMacOSXMouseEvent.c @@ -48,7 +48,7 @@ * permission to use and distribute the software in accordance with the * terms specified in this license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.2 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.3 2010/01/06 14:58:30 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -1148,6 +1148,40 @@ GenerateToolbarButtonEvent( return true; } +void +TkpWarpPointer( + TkDisplay *dispPtr) +{ + CGPoint pt; + UInt32 buttonState; + + if (dispPtr->warpWindow) { + int x, y; + + Tk_GetRootCoords(dispPtr->warpWindow, &x, &y); + pt.x = x + dispPtr->warpX; + pt.y = y + dispPtr->warpY; + } else { + pt.x = dispPtr->warpX; + pt.y = dispPtr->warpY; + } + + /* + * Tell the OSX core to generate the events to make it happen. This is + * fairly ugly, but means that under most circumstances we'll register all + * the events that would normally be generated correctly. If we use + * CGWarpMouseCursorPosition instead, strange things happen. + */ + + buttonState = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()) + ? GetCurrentEventButtonState() : GetCurrentButtonState(); + + CGPostMouseEvent(pt, 1 /* generate motion events */, 5, + buttonState&1 ? 1 : 0, buttonState&2 ? 1 : 0, + buttonState&4 ? 1 : 0, buttonState&8 ? 1 : 0, + buttonState&16 ? 1 : 0); +} + /* * Local Variables: * mode: c |