summaryrefslogtreecommitdiff
path: root/multitouch.c
diff options
context:
space:
mode:
Diffstat (limited to 'multitouch.c')
-rw-r--r--multitouch.c90
1 files changed, 87 insertions, 3 deletions
diff --git a/multitouch.c b/multitouch.c
index 3b5fad3..fddc53f 100644
--- a/multitouch.c
+++ b/multitouch.c
@@ -109,8 +109,6 @@ MultitouchDisplay *md = GET_MULTITOUCH_DISPLAY (d)
#define MULTITOUCH_SCREEN(s) \
MultitouchScreen *ms = GET_MULTITOUCH_SCREEN (s, GET_MULTITOUCH_DISPLAY (s->display))
-/* TODO: draw debug info on cairo, animated effect for each blob, pie (radial) menu */
-
static int findWindowAtPoint ( int x, int y)
{
char *display_name;
@@ -164,6 +162,84 @@ static int findWindowAtPoint ( int x, int y)
return wid;
}
+static void moveCursorTo(int x, int y)
+{
+ char *display_name;
+ Display *d;
+ if ( (display_name = getenv("DISPLAY")) == (void *)NULL)
+ {
+ compLogMessage (firstDisplay, "multitouch", CompLogLevelError,
+ "Error: DISPLAY environment variable not set!");
+ return;
+ }
+ if ((d = XOpenDisplay(display_name)) == NULL)
+ {
+ compLogMessage (firstDisplay, "multitouch", CompLogLevelError,
+ "Error: Can't open display: %s!", display_name);
+ return;
+ }
+ Window root;
+ int s;
+ root = currentRoot;
+ s = XGrabPointer(d,root,True,ButtonPressMask | EnterWindowMask,GrabModeSync,
+ GrabModeSync,None,None,CurrentTime);
+ XWarpPointer(d,None,root,0,0,0,0,x,y);
+ XUngrabPointer(d,CurrentTime);
+ XFlush(d);
+ XCloseDisplay(d);
+}
+
+static void mouseClick(int button, CompDisplay * d)
+{
+ XEvent event;
+
+ memset(&event, 0x00, sizeof(event));
+ event.type = ButtonPress;
+ event.xbutton.button = button;
+ event.xbutton.same_screen = True;
+
+ XQueryPointer(d->display,currentRoot,
+ &event.xbutton.root,
+ &event.xbutton.window,
+ &event.xbutton.x_root,
+ &event.xbutton.y_root,
+ &event.xbutton.x,
+ &event.xbutton.y,
+ &event.xbutton.state);
+
+ event.xbutton.subwindow = event.xbutton.window;
+
+ while (event.xbutton.subwindow)
+ {
+ event.xbutton.window = event.xbutton.subwindow;
+ XQueryPointer(d->display,
+ event.xbutton.window,
+ &event.xbutton.root,
+ &event.xbutton.subwindow,
+ &event.xbutton.x_root,
+ &event.xbutton.y_root,
+ &event.xbutton.x,
+ &event.xbutton.y,
+ &event.xbutton.state);
+ }
+
+ if (XSendEvent(d->display, PointerWindow,
+ True, 0xfff, &event)==0)
+ printf("XSendEvent() error!\n");
+
+ XFlush(d->display);
+ usleep(100000);
+
+ event.type = ButtonRelease;
+ event.xbutton.state = 0x100;
+
+ if (XSendEvent(d->display, PointerWindow,
+ True, 0xfff, &event)==0)
+ printf("XSendEvent() error2!\n");
+
+ XFlush(d->display);
+}
+
static Bool
sendInfoToPlugin (CompDisplay * d, CompOption * argument, int nArgument,
char *pluginName, char *actionName)
@@ -489,7 +565,7 @@ static void click_handler(mtEvent event, CompDisplay * d,int BlobID)
CompScreen *s;
s = findScreenAtDisplay (d, currentRoot);
mtblob *blobs = md->blob;
- int k,multiblobs;
+ int k,multiblobs,oldestblob;
int wid = 0;
MULTITOUCH_SCREEN(s);
switch (event)
@@ -509,6 +585,14 @@ static void click_handler(mtEvent event, CompDisplay * d,int BlobID)
md->timeoutHandles = compAddTimeout (0,makeannotate, dv);
else md->timeoutHandles = compAddTimeout (0,makeripple, dv);
}
+ oldestblob = blobs[BlobID].id;
+ for ( k=0;k<MAXBLOBS; k++)
+ {
+ if (blobs[k].id && blobs[k].id < oldestblob)
+ oldestblob=blobs[k].id;
+ }
+ if (oldestblob == blobs[BlobID].id)
+ moveCursorTo(blobs[BlobID].x * s->width,blobs[BlobID].y * s->height);
if ( blobs[BlobID].w )
{
for (k=0;k<MAXBLOBS; k++)