winemac: Allow for processing Cocoa events while waiting for query results.
This commit is contained in:
parent
bff19b1739
commit
761ad810d9
|
@ -26,6 +26,11 @@
|
|||
#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
|
||||
|
||||
|
||||
enum {
|
||||
WineApplicationEventWakeQuery,
|
||||
};
|
||||
|
||||
|
||||
@class WineEventQueue;
|
||||
@class WineWindow;
|
||||
|
||||
|
@ -87,7 +92,7 @@ - (double) ticksForEventTime:(NSTimeInterval)eventTime;
|
|||
|
||||
- (void) windowGotFocus:(WineWindow*)window;
|
||||
|
||||
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout;
|
||||
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents;
|
||||
|
||||
- (void) keyboardSelectionDidChange;
|
||||
|
||||
|
|
|
@ -172,12 +172,24 @@ - (void) transformProcessToForeground
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout
|
||||
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents
|
||||
{
|
||||
PerformRequest(NULL);
|
||||
|
||||
do
|
||||
{
|
||||
if (processEvents)
|
||||
{
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:timeout
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES];
|
||||
if (event)
|
||||
[NSApp sendEvent:event];
|
||||
[pool release];
|
||||
}
|
||||
else
|
||||
[[NSRunLoop currentRunLoop] runMode:WineAppWaitQueryResponseMode beforeDate:timeout];
|
||||
} while (!*done && [timeout timeIntervalSinceNow] >= 0);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ @interface WineEventQueue : NSObject
|
|||
- (void) postEvent:(const macdrv_event*)inEvent;
|
||||
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window;
|
||||
|
||||
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents;
|
||||
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout;
|
||||
|
||||
@end
|
||||
|
|
|
@ -252,7 +252,7 @@ - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)
|
|||
[eventsLock unlock];
|
||||
}
|
||||
|
||||
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout
|
||||
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents
|
||||
{
|
||||
macdrv_event event;
|
||||
NSDate* timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||
|
@ -264,10 +264,15 @@ - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout
|
|||
query->done = FALSE;
|
||||
|
||||
[self postEvent:&event];
|
||||
timedout = ![NSApp waitUntilQueryDone:&query->done timeout:timeoutDate];
|
||||
timedout = ![NSApp waitUntilQueryDone:&query->done timeout:timeoutDate processEvents:processEvents];
|
||||
return !timedout && query->status;
|
||||
}
|
||||
|
||||
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout
|
||||
{
|
||||
return [self query:query timeout:timeout processEvents:FALSE];
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* OnMainThread
|
||||
|
@ -470,8 +475,21 @@ void macdrv_set_query_done(macdrv_query *query)
|
|||
macdrv_retain_query(query);
|
||||
|
||||
OnMainThreadAsync(^{
|
||||
NSEvent* event;
|
||||
|
||||
query->done = TRUE;
|
||||
macdrv_release_query(query);
|
||||
|
||||
event = [NSEvent otherEventWithType:NSApplicationDefined
|
||||
location:NSZeroPoint
|
||||
modifierFlags:0
|
||||
timestamp:[[NSProcessInfo processInfo] systemUptime]
|
||||
windowNumber:0
|
||||
context:nil
|
||||
subtype:WineApplicationEventWakeQuery
|
||||
data1:0
|
||||
data2:0];
|
||||
[NSApp postEvent:event atStart:TRUE];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,8 @@ DWORD CDECL macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handle
|
|||
timeout, flags & MWMO_ALERTABLE);
|
||||
}
|
||||
|
||||
if (data->current_event) event_mask = 0; /* don't process nested events */
|
||||
if (data->current_event && data->current_event->type != QUERY_EVENT)
|
||||
event_mask = 0; /* don't process nested events */
|
||||
|
||||
if (process_events(data->queue, event_mask)) ret = count - 1;
|
||||
else if (count || timeout)
|
||||
|
|
Loading…
Reference in New Issue