diff options
author | Colin Hill <colin.james.hill@gmail.com> | 2011-02-16 22:12:38 -0800 |
---|---|---|
committer | Colin Hill <colin.james.hill@gmail.com> | 2011-02-16 22:12:38 -0800 |
commit | e651e956b96df807fc239d226545eee00cb26c60 (patch) | |
tree | d09fa086d339f413b094115ec187102e61479d23 | |
parent | 8204ce456c5b99f4b2a634b6d06aa5cae56e2517 (diff) |
Mouse button 1.
-rw-r--r-- | src/xNestedMouse.c | 30 | ||||
-rw-r--r-- | src/xNestedMouse.h | 1 | ||||
-rw-r--r-- | src/xlibclient.c | 2 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/xNestedMouse.c b/src/xNestedMouse.c index be54b33..3c0adb8 100644 --- a/src/xNestedMouse.c +++ b/src/xNestedMouse.c @@ -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); +} diff --git a/src/xNestedMouse.h b/src/xNestedMouse.h index b4d5ddb..9cb48e1 100644 --- a/src/xNestedMouse.h +++ b/src/xNestedMouse.h @@ -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); diff --git a/src/xlibclient.c b/src/xlibclient.c index 7d07706..ee4b330 100644 --- a/src/xlibclient.c +++ b/src/xlibclient.c @@ -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; |