/************************************************************ Copyright 2009 Red Hat, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the author shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the author. */ /*********************************************************************** * * XISelectEvent - Select for XI2 events. * */ #include #include #include #include #include #include #include #include #include "XIint.h" int XISelectEvent(Display* dpy, Window win, XIDeviceEventMask* masks, int num_masks) { XIDeviceEventMask *current; xXISelectEventsReq *req; xXIDeviceEventMask mask; int i; int len = 0; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(XISelectEvents, req); req->reqType = info->codes->major_opcode; req->ReqType = X_XISelectEvents; req->window = win; req->num_masks = num_masks; /* get the right length */ for (i = 0; i < num_masks; i++) { len++; current = &masks[i]; len += (current->mask_len + 3)/4; } SetReqLen(req, len, len); for (i = 0; i < num_masks; i++) { current = &masks[i]; mask.deviceid = current->deviceid; mask.mask_len = (current->mask_len + 3)/4; Data32(dpy, &mask, sizeof(xXIDeviceEventMask)); Data(dpy, (char*)current->mask, current->mask_len); } UnlockDisplay(dpy); SyncHandle(); return Success; }