node-mac-recorder 2.22.13 → 2.22.15
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 +30 -9
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -1967,18 +1967,26 @@ static void emitTextInputEvent(NSTimeInterval timestamp, NSTimeInterval unixTime
|
|
|
1967
1967
|
return;
|
|
1968
1968
|
}
|
|
1969
1969
|
|
|
1970
|
-
// Focused element text field mi kontrol et
|
|
1971
1970
|
NSString *role = CopyAttributeString(focusedElement, kAXRoleAttribute);
|
|
1972
1971
|
BOOL isEditable = NO;
|
|
1973
1972
|
CopyAttributeBoolean(focusedElement, CFSTR("AXEditable"), &isEditable);
|
|
1974
1973
|
|
|
1975
|
-
|
|
1974
|
+
CFTypeRef selectedRangeValue = NULL;
|
|
1975
|
+
AXError rangeProbeErr = AXUIElementCopyAttributeValue(
|
|
1976
|
+
focusedElement, CFSTR("AXSelectedTextRange"), (CFTypeRef *)&selectedRangeValue);
|
|
1977
|
+
BOOL hasTextRange = (rangeProbeErr == kAXErrorSuccess && selectedRangeValue != NULL);
|
|
1978
|
+
|
|
1979
|
+
// Electron/Chromium: gerçek yazma genelde AXSelectedTextRange ile gelir; AXWebArea tek başına tüm sayfa olabilir.
|
|
1980
|
+
BOOL isStandardTextRole = StringEqualsAny(role, @[
|
|
1976
1981
|
@"AXTextField", @"AXTextArea", @"AXTextView",
|
|
1977
1982
|
@"AXTextEditor", @"AXSearchField",
|
|
1978
1983
|
@"AXComboBox"
|
|
1979
|
-
])
|
|
1984
|
+
]);
|
|
1985
|
+
BOOL isWebAreaWithCaret = [role isEqualToString:@"AXWebArea"] && hasTextRange;
|
|
1986
|
+
BOOL isTextField = isStandardTextRole || isEditable || isWebAreaWithCaret || hasTextRange;
|
|
1980
1987
|
|
|
1981
1988
|
if (!isTextField) {
|
|
1989
|
+
if (selectedRangeValue) CFRelease(selectedRangeValue);
|
|
1982
1990
|
CFRelease(focusedElement);
|
|
1983
1991
|
CFRelease(systemWide);
|
|
1984
1992
|
return;
|
|
@@ -2006,11 +2014,7 @@ static void emitTextInputEvent(NSTimeInterval timestamp, NSTimeInterval unixTime
|
|
|
2006
2014
|
CGPoint caretPos = CGPointMake(inputOrigin.x, inputOrigin.y);
|
|
2007
2015
|
BOOL hasCaretPos = NO;
|
|
2008
2016
|
|
|
2009
|
-
|
|
2010
|
-
AXError rangeErr = AXUIElementCopyAttributeValue(
|
|
2011
|
-
focusedElement, CFSTR("AXSelectedTextRange"), &selectedRangeValue);
|
|
2012
|
-
|
|
2013
|
-
if (rangeErr == kAXErrorSuccess && selectedRangeValue) {
|
|
2017
|
+
if (selectedRangeValue) {
|
|
2014
2018
|
CFTypeRef boundsValue = NULL;
|
|
2015
2019
|
AXError boundsErr = AXUIElementCopyParameterizedAttributeValue(
|
|
2016
2020
|
focusedElement, CFSTR("AXBoundsForRange"),
|
|
@@ -2019,7 +2023,6 @@ static void emitTextInputEvent(NSTimeInterval timestamp, NSTimeInterval unixTime
|
|
|
2019
2023
|
if (boundsErr == kAXErrorSuccess && boundsValue) {
|
|
2020
2024
|
CGRect caretBounds = CGRectZero;
|
|
2021
2025
|
if (AXValueGetValue((AXValueRef)boundsValue, kAXValueTypeCGRect, &caretBounds)) {
|
|
2022
|
-
// Caret'in dikey ortası
|
|
2023
2026
|
caretPos = CGPointMake(
|
|
2024
2027
|
caretBounds.origin.x,
|
|
2025
2028
|
caretBounds.origin.y + caretBounds.size.height / 2.0
|
|
@@ -2029,6 +2032,7 @@ static void emitTextInputEvent(NSTimeInterval timestamp, NSTimeInterval unixTime
|
|
|
2029
2032
|
CFRelease(boundsValue);
|
|
2030
2033
|
}
|
|
2031
2034
|
CFRelease(selectedRangeValue);
|
|
2035
|
+
selectedRangeValue = NULL;
|
|
2032
2036
|
}
|
|
2033
2037
|
|
|
2034
2038
|
// Caret alınamazsa input frame'in sol ortasını kullan
|
|
@@ -2091,6 +2095,23 @@ CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef eve
|
|
|
2091
2095
|
// Event tipini belirle
|
|
2092
2096
|
switch (type) {
|
|
2093
2097
|
case kCGEventLeftMouseDown:
|
|
2098
|
+
eventType = @"mousedown";
|
|
2099
|
+
// Odak/caret çoğu uygulamada tıklamadan hemen sonra oluşur; kısa gecikmeyle AX caret yaz.
|
|
2100
|
+
// (Sadece tuşta emit edilince ilk tıkta timeline'da textInput olmuyordu.)
|
|
2101
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.028 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
2102
|
+
if (!g_isCursorTracking || !g_trackingStartTime || !g_fileHandle) return;
|
|
2103
|
+
NSDate *now = [NSDate date];
|
|
2104
|
+
NSTimeInterval ts = [now timeIntervalSinceDate:g_trackingStartTime] * 1000.0;
|
|
2105
|
+
NSTimeInterval unixMs = [now timeIntervalSince1970] * 1000.0;
|
|
2106
|
+
CGPoint loc = CGPointZero;
|
|
2107
|
+
CGEventRef posEv = CGEventCreate(NULL);
|
|
2108
|
+
if (posEv) {
|
|
2109
|
+
loc = CGEventGetLocation(posEv);
|
|
2110
|
+
CFRelease(posEv);
|
|
2111
|
+
}
|
|
2112
|
+
emitTextInputEvent(ts, unixMs, loc);
|
|
2113
|
+
});
|
|
2114
|
+
break;
|
|
2094
2115
|
case kCGEventRightMouseDown:
|
|
2095
2116
|
case kCGEventOtherMouseDown:
|
|
2096
2117
|
eventType = @"mousedown";
|