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: 10150235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3999A60210 for ; Mon, 8 Jan 2018 18:09:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C40126538 for ; Mon, 8 Jan 2018 18:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40B7328887; Mon, 8 Jan 2018 18:09:26 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C01D526538 for ; Mon, 8 Jan 2018 18:09:25 +0000 (UTC) Received: from localhost ([::1]:49077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbrQ-00026H-Uk for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Jan 2018 13:09:25 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;