Skip to content

Commit

Permalink
Merge pull request #31 from patelnav/master
Browse files Browse the repository at this point in the history
Cursor defaults to center of screen
  • Loading branch information
abyssoft committed Sep 4, 2018
2 parents 55ecaa2 + b57f9f4 commit 0c374fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions TPEventsController.h
Expand Up @@ -43,6 +43,7 @@
- (void)stopPostingEvents;
- (void)postEventWithEventData:(NSData*)eventData;

- (void)warpMouseToCenter;
- (void)warpMouseToPosition:(NSPoint)position;
- (void)mouseDownAtPosition:(NSPoint)position;
- (void)mouseUpAtPosition:(NSPoint)position;
Expand Down
9 changes: 9 additions & 0 deletions TPEventsController.m
Expand Up @@ -145,6 +145,15 @@ - (void)_postEventWithEventData:(NSData*)eventData
// overloaded
}

- (void)warpMouseToCenter
{
NSArray * screens = [[TPLocalHost localHost] screens];
NSRect mainScreenRect = [screens[0] frame];

NSPoint centerPoint = NSMakePoint(NSMidX(mainScreenRect), NSMidY(mainScreenRect));
return [self warpMouseToPosition:centerPoint];
}

- (void)warpMouseToPosition:(NSPoint)position
{
_currentMouseLocation = *(CGPoint*)&position;
Expand Down
2 changes: 1 addition & 1 deletion TPServerController.m
Expand Up @@ -303,7 +303,7 @@ - (void)stopControlWithDisconnect:(BOOL)disconnect
_state = TPServerSharedState;

if([[TPPreferencesManager sharedPreferencesManager] boolForPref:WRAP_ON_STOP_CONTROL])
[[self eventsController] warpMouseToPosition:NSMakePoint(16.0, 16.0)];
[[self eventsController] warpMouseToCenter];

[[self eventsController] stopPostingEvents];

Expand Down

0 comments on commit 0c374fe

Please sign in to comment.