I am writing an application that does a blocking operation on the main thread using dispatch_sync_f
when toggled (input from keyboard). I have a while loop inside the function that was passed to dispatch_sync_f
that performs some routines. To ensure window events are processed while in this loop, I wrote the following and pass it along.
event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:nil
inMode:NSDefaultRunLoopMode
dequeue:YES];
[NSApp sendEvent:event]
However, when I try to go fullscreen (green button) it is stuck until this blocking function is untoggled. I thought I was passing along all events any keyboard/mouse input to the window is processed. But going fullscreen may not have been an event in this case. Is there a way to detect fullscreen event and pass it to the window while the main thread is blocked?