From patchwork Thu Nov 26 11:45:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 57326 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp462759lbb; Thu, 26 Nov 2015 03:46:01 -0800 (PST) X-Received: by 10.55.72.23 with SMTP id v23mr37663460qka.24.1448538361480; Thu, 26 Nov 2015 03:46:01 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q78si25946286qhb.6.2015.11.26.03.46.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Nov 2015 03:46:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([::1]:50602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1uzx-0003A5-4K for patch@linaro.org; Thu, 26 Nov 2015 06:46:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1uzR-0002sW-JN for qemu-devel@nongnu.org; Thu, 26 Nov 2015 06:45:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1uzQ-0004SV-Oh for qemu-devel@nongnu.org; Thu, 26 Nov 2015 06:45:29 -0500 Received: from mail-vk0-x233.google.com ([2607:f8b0:400c:c05::233]:35330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1uzQ-0004Rj-GW for qemu-devel@nongnu.org; Thu, 26 Nov 2015 06:45:28 -0500 Received: by vkha189 with SMTP id a189so51908460vkh.2 for ; Thu, 26 Nov 2015 03:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=MmUpal3Dgvq2Zw5+I06i9QTzC3aBqHGaSNR2xIAfyjQ=; b=HDH1JfR0vq5fbiUYALuPq+HzMqIiKzfjoMbCeSz1MuOGbDf7ZrRYkFHmgu9BOPTRQ3 VxzG2Wp9RKJW7j7vZhwqqefqgSKw7pZrwUUbYK6hp84tKf64+oSqp1OxvR2aj/GwHif8 bZ4fBpU5Ktw60N/cECYvIydmYveVXzuZe9MD1ifWCGbdEfNgQFbdbkBj1A36oI/6b9a1 wYRS8SE/My935bsI5Mfq6RADOoV/74gE6GEEHF1tS8/tgk2ICU5mxWUho3VYBE5XCPw8 WlzlIhVwRUhvlWhniwO1gvMdv+5nNJTdcacHVwDh+B1vmUT5o3wG0elmk08Uwe98tYxl /p7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=MmUpal3Dgvq2Zw5+I06i9QTzC3aBqHGaSNR2xIAfyjQ=; b=d6Qebs8E4m+gX+sSDwEIej+Srkr303ZngOPSmPBxQjZOxitG6rzDRfmbEbzaYi6Lq4 0NVLFRbbu1vDpMqWm3x5PwggZbhZox6p163q38a/AoWmUAWDJoixrYD4g0yc/kJdQrS7 1npKx8WXgH940L+OWpy2hMWH4WE/IOgWup0GkmjdG/MdZkXcWmIR3XbP9vr1Sylpq9es rE8jy+Pn7cK6Ck+AsxsiT4csYYHR31+G2SnlnuJW9ZPT241VMStj8/RVXds1aQI6qPCi OUWEzNUQs6stkXSbKoLmYq/uVmQpKFiOXetN19pw2jVF+DyCNzIhSfO+aMbkdfsrmQtg g//g== X-Gm-Message-State: ALoCoQldYs7p/+uHoC4QG4vui1NSc3M9JrfkuV2o7wxvMJX6RtOtXd2VXc/kQKxLBNCsDPE2NR1o X-Received: by 10.31.131.201 with SMTP id f192mr38770339vkd.90.1448538328029; Thu, 26 Nov 2015 03:45:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.153.15 with HTTP; Thu, 26 Nov 2015 03:45:07 -0800 (PST) In-Reply-To: References: From: Peter Maydell Date: Thu, 26 Nov 2015 11:45:07 +0000 Message-ID: To: Programmingkid X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c05::233 Cc: qemu-devel qemu-devel Subject: Re: [Qemu-devel] [PATCH v2] ui/cocoa.m: Prevent activation clicks from going to guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org On 26 November 2015 at 01:14, Programmingkid wrote: > When QEMU is brought to the foreground, the click event that activates QEMU > should not go to the guest. Accidents happen when they do go to the guest > without giving the user a change to handle them. Buttons are clicked accidently. > Windows are closed accidently. Volumes are unmounted accidently. This patch > prevents these accidents from happening. > > Signed-off-by: John Arbuckle > > --- > Added code that handles the right mouse button and the other mouse button. This seems like a fair bit of repeated code. Does the change below do the right thing? I think it ought to work but I don't have any guests handy which use the mouse to check with. (if this is the activation click then we will do the mousegrab on mouse-button-up so it's not necessary to do it on button-down, I think.) thanks -- PMM diff --git a/ui/cocoa.m b/ui/cocoa.m index 1554331..d76b942 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -724,7 +724,15 @@ QemuCocoaView *cocoaView; } if (mouse_event) { - if (last_buttons != buttons) { + /* Don't send button events to the guest unless we've got a + * mouse grab or window focus. If we have neither then this event + * is the user clicking on the background window to activate and + * bring us to the front, which will be done by the sendEvent + * call below. We definitely don't want to pass that click through + * to the guest. + */ + if ((isMouseGrabbed || [[self window] isKeyWindow]) && + (last_buttons != buttons)) { static uint32_t bmap[INPUT_BUTTON_MAX] = { [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,