Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macpaste.c That uses leftclick to paste #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions macpaste.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down