File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88clean :
99 -rm -f macpaste
1010
11- macpaste : macpaste.c
12- gcc -O2 -framework ApplicationServices -o macpaste macpaste.c
11+ macpaste : macpaste.m
12+ gcc -O2 -framework AppKit -framework ApplicationServices -o macpaste macpaste.m
1313
1414run :
1515 ./macpaste
Original file line number Diff line number Diff line change 1717#include < ApplicationServices/ApplicationServices.h>
1818#include < Carbon/Carbon.h> // kVK_ANSI_*
1919#include < sys/time.h> // gettimeofday
20+ #include < AppKit/NSCursor.h>
2021
2122char isDragging = 0 ;
2223long long prevClickTime = 0 ;
@@ -99,7 +100,9 @@ static void paste(CGEventRef event) {
99100 {
100101 case kCGEventOtherMouseDown :
101102 button = CGEventGetIntegerValueField (event, kCGMouseEventButtonNumber );
102- if (* dontpaste == 0 && button == 2 )
103+ NSCursor * cursor = [NSCursor currentSystemCursor ];
104+ NSCursor * ibeam = [NSCursor IBeamCursor ];
105+ if (*dontpaste == 0 && button == 2 && NSEqualPoints ([cursor hotSpot ] , [ibeam hotSpot ] ))
103106 paste ( event );
104107 break ;
105108
@@ -134,6 +137,7 @@ static void paste(CGEventRef event) {
134137 CFMachPortRef myEventTap;
135138 CFRunLoopSourceRef eventTapRLSrc;
136139
140+
137141 // parse args for -n flag
138142 int c;
139143 int dontpaste = 0 ;
@@ -152,6 +156,7 @@ static void paste(CGEventRef event) {
152156 CGEventMaskBit ( kCGEventLeftMouseDown ) |
153157 CGEventMaskBit ( kCGEventLeftMouseUp ) |
154158 CGEventMaskBit ( kCGEventLeftMouseDragged );
159+ NSApplicationLoad ();
155160
156161 // Create the Tap
157162 myEventTap = CGEventTapCreate (
You can’t perform that action at this time.
0 commit comments