XQuartz: Send tablet proximity events with tilt and pressure
<rdar://problem/6257569> Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
parent
034538ea9b
commit
72bd232b11
|
@ -1079,13 +1079,29 @@ static const char *untrusted_str(NSEvent *e) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (void) sendX11NSEvent:(NSEvent *)e {
|
- (void) sendX11NSEvent:(NSEvent *)e {
|
||||||
NSPoint location = NSZeroPoint, tilt = NSZeroPoint;
|
NSPoint location = NSZeroPoint;
|
||||||
int ev_button, ev_type;
|
int ev_button, ev_type;
|
||||||
float pressure = 0.0;
|
static float pressure = 0.0; // static so ProximityOut will have the value from the previous tablet event
|
||||||
|
static NSPoint tilt; // static so ProximityOut will have the value from the previous tablet event
|
||||||
|
static DeviceIntPtr darwinTabletCurrent = NULL;
|
||||||
|
static BOOL needsProximityIn = NO; // Do we do need to handle a pending ProximityIn once we have pressure/tilt?
|
||||||
DeviceIntPtr pDev;
|
DeviceIntPtr pDev;
|
||||||
int modifierFlags;
|
int modifierFlags;
|
||||||
BOOL isMouseOrTabletEvent, isTabletEvent;
|
BOOL isMouseOrTabletEvent, isTabletEvent;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBDISPATCH
|
||||||
|
static dispatch_once_t once_pred;
|
||||||
|
dispatch_once(&once_pred, ^{
|
||||||
|
tilt = NSZeroPoint;
|
||||||
|
darwinTabletCurrent = darwinTabletStylus;
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
if(!darwinTabletCurrent) {
|
||||||
|
tilt = NSZeroPoint;
|
||||||
|
darwinTabletCurrent = darwinTabletStylus;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
|
isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
|
||||||
[e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
|
[e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
|
||||||
[e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
|
[e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
|
||||||
|
@ -1208,18 +1224,13 @@ static const char *untrusted_str(NSEvent *e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NSTabletProximityEventSubtype doesn't encode pressure ant tilt
|
if([e isEnteringProximity])
|
||||||
* So we just pretend the motion was caused by the mouse. Hopefully
|
needsProximityIn = YES;
|
||||||
* we'll have a better solution for this in the future (like maybe
|
else
|
||||||
* NSTabletProximityEventSubtype will come from NSTabletPoint
|
DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
|
||||||
* rather than NSMouseMoved.
|
location.x, location.y, pressure,
|
||||||
pressure = [e pressure];
|
tilt.x, tilt.y);
|
||||||
tilt = [e tilt];
|
return;
|
||||||
pDev = darwinTabletCurrent;
|
|
||||||
*/
|
|
||||||
|
|
||||||
DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut,
|
|
||||||
location.x, location.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
|
if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
|
||||||
|
@ -1227,6 +1238,14 @@ static const char *untrusted_str(NSEvent *e) {
|
||||||
tilt = [e tilt];
|
tilt = [e tilt];
|
||||||
|
|
||||||
pDev = darwinTabletCurrent;
|
pDev = darwinTabletCurrent;
|
||||||
|
|
||||||
|
if(needsProximityIn) {
|
||||||
|
DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
|
||||||
|
location.x, location.y, pressure,
|
||||||
|
tilt.x, tilt.y);
|
||||||
|
|
||||||
|
needsProximityIn = NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!XQuartzServerVisible && noTestExtensions) {
|
if(!XQuartzServerVisible && noTestExtensions) {
|
||||||
|
@ -1280,8 +1299,12 @@ static const char *untrusted_str(NSEvent *e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut,
|
if([e isEnteringProximity])
|
||||||
location.x, location.y);
|
needsProximityIn = YES;
|
||||||
|
else
|
||||||
|
DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
|
||||||
|
location.x, location.y, pressure,
|
||||||
|
tilt.x, tilt.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
|
|
|
@ -117,7 +117,6 @@ unsigned int windowItemModMask = NX_COMMANDMASK;
|
||||||
// devices
|
// devices
|
||||||
DeviceIntPtr darwinKeyboard = NULL;
|
DeviceIntPtr darwinKeyboard = NULL;
|
||||||
DeviceIntPtr darwinPointer = NULL;
|
DeviceIntPtr darwinPointer = NULL;
|
||||||
DeviceIntPtr darwinTabletCurrent = NULL;
|
|
||||||
DeviceIntPtr darwinTabletStylus = NULL;
|
DeviceIntPtr darwinTabletStylus = NULL;
|
||||||
DeviceIntPtr darwinTabletCursor = NULL;
|
DeviceIntPtr darwinTabletCursor = NULL;
|
||||||
DeviceIntPtr darwinTabletEraser = NULL;
|
DeviceIntPtr darwinTabletEraser = NULL;
|
||||||
|
@ -492,8 +491,6 @@ void InitInput( int argc, char **argv )
|
||||||
darwinTabletEraser = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
|
darwinTabletEraser = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
|
||||||
darwinTabletEraser->name = strdup("eraser");
|
darwinTabletEraser->name = strdup("eraser");
|
||||||
|
|
||||||
darwinTabletCurrent = darwinTabletStylus;
|
|
||||||
|
|
||||||
DarwinEQInit();
|
DarwinEQInit();
|
||||||
|
|
||||||
QuartzInitInput(argc, argv);
|
QuartzInitInput(argc, argv);
|
||||||
|
|
|
@ -56,7 +56,6 @@ extern io_connect_t darwinParamConnect;
|
||||||
extern int darwinEventReadFD;
|
extern int darwinEventReadFD;
|
||||||
extern int darwinEventWriteFD;
|
extern int darwinEventWriteFD;
|
||||||
extern DeviceIntPtr darwinPointer;
|
extern DeviceIntPtr darwinPointer;
|
||||||
extern DeviceIntPtr darwinTabletCurrent;
|
|
||||||
extern DeviceIntPtr darwinTabletCursor;
|
extern DeviceIntPtr darwinTabletCursor;
|
||||||
extern DeviceIntPtr darwinTabletStylus;
|
extern DeviceIntPtr darwinTabletStylus;
|
||||||
extern DeviceIntPtr darwinTabletEraser;
|
extern DeviceIntPtr darwinTabletEraser;
|
||||||
|
|
|
@ -489,7 +489,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
|
||||||
DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
darwinEvents_lock(); {
|
darwinEvents_lock(); {
|
||||||
ValuatorMask mask;
|
ValuatorMask mask;
|
||||||
valuator_mask_set_range(&mask, 0, (pDev == darwinTabletCurrent) ? 5 : 2, valuators);
|
valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
|
||||||
num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button,
|
num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button,
|
||||||
POINTER_ABSOLUTE, &mask);
|
POINTER_ABSOLUTE, &mask);
|
||||||
for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
|
for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
|
||||||
|
@ -512,13 +512,13 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
|
||||||
} darwinEvents_unlock();
|
} darwinEvents_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
|
void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
|
||||||
|
float pressure, float tilt_x, float tilt_y) {
|
||||||
int i, num_events;
|
int i, num_events;
|
||||||
ScreenPtr screen;
|
ScreenPtr screen;
|
||||||
DeviceIntPtr pDev = darwinTabletCurrent;
|
|
||||||
int valuators[5];
|
int valuators[5];
|
||||||
|
|
||||||
DEBUG_LOG("DarwinSendProximityEvents(%d, %f, %f)\n", ev_type, pointer_x, pointer_y);
|
DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
|
|
||||||
if(!darwinEvents) {
|
if(!darwinEvents) {
|
||||||
DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
|
DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
|
||||||
|
@ -531,7 +531,7 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f);
|
DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
darwinEvents_lock(); {
|
darwinEvents_lock(); {
|
||||||
ValuatorMask mask;
|
ValuatorMask mask;
|
||||||
valuator_mask_set_range(&mask, 0, 5, valuators);
|
valuator_mask_set_range(&mask, 0, 5, valuators);
|
||||||
|
|
|
@ -37,7 +37,8 @@ void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
|
||||||
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
|
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
|
||||||
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
|
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
|
||||||
float pressure, float tilt_x, float tilt_y);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y);
|
void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float 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, float pointer_x, float pointer_y,
|
void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y,
|
||||||
float pressure, float tilt_x, float tilt_y);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
|
|
Loading…
Reference in New Issue