From 9cf603d26273b83f075d5e1c6920466edd5ba29c Mon Sep 17 00:00:00 2001 From: NSlabs73 Date: Tue, 20 Aug 2024 19:27:23 -0400 Subject: [PATCH] Update macpaste.c --- macpaste.c | 63 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/macpaste.c b/macpaste.c index 9416330..02df40f 100644 --- a/macpaste.c +++ b/macpaste.c @@ -87,42 +87,41 @@ static void paste(CGEventRef event) { return isDoubleClickSpeed(); } - static CGEventRef mouseCallback ( - CGEventTapProxy proxy, - CGEventType type, - CGEventRef event, - void * refcon - ) { - int* dontpaste = refcon; - switch ( type ) - { - case kCGEventOtherMouseDown: - if (*dontpaste == 0) - paste( event ); - break; - - case kCGEventLeftMouseDown: - recordClickTime(); - break; +static CGEventRef mouseCallback ( + CGEventTapProxy proxy, + CGEventType type, + CGEventRef event, + void * refcon +) { + int* dontpaste = refcon; + switch (type) { + case kCGEventLeftMouseDown: + recordClickTime(); + // Paste on a single left-click (if it's not a double-click or dragging). + if (*dontpaste == 0 && !isDoubleClick() && !isDragging) { + paste(event); + } + break; - case kCGEventLeftMouseUp: - if ( isDoubleClick() || isDragging ) { - copy(); - } - isDragging = 0; - break; + case kCGEventLeftMouseUp: + // Trigger copy only if it's a double-click or dragging event. + if (isDoubleClick() || isDragging) { + copy(); + } + isDragging = 0; + break; - case kCGEventLeftMouseDragged: - isDragging = 1; - break; + case kCGEventLeftMouseDragged: + isDragging = 1; + break; - default: - break; - } + default: + break; + } - // Pass on the event, we must not modify it anyway, we are a listener - return event; - } + // Pass on the event, we must not modify it anyway, we are a listener. + return event; +} int main ( int argc,