winemac: Post WINDOW_FRAME_CHANGED with the non-fullscreen frame when exiting of fullscreen mode begins.

Ken Thomases ken at codeweavers.com
Mon Oct 10 22:38:13 CDT 2016


We had been posting it when exiting fullscreen mode ended.  However, certain
events during exiting could provoke the back-end to assert the window frame as
it knows it, which would be the one from full-screen mode.  This would be
handled by the Cocoa thread after exiting full-screen mode.  So, the window
would animate to its pre-fullscreen frame and then spontaneously go back to
covering the screen.  This would be Windows-style fullscreen rather than
Cocoa-style and there'd be no obvious way to get out.

The problem occurs on macOS 10.12 (Sierra) due to a change in what methods it
calls on the window while exiting fullscreen.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/winemac.drv/cocoa_window.m | 48 ++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 8e8ac9f..e638991 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1842,6 +1842,30 @@ - (void) postBroughtForwardEvent
         macdrv_release_event(event);
     }
 
+    - (void) postWindowFrameChanged:(NSRect)frame fullscreen:(BOOL)isFullscreen resizing:(BOOL)resizing
+    {
+        macdrv_event* event;
+        NSUInteger style = self.styleMask;
+
+        if (isFullscreen)
+            style |= NSFullScreenWindowMask;
+        else
+            style &= ~NSFullScreenWindowMask;
+        frame = [[self class] contentRectForFrameRect:frame styleMask:style];
+        [[WineApplicationController sharedController] flipRect:&frame];
+
+        /* Coalesce events by discarding any previous ones still in the queue. */
+        [queue discardEventsMatchingMask:event_mask_for_type(WINDOW_FRAME_CHANGED)
+                               forWindow:self];
+
+        event = macdrv_create_event(WINDOW_FRAME_CHANGED, self);
+        event->window_frame_changed.frame = cgrect_win_from_mac(NSRectToCGRect(frame));
+        event->window_frame_changed.fullscreen = isFullscreen;
+        event->window_frame_changed.in_resize = resizing;
+        [queue postEvent:event];
+        macdrv_release_event(event);
+    }
+
     - (void) updateForCursorClipping
     {
         [self adjustFeaturesForState];
@@ -2589,7 +2613,6 @@ - (void)windowDidResignKey:(NSNotification *)notification
 
     - (void)windowDidResize:(NSNotification *)notification
     {
-        macdrv_event* event;
         NSRect frame = self.wine_fractionalFrame;
 
         if ([self inLiveResize])
@@ -2600,28 +2623,18 @@ - (void)windowDidResize:(NSNotification *)notification
                 resizingFromTop = TRUE;
         }
 
-        frame = [self contentRectForFrameRect:frame];
-
         if (ignore_windowResize || exitingFullScreen) return;
 
         if ([self preventResizing])
         {
-            [self setContentMinSize:frame.size];
-            [self setContentMaxSize:frame.size];
+            NSRect contentRect = [self contentRectForFrameRect:frame];
+            [self setContentMinSize:contentRect.size];
+            [self setContentMaxSize:contentRect.size];
         }
 
-        [[WineApplicationController sharedController] flipRect:&frame];
-
-        /* Coalesce events by discarding any previous ones still in the queue. */
-        [queue discardEventsMatchingMask:event_mask_for_type(WINDOW_FRAME_CHANGED)
-                               forWindow:self];
-
-        event = macdrv_create_event(WINDOW_FRAME_CHANGED, self);
-        event->window_frame_changed.frame = cgrect_win_from_mac(NSRectToCGRect(frame));
-        event->window_frame_changed.fullscreen = ([self styleMask] & NSFullScreenWindowMask) != 0;
-        event->window_frame_changed.in_resize = [self inLiveResize];
-        [queue postEvent:event];
-        macdrv_release_event(event);
+        [self postWindowFrameChanged:frame
+                          fullscreen:([self styleMask] & NSFullScreenWindowMask) != 0
+                            resizing:[self inLiveResize]];
 
         [[[self contentView] inputContext] invalidateCharacterCoordinates];
         [self updateFullscreen];
@@ -2683,6 +2696,7 @@ - (void) windowWillEnterFullScreen:(NSNotification*)notification
     - (void) windowWillExitFullScreen:(NSNotification*)notification
     {
         exitingFullScreen = TRUE;
+        [self postWindowFrameChanged:nonFullscreenFrame fullscreen:FALSE resizing:FALSE];
     }
 
     - (void)windowWillMiniaturize:(NSNotification *)notification
-- 
2.8.2




More information about the wine-patches mailing list