From 51129752bc0ef5c4b2f90c1af09ed2c63d79e119 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Fri, 26 Apr 2013 04:06:12 -0500 Subject: [PATCH] winemac: For SetCursorPos(), reset positions of pending mouse button and scroll events. They are effectively deemed to have happened after the SetCursorPos(). --- dlls/winemac.drv/cocoa_app.m | 3 ++- dlls/winemac.drv/cocoa_event.h | 2 ++ dlls/winemac.drv/cocoa_event.m | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index cde93d87777..7a304a80190 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1032,8 +1032,8 @@ int macdrv_err_on; { [self clipCursorLocation:&pos]; + ret = [self warpCursorTo:&pos from:NULL]; synthesizedLocation = pos; - ret = [self warpCursorTo:&synthesizedLocation from:NULL]; if (ret) { // We want to discard mouse-move events that have already been @@ -1076,6 +1076,7 @@ int macdrv_err_on; [queue discardEventsMatchingMask:event_mask_for_type(MOUSE_MOVED) | event_mask_for_type(MOUSE_MOVED_ABSOLUTE) forWindow:nil]; + [queue resetMouseEventPositions:pos]; } [eventQueuesLock unlock]; } diff --git a/dlls/winemac.drv/cocoa_event.h b/dlls/winemac.drv/cocoa_event.h index c1afc733579..4e6bf8437a1 100644 --- a/dlls/winemac.drv/cocoa_event.h +++ b/dlls/winemac.drv/cocoa_event.h @@ -42,6 +42,8 @@ - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents; - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout; + - (void) resetMouseEventPositions:(CGPoint)pos; + @end void OnMainThread(dispatch_block_t block); diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index 1cbd5fbe007..7c41d267e34 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -280,6 +280,29 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea return [self query:query timeout:timeout processEvents:FALSE]; } + - (void) resetMouseEventPositions:(CGPoint)pos + { + MacDrvEvent* event; + + [eventsLock lock]; + + for (event in events) + { + if (event->event->type == MOUSE_BUTTON) + { + event->event->mouse_button.x = pos.x; + event->event->mouse_button.y = pos.y; + } + else if (event->event->type == MOUSE_SCROLL) + { + event->event->mouse_scroll.x = pos.x; + event->event->mouse_scroll.y = pos.y; + } + } + + [eventsLock unlock]; + } + /*********************************************************************** * OnMainThread -- 2.11.4.GIT