From patchwork Tue Mar 26 15:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1916257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=zL+i41wI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V3vPB1mqTz1yWv for ; Wed, 27 Mar 2024 02:49:18 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp90N-0004vP-Hi; Tue, 26 Mar 2024 11:46:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rp90M-0004tC-1l for qemu-ppc@nongnu.org; Tue, 26 Mar 2024 11:46:26 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp90K-0001Ld-5W for qemu-ppc@nongnu.org; Tue, 26 Mar 2024 11:46:25 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33ececeb19eso3755676f8f.3 for ; Tue, 26 Mar 2024 08:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711467983; x=1712072783; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=usUN06CXz0bBKoHDMc3RGiloPrjkbc783kJkw+v3z/k=; b=zL+i41wI2OQLyaW+F97VcEN78Tgz7Y7XJyWGQzfbgsZ9BBWGOSpDMH2++dJiFt+9Pq 533oQhTszL7C8hHLwZhaEUprwHJVHabudjQ/0vgJY6le3GfPnEygtVvoWCf3Lp4EOmKI JbXPEYGmUk+gom7bFL4f5L/lgASqYu0DwQwyvR5UdCx6KffsYr7MNky+qsXNNd3+5kDH py305Y3F4zJBgKg3HjxZeqBREQzpJQqNefSUjoWGqDE1/vjNaEKmTq1a2j9qEECBNQ+D jjyFUZpRg/cHJjf8v/BGPiIbI0+8EmYpn4+biajxt1YCzUyjMzBe8TDiB9PXcwIUBoI5 zMAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711467983; x=1712072783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=usUN06CXz0bBKoHDMc3RGiloPrjkbc783kJkw+v3z/k=; b=nJQBwDwF+LcdWUHHdHpX4WAiXIlQeMqKz+oAVxFQMRM85AxtVfYh6shMDySQ/ejlPs 4yZB4ixLQDxrVXcvQFTksy2QRvZhaCR1GWCXq4O57wP3mL6UVbGpWd64wYuYWx1EgQMc dDJIHjjXLZQfC7VXaBAOPSYMcrUogQz/ZpS4rDxqZw4Ac9rnnuZ/sFrGf6qHXWKYy+8J XrcDU8BYv7/D4j0qdbjR0RTjosknQsmxDlLE7PG13LxW7P10HaIiCjR/1CldgsRTXDcQ Hv6/hLOitqB4TawAbEFTHLwI/5tGQK7Z4sOHaoSA3FVYsqThZXzT6ahKeEwcHFU69ymL oueg== X-Forwarded-Encrypted: i=1; AJvYcCWbvk4+1nJP8kJ4Tk0FE4RLXARAfTZSx6s1WvM6YeX81/QIO0qQcL+lWOe+87ygXR/JGYKY+dawioIRl5gm+eAVdDa8 X-Gm-Message-State: AOJu0YyizVJXVlOwa7e/Y1YZP0aMpiWtc8parH5LYR42znWeamLwIHX3 6WDFL2pSyRQGDIMWKjNEZJtWyHSa+1xUos7AaH4b5sJwJEMtnDlhJCof/vY9QEk= X-Google-Smtp-Source: AGHT+IGOf6ZEMSb7TpgL4kqO++Mk9y+JX94tncdO3Hs4TvnAcC68XNkXOg4saPupWEICcD/XP/0ftg== X-Received: by 2002:a05:6000:2c1:b0:341:b836:6318 with SMTP id o1-20020a05600002c100b00341b8366318mr45533wry.11.1711467982753; Tue, 26 Mar 2024 08:46:22 -0700 (PDT) Received: from m1x-phil.lan ([176.176.155.229]) by smtp.gmail.com with ESMTPSA id dk9-20020a0560000b4900b00341cb3489b7sm6710357wrb.71.2024.03.26.08.46.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 26 Mar 2024 08:46:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 13/13] ui/cocoa: Use NSTrackingInVisibleRect Date: Tue, 26 Mar 2024 16:45:04 +0100 Message-ID: <20240326154505.8300-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240326154505.8300-1-philmd@linaro.org> References: <20240326154505.8300-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Akihiko Odaki I observed [NSTrackingArea rect] becomes de-synchronized with the view frame with some unknown condition, and fails to track mouse movement on some area of the view. Specify NSTrackingInVisibleRect option to let Cocoa automatically update NSTrackingArea, which also saves code for synchronization. Fixes: 91aa508d0274 ("ui/cocoa: Let the platform toggle fullscreen") Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Message-ID: <20240323-fixes-v2-3-18651a2b0394@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 3efa8ac1a9..25e0db9dd0 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -307,7 +307,6 @@ static void handleAnyDeviceErrors(Error * err) */ @interface QemuCocoaView : NSView { - NSTrackingArea *trackingArea; QEMUScreen screen; pixman_image_t *pixman_image; BOOL isMouseGrabbed; @@ -359,6 +358,19 @@ - (id)initWithFrame:(NSRect)frameRect self = [super initWithFrame:frameRect]; if (self) { + NSTrackingAreaOptions options = NSTrackingActiveInKeyWindow | + NSTrackingMouseEnteredAndExited | + NSTrackingMouseMoved | + NSTrackingInVisibleRect; + + NSTrackingArea *trackingArea = + [[NSTrackingArea alloc] initWithRect:CGRectZero + options:options + owner:self + userInfo:nil]; + + [self addTrackingArea:trackingArea]; + [trackingArea release]; screen.width = frameRect.size.width; screen.height = frameRect.size.height; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0 @@ -389,41 +401,9 @@ - (BOOL) isOpaque return YES; } -- (void) removeTrackingRect -{ - if (trackingArea) { - [self removeTrackingArea:trackingArea]; - [trackingArea release]; - trackingArea = nil; - } -} - -- (void) frameUpdated -{ - [self removeTrackingRect]; - - if ([self window]) { - NSTrackingAreaOptions options = NSTrackingActiveInKeyWindow | - NSTrackingMouseEnteredAndExited | - NSTrackingMouseMoved; - trackingArea = [[NSTrackingArea alloc] initWithRect:[self frame] - options:options - owner:self - userInfo:nil]; - [self addTrackingArea:trackingArea]; - [self updateUIInfo]; - } -} - - (void) viewDidMoveToWindow { [self resizeWindow]; - [self frameUpdated]; -} - -- (void) viewWillMoveToWindow:(NSWindow *)newWindow -{ - [self removeTrackingRect]; } - (void) selectConsoleLocked:(unsigned int)index @@ -1314,7 +1294,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification { [cocoaView updateBounds]; - [cocoaView frameUpdated]; + [cocoaView updateUIInfo]; } /* Called when the user clicks on a window's close button */