node-mac-recorder 2.17.4 → 2.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cursor_tracker.mm +109 -2
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -58,11 +58,15 @@ NSString* getCursorType() {
|
|
|
58
58
|
// Get current cursor info
|
|
59
59
|
NSCursor *currentCursor = [NSCursor currentSystemCursor];
|
|
60
60
|
NSString *cursorType = @"default";
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
// Get cursor image info
|
|
63
63
|
NSImage *cursorImage = [currentCursor image];
|
|
64
64
|
NSPoint hotSpot = [currentCursor hotSpot];
|
|
65
65
|
NSSize imageSize = [cursorImage size];
|
|
66
|
+
|
|
67
|
+
// DEBUG: Log cursor details
|
|
68
|
+
NSLog(@"🖱️ CURSOR DEBUG: size=(%.0f,%.0f), hotspot=(%.0f,%.0f)",
|
|
69
|
+
imageSize.width, imageSize.height, hotSpot.x, hotSpot.y);
|
|
66
70
|
|
|
67
71
|
// Check cursor type by comparing with standard cursors
|
|
68
72
|
if ([currentCursor isEqual:[NSCursor pointingHandCursor]] ||
|
|
@@ -76,7 +80,7 @@ NSString* getCursorType() {
|
|
|
76
80
|
} else if ([currentCursor isEqual:[NSCursor resizeLeftRightCursor]]) {
|
|
77
81
|
return @"col-resize";
|
|
78
82
|
} else if ([currentCursor isEqual:[NSCursor resizeUpDownCursor]]) {
|
|
79
|
-
return @"
|
|
83
|
+
return @"ns-resize";
|
|
80
84
|
} else if ([currentCursor isEqual:[NSCursor openHandCursor]]) {
|
|
81
85
|
return @"grab";
|
|
82
86
|
} else if ([currentCursor isEqual:[NSCursor closedHandCursor]]) {
|
|
@@ -93,6 +97,109 @@ NSString* getCursorType() {
|
|
|
93
97
|
return @"help";
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
// Additional detection based on image characteristics
|
|
101
|
+
if (imageSize.width > 0 && imageSize.height > 0) {
|
|
102
|
+
NSLog(@"🖱️ Checking cursor: size=(%.0f,%.0f), hotspot=(%.0f,%.0f)",
|
|
103
|
+
imageSize.width, imageSize.height, hotSpot.x, hotSpot.y);
|
|
104
|
+
|
|
105
|
+
// Hand cursors (grab/grabbing) - different from regular cursors
|
|
106
|
+
// Looking for cursors that are NOT the common patterns we know
|
|
107
|
+
bool isKnownPattern = false;
|
|
108
|
+
|
|
109
|
+
// Text cursor: narrow tall with centered hotspot
|
|
110
|
+
if (imageSize.width <= 12 && imageSize.height >= 16 &&
|
|
111
|
+
hotSpot.x >= imageSize.width/2 - 2 && hotSpot.x <= imageSize.width/2 + 2) {
|
|
112
|
+
isKnownPattern = true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Pointer cursor: larger with off-center hotspot
|
|
116
|
+
if ((imageSize.width >= 28 && imageSize.height >= 32 && hotSpot.x <= 8) ||
|
|
117
|
+
(imageSize.width == 32 && imageSize.height == 32 && hotSpot.x <= 15 && hotSpot.y <= 10)) {
|
|
118
|
+
isKnownPattern = true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Default cursor: 32x32 with center hotspot
|
|
122
|
+
if (imageSize.width == 32 && imageSize.height == 32 &&
|
|
123
|
+
hotSpot.x >= 14 && hotSpot.x <= 18 && hotSpot.y >= 14 && hotSpot.y <= 18) {
|
|
124
|
+
isKnownPattern = true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Special cursor patterns detection
|
|
128
|
+
if (!isKnownPattern) {
|
|
129
|
+
// Progress cursor (loading/spinning) - usually larger, center hotspot
|
|
130
|
+
if (imageSize.width >= 24 && imageSize.width <= 40 &&
|
|
131
|
+
imageSize.height >= 24 && imageSize.height <= 40 &&
|
|
132
|
+
hotSpot.x >= imageSize.width/2 - 4 && hotSpot.x <= imageSize.width/2 + 4 &&
|
|
133
|
+
hotSpot.y >= imageSize.height/2 - 4 && hotSpot.y <= imageSize.height/2 + 4) {
|
|
134
|
+
NSLog(@"🖱️ DETECTED PROGRESS: size=(%.0f,%.0f), hotspot=(%.0f,%.0f)",
|
|
135
|
+
imageSize.width, imageSize.height, hotSpot.x, hotSpot.y);
|
|
136
|
+
return @"progress";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Zoom cursors (magnifying glass) - distinctive size/hotspot patterns
|
|
140
|
+
if (imageSize.width >= 18 && imageSize.width <= 30 &&
|
|
141
|
+
imageSize.height >= 18 && imageSize.height <= 30) {
|
|
142
|
+
// Zoom-in usually has hotspot in center or slightly off
|
|
143
|
+
if (hotSpot.x >= imageSize.width/2 - 3 && hotSpot.x <= imageSize.width/2 + 3) {
|
|
144
|
+
NSLog(@"🖱️ DETECTED ZOOM-IN: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
145
|
+
return @"zoom-in";
|
|
146
|
+
}
|
|
147
|
+
// Zoom-out usually has different hotspot pattern
|
|
148
|
+
else {
|
|
149
|
+
NSLog(@"🖱️ DETECTED ZOOM-OUT: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
150
|
+
return @"zoom-out";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// All-scroll cursor (move in all directions) - usually square with center hotspot
|
|
155
|
+
if (imageSize.width >= 16 && imageSize.width <= 24 &&
|
|
156
|
+
imageSize.height >= 16 && imageSize.height <= 24 &&
|
|
157
|
+
abs(imageSize.width - imageSize.height) <= 2 &&
|
|
158
|
+
hotSpot.x >= imageSize.width/2 - 2 && hotSpot.x <= imageSize.width/2 + 2 &&
|
|
159
|
+
hotSpot.y >= imageSize.height/2 - 2 && hotSpot.y <= imageSize.height/2 + 2) {
|
|
160
|
+
NSLog(@"🖱️ DETECTED ALL-SCROLL: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
161
|
+
return @"all-scroll";
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Diagonal resize cursors - typically 16x16 or similar
|
|
165
|
+
if (imageSize.width >= 14 && imageSize.width <= 20 &&
|
|
166
|
+
imageSize.height >= 14 && imageSize.height <= 20) {
|
|
167
|
+
// NW-SE resize (diagonal top-left to bottom-right)
|
|
168
|
+
if (hotSpot.x <= imageSize.width/2 && hotSpot.y <= imageSize.height/2) {
|
|
169
|
+
NSLog(@"🖱️ DETECTED NWSE-RESIZE: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
170
|
+
return @"nwse-resize";
|
|
171
|
+
}
|
|
172
|
+
// NE-SW resize (diagonal top-right to bottom-left)
|
|
173
|
+
else if (hotSpot.x >= imageSize.width/2 && hotSpot.y <= imageSize.height/2) {
|
|
174
|
+
NSLog(@"🖱️ DETECTED NESW-RESIZE: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
175
|
+
return @"nesw-resize";
|
|
176
|
+
}
|
|
177
|
+
// Row resize (vertical resize)
|
|
178
|
+
else if (abs(hotSpot.x - imageSize.width/2) <= 2) {
|
|
179
|
+
NSLog(@"🖱️ DETECTED ROW-RESIZE: size=(%.0f,%.0f)", imageSize.width, imageSize.height);
|
|
180
|
+
return @"row-resize";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Hand cursors (grab/grabbing) - medium-sized, various hotspots
|
|
185
|
+
if (imageSize.width >= 14 && imageSize.width <= 24 &&
|
|
186
|
+
imageSize.height >= 14 && imageSize.height <= 24) {
|
|
187
|
+
NSLog(@"🖱️ POTENTIAL GRAB/GRABBING: size=(%.0f,%.0f), hotspot=(%.0f,%.0f)",
|
|
188
|
+
imageSize.width, imageSize.height, hotSpot.x, hotSpot.y);
|
|
189
|
+
|
|
190
|
+
// Try to differentiate grab vs grabbing by hotspot position
|
|
191
|
+
if (hotSpot.x >= imageSize.width/2 - 2 && hotSpot.x <= imageSize.width/2 + 2 &&
|
|
192
|
+
hotSpot.y >= imageSize.height/2 - 2 && hotSpot.y <= imageSize.height/2 + 2) {
|
|
193
|
+
NSLog(@"🖱️ DETECTED GRAB (center hotspot)");
|
|
194
|
+
return @"grab";
|
|
195
|
+
} else {
|
|
196
|
+
NSLog(@"🖱️ DETECTED GRABBING (off-center hotspot)");
|
|
197
|
+
return @"grabbing";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
96
203
|
|
|
97
204
|
// Check if we're in a drag operation
|
|
98
205
|
CGEventRef event = CGEventCreate(NULL);
|