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)
This commit is contained in:
parent
f65a1a62f9
commit
d70487a4c0
|
@ -49,6 +49,13 @@
|
||||||
|
|
||||||
#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
|
#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 X11EnableKeyEquivalents = TRUE;
|
||||||
int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
|
int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
|
||||||
|
|
||||||
|
@ -852,27 +859,37 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
|
||||||
tilt_y = 0;
|
tilt_y = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
|
case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto check_subtype;
|
||||||
case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
|
case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto check_subtype;
|
||||||
case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
|
case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto check_subtype;
|
||||||
case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
|
case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto check_subtype;
|
||||||
case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
|
case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto check_subtype;
|
||||||
case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
|
case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto check_subtype;
|
||||||
case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
|
case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto check_subtype;
|
||||||
case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
|
case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype;
|
||||||
case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
|
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:
|
case NSTabletPoint:
|
||||||
pressure = [e pressure];
|
pressure = [e pressure];
|
||||||
tilt_x = [e tilt].x;
|
tilt_x = [e tilt].x;
|
||||||
tilt_y = [e tilt].y; // fall through
|
tilt_y = [e tilt].y;
|
||||||
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
|
// fall through to normal mouse handling
|
||||||
handle_mouse:
|
|
||||||
|
|
||||||
// if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
|
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
|
||||||
|
|
||||||
|
handle_mouse:
|
||||||
DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
|
DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
|
||||||
pressure, tilt_x, tilt_y);
|
pressure, tilt_x, tilt_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NSTabletProximity:
|
||||||
|
DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
|
||||||
|
pointer_x, pointer_y);
|
||||||
|
break;
|
||||||
|
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
|
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
|
||||||
pressure, tilt_x, tilt_y);
|
pressure, tilt_x, tilt_y);
|
||||||
|
|
|
@ -65,6 +65,10 @@ in this Software without prior written authorization from The Open Group.
|
||||||
#define SCROLLWHEELLEFTFAKE 6
|
#define SCROLLWHEELLEFTFAKE 6
|
||||||
#define SCROLLWHEELRIGHTFAKE 7
|
#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_
|
#define _APPLEWM_SERVER_
|
||||||
#include "applewmExt.h"
|
#include "applewmExt.h"
|
||||||
#include <X11/extensions/applewm.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;
|
static int darwinFakeMouseButtonMask = 0;
|
||||||
int i, num_events;
|
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) {
|
if(!darwinEvents) {
|
||||||
ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
|
ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
|
||||||
return;
|
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) {
|
if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
|
||||||
// Mimic multi-button mouse with modifier-clicks
|
// Mimic multi-button mouse with modifier-clicks
|
||||||
// If both sets of modifiers are pressed,
|
// If both sets of modifiers are pressed,
|
||||||
|
@ -450,16 +446,16 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
|
||||||
} mieqEnqueue_unlock();
|
} mieqEnqueue_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
|
||||||
float pressure, float tilt_x, float tilt_y) {
|
|
||||||
int i, num_events;
|
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) {
|
if(!darwinEvents) {
|
||||||
ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
|
ErrorF("DarwinSendProximityEvents called before darwinEvents was initialized\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
|
||||||
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
|
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
|
||||||
void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
|
void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
|
||||||
float pressure, float tilt_x, float tilt_y);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
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 DarwinSendKeyboardEvents(int ev_type, int keycode);
|
||||||
void DarwinSendScrollEvents(float count_x, float count_y, 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);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
|
|
Loading…
Reference in New Issue