summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-04-29 23:58:47 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-04-29 23:58:47 -0700
commitc6edfc2caba6d5592c3d3e159db1534dc6bb3f55 (patch)
tree5acbb305953afe7177e6fcfbd7b95e44be540fcf
parentdd876f2c594a8e5d695dd6de487efadd5f6ac64f (diff)
XQuartz: Fix to tablet-event handling code; we now scale
more conservatively (to match Linux's Wacom driver) and we now receive all tablet-related events. (cherry picked from commit 588683cecca2cfc65a28de035cd6ee3d64ff59d2)
-rw-r--r--hw/xquartz/X11Application.m41
-rw-r--r--hw/xquartz/darwinEvents.c38
-rw-r--r--hw/xquartz/darwinEvents.h3
3 files changed, 47 insertions, 35 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index e10e71e10..646b9ef12 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -49,6 +49,13 @@
#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
+#define ProximityIn 0
+#define ProximityOut 1
+
int X11EnableKeyEquivalents = TRUE;
int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
@@ -852,27 +859,37 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
tilt_y = 0;
switch (type) {
- case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
- case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
- case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
- case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
- case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
- case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
- case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
- case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
- case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+ case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto check_subtype;
+ case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto check_subtype;
+ case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto check_subtype;
+ case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto check_subtype;
+ case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto check_subtype;
+ case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto check_subtype;
+ case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto check_subtype;
+ case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype;
+ case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto check_subtype;
+
+check_subtype:
+ if ([e subtype] != NSTabletPointEventSubtype) goto handle_mouse;
+ // fall through to get tablet data
case NSTabletPoint:
pressure = [e pressure];
tilt_x = [e tilt].x;
- tilt_y = [e tilt].y; // fall through
+ tilt_y = [e tilt].y;
+ // fall through to normal mouse handling
+
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
- handle_mouse:
-// if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
+handle_mouse:
DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
pressure, tilt_x, tilt_y);
break;
+ case NSTabletProximity:
+ DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
+ pointer_x, pointer_y);
+ break;
+
case NSScrollWheel:
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
pressure, tilt_x, tilt_y);
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 86e7704fc..cd2b49af9 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -65,6 +65,10 @@ in this Software without prior written authorization from The Open Group.
#define SCROLLWHEELLEFTFAKE 6
#define SCROLLWHEELRIGHTFAKE 7
+/* These values were chosen to match the output of xinput under Linux */
+#define SCALEFACTOR_TILT 64.0
+#define SCALEFACTOR_PRESSURE 1000.0
+
#define _APPLEWM_SERVER_
#include "applewmExt.h"
#include <X11/extensions/applewm.h>
@@ -362,26 +366,18 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
static int darwinFakeMouseButtonMask = 0;
int i, num_events;
- //DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+// DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
if(!darwinEvents) {
ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
return;
}
- /* I can't find a spec for this, but at least GTK expects that tablets are
- just like mice, except they have either one or three extra valuators, in this
- order:
-
- X coord, Y coord, pressure, X tilt, Y tilt
- Pressure and tilt should be represented natively as floats; unfortunately,
- we can't do that. Again, GTK seems to record the min/max of each valuator,
- and then perform scaling back to float itself using that info. Soo.... */
-
- int valuators[5] = {pointer_x, pointer_y,
- pressure * INT32_MAX * 1.0f,
- tilt_x * INT32_MAX * 1.0f,
- tilt_y * INT32_MAX * 1.0f};
+ int valuators[5] = {pointer_x, pointer_y, pressure * SCALEFACTOR_PRESSURE,
+ tilt_x * SCALEFACTOR_TILT, tilt_y * SCALEFACTOR_TILT};
+
+ DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n",
+ valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
// Mimic multi-button mouse with modifier-clicks
// If both sets of modifiers are pressed,
@@ -450,16 +446,16 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
} mieqEnqueue_unlock();
}
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
- float pressure, float tilt_x, float tilt_y) {
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
int i, num_events;
- int valuators[5] = {pointer_x, pointer_y,
- pressure * INT32_MAX * 1.0f,
- tilt_x * INT32_MAX * 1.0f,
- tilt_y * INT32_MAX * 1.0f};
+ // tilt and pressure have no meaning for a Prox event
+ int valuators[5] = {pointer_x, pointer_y, 0, 0, 0};
+
+ DEBUG_LOG("DarwinSendProximityEvents(%d, %d, %d)\n", ev_type, pointer_x, pointer_y);
+
if(!darwinEvents) {
- ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
+ ErrorF("DarwinSendProximityEvents called before darwinEvents was initialized\n");
return;
}
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index dd3f81c30..4a619c9ac 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -34,8 +34,7 @@ void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y);
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
- float pressure, float tilt_x, float tilt_y);
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y);
void DarwinSendKeyboardEvents(int ev_type, int keycode);
void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y);