From patchwork Thu Nov 26 01:14:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 548889 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 CC6B91402DD for ; Thu, 26 Nov 2015 12:15: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=prvuK39L; dkim-atps=neutral Received: from localhost ([::1]:48610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1l9N-0005wC-Ak for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2015 20:15:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1l98-0005f6-A4 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 20:14:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1l95-0001cp-1Z for qemu-devel@nongnu.org; Wed, 25 Nov 2015 20:14:50 -0500 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:34102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1l94-0001cl-Tl for qemu-devel@nongnu.org; Wed, 25 Nov 2015 20:14:46 -0500 Received: by qgeb1 with SMTP id b1so45435283qge.1 for ; Wed, 25 Nov 2015 17:14:46 -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=MMVhwYm9Ut7oR6hpit7oDse6bo/o+Nkyzu1Jy6dqJm0=; b=prvuK39L+LBi+J+LjdG4wMSDhxU+qyim6J+oxbgcUJfhy+8HBq9O+k7N9NiMr3vAK5 wpCWqYNobCmxeGwXnECVQrpo3tnvJFd0tGCG03nTiwKafh8GBhwVER4Rr2adbBvSgDy6 Mvl2zsOokD2xMrZWWxnvOMLPgADhJWgK4TAJLEcg7nOiQlEgTvI4z0l2ytx459A9x4FB 6ah1OwfpEvSDDRIiu2aAhqdtTmB6ekNGiNBAej92J0odUdz8vhL2Wbkj/jDXXMUnHzV2 k0laRDGRnk83o/040rMlQKfL0gg5IIXPSrsRyC66bDCB+nmVhmwjos2CIg4Bv79roI51 LS8w== X-Received: by 10.140.36.232 with SMTP id p95mr6621403qgp.55.1448500486518; Wed, 25 Nov 2015 17:14:46 -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 u45sm6380328qgd.26.2015.11.25.17.14.44 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Nov 2015 17:14:45 -0800 (PST) From: Programmingkid Date: Wed, 25 Nov 2015 20:14:43 -0500 Message-Id: To: Peter Maydell 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::234 Cc: qemu-devel qemu-devel Subject: [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+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 --- Added code that handles the right mouse button and the other mouse button. ui/cocoa.m | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 7730d0f..f23f5fd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -696,6 +696,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 { @@ -704,10 +714,22 @@ QemuCocoaView *cocoaView; mouse_event = true; break; case NSRightMouseDown: + if (!isMouseGrabbed && [self screenContainsPoint:p]) { + [self grabMouse]; + [NSApp sendEvent:event]; + return; + } + buttons |= MOUSE_EVENT_RBUTTON; mouse_event = true; break; case NSOtherMouseDown: + if (!isMouseGrabbed && [self screenContainsPoint:p]) { + [self grabMouse]; + [NSApp sendEvent:event]; + return; + } + buttons |= MOUSE_EVENT_MBUTTON; mouse_event = true; break;