diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 31c80dfa8..147b4b4c0 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -61,7 +61,7 @@ int X11EnableKeyEquivalents = TRUE; int quartzHasRoot = FALSE, quartzEnableRootless = TRUE; extern int darwinFakeButtons, input_check_flag; -extern Bool enable_stereo; +extern Bool enable_stereo; extern xEvent *darwinEvents; @@ -153,7 +153,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { tem = [infoDict objectForKey:@"CFBundleShortVersionString"]; - [dict setObject:[NSString stringWithFormat:@"Xquartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] + [dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] forKey:@"ApplicationVersion"]; [self orderFrontStandardAboutPanelWithOptions: dict]; @@ -501,7 +501,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) { if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID () - && CFNumberIsFloatType (value)) + && CFNumberIsFloatType (value)) CFNumberGetValue (value, kCFNumberFloatType, &ret); else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) ret = CFStringGetDoubleValue (value); @@ -862,7 +862,9 @@ static void send_nsevent (NSEventType type, NSEvent *e) { NSRect screen; NSPoint location; NSWindow *window; - int pointer_x, pointer_y, ev_button, ev_type; + int pointer_x, pointer_y, ev_button, ev_type; + float pressure, tilt_x, tilt_y; + // int num_events=0, i=0, state; // xEvent xe; @@ -884,6 +886,10 @@ static void send_nsevent (NSEventType type, NSEvent *e) { pointer_y -= aquaMenuBarHeight; // state = convert_flags ([e modifierFlags]); + pressure = 0; // for tablets + tilt_x = 0; + 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; @@ -894,6 +900,10 @@ static void send_nsevent (NSEventType type, NSEvent *e) { 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 NSTabletPoint: + pressure = [e pressure]; + tilt_x = [e tilt].x; + tilt_y = [e tilt].y; // fall through case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse; handle_mouse: @@ -907,10 +917,14 @@ static void send_nsevent (NSEventType type, NSEvent *e) { DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break; */ - DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); + + // if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure]; + DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y, + pressure, tilt_x, tilt_y); break; - case NSScrollWheel: - DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y); + case NSScrollWheel: + DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y, + pressure, tilt_x, tilt_y); break; case NSKeyDown: // do we need to translate these keyCodes? diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 113cfc109..2a28b1a31 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -173,6 +173,9 @@ static void DarwinReleaseModifiers(void) { static void DarwinSimulateMouseClick( int pointer_x, int pointer_y, + float pressure, + float tilt_x, + float tilt_y, int whichButton, // mouse button to be pressed int modifierMask) // modifiers used for the fake click { @@ -183,8 +186,10 @@ static void DarwinSimulateMouseClick( DarwinUpdateModifiers(KeyRelease, modifierMask); // push the mouse button - DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y); - DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y); + DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y, + pressure, tilt_x, tilt_y); + DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y, + pressure, tilt_x, tilt_y); // restore old modifiers DarwinUpdateModifiers(KeyPress, modifierMask); @@ -378,22 +383,39 @@ void DarwinPokeEQ(void) { write(darwinEventWriteFD, &nullbyte, 1); } -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) { static int darwinFakeMouseButtonDown = 0; static int darwinFakeMouseButtonMask = 0; int i, num_events; - int valuators[2] = {pointer_x, pointer_y}; + + /* 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}; + if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) { // Mimic multi-button mouse with modifier-clicks // If both sets of modifiers are pressed, // button 2 is clicked. if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) { - DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask); + DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, + tilt_x, tilt_y, 2, darwinFakeMouse2Mask); darwinFakeMouseButtonDown = 2; darwinFakeMouseButtonMask = darwinFakeMouse2Mask; return; } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) { - DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask); + DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, + tilt_x, tilt_y, 3, darwinFakeMouse3Mask); darwinFakeMouseButtonDown = 3; darwinFakeMouseButtonMask = darwinFakeMouse3Mask; return; @@ -412,7 +434,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin } num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, - POINTER_ABSOLUTE, 0, 2, valuators); + POINTER_ABSOLUTE, 0, 5, valuators); for(i=0; i 0.0f ? 4 : 5; - int valuators[2] = {pointer_x, pointer_y}; + int valuators[5] = {pointer_x, pointer_y, + pressure * INT32_MAX * 1.0f, + tilt_x * INT32_MAX * 1.0f, + tilt_y * INT32_MAX * 1.0f}; for (count = fabs(count); count > 0.0; count = count - 1.0f) { int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, - POINTER_ABSOLUTE, 0, 2, valuators); + POINTER_ABSOLUTE, 0, 5, valuators); for(i=0; i