[PATCH 5/5] winemac.drv: Use -setMouseConfinementRect: for cursor clipping by default.

Tim Clem tclem at codeweavers.com
Wed Jan 19 13:40:28 CST 2022


On macOS 10.13+, use this private NSWindow method for ClipCursor
calls. The old behavior can be restored by setting the per-app Mac
Driver registry key UseConfinementCursorClipping to N.

Signed-off-by: Tim Clem <tclem at codeweavers.com>
---
 dlls/winemac.drv/cocoa_app.m            | 8 ++++++--
 dlls/winemac.drv/cocoa_cursorclipping.m | 4 ++++
 dlls/winemac.drv/macdrv_cocoa.h         | 1 +
 dlls/winemac.drv/macdrv_main.c          | 4 ++++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index ac52a7425dd5..16d446111191 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1208,8 +1208,12 @@ - (void) updateWindowsForCursorClipping
 
     - (BOOL) startClippingCursor:(CGRect)rect
     {
-        if (!clipCursorHandler)
-            clipCursorHandler = [[WineEventTapClipCursorHandler alloc] init];
+        if (!clipCursorHandler) {
+            if (use_confinement_cursor_clipping && [WineConfinementClipCursorHandler isAvailable])
+                clipCursorHandler = [[WineConfinementClipCursorHandler alloc] init];
+            else
+                clipCursorHandler = [[WineEventTapClipCursorHandler alloc] init];
+        }
 
         if (self.clippingCursor && CGRectEqualToRect(rect, clipCursorHandler.cursorClipRect))
             return TRUE;
diff --git a/dlls/winemac.drv/cocoa_cursorclipping.m b/dlls/winemac.drv/cocoa_cursorclipping.m
index bbaa896099b3..81b53c2703cb 100644
--- a/dlls/winemac.drv/cocoa_cursorclipping.m
+++ b/dlls/winemac.drv/cocoa_cursorclipping.m
@@ -34,6 +34,10 @@
  * -[NSWindow setMouseConfinementRect:]. It comes with its own drawbacks,
  * but is generally far simpler. It is described and implemented in
  * the WineConfinementClipCursorHandler class.
+ *
+ * On macOS 10.13+, WineConfinementClipCursorHandler is the default.
+ * The Mac driver registry key UseConfinementCursorClipping can be set
+ * to "n" to use the event tap implementation.
  */
 
 
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 2c903bfb12a3..ef4e0b9205e1 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -162,6 +162,7 @@
 extern int left_command_is_ctrl DECLSPEC_HIDDEN;
 extern int right_command_is_ctrl DECLSPEC_HIDDEN;
 extern int allow_immovable_windows DECLSPEC_HIDDEN;
+extern int use_confinement_cursor_clipping DECLSPEC_HIDDEN;
 extern int cursor_clipping_locks_windows DECLSPEC_HIDDEN;
 extern int use_precise_scrolling DECLSPEC_HIDDEN;
 extern int gl_surface_mode DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c
index 63c6a8199e06..a6a7f73e0401 100644
--- a/dlls/winemac.drv/macdrv_main.c
+++ b/dlls/winemac.drv/macdrv_main.c
@@ -57,6 +57,7 @@ int right_command_is_ctrl = 0;
 BOOL allow_software_rendering = FALSE;
 BOOL disable_window_decorations = FALSE;
 int allow_immovable_windows = TRUE;
+int use_confinement_cursor_clipping = TRUE;
 int cursor_clipping_locks_windows = TRUE;
 int use_precise_scrolling = TRUE;
 int gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE;
@@ -194,6 +195,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, "UseConfinementCursorClipping", buffer, sizeof(buffer)))
+        use_confinement_cursor_clipping = IS_OPTION_TRUE(buffer[0]);
+
     if (!get_config_key(hkey, appkey, "CursorClippingLocksWindows", buffer, sizeof(buffer)))
         cursor_clipping_locks_windows = IS_OPTION_TRUE(buffer[0]);
 
-- 
2.34.1




More information about the wine-devel mailing list