mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
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.
This commit is contained in:
parent
1ee93853c2
commit
ca2d7140fb
@ -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;
|
||||
{
|
||||
[[event retain] autorelease];
|
||||
[events removeObjectAtIndex:index];
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
if (event)
|
||||
{
|
||||
[event retain];
|
||||
[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 {
|
||||
|
Loading…
Reference in New Issue
Block a user