winemac: When removing the status item for a systray icon, discard any associated events in the queue.
Ken Thomases
ken at codeweavers.com
Mon Aug 4 13:57:41 CDT 2014
---
dlls/winemac.drv/cocoa_event.m | 13 ++++++++++---
dlls/winemac.drv/cocoa_status_item.m | 6 ++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m
index 85cac5f..757ad6b 100644
--- a/dlls/winemac.drv/cocoa_event.m
+++ b/dlls/winemac.drv/cocoa_event.m
@@ -267,7 +267,7 @@ - (MacDrvEvent*) getEventMatchingMask:(macdrv_event_mask)mask
return ret;
}
- - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window
+ - (void) discardEventsPassingTest:(BOOL (^)(macdrv_event* event))block
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSIndexSet* indexes;
@@ -276,8 +276,7 @@ - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)
indexes = [events indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){
MacDrvEvent* event = obj;
- return ((event_mask_for_type(event->event->type) & mask) &&
- (!window || event->event->window == (macdrv_window)window));
+ return block(event->event);
}];
[events removeObjectsAtIndexes:indexes];
@@ -287,6 +286,14 @@ - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)
[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
{
macdrv_event* event;
diff --git a/dlls/winemac.drv/cocoa_status_item.m b/dlls/winemac.drv/cocoa_status_item.m
index f0a5863..c38dc51 100644
--- a/dlls/winemac.drv/cocoa_status_item.m
+++ b/dlls/winemac.drv/cocoa_status_item.m
@@ -96,6 +96,12 @@ - (void) removeFromStatusBar
NSStatusBar* statusBar = [NSStatusBar systemStatusBar];
[statusBar removeStatusItem:item];
[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;
}
}
--
1.8.5.2 (Apple Git-48)
More information about the wine-patches
mailing list