From 480fd8a750b410077bd4147bf98ffbf255acc1de Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Mon, 10 Sep 2018 09:50:36 -0700 Subject: [PATCH] Backport PR #12053: Fix up some OSX backend issues --- src/_macosx.m | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/_macosx.m b/src/_macosx.m index 119fc1b8d622..ce791d1f9d21 100644 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -1804,8 +1804,16 @@ - (void)mouseEntered:(NSEvent *)event NSWindow* window = [self window]; if ([window isKeyWindow]==false) return; + int x, y; + NSPoint location = [event locationInWindow]; + location = [self convertPoint: location fromView: nil]; + x = location.x * device_scale; + y = location.y * device_scale; + gstate = PyGILState_Ensure(); - result = PyObject_CallMethod(canvas, "enter_notify_event", ""); + result = PyObject_CallMethod(canvas, "enter_notify_event", "O(ii)", + Py_None, x, y); + if(result) Py_DECREF(result); else @@ -2414,6 +2422,7 @@ static void context_cleanup(const void* info) CFRunLoopTimerRef timer; CFRunLoopTimerContext context; double milliseconds; + CFAbsoluteTime firstFire; CFTimeInterval interval; PyObject* attribute; PyObject* failure; @@ -2438,12 +2447,15 @@ static void context_cleanup(const void* info) PyErr_SetString(PyExc_AttributeError, "Timer has no attribute '_single'"); return NULL; } + // Need to tell when to first fire this timer, so get the current time + // and add an interval. + interval = milliseconds / 1000.0; + firstFire = CFAbsoluteTimeGetCurrent() + interval; switch (PyObject_IsTrue(attribute)) { case 1: interval = 0; break; - case 0: - interval = milliseconds / 1000.0; + case 0: // Set by default above break; case -1: default: @@ -2467,7 +2479,7 @@ static void context_cleanup(const void* info) context.copyDescription = NULL; context.info = attribute; timer = CFRunLoopTimerCreate(kCFAllocatorDefault, - 0, + firstFire, interval, 0, 0,