From patchwork Mon Jul 9 15:02:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 941343 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; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CEONmt3F"; 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 41PT9W4dssz9rvt for ; Tue, 10 Jul 2018 01:03:27 +1000 (AEST) Received: from localhost ([::1]:42578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcXhF-0004xt-Ae for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2018 11:03:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcXgh-0004wT-GQ for qemu-devel@nongnu.org; Mon, 09 Jul 2018 11:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcXgc-0005Me-Ht for qemu-devel@nongnu.org; Mon, 09 Jul 2018 11:02:51 -0400 Received: from mail-io0-x232.google.com ([2607:f8b0:4001:c06::232]:38386) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fcXgc-0005M2-Cr for qemu-devel@nongnu.org; Mon, 09 Jul 2018 11:02:46 -0400 Received: by mail-io0-x232.google.com with SMTP id v26-v6so17335160iog.5 for ; Mon, 09 Jul 2018 08:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=meGf0TFtEcfLgcDGVmZ8GW9lkRhFsQ6meoEVNKlsJzY=; b=CEONmt3F+aO9Df1fNIsnvzuiUfEodSTPloM54wrAOR8kQauY640yPeR9D0FpkQ8nKL vZnUzFBDMn2//2uon5ETMQ+r969BWiMfSl7IPpuauVGxxOSVcnqUskY586OZ4siHNnX9 TW1OYR3oye3W7h9fgLHIVHYJbZAHILJx4DixtfkM5TKqWua/PnN5W4L4ameoeYDqyXsp bRo5wpa/rA1Woeb1pNcn8PACaC/1xwSP0RYJJTSMcObvxzt0flj1K8MsecRNSXYrrzvg 0xypUh4L+6QEQ+VS644+ym3iYoE1SRxNOOs+j/7f760lHi1Xpx5e2sH1iKVz1ZiC30j+ BbcA== 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=meGf0TFtEcfLgcDGVmZ8GW9lkRhFsQ6meoEVNKlsJzY=; b=o3l9WxIFxRIU4q32mHsWd/ZifaH2vMsXMZmADa8SWHsAcMznZEfJuuppImqd0+crou J4p6TVRPfrHVxDywYVdxEMaxeBgudxtV9EUjFWZa/+4E8G/uYI2phuS+oUZN3lMJ3Jak lLO9JzyH/fIkYxkgjS+LoKnsrGmP993eHU8vbq0RHUvtaa6wykvLNGZYDbsNJ2KSac7X /n68g82maE2EsKrB7BK4+hqyk2Xrq/mooPKbc7E4uvbGY6EfaFcKBoGQuEStkYpE59e8 eMiE9IbYYV0RlrtADFGxhnM5NBnknWRkLpNS8WLSwJGCfNQP8imOwzIVelx1/QIphskE jULA== X-Gm-Message-State: AOUpUlEVVUbGItVy9heKG/Wj46hGvFnjO+E27R1shpAG9MAdWZdTsO5U Ijp0COx9R+cXhEn+k4d36RY= X-Google-Smtp-Source: AAOMgpdc+QewMnHENNEkZFIP+MqZkyJind6NsH7q1epRPMCcVzAOLsvG9adjzjOAd2o6+LPyEYzYNQ== X-Received: by 2002:a6b:1746:: with SMTP id 67-v6mr18976600iox.292.1531148565397; Mon, 09 Jul 2018 08:02:45 -0700 (PDT) Received: from localhost.localdomain ([69.14.184.20]) by smtp.gmail.com with ESMTPSA id g6-v6sm7436175iti.0.2018.07.09.08.02.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 08:02:44 -0700 (PDT) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 9 Jul 2018 11:02:35 -0400 Message-Id: <20180709150235.7573-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::232 Subject: [Qemu-devel] [PATCH v3] ui/cocoa.m: replace scrollingDeltaY with deltaY 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" The NSEvent class method scrollingDeltaY is available for Mac OS 10.7 and newer. Since QEMU supports Mac OS 10.5 and up, we need to be using a method that is available on these version of Mac OS X. The deltaY method is a method that does the same thing as scrollingDeltaY and is available on Mac OS 10.5 and up. So we replace scrollingDeltaY with deltaY. We only check deltaY's value if it is not zero because zero means no scrolling took place. Signed-off-by: John Arbuckle --- v3 changes: - Added a comment explaining why we drop scrolling events in both the code and the patch comment. v2 changes: - Added a condition that drops scroll events that have a deltaY value of zero. ui/cocoa.m | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2991ed4f19..3bae090101 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -802,14 +802,19 @@ - (void) handleEvent:(NSEvent *)event * This is in-line with standard Mac OS X UI behaviour. */ + /* + * When deltaY is zero, it means the scrolling device did not move + * for this event. So we drop the event. + */ + if ([event deltaY] != 0) { /* 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(); - + buttons = ([event deltaY] > 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.