diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-25 23:33:54 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-26 10:23:10 -0700 |
commit | 31646d8fa9524adca1d7bc2cd2db90d47c2eb96e (patch) | |
tree | 9f07e6995b5dc30a201ed163aa2b6bec092ef623 /hw/xquartz/darwinEvents.c | |
parent | 7790dc86384cc451ac44663737fde84dd81ad4e1 (diff) |
XQuartz: Use scrolling valuators
This lets use send more accurate data to Xi clients and uses dix
for legacy scroll buttons rather than reinventing the wheel.
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'hw/xquartz/darwinEvents.c')
-rw-r--r-- | hw/xquartz/darwinEvents.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 44f0639bc..c62dd4484 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -653,42 +653,33 @@ DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x, /* Send the appropriate number of button clicks to emulate scroll wheel */ void -DarwinSendScrollEvents(double scroll_x, double scroll_y, - double pointer_x, double pointer_y, - double pressure, double tilt_x, double tilt_y) -{ - int sign_x, sign_y; +DarwinSendScrollEvents(double scroll_x, double scroll_y) { + ScreenPtr screen; + ValuatorMask valuators; + if (!darwinEvents) { DEBUG_LOG( "DarwinSendScrollEvents called before darwinEvents was initialized\n"); return; } - sign_x = scroll_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; - sign_y = scroll_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; - scroll_x = fabs(scroll_x); - scroll_y = fabs(scroll_y); - - while ((scroll_x > 0.0f) || (scroll_y > 0.0f)) { - if (scroll_x > 0.0f) { - DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, - pointer_x, pointer_y, pressure, tilt_x, - tilt_y); - DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, - pointer_x, pointer_y, pressure, tilt_x, - tilt_y); - scroll_x = scroll_x - 1.0f; - } - if (scroll_y > 0.0f) { - DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, - pointer_x, pointer_y, pressure, tilt_x, - tilt_y); - DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, - pointer_x, pointer_y, pressure, tilt_x, - tilt_y); - scroll_y = scroll_y - 1.0f; - } + screen = miPointerGetScreen(darwinPointer); + if (!screen) { + DEBUG_LOG( + "DarwinSendScrollEvents called before screen was initialized\n"); + return; } + + valuator_mask_zero(&valuators); + valuator_mask_set_double(&valuators, 2, scroll_y); + valuator_mask_set_double(&valuators, 3, scroll_x); + + darwinEvents_lock(); + { + QueuePointerEvents(darwinPointer, MotionNotify, 0, + POINTER_RELATIVE, &valuators); + DarwinPokeEQ(); + } darwinEvents_unlock(); } /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to |