xserver: Branch 'master' - 3 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Mon Mar 31 16:44:42 PDT 2008
hw/xquartz/X11Application.m | 28 ++++++++++++++-----
hw/xquartz/darwin.c | 20 +------------
hw/xquartz/darwinEvents.c | 64 ++++++++++++++++++++++++++++++++++++--------
hw/xquartz/darwinEvents.h | 8 ++++-
hw/xquartz/darwinXinput.c | 16 ++++++++---
5 files changed, 95 insertions(+), 41 deletions(-)
New commits:
commit a4d034941100c6ca3b7cc4e59952c2745b9306cc
Author: Ben Byer <bbyer at bushing.apple.com>
Date: Fri Mar 28 20:47:44 2008 -0700
Add code to track 5 valuators for pointing device, in preparation
for supporting tablet input in Xquartz.
(cherry picked from commit 22c8849ea819eb70a14b2e06330b11b22aa63ebc)
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 31c80df..147b4b4 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 113cfc1..2a28b1a 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<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
DarwinPokeEQ();
@@ -438,18 +460,38 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
DarwinPokeEQ();
}
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
+ float pressure, float tilt_x, float tilt_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};
+
+ num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
+ 0, 5, valuators);
+
+ for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+ DarwinPokeEQ();
+}
+
+
/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
int i;
int ev_button = count > 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<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,
- POINTER_ABSOLUTE, 0, 2, valuators);
+ POINTER_ABSOLUTE, 0, 5, valuators);
for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
}
DarwinPokeEQ();
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 82cc26b..4960614 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -32,9 +32,13 @@ void DarwinEQEnqueue(const xEventPtr e);
void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
void DarwinPokeEQ(void);
-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);
+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 DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+ float pressure, float tilt_x, float tilt_y);
void DarwinUpdateModKeys(int flags);
#endif /* _DARWIN_EVENTS_H */
commit 6648867d8bd1e86458d2ade77a3ee4567c3d6a97
Author: Ben Byer <bbyer at bushing.apple.com>
Date: Fri Mar 28 18:27:02 2008 -0700
add debug statements so we can see if/when our Xinput stubs are getting called.
(cherry picked from commit 6e160bbe15dd2c2b8685847c06831cb6aebc6f74)
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 50ba656..59bae6f 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -62,6 +62,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
+#include "darwin.h"
/***********************************************************************
*
@@ -79,6 +80,7 @@ SOFTWARE.
void
CloseInputDevice(DeviceIntPtr d, ClientPtr client)
{
+ DEBUG_LOG("CloseInputDevice(%p, %p)\n", d, client);
}
/***********************************************************************
@@ -122,7 +124,7 @@ AddOtherInputDevices(void)
RegisterOtherDevice(dev);
dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
************************************************************************/
-
+ DEBUG_LOG("AddOtherInputDevices\n");
}
/***********************************************************************
@@ -150,6 +152,7 @@ AddOtherInputDevices(void)
void
OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
{
+ DEBUG_LOG("OpenInputDevice(%p, %p, %p)\n", dev, client, status);
}
/****************************************************************************
@@ -167,6 +170,7 @@ OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
int
SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
{
+ DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
return BadMatch;
}
@@ -186,7 +190,9 @@ int
SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
int *valuators, int first_valuator, int num_valuators)
{
- return BadMatch;
+ DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
+ dev, valuators, first_valuator, num_valuators);
+ return BadMatch;
}
/****************************************************************************
@@ -201,6 +207,8 @@ int
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
xDeviceCtl * control)
{
+
+ DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
switch (control->control) {
case DEVICE_RESOLUTION:
return (BadMatch);
@@ -225,7 +233,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
int
NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
{
- return BadValue;
+ DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
+ return BadValue;
}
/****************************************************************************
@@ -238,4 +247,5 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
void
DeleteInputDeviceRequest(DeviceIntPtr dev)
{
+ DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
}
commit 19ff23ab0e72a27d05ed4470f75a0934d6f6c1d1
Author: Ben Byer <bbyer at bushing.apple.com>
Date: Fri Mar 28 18:25:03 2008 -0700
Remove calls to InitValuatorAxisStruct -- these are now handled in dix by
InitValuatorDeviceClass.
Add InitProximityClassDeviceStruct call to prepare for tablet support.
(cherry picked from commit 1bd980a5b114f5320360943214f8f9f23b29c1e3)
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 0dbfafe..8f2511d 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -353,24 +353,8 @@ static int DarwinMouseProc(
InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
GetMotionHistory,
(PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), 2);
-
-#ifdef XINPUT
- InitValuatorAxisStruct( pPointer,
- 0, // X axis
- 0, // min value
- 16000, // max value (fixme screen size?)
- 1, // resolution (fixme ?)
- 1, // min resolution
- 1 ); // max resolution
- InitValuatorAxisStruct( pPointer,
- 1, // X axis
- 0, // min value
- 16000, // max value (fixme screen size?)
- 1, // resolution (fixme ?)
- 1, // min resolution
- 1 ); // max resolution
-#endif
+ GetMotionHistorySize(), 5);
+ InitProximityClassDeviceStruct( (DevicePtr)pPointer);
break;
case DEVICE_ON:
More information about the xorg-commit
mailing list