Commit 761ad810 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Allow for processing Cocoa events while waiting for query results.

parent bff19b17
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false) #define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
enum {
WineApplicationEventWakeQuery,
};
@class WineEventQueue; @class WineEventQueue;
@class WineWindow; @class WineWindow;
...@@ -87,7 +92,7 @@ ...@@ -87,7 +92,7 @@
- (void) windowGotFocus:(WineWindow*)window; - (void) windowGotFocus:(WineWindow*)window;
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout; - (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents;
- (void) keyboardSelectionDidChange; - (void) keyboardSelectionDidChange;
......
...@@ -172,13 +172,25 @@ int macdrv_err_on; ...@@ -172,13 +172,25 @@ int macdrv_err_on;
} }
} }
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout - (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents
{ {
PerformRequest(NULL); PerformRequest(NULL);
do do
{ {
[[NSRunLoop currentRunLoop] runMode:WineAppWaitQueryResponseMode beforeDate:timeout]; 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); } while (!*done && [timeout timeIntervalSinceNow] >= 0);
return *done; return *done;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
- (void) postEvent:(const macdrv_event*)inEvent; - (void) postEvent:(const macdrv_event*)inEvent;
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window; - (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; - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout;
@end @end
......
...@@ -252,7 +252,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea ...@@ -252,7 +252,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
[eventsLock unlock]; [eventsLock unlock];
} }
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents
{ {
macdrv_event event; macdrv_event event;
NSDate* timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout]; NSDate* timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout];
...@@ -264,10 +264,15 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea ...@@ -264,10 +264,15 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
query->done = FALSE; query->done = FALSE;
[self postEvent:&event]; [self postEvent:&event];
timedout = ![NSApp waitUntilQueryDone:&query->done timeout:timeoutDate]; timedout = ![NSApp waitUntilQueryDone:&query->done timeout:timeoutDate processEvents:processEvents];
return !timedout && query->status; return !timedout && query->status;
} }
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout
{
return [self query:query timeout:timeout processEvents:FALSE];
}
/*********************************************************************** /***********************************************************************
* OnMainThread * OnMainThread
...@@ -470,8 +475,21 @@ void macdrv_set_query_done(macdrv_query *query) ...@@ -470,8 +475,21 @@ void macdrv_set_query_done(macdrv_query *query)
macdrv_retain_query(query); macdrv_retain_query(query);
OnMainThreadAsync(^{ OnMainThreadAsync(^{
NSEvent* event;
query->done = TRUE; query->done = TRUE;
macdrv_release_query(query); 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 ...@@ -240,7 +240,8 @@ DWORD CDECL macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handle
timeout, flags & MWMO_ALERTABLE); 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; if (process_events(data->queue, event_mask)) ret = count - 1;
else if (count || timeout) else if (count || timeout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment