summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMouseEvent.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r--macosx/tkMacOSXMouseEvent.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index f4bfb44..1fdbc52 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -48,7 +48,7 @@ static unsigned int ButtonModifiers2State(UInt32 buttonState,
}
@end
#else
-- (NSPoint) convertPointToScreen: (NSPoint)point
+- (NSPoint) convertPointToScreen: (NSPoint) point
{
NSRect pointrect;
pointrect.origin = point;
@@ -88,7 +88,8 @@ enum {
*/
@implementation TKApplication(TKMouseEvent)
-- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent {
+- (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent
+{
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
@@ -122,13 +123,6 @@ enum {
case NSRightMouseDragged:
case NSOtherMouseDragged:
case NSMouseMoved:
-#if 0
- eventNumber = [theEvent eventNumber];
- if (!trackingArea) {
- clickCount = [theEvent clickCount];
- buttonNumber = [theEvent buttonNumber];
- }
-#endif
case NSTabletPoint:
case NSTabletProximity:
case NSScrollWheel:
@@ -182,24 +176,24 @@ enum {
EventRef eventRef = (EventRef)[theEvent eventRef];
UInt32 buttons;
OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
- typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
+ typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
+
if (err == noErr) {
- state |= (buttons & ((1<<5) - 1)) << 8;
- } else {
- if (button < 5) {
- switch (type) {
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- state |= 1 << (button + 8);
- break;
- default:
- break;
- }
+ state |= (buttons & ((1<<5) - 1)) << 8;
+ } else if (button < 5) {
+ switch (type) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDown:
+ state |= 1 << (button + 8);
+ break;
+ default:
+ break;
}
}
+
NSUInteger modifiers = [theEvent modifierFlags];
if (modifiers & NSAlphaShiftKeyMask) {
@@ -589,6 +583,39 @@ 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.
+ */
+
+ buttonState = [NSEvent pressedMouseButtons];
+ CGEventType type = kCGEventMouseMoved;
+ CGEventRef theEvent = CGEventCreateMouseEvent(NULL,
+ type,
+ pt,
+ buttonState);
+ CGWarpMouseCursorPosition(pt);
+ CGEventPost(kCGHIDEventTap, theEvent);
+ CFRelease(theEvent);
+}
+
/*
* Local Variables:
* mode: objc