From 599ecd97a8fded8c00aa261535880a4d8b5d2693 Mon Sep 17 00:00:00 2001 From: Tim Clem Date: Wed, 19 Jan 2022 11:40:28 -0800 Subject: [PATCH] winemac.drv: Use -setMouseConfinementRect: for cursor clipping by default. 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 Signed-off-by: Alexandre Julliard --- 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 b0dd36f4abc..b5a3059382e 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1211,8 +1211,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 bbaa896099b..81b53c2703c 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 5c19b4f4e81..94f9fbcfa17 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 63c6a8199e0..a6a7f73e040 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]);