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>
This commit is contained in:
parent
7790dc8638
commit
31646d8fa9
|
@ -1656,8 +1656,7 @@ handle_mouse:
|
|||
deltaY *= -1;
|
||||
}
|
||||
#endif
|
||||
DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
|
||||
pressure, tilt.x, tilt.y);
|
||||
DarwinSendScrollEvents(deltaX, deltaY);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -308,10 +308,10 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
|
|||
static int
|
||||
DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
||||
{
|
||||
#define NBUTTONS 7
|
||||
#define NAXES 2
|
||||
// 7 buttons: left, right, middle, then four scroll wheel "buttons"
|
||||
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
#define NBUTTONS 3
|
||||
#define NAXES 4
|
||||
// 3 buttons: left, middle, right
|
||||
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3};
|
||||
Atom btn_labels[NBUTTONS] = { 0 };
|
||||
Atom axes_labels[NAXES] = { 0 };
|
||||
|
||||
|
@ -322,13 +322,11 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
|||
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
||||
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
||||
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
||||
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
|
||||
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
|
||||
|
||||
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
||||
axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL);
|
||||
axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL);
|
||||
|
||||
// Set button map.
|
||||
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
|
||||
|
@ -336,12 +334,21 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
|||
(PtrCtrlProcPtr)NoopDDA,
|
||||
GetMotionHistorySize(), NAXES,
|
||||
axes_labels);
|
||||
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS,
|
||||
NO_AXIS_LIMITS, 1, 0, 1,
|
||||
Relative);
|
||||
InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS,
|
||||
NO_AXIS_LIMITS, 1, 0, 1,
|
||||
Relative);
|
||||
InitValuatorAxisStruct(pPointer, 0, axes_labels[0],
|
||||
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||
1, 0, 1, Relative);
|
||||
InitValuatorAxisStruct(pPointer, 1, axes_labels[1],
|
||||
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||
1, 0, 1, Relative);
|
||||
InitValuatorAxisStruct(pPointer, 2, axes_labels[2],
|
||||
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||
1, 0, 1, Relative);
|
||||
InitValuatorAxisStruct(pPointer, 3, axes_labels[3],
|
||||
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||
1, 0, 1, Relative);
|
||||
|
||||
SetScrollValuator(pPointer, 2, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_PREFERRED);
|
||||
SetScrollValuator(pPointer, 3, SCROLL_TYPE_HORIZONTAL, -1.0, SCROLL_FLAG_NONE);
|
||||
break;
|
||||
|
||||
case DEVICE_ON:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -55,9 +55,7 @@ DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
|
|||
void
|
||||
DarwinSendKeyboardEvents(int ev_type, int keycode);
|
||||
void
|
||||
DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
|
||||
double pointer_y, double pressure, double tilt_x,
|
||||
double tilt_y);
|
||||
DarwinSendScrollEvents(double scroll_x, double scroll_y);
|
||||
void
|
||||
DarwinUpdateModKeys(int flags);
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue
Block a user