qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Arbuckle <programmingkidx@gmail.com>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: John Arbuckle <programmingkidx@gmail.com>
Subject: [Qemu-devel] [PATCH v3] ui/cocoa.m: replace scrollingDeltaY with deltaY
Date: Mon,  9 Jul 2018 11:02:35 -0400	[thread overview]
Message-ID: <20180709150235.7573-1-programmingkidx@gmail.com> (raw)

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 <programmingkidx@gmail.com>
---
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.
-- 
2.14.3 (Apple Git-98)

             reply	other threads:[~2018-07-09 15:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:02 John Arbuckle [this message]
2018-07-11 21:18 ` [Qemu-devel] [PATCH v3] ui/cocoa.m: replace scrollingDeltaY with deltaY Peter Maydell
2018-07-12 14:08   ` G 3
2018-07-12 15:50   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180709150235.7573-1-programmingkidx@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).