From patchwork Sat Dec 30 16:30:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 10137833 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 7040960375 for ; Sat, 30 Dec 2017 16:31:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE08286A8 for ; Sat, 30 Dec 2017 16:31:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E58728757; Sat, 30 Dec 2017 16:31:23 +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 1A240286A8 for ; Sat, 30 Dec 2017 16:31:21 +0000 (UTC) Received: from localhost ([::1]:59699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVK2a-00070t-ST for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Dec 2017 11:31:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVK1j-0006Zz-7A for qemu-devel@nongnu.org; Sat, 30 Dec 2017 11:30:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eVK1e-0007Jy-Rr for qemu-devel@nongnu.org; Sat, 30 Dec 2017 11:30:26 -0500 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:39164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eVK1e-0007J0-NF for qemu-devel@nongnu.org; Sat, 30 Dec 2017 11:30:22 -0500 Received: by mail-io0-x244.google.com with SMTP id g70so31162864ioj.6 for ; Sat, 30 Dec 2017 08:30:22 -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=/XHroQKUZLSaGqrxKJMiuUje9UUkOV3QyPZ4a9otkN4=; b=UdcsK9brJ9UxnoL+/eqH9WU0A2AuzKfyIiA0n+TVFcAAEB8lrfKuQbPM9DjghXSfyE ZkZdrmBXmyXKDMheaFpNCdM9mU2CAjrhcTH2ZlHRaOdKBPqifSHPGVVkf37UB7e7Sw0R k5kpzGJnoESRFvodp89X9kEzoD+jvIrTg6h+PTWiCOEC4O0XZ7SfnbnOK2KlIFORTIUp wQg3ialpe62Vg4DjKfnTsmuGZqpzIH4/kne7IedFpV6LTVGKSgCDQhITEoLW/N1o2Sqm sAKMNS0ivPV7buouwM+4emhnVXVnlnV+38lRiJ1brTXDvuDM+x6VflQzEljeQC+4Rh4n qdTw== 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=/XHroQKUZLSaGqrxKJMiuUje9UUkOV3QyPZ4a9otkN4=; b=kftyxjvrZuA/3B8/VW0ZV6Dk5FsW0ju/BTE7v2ckqZN0oKQFnbfdv0Y6OngveLpCwK HVzukYbB+xyOXVNDFWZ8L50o2lC5H9EM0ReuWJXEgFCoJGJruTvIUEoDWkYCxh0bKX3f waTEvqZU09CkyjreUK+XjU9VP0+J02v3t6HY2mTxvEm5g08oOwJMxx7NxPRgn+VcpYq9 Lp4F0l2QKSXINUh5ibV3UGvL1xFfT23YBePIjTew3M3YlvYR8ZifW858xBU4pf7fDhDg +XMJeaY/RFoHEJyF64aG7HHyS36KTBFlHcfumxCTeNrGZSnION+qYnhaRASOpLTcTkr2 s5rQ== X-Gm-Message-State: AKGB3mKFxIcuOMmr5+NHxGq9dPl1mPCmcoEUuf2rabd9MRwvHtNIexF6 Gny92H6LlLgHzSvdJLpcEwk= X-Google-Smtp-Source: ACJfBouqbZ1/nWVqEUAJkjcS29xdheLYbkQ8pEqn5VKbpxO+SomhygnqKTmMi65Ay1PQ7fT1DDWfdA== X-Received: by 10.107.161.16 with SMTP id k16mr11888812ioe.81.1514651421839; Sat, 30 Dec 2017 08:30:21 -0800 (PST) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id g79sm13987796itb.29.2017.12.30.08.30.20 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 30 Dec 2017 08:30:21 -0800 (PST) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Sat, 30 Dec 2017 11:30:12 -0500 Message-Id: <20171230163012.95032-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::244 Subject: [Qemu-devel] [PATCH] 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 330ccebf90..d2e5f80b74 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -786,11 +786,18 @@ - (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; + /* 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];