Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b70003

Browse files
authored
Merge pull request #12080 from meeseeksmachine/auto-backport-of-pr-12053-on-v3.0.x
Backport PR #12053 on branch v3.0.x (Fix up some OSX backend issues)
2 parents 68845f8 + 480fd8a commit 0b70003

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/_macosx.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,8 +1804,16 @@ - (void)mouseEntered:(NSEvent *)event
18041804
NSWindow* window = [self window];
18051805
if ([window isKeyWindow]==false) return;
18061806

1807+
int x, y;
1808+
NSPoint location = [event locationInWindow];
1809+
location = [self convertPoint: location fromView: nil];
1810+
x = location.x * device_scale;
1811+
y = location.y * device_scale;
1812+
18071813
gstate = PyGILState_Ensure();
1808-
result = PyObject_CallMethod(canvas, "enter_notify_event", "");
1814+
result = PyObject_CallMethod(canvas, "enter_notify_event", "O(ii)",
1815+
Py_None, x, y);
1816+
18091817
if(result)
18101818
Py_DECREF(result);
18111819
else
@@ -2414,6 +2422,7 @@ static void context_cleanup(const void* info)
24142422
CFRunLoopTimerRef timer;
24152423
CFRunLoopTimerContext context;
24162424
double milliseconds;
2425+
CFAbsoluteTime firstFire;
24172426
CFTimeInterval interval;
24182427
PyObject* attribute;
24192428
PyObject* failure;
@@ -2438,12 +2447,15 @@ static void context_cleanup(const void* info)
24382447
PyErr_SetString(PyExc_AttributeError, "Timer has no attribute '_single'");
24392448
return NULL;
24402449
}
2450+
// Need to tell when to first fire this timer, so get the current time
2451+
// and add an interval.
2452+
interval = milliseconds / 1000.0;
2453+
firstFire = CFAbsoluteTimeGetCurrent() + interval;
24412454
switch (PyObject_IsTrue(attribute)) {
24422455
case 1:
24432456
interval = 0;
24442457
break;
2445-
case 0:
2446-
interval = milliseconds / 1000.0;
2458+
case 0: // Set by default above
24472459
break;
24482460
case -1:
24492461
default:
@@ -2467,7 +2479,7 @@ static void context_cleanup(const void* info)
24672479
context.copyDescription = NULL;
24682480
context.info = attribute;
24692481
timer = CFRunLoopTimerCreate(kCFAllocatorDefault,
2470-
0,
2482+
firstFire,
24712483
interval,
24722484
0,
24732485
0,

0 commit comments

Comments
 (0)