From patchwork Mon Jan 8 18:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 857013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MFrTfP8M"; dkim-atps=neutral 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 3zFjvT3VMZz9s7v for ; Tue, 9 Jan 2018 05:08:53 +1100 (AEDT) Received: from localhost ([::1]:49060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbqt-00013f-GZ for incoming@patchwork.ozlabs.org; Mon, 08 Jan 2018 13:08:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbpV-0000MK-IJ for qemu-devel@nongnu.org; Mon, 08 Jan 2018 13:07:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYbpR-0001xX-Ji for qemu-devel@nongnu.org; Mon, 08 Jan 2018 13:07:25 -0500 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]:45852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYbpR-0001wt-EL for qemu-devel@nongnu.org; Mon, 08 Jan 2018 13:07:21 -0500 Received: by mail-io0-x243.google.com with SMTP id e20so15511851iof.12 for ; Mon, 08 Jan 2018 10:07:21 -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; bh=p2+guRRsy4rZJ7vENASikd9O8ZzgNNvpzlvk09qJ47M=; b=MFrTfP8MRF4eSSpa6bDjecGic7PQCQjLVtfWl3bS39VPjm9+OzB9549ynFFtCK0j4v ieNMRPaKk9wnUTEyFFURfTDxwNwa2PUropWorU7kYORF2iOR+BZNtxXssEUqYxh0x2kq 5YOqxZmxWe8o9TfU+P5sjltZtsZ1h6DjUoY3S4m1czB1/nvWOmJ4qKAG/vXTT5bPtmtb Eifel5WLpCZE6AS5XWRVNaa5ESEhGUk4nWkbBdaQVwOGA0kDXN3hCj5rFhmBpux2oUJU gE9ewKAwumLZ5y2cHV9ydKF/jEvYRcJyn8yS1Tfqtb7oXR4VzMqUJV/d6sIKGPezHoxT x7DQ== 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; bh=p2+guRRsy4rZJ7vENASikd9O8ZzgNNvpzlvk09qJ47M=; b=RU7HcPheGcpN+U10swPcVTAL251XYNMKNeyKgpDRnwT31KdBaDO2sBSry1UfDJBN8M C60/8+bdDG9DMdJfd69jafufZLnIv/PMn4cG1YvlDFseCrFdueBtao2gXAEPSnXRqfGW 0V0bLJoFAkAWvz8RxQsonUNNph2CPmbiTrxCY3T+OarGf/zo1qGRcC8DEXtYFzZ2+Ea9 yLborKU9IVW4aDZlYHJtM3dG8TurLTMhqY4ePCrQHlgb/bcWc+TJd5AznYBDIrfh5NG3 AJLocPvHnLPE+ZjgwRO6f+kU0Jk7SpmY1KUzDTi/9zNitfPCycN+xA1/RY1I3MgrriFn RbUA== X-Gm-Message-State: AKwxytej3LM2+gHrLjhwnMyyQLRjnTH0J8CKSMJ6vtqr/CGlgHU7SI6z YbC2hRpMFUb8YzuVPAX9Rf9Hpw== X-Google-Smtp-Source: ACJfBos4QJ/a1NAi941j1qwbsBjBcZ1rX3OcwowDkYpLjFuwm7qqExCTuwXjugKjlGxU7+oWsV4oZQ== X-Received: by 10.107.175.208 with SMTP id p77mr12361413ioo.121.1515434840389; Mon, 08 Jan 2018 10:07:20 -0800 (PST) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id c32sm7247368ioj.28.2018.01.08.10.07.19 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jan 2018 10:07:19 -0800 (PST) From: John Arbuckle To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Mon, 8 Jan 2018 13:07:07 -0500 Message-Id: <20180108180707.7976-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::243 Subject: [Qemu-devel] [PATCH v2] cocoa.m: Fix scroll wheel support 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: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When using a mouse's scroll wheel in a guest with the cocoa front-end, the mouse pointer moves up and down instead of scrolling the window. This patch fixes this problem. Signed-off-by: John Arbuckle --- ui/cocoa.m | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 330ccebf90..6be9848391 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -786,11 +786,24 @@ - (void) handleEvent:(NSEvent *)event mouse_event = true; break; case NSEventTypeScrollWheel: - if (isMouseGrabbed) { - buttons |= ([event deltaY] < 0) ? - MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN; - } - mouse_event = true; + /* + * Send wheel events to the guest regardless of window focus. + * This is in-line with standard Mac OS X UI behaviour. + */ + + /* Determine if this is a scroll up or scroll down event */ + buttons = ([event scrollingDeltaY] > 0) ? + INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN; + qemu_input_queue_btn(dcl->con, buttons, true); + qemu_input_event_sync(); + qemu_input_queue_btn(dcl->con, buttons, false); + qemu_input_event_sync(); + + /* + * Since deltaY also reports scroll wheel events we prevent mouse + * movement code from executing. + */ + mouse_event = false; break; default: [NSApp sendEvent:event]; @@ -809,9 +822,7 @@ - (void) handleEvent:(NSEvent *)event static uint32_t bmap[INPUT_BUTTON__MAX] = { [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, - [INPUT_BUTTON_WHEEL_UP] = MOUSE_EVENT_WHEELUP, - [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN, + [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON }; qemu_input_update_buttons(dcl->con, bmap, last_buttons, buttons); last_buttons = buttons;