diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 2ac8a8c8e..726ddb443 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -903,7 +903,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 e39779554..2232cf507 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 #include +/* 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 @@ -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 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);