winemac: When removing the status item for a systray icon, discard any associated events in the queue.

This commit is contained in:
Ken Thomases 2014-08-05 19:11:09 -05:00 committed by Alexandre Julliard
parent ba57f57209
commit 9d1cfecc6d
2 changed files with 16 additions and 3 deletions

View File

@ -267,7 +267,7 @@ - (MacDrvEvent*) getEventMatchingMask:(macdrv_event_mask)mask
return ret; return ret;
} }
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window - (void) discardEventsPassingTest:(BOOL (^)(macdrv_event* event))block
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSIndexSet* indexes; NSIndexSet* indexes;
@ -276,8 +276,7 @@ - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)
indexes = [events indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){ indexes = [events indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){
MacDrvEvent* event = obj; MacDrvEvent* event = obj;
return ((event_mask_for_type(event->event->type) & mask) && return block(event->event);
(!window || event->event->window == (macdrv_window)window));
}]; }];
[events removeObjectsAtIndexes:indexes]; [events removeObjectsAtIndexes:indexes];
@ -287,6 +286,14 @@ - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)
[pool release]; [pool release];
} }
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window
{
[self discardEventsPassingTest:^BOOL (macdrv_event* event){
return ((event_mask_for_type(event->type) & mask) &&
(!window || event->window == (macdrv_window)window));
}];
}
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents
{ {
macdrv_event* event; macdrv_event* event;

View File

@ -96,6 +96,12 @@ - (void) removeFromStatusBar
NSStatusBar* statusBar = [NSStatusBar systemStatusBar]; NSStatusBar* statusBar = [NSStatusBar systemStatusBar];
[statusBar removeStatusItem:item]; [statusBar removeStatusItem:item];
[item setView:nil]; [item setView:nil];
[queue discardEventsPassingTest:^BOOL (macdrv_event* event){
return ((event->type == STATUS_ITEM_MOUSE_BUTTON && event->status_item_mouse_button.item == (macdrv_status_item)self) ||
(event->type == STATUS_ITEM_MOUSE_MOVE && event->status_item_mouse_move.item == (macdrv_status_item)self));
}];
self.item = nil; self.item = nil;
} }
} }