1c27c18e8Smrg/* 2c27c18e8Smrg * Copyright © 2009 Red Hat, Inc. 3c27c18e8Smrg * 4c27c18e8Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5c27c18e8Smrg * copy of this software and associated documentation files (the "Software"), 6c27c18e8Smrg * to deal in the Software without restriction, including without limitation 7c27c18e8Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8c27c18e8Smrg * and/or sell copies of the Software, and to permit persons to whom the 9c27c18e8Smrg * Software is furnished to do so, subject to the following conditions: 10c27c18e8Smrg * 11c27c18e8Smrg * The above copyright notice and this permission notice (including the next 12c27c18e8Smrg * paragraph) shall be included in all copies or substantial portions of the 13c27c18e8Smrg * Software. 14c27c18e8Smrg * 15c27c18e8Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16c27c18e8Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17c27c18e8Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18c27c18e8Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19c27c18e8Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20c27c18e8Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21c27c18e8Smrg * DEALINGS IN THE SOFTWARE. 22c27c18e8Smrg * 23c27c18e8Smrg */ 24c27c18e8Smrg 25f1ee322dSmrg#if HAVE_CONFIG_H 26f1ee322dSmrg#include <config.h> 27f1ee322dSmrg#endif 28f1ee322dSmrg 29c27c18e8Smrg#include <stdint.h> 30c27c18e8Smrg#include <X11/Xlibint.h> 31c27c18e8Smrg#include <X11/extensions/XI2proto.h> 32c27c18e8Smrg#include <X11/extensions/XInput2.h> 33c27c18e8Smrg#include <X11/extensions/extutil.h> 34c27c18e8Smrg#include "XIint.h" 35c27c18e8Smrg 36f1ee322dSmrg/* for GetRequest() to work */ 37f1ee322dSmrg#define X_XI2_2AllowEvents X_XIAllowEvents 38f1ee322dSmrg 39f1ee322dSmrgstatic Status 40f1ee322dSmrg_XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time, 41f1ee322dSmrg unsigned int touchid, Window grab_window) 42c27c18e8Smrg{ 4344584a44Smrg Bool have_XI22 = False; 44c27c18e8Smrg xXIAllowEventsReq *req; 45f1ee322dSmrg xXI2_2AllowEventsReq *req_XI22; 46c27c18e8Smrg 47c27c18e8Smrg XExtDisplayInfo *extinfo = XInput_find_display(dpy); 48c27c18e8Smrg 49c27c18e8Smrg LockDisplay(dpy); 50b789ec8aSmrg if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) 51c27c18e8Smrg return (NoSuchExtension); 52c27c18e8Smrg 5344584a44Smrg if (_XiCheckVersion(extinfo, XInput_2_2) >= 0) 54f1ee322dSmrg have_XI22 = True; 55f1ee322dSmrg 56f1ee322dSmrg if (have_XI22) 57f1ee322dSmrg { 58f1ee322dSmrg GetReq(XI2_2AllowEvents, req_XI22); 59f1ee322dSmrg req = (xXIAllowEventsReq*)req_XI22; 60f1ee322dSmrg } else 61f1ee322dSmrg GetReq(XIAllowEvents, req); 62f1ee322dSmrg 63c27c18e8Smrg req->reqType = extinfo->codes->major_opcode; 64c27c18e8Smrg req->ReqType = X_XIAllowEvents; 65c27c18e8Smrg req->deviceid = deviceid; 66c27c18e8Smrg req->mode = event_mode; 67c27c18e8Smrg req->time = time; 68c27c18e8Smrg 69f1ee322dSmrg if (have_XI22) { 70f1ee322dSmrg req_XI22->touchid = touchid; 71f1ee322dSmrg req_XI22->grab_window = grab_window; 72f1ee322dSmrg } 73f1ee322dSmrg 74c27c18e8Smrg UnlockDisplay(dpy); 75c27c18e8Smrg SyncHandle(); 76c27c18e8Smrg return Success; 77c27c18e8Smrg} 78f1ee322dSmrg 79f1ee322dSmrgStatus 80f1ee322dSmrgXIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time) 81f1ee322dSmrg{ 82f1ee322dSmrg return _XIAllowEvents(dpy, deviceid, event_mode, time, 0, None); 83f1ee322dSmrg} 84f1ee322dSmrg 85f1ee322dSmrgStatus 86f1ee322dSmrgXIAllowTouchEvents(Display *dpy, int deviceid, unsigned int touchid, 87f1ee322dSmrg Window grab_window, int event_mode) 88f1ee322dSmrg{ 89f1ee322dSmrg XExtDisplayInfo *extinfo = XInput_find_display(dpy); 90f1ee322dSmrg 91f1ee322dSmrg LockDisplay(dpy); 92f1ee322dSmrg if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == -1) 93f1ee322dSmrg return (NoSuchExtension); 94f1ee322dSmrg UnlockDisplay(dpy); 95f1ee322dSmrg 962bd699fbSmrg return _XIAllowEvents(dpy, deviceid, event_mode, CurrentTime, touchid, grab_window); 97f1ee322dSmrg} 98