Ken Thomases : winemac: Avoid moving owned windows when programmatically moving the owner.

Alexandre Julliard julliard at winehq.org
Fri Nov 15 13:14:29 CST 2013


Module: wine
Branch: master
Commit: 3a03dcf09733cddd2c5b70cfa956df9a5c12437b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3a03dcf09733cddd2c5b70cfa956df9a5c12437b

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu Nov 14 20:52:07 2013 -0600

winemac: Avoid moving owned windows when programmatically moving the owner.

Cocoa normally maintains the relative position of owned windows with respect
to the owner, which differs from Windows.

---

 dlls/winemac.drv/cocoa_window.h |    1 +
 dlls/winemac.drv/cocoa_window.m |   32 ++++++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index d9130ac..ba5e34f 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -64,6 +64,7 @@
     NSTimeInterval enteredFullScreenTime;
 
     BOOL ignore_windowDeminiaturize;
+    BOOL ignore_windowResize;
     BOOL fakingClose;
 }
 
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index f7c2cd0..8b44fec 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1190,14 +1190,34 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
             frame = [self frameRectForContentRect:contentRect];
             if (!NSEqualRects(frame, oldFrame))
             {
-                if (NSEqualSizes(frame.size, oldFrame.size))
-                    [self setFrameOrigin:frame.origin];
-                else
+                BOOL equalSizes = NSEqualSizes(frame.size, oldFrame.size);
+                BOOL needEnableScreenUpdates = FALSE;
+
+                if (equalSizes && [[self childWindows] count])
                 {
-                    [self setFrame:frame display:YES];
-                    [self updateColorSpace];
+                    // If we change the window frame such that the origin moves
+                    // but the size doesn't change, then Cocoa moves child
+                    // windows with the parent.  We don't want that so we fake
+                    // a change of the size and then change it back.
+                    NSRect bogusFrame = frame;
+                    bogusFrame.size.width++;
+
+                    NSDisableScreenUpdates();
+                    needEnableScreenUpdates = TRUE;
+
+                    ignore_windowResize = TRUE;
+                    [self setFrame:bogusFrame display:NO];
+                    ignore_windowResize = FALSE;
                 }
 
+                [self setFrame:frame display:YES];
+
+                if (needEnableScreenUpdates)
+                    NSEnableScreenUpdates();
+
+                if (!equalSizes)
+                    [self updateColorSpace];
+
                 if (!enteringFullScreen &&
                     [[NSProcessInfo processInfo] systemUptime] - enteredFullScreenTime > 1.0)
                     nonFullscreenFrame = frame;
@@ -1683,7 +1703,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         macdrv_event* event;
         NSRect frame = [self contentRectForFrameRect:[self frame]];
 
-        if (exitingFullScreen) return;
+        if (ignore_windowResize || exitingFullScreen) return;
 
         if (self.disabled)
         {




More information about the wine-cvs mailing list