Mouse button 1.

This commit is contained in:
Colin Hill
2011-02-16 22:12:38 -08:00
parent 8204ce456c
commit e651e956b9
3 changed files with 32 additions and 1 deletions

View File

@@ -128,7 +128,31 @@ NestedMouseUnplug(pointer p) {
static int
_nested_mouse_init_buttons(DeviceIntPtr device) {
return -1;
InputInfoPtr pInfo = device->public.devicePrivate;
CARD8 *map;
int i;
int ret = Success;
const int num_buttons = 2;
Atom btn_labels[2] = {0};
btn_labels[0] = "left";
btn_labels[1] = "right";
map = xcalloc(num_buttons, sizeof(CARD8));
for (i = 0; i < num_buttons; i++)
map[i] = i;
if (!InitButtonClassDeviceStruct(device, num_buttons, btn_labels, map)) {
xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", pInfo->name);
ret = BadAlloc;
}
xfree(map);
return ret;
return -1;
}
static int
@@ -232,3 +256,7 @@ void Load_Nested_Mouse(NestedClientPrivatePtr clientData) {
void NestedPostMouseMotion(void* dev, int x, int y) {
xf86PostMotionEvent(dev, TRUE, 0, 2, x, y);
}
void NestedPostMouseButton(void* dev, int button, int isDown) {
xf86PostButtonEvent(dev, 0, button, isDown, 0, 0);
}

View File

@@ -6,3 +6,4 @@ InputInfoPtr NestedMousePreInit(InputDriverPtr drv, IDevPtr dev, int flags);
void NestedMouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
void NestedPostMouseMotion(void* dev, int x, int y);
void NestedPostMouseButton(void* dev, int button, int isDown);

View File

@@ -299,6 +299,7 @@ NestedClientTimerCallback(NestedClientPrivatePtr pPriv) {
if (ev.type == ButtonPress) {
switch (ev.xbutton.button) {
case Button1: xf86DrvMsg(pPriv->scrnIndex, X_INFO, "Left Mouse Button Pressed\n");
NestedPostMouseButton(pPriv->dev, 1, TRUE);
break;
case Button2: xf86DrvMsg(pPriv->scrnIndex, X_INFO, "Middle Mouse Button Pressed\n");
break;
@@ -313,6 +314,7 @@ NestedClientTimerCallback(NestedClientPrivatePtr pPriv) {
if (ev.type == ButtonRelease) {
switch (ev.xbutton.button) {
case Button1: xf86DrvMsg(pPriv->scrnIndex, X_INFO, "Left Mouse Button Released\n");
NestedPostMouseButton(pPriv->dev, 1, FALSE);
break;
case Button2: xf86DrvMsg(pPriv->scrnIndex, X_INFO, "Middle Mouse Button Released\n");
break;