static void handle_gestures(LocalDevicePtr local, struct Gestures* gs) { struct MTouch *mt = local->private; static bitmask_t buttons_prev = 0U; int i; if(mt->absolute_mode == FALSE){ if (mt->cfg.scroll_smooth){ /* Copy states from button_prev into current buttons state */ MODBIT(gs->buttons, 3, GETBIT(buttons_prev, 3)); MODBIT(gs->buttons, 4, GETBIT(buttons_prev, 4)); MODBIT(gs->buttons, 5, GETBIT(buttons_prev, 5)); MODBIT(gs->buttons, 6, GETBIT(buttons_prev, 6)); set_and_post_mask(mt, local->dev, timertoms(&gs->dt)); } else{ // mt->absolute_mode == FALSE if (gs->move_dx != 0 || gs->move_dy != 0) xf86PostMotionEvent(local->dev, 0, 0, 2, gs->move_dx, gs->move_dy); } } else{ /* Give the HW coordinates to Xserver as absolute coordinates, these coordinates * are not scaled, this is oke if the touchscreen has the same resolution as the display. */ xf86PostMotionEvent(local->dev, 1, 0, 2, mt->state.touch[0].x + get_cap_xmid(&mt->caps), mt->state.touch[0].y + get_cap_ymid(&mt->caps)); } for (i = 0; i < 32; i++) { if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i)) continue; if (GETBIT(gs->buttons, i)) { xf86PostButtonEvent(local->dev, FALSE, i+1, 1, 0, 0); #define DEBUG_DRIVER 0 #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d down\n", i+1); #endif } else { xf86PostButtonEvent(local->dev, FALSE, i+1, 0, 0, 0); #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d up\n", i+1); #endif #undef DEBUG_DRIVER } } buttons_prev = gs->buttons; }
void selnotify(XEvent *e) { ulong nitems, ofs, rem; int format; uchar *data, *last, *repl; Atom type, incratom, property; incratom = XInternAtom(xw.dpy, "INCR", 0); ofs = 0; if (e->type == SelectionNotify) { property = e->xselection.property; } else if(e->type == PropertyNotify) { property = e->xproperty.atom; } else { return; } if (property == None) return; do { if (XGetWindowProperty(xw.dpy, xw.win, property, ofs, BUFSIZ/4, False, AnyPropertyType, &type, &format, &nitems, &rem, &data)) { fprintf(stderr, "Clipboard allocation failed\n"); return; } if (e->type == PropertyNotify && nitems == 0 && rem == 0) { /* * If there is some PropertyNotify with no data, then * this is the signal of the selection owner that all * data has been transferred. We won't need to receive * PropertyNotify events anymore. */ MODBIT(xw.attrs.event_mask, 0, PropertyChangeMask); XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); } if (type == incratom) { /* * Activate the PropertyNotify events so we receive * when the selection owner does send us the next * chunk of data. */ MODBIT(xw.attrs.event_mask, 1, PropertyChangeMask); XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); /* * Deleting the property is the transfer start signal. */ XDeleteProperty(xw.dpy, xw.win, (int)property); continue; } /* * As seen in getsel: * Line endings are inconsistent in the terminal and GUI world * copy and pasting. When receiving some selection data, * replace all '\n' with '\r'. * FIXME: Fix the computer world. */ repl = data; last = data + nitems * format / 8; while ((repl = memchr(repl, '\n', last - repl))) { *repl++ = '\r'; } if (IS_SET(MODE_BRCKTPASTE) && ofs == 0) ttywrite("\033[200~", 6); ttysend((char *)data, nitems * format / 8); if (IS_SET(MODE_BRCKTPASTE) && rem == 0) ttywrite("\033[201~", 6); XFree(data); /* number of 32-bit chunks returned */ ofs += nitems * format / 32; } while (rem > 0); /* * Deleting the property again tells the selection owner to send the * next data chunk in the property. */ XDeleteProperty(xw.dpy, xw.win, (int)property); }