Ken Thomases : winemac: Disable moving or resizing windows when cursor clipping is in effect.

Alexandre Julliard julliard at winehq.org
Tue Apr 29 13:36:12 CDT 2014


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

Author: Ken Thomases <ken at codeweavers.com>
Date:   Mon Apr 28 15:09:28 2014 -0500

winemac: Disable moving or resizing windows when cursor clipping is in effect.

Many games clip the cursor to the client area of the window.  However, on OS X,
the resizing controls extend into that client area.  So, it's possible that
while playing, the user might unintentionally click in the resizing area and
drag, resizing the window.

---

 dlls/winemac.drv/cocoa_app.h    |    2 ++
 dlls/winemac.drv/cocoa_app.m    |   14 ++++++++++++++
 dlls/winemac.drv/cocoa_window.h |    2 ++
 dlls/winemac.drv/cocoa_window.m |   19 ++++++++++++++++---
 dlls/winemac.drv/macdrv_cocoa.h |    1 +
 dlls/winemac.drv/macdrv_main.c  |    4 ++++
 6 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h
index cf168c1..0f8926d 100644
--- a/dlls/winemac.drv/cocoa_app.h
+++ b/dlls/winemac.drv/cocoa_app.h
@@ -97,6 +97,8 @@ enum {
 @property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
 @property (readonly, nonatomic) BOOL areDisplaysCaptured;
 
+ at property (readonly) BOOL clippingCursor;
+
     + (WineApplicationController*) sharedController;
 
     - (void) transformProcessToForeground;
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index dff6977..ab045b2 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -100,6 +100,8 @@ int macdrv_err_on;
     @synthesize cursorFrames, cursorTimer, cursor;
     @synthesize mouseCaptureWindow;
 
+    @synthesize clippingCursor;
+
     + (void) initialize
     {
         if (self == [WineApplicationController class])
@@ -1354,6 +1356,16 @@ int macdrv_err_on;
             [self deactivateCursorClipping];
     }
 
+    - (void) updateWindowsForCursorClipping
+    {
+        WineWindow* window;
+        for (window in [NSApp windows])
+        {
+            if ([window isKindOfClass:[WineWindow class]])
+                [window updateForCursorClipping];
+        }
+    }
+
     - (BOOL) startClippingCursor:(CGRect)rect
     {
         CGError err;
@@ -1372,6 +1384,7 @@ int macdrv_err_on;
         clippingCursor = TRUE;
         cursorClipRect = rect;
         [self updateCursorClippingState];
+        [self updateWindowsForCursorClipping];
 
         return TRUE;
     }
@@ -1384,6 +1397,7 @@ int macdrv_err_on;
 
         clippingCursor = FALSE;
         [self updateCursorClippingState];
+        [self updateWindowsForCursorClipping];
 
         return TRUE;
     }
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 68905a5..88ef23d 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -88,4 +88,6 @@
 
     - (WineWindow*) ancestorWineWindow;
 
+    - (void) updateForCursorClipping;
+
 @end
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index bb173e9..48d0651 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -628,7 +628,8 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
 
     - (BOOL) preventResizing
     {
-        return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || maximized);
+        BOOL preventForClipping = cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor];
+        return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || maximized || preventForClipping);
     }
 
     - (void) adjustFeaturesForState
@@ -659,8 +660,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
             [self setContentMinSize:savedContentMinSize];
         }
 
-        if (allow_immovable_windows)
-            [self setMovable:!disabled && !maximized];
+        if (allow_immovable_windows || cursor_clipping_locks_windows)
+        {
+            if (allow_immovable_windows && (disabled || maximized))
+                [self setMovable:NO];
+            else if (cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor])
+                [self setMovable:NO];
+            else
+                [self setMovable:YES];
+        }
     }
 
     - (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
@@ -1494,6 +1502,11 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         macdrv_release_event(event);
     }
 
+    - (void) updateForCursorClipping
+    {
+        [self adjustFeaturesForState];
+    }
+
 
     /*
      * ---------- NSWindow method overrides ----------
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 6dbaae1..d3d3ffc 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -147,6 +147,7 @@ extern int capture_displays_for_fullscreen DECLSPEC_HIDDEN;
 extern int left_option_is_alt DECLSPEC_HIDDEN;
 extern int right_option_is_alt DECLSPEC_HIDDEN;
 extern int allow_immovable_windows DECLSPEC_HIDDEN;
+extern int cursor_clipping_locks_windows DECLSPEC_HIDDEN;
 
 extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
 extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c
index 1aab785..300b1a7 100644
--- a/dlls/winemac.drv/macdrv_main.c
+++ b/dlls/winemac.drv/macdrv_main.c
@@ -55,6 +55,7 @@ int right_option_is_alt = 0;
 BOOL allow_software_rendering = FALSE;
 BOOL disable_window_decorations = FALSE;
 int allow_immovable_windows = TRUE;
+int cursor_clipping_locks_windows = TRUE;
 HMODULE macdrv_module = 0;
 
 
@@ -175,6 +176,9 @@ static void setup_options(void)
     if (!get_config_key(hkey, appkey, "AllowImmovableWindows", buffer, sizeof(buffer)))
         allow_immovable_windows = IS_OPTION_TRUE(buffer[0]);
 
+    if (!get_config_key(hkey, appkey, "CursorClippingLocksWindows", buffer, sizeof(buffer)))
+        cursor_clipping_locks_windows = IS_OPTION_TRUE(buffer[0]);
+
     if (appkey) RegCloseKey(appkey);
     if (hkey) RegCloseKey(hkey);
 }




More information about the wine-cvs mailing list