File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 8
8
clean :
9
9
-rm -f macpaste
10
10
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
13
13
14
14
run :
15
15
./macpaste
Original file line number Diff line number Diff line change 17
17
#include < ApplicationServices/ApplicationServices.h>
18
18
#include < Carbon/Carbon.h> // kVK_ANSI_*
19
19
#include < sys/time.h> // gettimeofday
20
+ #include < AppKit/NSCursor.h>
20
21
21
22
char isDragging = 0 ;
22
23
long long prevClickTime = 0 ;
@@ -99,7 +100,9 @@ static void paste(CGEventRef event) {
99
100
{
100
101
case kCGEventOtherMouseDown :
101
102
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 ] ))
103
106
paste ( event );
104
107
break ;
105
108
@@ -134,6 +137,7 @@ static void paste(CGEventRef event) {
134
137
CFMachPortRef myEventTap;
135
138
CFRunLoopSourceRef eventTapRLSrc;
136
139
140
+
137
141
// parse args for -n flag
138
142
int c;
139
143
int dontpaste = 0 ;
@@ -152,6 +156,7 @@ static void paste(CGEventRef event) {
152
156
CGEventMaskBit ( kCGEventLeftMouseDown ) |
153
157
CGEventMaskBit ( kCGEventLeftMouseUp ) |
154
158
CGEventMaskBit ( kCGEventLeftMouseDragged );
159
+ NSApplicationLoad ();
155
160
156
161
// Create the Tap
157
162
myEventTap = CGEventTapCreate (
You can’t perform that action at this time.
0 commit comments