diff options
author | Ben Byer <bbyer@apple.com> | 2008-04-17 02:21:11 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-04-17 10:41:50 -0700 |
commit | a440eebf2541ae0bb06bf65281b5facff2f04e00 (patch) | |
tree | 10a75979e71a371b9559b1fa37133a80670021f5 | |
parent | 612e901ef6aa3edc54b39e55e8040cda0e5ab7b6 (diff) |
add support for horizontal scrolling (buttons 6 and 7)
(cherry picked from commit f525a4a432ebd0545ad1dd0a7ad84ad3e47e8b61)
-rw-r--r-- | hw/xquartz/X11Application.m | 2 | ||||
-rw-r--r-- | hw/xquartz/darwin.c | 11 | ||||
-rw-r--r-- | hw/xquartz/darwinEvents.c | 54 | ||||
-rw-r--r-- | hw/xquartz/darwinEvents.h | 2 |
4 files changed, 34 insertions, 35 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 4a678f8a7..28bb6fb90 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -899,7 +899,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) { break; case NSScrollWheel: - DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y, + DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y, pressure, tilt_x, tilt_y); break; diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index 002ea413d..7d81a0269 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -337,7 +337,7 @@ static int DarwinMouseProc( DeviceIntPtr pPointer, int what ) { - CARD8 map[6]; + CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7}; switch (what) { @@ -345,15 +345,10 @@ static int DarwinMouseProc( pPointer->public.on = FALSE; // Set button map. - map[1] = 1; - map[2] = 2; - map[3] = 3; - map[4] = 4; - map[5] = 5; - InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5, + InitPointerDeviceStruct( (DevicePtr)pPointer, map, 7, GetMotionHistory, (PtrCtrlProcPtr)NoopDDA, - GetMotionHistorySize(), 5); + GetMotionHistorySize(), 7); InitProximityClassDeviceStruct( (DevicePtr)pPointer); break; diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 70dfdaf7f..c4ba14656 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -1,7 +1,7 @@ /* Darwin event queue and event handling -Copyright 2007 Apple Inc. +Copyright 2007-2008 Apple Inc. Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. @@ -56,6 +56,12 @@ in this Software without prior written authorization from The Open Group. #include <unistd.h> #include <IOKit/hidsystem/IOLLEvent.h> +/* Fake button press/release for scroll wheel move. */ +#define SCROLLWHEELUPFAKE 4 +#define SCROLLWHEELDOWNFAKE 5 +#define SCROLLWHEELLEFTFAKE 6 +#define SCROLLWHEELRIGHTFAKE 7 + #define _APPLEWM_SERVER_ #include "applewmExt.h" #include <X11/extensions/applewm.h> @@ -65,10 +71,6 @@ in this Software without prior written authorization from The Open Group. #include "rootlessWindow.h" WindowPtr xprGetXWindow(xp_window_id wid); -/* Fake button press/release for scroll wheel move. */ -#define SCROLLWHEELUPFAKE 4 -#define SCROLLWHEELDOWNFAKE 5 - int input_check_zero, input_check_flag; static int old_flags = 0; // last known modifier state @@ -452,30 +454,32 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, } -/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */ -void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y, - float pressure, float tilt_x, float tilt_y) { - int i; - int ev_button = count > 0.0f ? 4 : 5; - int valuators[5] = {pointer_x, pointer_y, - pressure * INT32_MAX * 1.0f, - tilt_x * INT32_MAX * 1.0f, - tilt_y * INT32_MAX * 1.0f}; - +/* Send the appropriate number of button clicks to emulate scroll wheel */ +void DarwinSendScrollEvents(float count_x, float count_y, + int pointer_x, int pointer_y, + float pressure, float tilt_x, float tilt_y) { if(!darwinEvents) { ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n"); return; } - - for (count = fabs(count); count > 0.0; count = count - 1.0f) { - int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, - POINTER_ABSOLUTE, 0, 5, valuators); - for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]); - num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, - POINTER_ABSOLUTE, 0, 5, valuators); - for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]); - } - DarwinPokeEQ(); + ErrorF("scroll(%f, %f)\n", count_x, count_y); + int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; + int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; + count_x = fabs(count_x); + count_y = fabs(count_y); + + while ((count_x > 0.0f) || (count_y > 0.0f)) { + if (count_x > 0.0f) { + DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y); + DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y); + count_x = count_x - 1.0f; + } + if (count_y > 0.0f) { + DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y); + DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y); + count_y = count_y - 1.0f; + } + } } /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h index 7c56be9c8..98426d6ee 100644 --- a/hw/xquartz/darwinEvents.h +++ b/hw/xquartz/darwinEvents.h @@ -38,7 +38,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, float pressure, float tilt_x, float tilt_y); void DarwinSendKeyboardEvents(int ev_type, int keycode); -void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y, +void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y, float pressure, float tilt_x, float tilt_y); void DarwinUpdateModKeys(int flags); |