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

Alexandre Julliard julliard at winehq.org
Mon Sep 6 16:15:05 CDT 2021


Module: wine
Branch: master
Commit: 0d22e8455a2e809a891df289df42113276c0a276
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0d22e8455a2e809a891df289df42113276c0a276

Author: Jan Sikorski <jsikorski at codeweavers.com>
Date:   Mon Sep  6 12:50:54 2021 +0200

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/cocoa_window.m | 19 +++++++++++++------
 dlls/winemac.drv/macdrv_cocoa.h |  1 +
 dlls/winemac.drv/window.c       |  5 +++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index eec750706a8..0926756c875 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1785,7 +1785,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
             /* 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
                it if nothing actually changed. */
-            [self windowDidResize:nil];
+            [self windowDidResize:nil skipSizeMove:TRUE];
 
             if (![self isExcludedFromWindowsMenu])
                 [NSApp addWindowsItem:self title:[self title] filename:NO];
@@ -1964,7 +1964,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
                 {
                     /* 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. */
-                    [self windowDidResize:nil];
+                    [self windowDidResize:nil skipSizeMove:TRUE];
                 }
             }
         }
@@ -2129,7 +2129,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
         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;
         NSUInteger style = self.styleMask;
@@ -2149,6 +2149,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
         event->window_frame_changed.frame = cgrect_win_from_mac(NSRectToCGRect(frame));
         event->window_frame_changed.fullscreen = isFullscreen;
         event->window_frame_changed.in_resize = resizing;
+        event->window_frame_changed.skip_size_move_loop = skipSizeMove;
         [queue postEvent:event];
         macdrv_release_event(event);
     }
@@ -2912,7 +2913,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
         macdrv_release_event(event);
     }
 
-    - (void)windowDidResize:(NSNotification *)notification
+    - (void)windowDidResize:(NSNotification *)notification skipSizeMove:(BOOL)skipSizeMove
     {
         NSRect frame = self.wine_fractionalFrame;
 
@@ -2935,12 +2936,18 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
 
         [self postWindowFrameChanged:frame
                           fullscreen:([self styleMask] & NSWindowStyleMaskFullScreen) != 0
-                            resizing:[self inLiveResize]];
+                            resizing:[self inLiveResize]
+                        skipSizeMove:skipSizeMove];
 
         [[[self contentView] inputContext] invalidateCharacterCoordinates];
         [self updateFullscreen];
     }
 
+    - (void)windowDidResize:(NSNotification *)notification
+    {
+        [self windowDidResize:notification skipSizeMove:FALSE];
+    }
+
     - (BOOL)windowShouldClose:(id)sender
     {
         macdrv_event* event = macdrv_create_event(WINDOW_CLOSE_REQUESTED, self);
@@ -2997,7 +3004,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
     - (void) windowWillExitFullScreen:(NSNotification*)notification
     {
         exitingFullScreen = TRUE;
-        [self postWindowFrameChanged:nonFullscreenFrame fullscreen:FALSE resizing:FALSE];
+        [self postWindowFrameChanged:nonFullscreenFrame fullscreen:FALSE resizing:FALSE skipSizeMove:FALSE];
     }
 
     - (void)windowWillMiniaturize:(NSNotification *)notification
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 47ae6627b9f..81840e067a9 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -443,6 +443,7 @@ typedef struct macdrv_event {
             CGRect  frame;
             int     fullscreen;
             int     in_resize;
+            int     skip_size_move_loop;
         }                                           window_frame_changed;
         struct {
             unsigned long   serial;
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 14d6a6fd1b2..622f136930c 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -2322,10 +2322,11 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event)
         flags |= SWP_NOSENDCHANGING;
     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);
         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);
     }
 }




More information about the wine-cvs mailing list