[PATCH v2 09/12] macdrv: Fix applications failing to gain or lose focus.
Elaine Lefler
elaineclefler at gmail.com
Thu Mar 24 23:46:23 CDT 2022
Wine apps no longer accept the first mouse click when the application
is inactive. This mirrors the expected behavior of Mac apps and
prevents a bug where focus is never received.
Call SetActiveWindow(NULL) on deactivate to prevent a bug where focus
is never lost.
Signed-off-by: Elaine Lefler <elaineclefler at gmail.com>
---
v2: Was PATCH 2/3. No changes from v1.
---
dlls/winemac.drv/cocoa_app.m | 9 ++++++---
dlls/winemac.drv/window.c | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index b5a3059382e..8c525333e8d 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1524,15 +1524,18 @@ - (void) handleMouseButton:(NSEvent*)theEvent
{
if (mouseCaptureWindow)
process = TRUE;
- else
+ /* Don't deliver mouse-down to an application that isn't active.
+ * This mirrors macOS's behavior and delivering the mouse event
+ * before activate can make the window fail to receive focus. */
+ else if ([[NSApplication sharedApplication] isActive])
{
- // Test if the click was in the window's content area.
+ /* Test if the click was in the window's content area. */
NSPoint nspoint = [self flippedMouseLocation:NSPointFromCGPoint(pt)];
NSRect contentRect = [window contentRectForFrameRect:[window frame]];
process = NSMouseInRect(nspoint, contentRect, NO);
if (process && [window styleMask] & NSWindowStyleMaskResizable)
{
- // Ignore clicks in the grow box (resize widget).
+ /* Ignore clicks in the grow box (resize widget). */
HIPoint origin = { 0, 0 };
HIThemeGrowBoxDrawInfo info = { 0 };
HIRect bounds;
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 4f3dbc08311..9177f493a5f 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -2415,6 +2415,7 @@ void macdrv_app_deactivated(void)
TRACE("setting fg to desktop\n");
SetForegroundWindow(GetDesktopWindow());
}
+ SetActiveWindow(NULL);
}
--
2.32.0 (Apple Git-132)
More information about the wine-devel
mailing list