From patchwork Sun Nov 22 01:43:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 547271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0CC101402B4 for ; Sun, 22 Nov 2015 12:44:07 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=IuSkd8Fy; dkim-atps=neutral Received: from localhost ([::1]:54409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0JhE-0002QT-CU for incoming@patchwork.ozlabs.org; Sat, 21 Nov 2015 20:44:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0Jh0-00028j-Rz for qemu-devel@nongnu.org; Sat, 21 Nov 2015 20:43:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0Jgv-0003IH-Sh for qemu-devel@nongnu.org; Sat, 21 Nov 2015 20:43:50 -0500 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]:33379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0Jgv-0003ID-Ok for qemu-devel@nongnu.org; Sat, 21 Nov 2015 20:43:45 -0500 Received: by qgea14 with SMTP id a14so95906999qge.0 for ; Sat, 21 Nov 2015 17:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=0YWmC+4s/yYWwBD3rw/PQT5plpU9wTbhVANCdwO/RFA=; b=IuSkd8Fyjengml6XGKQAgjMoTkKobEgdRmf+MAt8UEmOcoU9fFAq6p7OIm4fY6naTM gseXDA78MbNdmrG8iqh56vAKsCABkBDssaStKKO2B9hWLY38tjFC7Ravn7euLKy1fGPr D2oKtX0U1vMdU//n76xugZxPKFn5NWBjjYfTg08drXYo6aZP1a2Wm6cpLWEoW6af04oG NMNazdh29yPCOxwiRJ1+WJQWIaDMZzLCIWCF45Kqzowa8ojXCGSBHS9Xl74OZpPY6P2I RmHQy7TafpIPZXT8TQ73yurS+sZi1Xpr39LTv6tLwADbVkd7WfwMweRxj/s62lI8goqQ AluQ== X-Received: by 10.140.168.8 with SMTP id o8mr21695815qho.28.1448156625339; Sat, 21 Nov 2015 17:43:45 -0800 (PST) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id r64sm1510844qkh.12.2015.11.21.17.43.44 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 21 Nov 2015 17:43:44 -0800 (PST) From: Programmingkid Date: Sat, 21 Nov 2015 20:43:43 -0500 Message-Id: To: qemu-devel qemu-devel Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::229 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- ui/cocoa.m | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 1554331..b75c01e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -669,6 +669,16 @@ QemuCocoaView *cocoaView; mouse_event = true; break; case NSLeftMouseDown: + /* + * This prevents the click that activates QEMU from being sent to + * the guest. + */ + if (!isMouseGrabbed && [self screenContainsPoint:p]) { + [self grabMouse]; + [NSApp sendEvent:event]; + return; + } + if ([event modifierFlags] & NSCommandKeyMask) { buttons |= MOUSE_EVENT_RBUTTON; } else {