Commit ca2d7140 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Add a delivery limit to events.

Some events are application-wide, not specific to a thread. Such an event needs to be broadcast to all GUI-attached threads because we don't know which are handling events, but we don't want the event to be processed in each. Often it should only be processed by the first to pull it from its queue.
parent 1ee93853
......@@ -413,6 +413,13 @@ int macdrv_err_on;
event->displays_changed.activating = activating;
[eventQueuesLock lock];
// If we're activating, then we just need one of our threads to get the
// event, so it can send it directly to the desktop window. Otherwise,
// we need all of the threads to get it because we don't know which owns
// the desktop window and only that one will do anything with it.
if (activating) event->deliver = 1;
for (queue in eventQueues)
[queue postEvent:event];
[eventQueuesLock unlock];
......
......@@ -198,7 +198,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
char buf[512];
int rc;
NSUInteger index;
MacDrvEvent* event;
MacDrvEvent* ret = nil;
/* Clear the pipe which signals there are pending events. */
do
......@@ -217,22 +217,27 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
[eventsLock lock];
index = 0;
for (event in events)
while (index < [events count])
{
MacDrvEvent* event = [events objectAtIndex:index];
if (event_mask_for_type(event->event->type) & mask)
break;
index++;
}
if (event)
{
[event retain];
[events removeObjectAtIndex:index];
{
[[event retain] autorelease];
[events removeObjectAtIndex:index];
if (event->event->deliver == INT_MAX ||
OSAtomicDecrement32Barrier(&event->event->deliver) >= 0)
{
ret = event;
break;
}
}
else
index++;
}
[eventsLock unlock];
return [event autorelease];
return ret;
}
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window
......@@ -416,6 +421,7 @@ macdrv_event* macdrv_create_event(int type, WineWindow* window)
event = calloc(1, sizeof(*event));
event->refs = 1;
event->deliver = INT_MAX;
event->type = type;
event->window = (macdrv_window)[window retain];
return event;
......
......@@ -176,6 +176,7 @@ typedef uint32_t macdrv_event_mask;
typedef struct macdrv_event {
int refs;
int deliver;
int type;
macdrv_window window;
union {
......
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