|
22 | 22 | char isDragging = 0; |
23 | 23 | long long prevClickTime = 0; |
24 | 24 | long long curClickTime = 0; |
| 25 | +NSPoint initialLocation; |
25 | 26 |
|
26 | 27 | CGEventTapLocation tapA = kCGAnnotatedSessionEventTap; |
27 | 28 | CGEventTapLocation tapH = kCGHIDEventTap; |
@@ -102,22 +103,38 @@ static CGEventRef mouseCallback ( |
102 | 103 | button = CGEventGetIntegerValueField(event, kCGMouseEventButtonNumber); |
103 | 104 | NSCursor* cursor = [NSCursor currentSystemCursor]; |
104 | 105 | NSCursor* ibeam = [NSCursor IBeamCursor]; |
105 | | - if (*dontpaste == 0 && button == 2 && NSEqualPoints([cursor hotSpot] , [ibeam hotSpot] )) |
| 106 | + if (*dontpaste == 0 && button == 2 && NSEqualPoints([cursor hotSpot] , [ibeam hotSpot] )) { |
| 107 | + // NSLog(@"paste %@", NSStringFromPoint( [NSEvent mouseLocation])); |
106 | 108 | paste( event ); |
| 109 | + } |
107 | 110 | break; |
108 | 111 |
|
109 | 112 | case kCGEventLeftMouseDown: |
| 113 | + //NSLog(@"down %@", NSStringFromPoint( [NSEvent mouseLocation])); |
110 | 114 | recordClickTime(); |
111 | 115 | break; |
112 | 116 |
|
113 | 117 | case kCGEventLeftMouseUp: |
114 | | - if ( isDoubleClick() || isDragging ) { |
| 118 | + //NSLog(@"up %@", NSStringFromPoint( [NSEvent mouseLocation])); |
| 119 | + if (isDoubleClick()) { |
| 120 | + //NSLog(@"copydblc %@", NSStringFromPoint( [NSEvent mouseLocation])); |
115 | 121 | copy(); |
116 | 122 | } |
| 123 | + if (isDragging) { |
| 124 | + NSPoint clickLocation = [NSEvent mouseLocation]; |
| 125 | + int xdiff = fabs(initialLocation.x-clickLocation.x); |
| 126 | + int ydiff = fabs(initialLocation.y-clickLocation.y); |
| 127 | + if (xdiff > 5 || ydiff > 5) { |
| 128 | + //NSLog(@"copydrag %@ %@", NSStringFromPoint(initialLocation), NSStringFromPoint( [NSEvent mouseLocation])); |
| 129 | + copy(); |
| 130 | + } |
| 131 | + } |
117 | 132 | isDragging = 0; |
118 | 133 | break; |
119 | 134 |
|
120 | 135 | case kCGEventLeftMouseDragged: |
| 136 | + if (!isDragging) |
| 137 | + initialLocation = [NSEvent mouseLocation]; |
121 | 138 | isDragging = 1; |
122 | 139 | break; |
123 | 140 |
|
|
0 commit comments