From patchwork Sun Feb 21 18:30:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12097581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECA40C433E0 for ; Sun, 21 Feb 2021 18:35:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A2856148E for ; Sun, 21 Feb 2021 18:35:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A2856148E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lDtZi-0006I3-CC for qemu-devel@archiver.kernel.org; Sun, 21 Feb 2021 13:35:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lDtWM-0004qG-Au for qemu-devel@nongnu.org; Sun, 21 Feb 2021 13:31:54 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:38610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lDtWH-00019W-Uu for qemu-devel@nongnu.org; Sun, 21 Feb 2021 13:31:54 -0500 Received: by mail-pj1-x1032.google.com with SMTP id l18so7282492pji.3 for ; Sun, 21 Feb 2021 10:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WzcKcf/cVBwjUvXgWgMMbJxDqMOS3ifxPSX5GwImQks=; b=Bx29NY6YwuooekxVSTNZtuWmNeUdYIKnhgaBgfMKUDAYBPGbz0KCR0ja5CxSUse5PM WPKxhVix9ikhfdVSxmtOw3JBLTO48UOHMhpx7SM+wdMPt9VCILyUnAX3QC8J3lfN9ir7 MN0NkanAsrREyCMZoFI2XKy7S/oW4Ky7NHUE02P439CF7RaTzPMD1unZC1jUYH606+74 rOOGZEkMdrcg7Qsx+xvhNWD8hpufstcZWmXVWluTsPY1WJnUl8XiFZXf0xl+FGXkWZPO Oqz13BnZ+KIkhfsdepYhu8L/aj8P7N/8im4CJyO1RzcGTunMqM9ZbnUL7hfU0y/cSS7n bdIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WzcKcf/cVBwjUvXgWgMMbJxDqMOS3ifxPSX5GwImQks=; b=DGlLgaNtgO5OOwEkkP7vceRWa6mNbd8EaKPJP/NcL8/JYh17UeqCuA2o1QkfutMPCF O9GxzdR/J28yz3mT/0M6AOlV6WM9l1LoLK0+oaiOdjDF51UJn2AzL7XkZvK7jApary8j hMcQF6zM97KCxtE3uguwsSRAIrsFU/8P2APy9HzbpKVFCMRqWcw1Po+njK+DOAd/BWQK 0Ej64Sn27Q1TWaZ8Cwnsayc3rdwT9lMg16YeHCiB2SuJvH99NP2SFbsxA6cMvosL5L9y BOCIwqgcvhUCsfNw182cWEwllEiRK5h1s9hx6M4gNtsqKb8pEpF+ApqE0IrsRbahcDfA iFCw== X-Gm-Message-State: AOAM533fdOuL8+chmBcfxO5s5e4+PefsBYsI7sjjGwKnLTsvyvUbjNdL NmMtb2XT4Z9OKvWDoz8hDbt3rshRDW26uw== X-Google-Smtp-Source: ABdhPJw9a32248jHiSD6pnvwDZAQo9sgqUHNc6qNdVpUwm1u3rhRaRbtkamIcQYoSrzplTgkiZNIDA== X-Received: by 2002:a17:90a:ab8b:: with SMTP id n11mr18980987pjq.85.1613932307511; Sun, 21 Feb 2021 10:31:47 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:b418:f77:22b4:17c9]) by smtp.gmail.com with ESMTPSA id w3sm15189831pjt.4.2021.02.21.10.31.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Feb 2021 10:31:47 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH] ui/cocoa: Fix mouse association state Date: Mon, 22 Feb 2021 03:30:55 +0900 Message-Id: <20210221183055.60338-1-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1032.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, FREEMAIL_FROM=0.001, 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-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 0ef5fdf3b7a..671af40b252 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -310,7 +310,6 @@ @interface QemuCocoaView : NSView BOOL isMouseGrabbed; BOOL isFullscreen; BOOL isAbsoluteEnabled; - BOOL isMouseDeassociated; } - (void) switchSurface:(pixman_image_t *)image; - (void) grabMouse; @@ -327,14 +326,9 @@ - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; * isMouseGrabbed tracks whether GUI events are directed to the guest; * it controls whether special keys like Cmd get sent to the guest, * and whether we capture the mouse when in non-absolute mode. - * isMouseDeassociated tracks whether we've told MacOSX to disassociate - * the mouse and mouse cursor position by calling - * CGAssociateMouseAndMouseCursorPosition(FALSE) - * (which basically happens if we grab in non-absolute mode). */ - (BOOL) isMouseGrabbed; - (BOOL) isAbsoluteEnabled; -- (BOOL) isMouseDeassociated; - (float) cdx; - (float) cdy; - (QEMUScreen) gscreen; @@ -974,10 +968,7 @@ - (void) grabMouse [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"]; } [self hideCursor]; - if (!isAbsoluteEnabled) { - isMouseDeassociated = TRUE; - CGAssociateMouseAndMouseCursorPosition(FALSE); - } + CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] } @@ -992,17 +983,18 @@ - (void) ungrabMouse [normalWindow setTitle:@"QEMU"]; } [self unhideCursor]; - if (isMouseDeassociated) { - CGAssociateMouseAndMouseCursorPosition(TRUE); - isMouseDeassociated = FALSE; - } + CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabbed = FALSE; } -- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled {isAbsoluteEnabled = tIsAbsoluteEnabled;} +- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled { + isAbsoluteEnabled = tIsAbsoluteEnabled; + if (isMouseGrabbed) { + CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); + } +} - (BOOL) isMouseGrabbed {return isMouseGrabbed;} - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;} -- (BOOL) isMouseDeassociated {return isMouseDeassociated;} - (float) cdx {return cdx;} - (float) cdy {return cdy;} - (QEMUScreen) gscreen {return screen;}