winemac: Use floor() rather than truncation when converting Cocoa event positions to integers.

Ken Thomases ken at codeweavers.com
Wed May 4 10:11:04 CDT 2016


This is so negative coordinates are adjusted in the same direction as positive
ones (left and up).

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/winemac.drv/cocoa_app.m    | 12 ++++++------
 dlls/winemac.drv/cocoa_window.m |  8 ++++----
 dlls/winemac.drv/mouse.c        |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 176d35c..97d13e2 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1592,8 +1592,8 @@ - (void) handleMouseMove:(NSEvent*)anEvent
                     [self clipCursorLocation:&point];
 
                 event = macdrv_create_event(MOUSE_MOVED_ABSOLUTE, targetWindow);
-                event->mouse_moved.x = point.x;
-                event->mouse_moved.y = point.y;
+                event->mouse_moved.x = floor(point.x);
+                event->mouse_moved.y = floor(point.y);
 
                 mouseMoveDeltaX = 0;
                 mouseMoveDeltaY = 0;
@@ -1733,8 +1733,8 @@ - (void) handleMouseButton:(NSEvent*)theEvent
                 event = macdrv_create_event(MOUSE_BUTTON, window);
                 event->mouse_button.button = [theEvent buttonNumber];
                 event->mouse_button.pressed = pressed;
-                event->mouse_button.x = pt.x;
-                event->mouse_button.y = pt.y;
+                event->mouse_button.x = floor(pt.x);
+                event->mouse_button.y = floor(pt.y);
                 event->mouse_button.time_ms = [self ticksForEventTime:[theEvent timestamp]];
 
                 [window.queue postEvent:event];
@@ -1812,8 +1812,8 @@ - (void) handleScrollWheel:(NSEvent*)theEvent
                 BOOL continuous = FALSE;
 
                 event = macdrv_create_event(MOUSE_SCROLL, window);
-                event->mouse_scroll.x = pt.x;
-                event->mouse_scroll.y = pt.y;
+                event->mouse_scroll.x = floor(pt.x);
+                event->mouse_scroll.y = floor(pt.y);
                 event->mouse_scroll.time_ms = [self ticksForEventTime:[theEvent timestamp]];
 
                 if (CGEventGetIntegerValueField(cgevent, kCGScrollWheelEventIsContinuous))
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 3012118..1b0b655 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -2630,8 +2630,8 @@ - (NSDragOperation) draggingUpdated:(id <NSDraggingInfo>)sender
         macdrv_query* query = macdrv_create_query();
         query->type = QUERY_DRAG_OPERATION;
         query->window = (macdrv_window)[self retain];
-        query->drag_operation.x = pt.x;
-        query->drag_operation.y = pt.y;
+        query->drag_operation.x = floor(pt.x);
+        query->drag_operation.y = floor(pt.y);
         query->drag_operation.offered_ops = [sender draggingSourceOperationMask];
         query->drag_operation.accepted_op = NSDragOperationNone;
         query->drag_operation.pasteboard = (CFTypeRef)[pb retain];
@@ -2652,8 +2652,8 @@ - (BOOL) performDragOperation:(id <NSDraggingInfo>)sender
         macdrv_query* query = macdrv_create_query();
         query->type = QUERY_DRAG_DROP;
         query->window = (macdrv_window)[self retain];
-        query->drag_drop.x = pt.x;
-        query->drag_drop.y = pt.y;
+        query->drag_drop.x = floor(pt.x);
+        query->drag_drop.y = floor(pt.y);
         query->drag_drop.op = [sender draggingSourceOperationMask];
         query->drag_drop.pasteboard = (CFTypeRef)[pb retain];
 
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c
index f9130c0..f25b06d 100644
--- a/dlls/winemac.drv/mouse.c
+++ b/dlls/winemac.drv/mouse.c
@@ -697,8 +697,8 @@ BOOL CDECL macdrv_GetCursorPos(LPPOINT pos)
     if (ret)
     {
         TRACE("pointer at (%g,%g) server pos %d,%d\n", pt.x, pt.y, pos->x, pos->y);
-        pos->x = pt.x;
-        pos->y = pt.y;
+        pos->x = floor(pt.x);
+        pos->y = floor(pt.y);
     }
     return ret;
 }
-- 
2.6.2




More information about the wine-patches mailing list