Revision: 16795
http://sourceforge.net/p/skim-app/code/16795
Author: hofman
Date: 2026-11-11 22:42:27 +0000 (Wed, 11 Nov 2026)
Log Message:
-----------
Ignore synthetic clicks for snapshot, marquee zoom, pdfsync, or anchored note
tool mode from single click
Modified Paths:
--------------
trunk/NSEvent_SKExtensions.h
trunk/NSEvent_SKExtensions.m
trunk/PDFView_SKExtensions.m
trunk/SKPDFView.m
Modified: trunk/NSEvent_SKExtensions.h
===================================================================
--- trunk/NSEvent_SKExtensions.h 2026-11-11 17:21:11 UTC (rev 16794)
+++ trunk/NSEvent_SKExtensions.h 2026-11-11 22:42:27 UTC (rev 16795)
@@ -53,6 +53,8 @@
@property (nonatomic, readonly) unichar firstCharacter;
+@property (nonatomic, readonly, getter=isSyntheticClick) BOOL syntheticClick;
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/NSEvent_SKExtensions.m
===================================================================
--- trunk/NSEvent_SKExtensions.m 2026-11-11 17:21:11 UTC (rev 16794)
+++ trunk/NSEvent_SKExtensions.m 2026-11-11 22:42:27 UTC (rev 16795)
@@ -59,4 +59,11 @@
return [characters length] > 0 ? [characters characterAtIndex:0] : 0;
}
+- (BOOL)isSyntheticClick {
+ CGEventRef cgEvent = [self CGEvent];
+ return (cgEvent == NULL ||
+ CGEventGetIntegerValueField(cgEvent, kCGEventSourceUnixProcessID)
!= 0 ||
+ CGEventGetIntegerValueField(cgEvent, kCGEventSourceStateID) !=
kCGEventSourceStateHIDSystemState);
+}
+
@end
Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m 2026-11-11 17:21:11 UTC (rev 16794)
+++ trunk/PDFView_SKExtensions.m 2026-11-11 22:42:27 UTC (rev 16795)
@@ -84,11 +84,16 @@
- (void)doPdfsyncWithEvent:(NSEvent *)theEvent {
// eat up mouseDragged/mouseUp events, so we won't get their event handlers
+ BOOL didDrag = NO;
while (YES) {
if ([[[self window] nextEventMatchingMask: NSEventMaskLeftMouseUp |
NSEventMaskLeftMouseDragged] type] == NSEventTypeLeftMouseUp)
break;
+ didDrag = YES;
}
+ if (didDrag == NO && [theEvent isSyntheticClick])
+ return;
+
SKMainDocument *document = (SKMainDocument *)[[[self window]
windowController] document];
if ([document respondsToSelector:@selector(synchronizer)]) {
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2026-11-11 17:21:11 UTC (rev 16794)
+++ trunk/SKPDFView.m 2026-11-11 22:42:27 UTC (rev 16795)
@@ -4040,10 +4040,12 @@
noteType = NOTE_TYPE_FROM_TEMP_TOOL_MODE(temporaryToolMode);
originalBounds =
SKRectFromCenterAndSquareSize(SKIntegralPoint(initialPoint), 0.0);
if (noteType == SKNoteTypeAnchored) {
- PDFAnnotation *newAnnotation = [PDFAnnotation
newSkimNoteWithBounds:SKRectFromCenterAndSize(initialPoint,
SKNPDFAnnotationNoteSize) forType:SKNNoteString];
- [self addAnnotation:newAnnotation toPage:page select:YES];
resizeHandle = SKRectEdgesNone;
- originalBounds = [[self currentAnnotation] bounds];
+ originalBounds = SKRectFromCenterAndSize(initialPoint,
SKNPDFAnnotationNoteSize);
+ if ([theEvent isSyntheticClick] == NO) {
+ PDFAnnotation *newAnnotation = [PDFAnnotation
newSkimNoteWithBounds:originalBounds forType:SKNNoteString];
+ [self addAnnotation:newAnnotation toPage:page select:YES];
+ }
} else if (noteType == SKNoteTypeLine) {
isLine = YES;
resizeHandle = SKRectEdgesMaxX;
@@ -4081,7 +4083,8 @@
} else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
if (draggedAnnotation == NO) {
if (currentAnnotation == nil) {
- PDFAnnotation *newAnnotation = [PDFAnnotation
newSkimNoteWithBounds:SKRectFromCenterAndSquareSize(initialPoint,
MIN_NOTE_SIZE) forType:SKTypeForNoteType(noteType)];
+ NSRect bounds = noteType == SKNoteTypeAnchored ?
SKRectFromCenterAndSize(initialPoint, SKNPDFAnnotationNoteSize) :
SKRectFromCenterAndSquareSize(initialPoint, MIN_NOTE_SIZE);
+ PDFAnnotation *newAnnotation = [PDFAnnotation
newSkimNoteWithBounds:bounds forType:SKTypeForNoteType(noteType)];
[self addAnnotation:newAnnotation toPage:page select:YES];
} else if (shouldAddAnnotation == NO) {
[self beginNewUndoGroupIfNeeded];
@@ -4809,6 +4812,11 @@
}
rect = [self convertRect:rect toPage:page];
+ } else if ([theEvent isSyntheticClick]) {
+
+ // ignore synthetic clicks
+ return;
+
} else if (toolMode == SKToolModeSelect && NSIsEmptyRect(selectionRect) ==
NO) {
rect = NSIntersectionRect(selectionRect, [page
boundsForBox:kPDFDisplayBoxCropBox]);
@@ -4914,7 +4922,7 @@
NSRect rect = [self convertRect:[self convertRect:selRect
fromView:[self documentView]] toPage:page];
[self zoomToRect:rect onPage:page];
- } else if (dragged == NO && [self autoScales] == NO) {
+ } else if (dragged == NO && [self autoScales] == NO && [theEvent
isSyntheticClick] == NO) {
[self setAutoScales:YES];
[self setAutoScales:NO];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit