Skip to contentSkip to conversation

ui/cocoa.m: replace scrollingDeltaY with deltaY

PATCH Superseded John Arbuckle 2 participants 4 messages Jul 6, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ui/cocoa.m: replace scrollingDeltaY with deltaY

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 simply replace scrollingDeltaY with deltaY.

---
v2 changes:
- Added a condition that drops scroll events that have a deltaY value of zero.

 ui/cocoa.m | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
ui/cocoa.m +8 -7
index 2991ed4..f371469 100644
@@ -802,14 +802,15 @@ QemuCocoaView *cocoaView;
              * This is in-line with standard Mac OS X UI behaviour.
              */
 
+            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.
Signature · 1 line
2.7.2
#1 lore raw
Quoted 7 lines · John Arbuckle

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 simply replace scrollingDeltaY with deltaY.

Commit message doesn't match code change.

Quoted 13 lines

---
v2 changes:
- Added a condition that drops scroll events that have a deltaY value of zero.

 ui/cocoa.m | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
ui/cocoa.m +0 -0
index 2991ed4..f371469 100644

ui/cocoa.m QemuCocoaView *cocoaView; · line 805

Quoted 4 lines
ui/cocoa.m +1 -0
@@ -802,14 +802,15 @@ QemuCocoaView *cocoaView;
              * This is in-line with standard Mac OS X UI behaviour.
              */
 
+            if ([event deltaY] != 0) {

This could use a comment about why we need to check it.

Quoted 19 lines
ui/cocoa.m +7 -8
             /* 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.
--
Quoted 1 line

2.7.2

thanks
-- PMM

author
#2 lore raw
Quoted 10 lines · Peter Maydell
Quoted 7 lines · John Arbuckle

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 simply replace scrollingDeltaY with deltaY.

Commit message doesn't match code change.

Did you want me to add information on dropping events with a deltaY value of zero?

Quoted 18 lines
Quoted 18 lines

---
v2 changes:
- Added a condition that drops scroll events that have a deltaY value of zero.

 ui/cocoa.m | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
ui/cocoa.m +0 -0
index 2991ed4..f371469 100644
@@ -802,14 +802,15 @@ QemuCocoaView *cocoaView;
              * This is in-line with standard Mac OS X UI behaviour.
              */
 
Quoted 3 lines

ui/cocoa.m QemuCocoaView *cocoaView; · line 805

Quoted 1 line
ui/cocoa.m +1 -0
+            if ([event deltaY] != 0) {

This could use a comment about why we need to check it.

Sounds good.

Quoted 26 lines
Quoted 19 lines
ui/cocoa.m +0 -0
             /* Determine if this is a scroll up or scroll down  

event */

ui/cocoa.m +7 -7
-            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  
Quoted 4 lines

prevent mouse
* movement code from executing.
--
2.7.2

thanks
-- PMM

#3 lore raw
Quoted 14 lines · On 6 July 2018 at 15:22, G 3 <[email protected]> wrote:
Quoted 11 lines · Peter Maydell
Quoted 8 lines · John Arbuckle

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 simply replace scrollingDeltaY with deltaY.

Quoted 5 lines
Quoted 1 line

Commit message doesn't match code change.

Did you want me to add information on dropping events with a deltaY value of zero?

Yes. The code is not doing a simple replace of one method with the other, so the commit message shouldn't say it is.

thanks
-- PMM