Skip to content

Instantly share code, notes, and snippets.

@eyelash
Created October 16, 2018 08:52
Show Gist options
  • Save eyelash/cc6f82bbeda43a830551ea8db359636e to your computer and use it in GitHub Desktop.
Save eyelash/cc6f82bbeda43a830551ea8db359636e to your computer and use it in GitHub Desktop.
void gral_window_warp_cursor(struct gral_window *window, float x, float y) {
NSRect window_rect = [[(GralWindow *)window contentView] convertRect:NSMakeRect(x, y, 0, 0) toView:nil];
NSRect screen_rect = [(GralWindow *)window convertRectToScreen:window_rect];
//CGWarpMouseCursorPosition(screen_rect.origin);
CGPoint point = [[(GralWindow *)window contentView] convertPoint:NSMakePoint(x, y) toView:nil];
NSRect frame = [(GralWindow *)window frame];
point = CGPointMake(NSMinX(frame) + point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + point.y));
//CGPoint display_point = CGPointMake(NSMinX(frame) + window_point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + window_point.y));
CGWarpMouseCursorPosition(point);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment