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;
|
deltaY *= -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
|
DarwinSendScrollEvents(deltaX, deltaY);
|
||||||
pressure, tilt.x, tilt.y);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,10 +308,10 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
|
||||||
static int
|
static int
|
||||||
DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
||||||
{
|
{
|
||||||
#define NBUTTONS 7
|
#define NBUTTONS 3
|
||||||
#define NAXES 2
|
#define NAXES 4
|
||||||
// 7 buttons: left, right, middle, then four scroll wheel "buttons"
|
// 3 buttons: left, middle, right
|
||||||
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3};
|
||||||
Atom btn_labels[NBUTTONS] = { 0 };
|
Atom btn_labels[NBUTTONS] = { 0 };
|
||||||
Atom axes_labels[NAXES] = { 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[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||||
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||||
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
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[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
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.
|
// Set button map.
|
||||||
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
|
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
|
||||||
|
@ -336,12 +334,21 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
|
||||||
(PtrCtrlProcPtr)NoopDDA,
|
(PtrCtrlProcPtr)NoopDDA,
|
||||||
GetMotionHistorySize(), NAXES,
|
GetMotionHistorySize(), NAXES,
|
||||||
axes_labels);
|
axes_labels);
|
||||||
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS,
|
InitValuatorAxisStruct(pPointer, 0, axes_labels[0],
|
||||||
NO_AXIS_LIMITS, 1, 0, 1,
|
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||||
Relative);
|
1, 0, 1, Relative);
|
||||||
InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS,
|
InitValuatorAxisStruct(pPointer, 1, axes_labels[1],
|
||||||
NO_AXIS_LIMITS, 1, 0, 1,
|
NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||||
Relative);
|
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;
|
break;
|
||||||
|
|
||||||
case DEVICE_ON:
|
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 */
|
/* Send the appropriate number of button clicks to emulate scroll wheel */
|
||||||
void
|
void
|
||||||
DarwinSendScrollEvents(double scroll_x, double scroll_y,
|
DarwinSendScrollEvents(double scroll_x, double scroll_y) {
|
||||||
double pointer_x, double pointer_y,
|
ScreenPtr screen;
|
||||||
double pressure, double tilt_x, double tilt_y)
|
ValuatorMask valuators;
|
||||||
{
|
|
||||||
int sign_x, sign_y;
|
|
||||||
if (!darwinEvents) {
|
if (!darwinEvents) {
|
||||||
DEBUG_LOG(
|
DEBUG_LOG(
|
||||||
"DarwinSendScrollEvents called before darwinEvents was initialized\n");
|
"DarwinSendScrollEvents called before darwinEvents was initialized\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sign_x = scroll_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
|
screen = miPointerGetScreen(darwinPointer);
|
||||||
sign_y = scroll_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
|
if (!screen) {
|
||||||
scroll_x = fabs(scroll_x);
|
DEBUG_LOG(
|
||||||
scroll_y = fabs(scroll_y);
|
"DarwinSendScrollEvents called before screen was initialized\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while ((scroll_x > 0.0f) || (scroll_y > 0.0f)) {
|
valuator_mask_zero(&valuators);
|
||||||
if (scroll_x > 0.0f) {
|
valuator_mask_set_double(&valuators, 2, scroll_y);
|
||||||
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x,
|
valuator_mask_set_double(&valuators, 3, scroll_x);
|
||||||
pointer_x, pointer_y, pressure, tilt_x,
|
|
||||||
tilt_y);
|
darwinEvents_lock();
|
||||||
DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x,
|
{
|
||||||
pointer_x, pointer_y, pressure, tilt_x,
|
QueuePointerEvents(darwinPointer, MotionNotify, 0,
|
||||||
tilt_y);
|
POINTER_RELATIVE, &valuators);
|
||||||
scroll_x = scroll_x - 1.0f;
|
DarwinPokeEQ();
|
||||||
}
|
} darwinEvents_unlock();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
|
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
|
||||||
|
|
|
@ -55,9 +55,7 @@ DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
|
||||||
void
|
void
|
||||||
DarwinSendKeyboardEvents(int ev_type, int keycode);
|
DarwinSendKeyboardEvents(int ev_type, int keycode);
|
||||||
void
|
void
|
||||||
DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
|
DarwinSendScrollEvents(double scroll_x, double scroll_y);
|
||||||
double pointer_y, double pressure, double tilt_x,
|
|
||||||
double tilt_y);
|
|
||||||
void
|
void
|
||||||
DarwinUpdateModKeys(int flags);
|
DarwinUpdateModKeys(int flags);
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue