summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMouseEvent.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-01-06 14:58:29 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-01-06 14:58:29 (GMT)
commit1a6ac30b077e52ba1da9ac22a8d38356ece00cec (patch)
tree26bd34fc1fc835f2a79bdefdc48e6aff6bbd207f /macosx/tkMacOSXMouseEvent.c
parentef7b2a248d85365c8bfc78d1ef62475638b1a6bc (diff)
downloadtk-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 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r--macosx/tkMacOSXMouseEvent.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 06b35b2..b5caf5a 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.37 2009/07/06 20:29:21 dkf Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.38 2010/01/06 14:58:30 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -537,6 +537,40 @@ GenerateButtonEvent(
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: objc