From cbfbe092c49c92d6ff1eb0f07af92c69f3a361e9 Mon Sep 17 00:00:00 2001 From: "J?rgen P. Tjern?" Date: Thu, 8 Aug 2013 13:29:44 -0700 Subject: [PATCH] Mac: Fix mouse tap on 10.5. There's no Block support in the runtime on 10.5, so the old code wouldn't work. --- src/video/cocoa/SDL_cocoamousetap.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamousetap.m b/src/video/cocoa/SDL_cocoamousetap.m index 7f2d6e4c8..5879d49bf 100644 --- a/src/video/cocoa/SDL_cocoamousetap.m +++ b/src/video/cocoa/SDL_cocoamousetap.m @@ -131,6 +131,12 @@ return event; } +static void +SemaphorePostCallback(CFRunLoopTimerRef timer, void *info) +{ + SDL_SemPost((SDL_sem*)info); +} + static int Cocoa_MouseTapThread(void *data) { @@ -163,10 +169,11 @@ tapdata->runloop = CFRunLoopGetCurrent(); CFRunLoopAddSource(tapdata->runloop, tapdata->runloopSource, kCFRunLoopCommonModes); - CFRunLoopPerformBlock(tapdata->runloop, kCFRunLoopCommonModes, ^{ - /* We signal this *after* the run loop has started, indicating it's safe to CFRunLoopStop it. */ - SDL_SemPost(tapdata->runloopStartedSemaphore); - }); + CFRunLoopTimerContext context = {.info = tapdata->runloopStartedSemaphore}; + /* We signal the runloop started semaphore *after* the run loop has started, indicating it's safe to CFRunLoopStop it. */ + CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0, 0, 0, &SemaphorePostCallback, &context); + CFRunLoopAddTimer(tapdata->runloop, timer, kCFRunLoopCommonModes); + CFRelease(timer); /* Run the event loop to handle events in the event tap. */ CFRunLoopRun();