From patchwork Tue Jun 4 09:12:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)\" via" X-Patchwork-Id: 10976237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9BDF1515 for ; Wed, 5 Jun 2019 01:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99EE6288C3 for ; Wed, 5 Jun 2019 01:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D9B288B9; Wed, 5 Jun 2019 01:01:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6862D287EA for ; Wed, 5 Jun 2019 01:01:50 +0000 (UTC) Received: from localhost ([127.0.0.1]:33543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYKJJ-0007dN-6j for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Jun 2019 21:01:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYKI9-0006am-Oe for qemu-devel@nongnu.org; Tue, 04 Jun 2019 21:00:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYKI7-000782-8z for qemu-devel@nongnu.org; Tue, 04 Jun 2019 21:00:37 -0400 Received: from [36.106.167.139] (port=63967 helo=cusers-Mac-mini.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYKI5-00070q-9f for qemu-devel@nongnu.org; Tue, 04 Jun 2019 21:00:34 -0400 Received: by cusers-Mac-mini.local (Postfix, from userid 501) id EFE5DEFD86D; Tue, 4 Jun 2019 17:13:59 +0800 (CST) To: peter.maydell@linaro.org, kraxel@redhat.com Date: Tue, 4 Jun 2019 17:12:45 +0800 Message-Id: <0095872e709300198d5fc96f42b112a6fd724391.1559638310.git.tgfbeta@me.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Mac OS X [generic] [fuzzy] X-Received-From: 36.106.167.139 Subject: [Qemu-devel] [PATCH 2/2] ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chen Zhang via Qemu-devel From: "Zhijian Li (Fujitsu)\" via" Reply-To: Chen Zhang Cc: qemu-devel@nongnu.org, Chen Zhang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fullscreen mode, the window property of cocoaView may not be the key window, and the current implementation would not re-grab cursor by left click in fullscreen mode after ungrabbed in fullscreen mode with hot-key ctrl-opt-g. This patch used value of isFullscreen as a short-cirtuit condition for relative input device grabbing. Signed-off-by: Chen Zhang --- ui/cocoa.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 474d44cb9f..aa7cf07368 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -901,7 +901,12 @@ QemuCocoaView *cocoaView; case NSEventTypeLeftMouseUp: mouse_event = true; if (!isMouseGrabbed && [self screenContainsPoint:p]) { - if([[self window] isKeyWindow]) { + /* + * In fullscreen mode, the window of cocoaView may not be the + * key window, therefore the position relative to the virtual + * screen alone will be sufficient. + */ + if(isFullscreen || [[self window] isKeyWindow]) { [self grabMouse]; } }