winemac.drv: Omit WM_ENTER/EXITSIZEMOVE on non-interactive window changes.

The motivating example is when a newly created window gets moved off the system
menu bar. A program might not be prepared to handle these messages yet.

Fixes a crash in Lord of the Rings online.

Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 0d22e8455a)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
Jan Sikorski 2021-09-06 12:50:54 +02:00 committed by Michael Stefaniuc
parent 7a9898344d
commit cb8fde193b
3 changed files with 17 additions and 8 deletions

View File

@ -1775,7 +1775,7 @@ - (void) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)a
/* Cocoa may adjust the frame when the window is ordered onto the screen. /* Cocoa may adjust the frame when the window is ordered onto the screen.
Generate a frame-changed event just in case. The back end will ignore Generate a frame-changed event just in case. The back end will ignore
it if nothing actually changed. */ it if nothing actually changed. */
[self windowDidResize:nil]; [self windowDidResize:nil skipSizeMove:TRUE];
if (![self isExcludedFromWindowsMenu]) if (![self isExcludedFromWindowsMenu])
[NSApp addWindowsItem:self title:[self title] filename:NO]; [NSApp addWindowsItem:self title:[self title] filename:NO];
@ -1954,7 +1954,7 @@ - (void) setFrameFromWine:(NSRect)contentRect
{ {
/* In case Cocoa adjusted the frame we tried to set, generate a frame-changed /* In case Cocoa adjusted the frame we tried to set, generate a frame-changed
event. The back end will ignore it if nothing actually changed. */ event. The back end will ignore it if nothing actually changed. */
[self windowDidResize:nil]; [self windowDidResize:nil skipSizeMove:TRUE];
} }
} }
} }
@ -2114,7 +2114,7 @@ - (void) postBroughtForwardEvent
macdrv_release_event(event); macdrv_release_event(event);
} }
- (void) postWindowFrameChanged:(NSRect)frame fullscreen:(BOOL)isFullscreen resizing:(BOOL)resizing - (void) postWindowFrameChanged:(NSRect)frame fullscreen:(BOOL)isFullscreen resizing:(BOOL)resizing skipSizeMove:(BOOL)skipSizeMove
{ {
macdrv_event* event; macdrv_event* event;
NSUInteger style = self.styleMask; NSUInteger style = self.styleMask;
@ -2134,6 +2134,7 @@ - (void) postWindowFrameChanged:(NSRect)frame fullscreen:(BOOL)isFullscreen resi
event->window_frame_changed.frame = cgrect_win_from_mac(NSRectToCGRect(frame)); event->window_frame_changed.frame = cgrect_win_from_mac(NSRectToCGRect(frame));
event->window_frame_changed.fullscreen = isFullscreen; event->window_frame_changed.fullscreen = isFullscreen;
event->window_frame_changed.in_resize = resizing; event->window_frame_changed.in_resize = resizing;
event->window_frame_changed.skip_size_move_loop = skipSizeMove;
[queue postEvent:event]; [queue postEvent:event];
macdrv_release_event(event); macdrv_release_event(event);
} }
@ -2897,7 +2898,7 @@ - (void)windowDidResignKey:(NSNotification *)notification
macdrv_release_event(event); macdrv_release_event(event);
} }
- (void)windowDidResize:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification skipSizeMove:(BOOL)skipSizeMove
{ {
NSRect frame = self.wine_fractionalFrame; NSRect frame = self.wine_fractionalFrame;
@ -2920,12 +2921,18 @@ - (void)windowDidResize:(NSNotification *)notification
[self postWindowFrameChanged:frame [self postWindowFrameChanged:frame
fullscreen:([self styleMask] & NSWindowStyleMaskFullScreen) != 0 fullscreen:([self styleMask] & NSWindowStyleMaskFullScreen) != 0
resizing:[self inLiveResize]]; resizing:[self inLiveResize]
skipSizeMove:skipSizeMove];
[[[self contentView] inputContext] invalidateCharacterCoordinates]; [[[self contentView] inputContext] invalidateCharacterCoordinates];
[self updateFullscreen]; [self updateFullscreen];
} }
- (void)windowDidResize:(NSNotification *)notification
{
[self windowDidResize:notification skipSizeMove:FALSE];
}
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender
{ {
macdrv_event* event = macdrv_create_event(WINDOW_CLOSE_REQUESTED, self); macdrv_event* event = macdrv_create_event(WINDOW_CLOSE_REQUESTED, self);
@ -2982,7 +2989,7 @@ - (void) windowWillEnterFullScreen:(NSNotification*)notification
- (void) windowWillExitFullScreen:(NSNotification*)notification - (void) windowWillExitFullScreen:(NSNotification*)notification
{ {
exitingFullScreen = TRUE; exitingFullScreen = TRUE;
[self postWindowFrameChanged:nonFullscreenFrame fullscreen:FALSE resizing:FALSE]; [self postWindowFrameChanged:nonFullscreenFrame fullscreen:FALSE resizing:FALSE skipSizeMove:FALSE];
} }
- (void)windowWillMiniaturize:(NSNotification *)notification - (void)windowWillMiniaturize:(NSNotification *)notification

View File

@ -443,6 +443,7 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display,
CGRect frame; CGRect frame;
int fullscreen; int fullscreen;
int in_resize; int in_resize;
int skip_size_move_loop;
} window_frame_changed; } window_frame_changed;
struct { struct {
unsigned long serial; unsigned long serial;

View File

@ -2322,10 +2322,11 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event)
flags |= SWP_NOSENDCHANGING; flags |= SWP_NOSENDCHANGING;
if (!(flags & SWP_NOSIZE) || !(flags & SWP_NOMOVE)) if (!(flags & SWP_NOSIZE) || !(flags & SWP_NOMOVE))
{ {
if (!event->window_frame_changed.in_resize && !being_dragged) int send_sizemove = !event->window_frame_changed.in_resize && !being_dragged && !event->window_frame_changed.skip_size_move_loop;
if (send_sizemove)
SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0); SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0);
SetWindowPos(hwnd, 0, rect.left, rect.top, width, height, flags); SetWindowPos(hwnd, 0, rect.left, rect.top, width, height, flags);
if (!event->window_frame_changed.in_resize && !being_dragged) if (send_sizemove)
SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0); SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0);
} }
} }