Commit 4f9de6bc authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: More thoroughly discard events which have been obsoleted by subsequent…

winemac: More thoroughly discard events which have been obsoleted by subsequent Wine- or program-driven changes. Among other things, this fixes Syberia 2. That game shows, hides, and then shows its window. Hiding it caused a WINDOW_LOST_FOCUS event to be queued. By the time it was processed, the window was the foreground window again. In response to being told it had lost focus, the game minimized its window. Hiding the window should have prevented or discarded the WINDOW_LOST_FOCUS event since the change was driven from Wine and the Win32 foreground/active window state would already be correct. In addition, when the program re-showed its window and made it foreground, that should have discarded the event as being out of date. Now they do.
parent 94cfa779
...@@ -2515,6 +2515,8 @@ void macdrv_set_mouse_capture_window(macdrv_window window) ...@@ -2515,6 +2515,8 @@ void macdrv_set_mouse_capture_window(macdrv_window window)
{ {
WineWindow* w = (WineWindow*)window; WineWindow* w = (WineWindow*)window;
[w.queue discardEventsMatchingMask:event_mask_for_type(RELEASE_CAPTURE) forWindow:w];
OnMainThread(^{ OnMainThread(^{
[[WineApplicationController sharedController] setMouseCaptureWindow:w]; [[WineApplicationController sharedController] setMouseCaptureWindow:w];
}); });
......
...@@ -269,6 +269,7 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -269,6 +269,7 @@ static const OSType WineHotKeySignature = 'Wine';
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSIndexSet* indexes; NSIndexSet* indexes;
[eventsLock lock]; [eventsLock lock];
...@@ -282,6 +283,8 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -282,6 +283,8 @@ static const OSType WineHotKeySignature = 'Wine';
[events removeObjectsAtIndexes:indexes]; [events removeObjectsAtIndexes:indexes];
[eventsLock unlock]; [eventsLock unlock];
[pool release];
} }
- (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents - (BOOL) query:(macdrv_query*)query timeout:(NSTimeInterval)timeout processEvents:(BOOL)processEvents
......
...@@ -838,7 +838,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif ...@@ -838,7 +838,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
if (state->minimized_valid) if (state->minimized_valid)
{ {
BOOL discardUnminimize = TRUE; macdrv_event_mask discard = event_mask_for_type(WINDOW_DID_UNMINIMIZE);
pendingMinimize = FALSE; pendingMinimize = FALSE;
if (state->minimized && ![self isMiniaturized]) if (state->minimized && ![self isMiniaturized])
...@@ -848,10 +848,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif ...@@ -848,10 +848,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
if ([self styleMask] & NSFullScreenWindowMask) if ([self styleMask] & NSFullScreenWindowMask)
{ {
[self postDidUnminimizeEvent]; [self postDidUnminimizeEvent];
discardUnminimize = FALSE; discard &= ~event_mask_for_type(WINDOW_DID_UNMINIMIZE);
} }
else else
{
[super miniaturize:nil]; [super miniaturize:nil];
discard |= event_mask_for_type(WINDOW_BROUGHT_FORWARD) |
event_mask_for_type(WINDOW_GOT_FOCUS) |
event_mask_for_type(WINDOW_LOST_FOCUS);
}
} }
else else
pendingMinimize = TRUE; pendingMinimize = TRUE;
...@@ -860,14 +865,11 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif ...@@ -860,14 +865,11 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
{ {
ignore_windowDeminiaturize = TRUE; ignore_windowDeminiaturize = TRUE;
[self deminiaturize:nil]; [self deminiaturize:nil];
discard |= event_mask_for_type(WINDOW_LOST_FOCUS);
} }
if (discardUnminimize) if (discard)
{ [queue discardEventsMatchingMask:discard forWindow:self];
/* Whatever events regarding minimization might have been in the queue are now stale. */
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_DID_UNMINIMIZE)
forWindow:self];
}
} }
if (state->maximized != maximized) if (state->maximized != maximized)
...@@ -1221,6 +1223,14 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif ...@@ -1221,6 +1223,14 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[controller updateFullscreenWindows]; [controller updateFullscreenWindows];
[controller adjustWindowLevels]; [controller adjustWindowLevels];
[NSApp removeWindowsItem:self]; [NSApp removeWindowsItem:self];
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_BROUGHT_FORWARD) |
event_mask_for_type(WINDOW_GOT_FOCUS) |
event_mask_for_type(WINDOW_LOST_FOCUS) |
event_mask_for_type(WINDOW_MAXIMIZE_REQUESTED) |
event_mask_for_type(WINDOW_MINIMIZE_REQUESTED) |
event_mask_for_type(WINDOW_RESTORE_REQUESTED)
forWindow:self];
} }
- (void) updateFullscreen - (void) updateFullscreen
...@@ -1399,6 +1409,10 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif ...@@ -1399,6 +1409,10 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
causing_becomeKeyWindow = self; causing_becomeKeyWindow = self;
[self makeKeyWindow]; [self makeKeyWindow];
causing_becomeKeyWindow = nil; causing_becomeKeyWindow = nil;
[queue discardEventsMatchingMask:event_mask_for_type(WINDOW_GOT_FOCUS) |
event_mask_for_type(WINDOW_LOST_FOCUS)
forWindow:self];
} }
- (void) postKey:(uint16_t)keyCode - (void) postKey:(uint16_t)keyCode
...@@ -2168,6 +2182,10 @@ void macdrv_order_cocoa_window(macdrv_window w, macdrv_window p, ...@@ -2168,6 +2182,10 @@ void macdrv_order_cocoa_window(macdrv_window w, macdrv_window p,
orAbove:next orAbove:next
activate:activate]; activate:activate];
}); });
[window.queue discardEventsMatchingMask:event_mask_for_type(WINDOW_BROUGHT_FORWARD)
forWindow:window];
[next.queue discardEventsMatchingMask:event_mask_for_type(WINDOW_BROUGHT_FORWARD)
forWindow:next];
} }
/*********************************************************************** /***********************************************************************
......
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