Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Mac: Fix mouse tap on 10.5.
Browse files Browse the repository at this point in the history
There's no Block support in the runtime on 10.5, so the old code
wouldn't work.
  • Loading branch information
jorgenpt committed Aug 8, 2013
1 parent f79d823 commit cbfbe09
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/video/cocoa/SDL_cocoamousetap.m
Expand Up @@ -131,6 +131,12 @@
return event;
}

static void
SemaphorePostCallback(CFRunLoopTimerRef timer, void *info)
{
SDL_SemPost((SDL_sem*)info);
}

static int
Cocoa_MouseTapThread(void *data)
{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit cbfbe09

Please sign in to comment.