summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2012-03-25 23:33:54 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2012-03-26 10:23:10 -0700
commit31646d8fa9524adca1d7bc2cd2db90d47c2eb96e (patch)
tree9f07e6995b5dc30a201ed163aa2b6bec092ef623
parent7790dc86384cc451ac44663737fde84dd81ad4e1 (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>
-rw-r--r--hw/xquartz/X11Application.m3
-rw-r--r--hw/xquartz/darwin.c35
-rw-r--r--hw/xquartz/darwinEvents.c49
-rw-r--r--hw/xquartz/darwinEvents.h4
4 files changed, 43 insertions, 48 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index e9c3feb4a..a203f7807 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -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;
}
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 5fbfa4d27..2e0bfe6da 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -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:
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
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 3868dc672..61ace6ee3 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -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