Commit 5c933c89 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Implement SetCursorPos().

parent de079223
......@@ -58,6 +58,8 @@
int cursorFrame;
NSTimer* cursorTimer;
BOOL cursorHidden;
NSTimeInterval lastSetCursorPositionTime;
}
@property (nonatomic) CGEventSourceKeyboardType keyboardType;
......
......@@ -548,6 +548,31 @@ int macdrv_err_on;
}
}
- (BOOL) setCursorPosition:(CGPoint)pos
{
BOOL ret;
ret = (CGWarpMouseCursorPosition(pos) == kCGErrorSuccess);
if (ret)
{
WineEventQueue* queue;
lastSetCursorPositionTime = [[NSProcessInfo processInfo] systemUptime];
// Discard all pending mouse move events.
[eventQueuesLock lock];
for (queue in eventQueues)
{
[queue discardEventsMatchingMask:event_mask_for_type(MOUSE_MOVED) |
event_mask_for_type(MOUSE_MOVED_ABSOLUTE)
forWindow:nil];
}
[eventQueuesLock unlock];
}
return ret;
}
/*
* ---------- NSApplication method overrides ----------
......@@ -587,6 +612,17 @@ int macdrv_err_on;
BOOL absolute = forceNextMouseMoveAbsolute || (targetWindow != lastTargetWindow);
forceNextMouseMoveAbsolute = FALSE;
// If we recently warped the cursor, discard mouse move events until
// we see an event which is later than that time.
if (lastSetCursorPositionTime)
{
if ([anEvent timestamp] <= lastSetCursorPositionTime)
return;
lastSetCursorPositionTime = 0;
absolute = TRUE;
}
[targetWindow postMouseMovedEvent:anEvent absolute:absolute];
lastTargetWindow = targetWindow;
}
......@@ -893,3 +929,20 @@ int macdrv_get_cursor_position(CGPoint *pos)
return TRUE;
}
/***********************************************************************
* macdrv_set_cursor_position
*
* Sets the cursor position without generating events. Returns zero on
* failure, non-zero on success.
*/
int macdrv_set_cursor_position(CGPoint pos)
{
__block int ret;
OnMainThread(^{
ret = [NSApp setCursorPosition:pos];
});
return ret;
}
......@@ -121,6 +121,7 @@ extern void macdrv_beep(void) DECLSPEC_HIDDEN;
/* cursor */
extern void macdrv_set_cursor(CFStringRef name, CFArrayRef frames) DECLSPEC_HIDDEN;
extern int macdrv_get_cursor_position(CGPoint *pos) DECLSPEC_HIDDEN;
extern int macdrv_set_cursor_position(CGPoint pos) DECLSPEC_HIDDEN;
/* display */
......
......@@ -848,6 +848,20 @@ done:
/***********************************************************************
* SetCursorPos (MACDRV.@)
*/
BOOL CDECL macdrv_SetCursorPos(INT x, INT y)
{
BOOL ret = macdrv_set_cursor_position(CGPointMake(x, y));
if (ret)
TRACE("warped to %d,%d\n", x, y);
else
ERR("failed to warp to %d,%d\n", x, y);
return ret;
}
/***********************************************************************
* macdrv_mouse_button
*
* Handler for MOUSE_BUTTON events.
......
......@@ -22,6 +22,7 @@
@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) macdrv_MsgWaitForMultipleObjectsEx
@ cdecl ScrollDC(long long long ptr ptr long ptr) macdrv_ScrollDC
@ cdecl SetCursor(long) macdrv_SetCursor
@ cdecl SetCursorPos(long long) macdrv_SetCursorPos
@ cdecl SetFocus(long) macdrv_SetFocus
@ cdecl SetLayeredWindowAttributes(long long long long) macdrv_SetLayeredWindowAttributes
@ cdecl SetParent(long long long) macdrv_SetParent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment