1c27c18e8Smrg/************************************************************ 2c27c18e8Smrg 3c27c18e8SmrgCopyright 2007 Peter Hutterer <peter@cs.unisa.edu.au> 4c27c18e8Smrg 5c27c18e8SmrgPermission to use, copy, modify, distribute, and sell this software and its 6c27c18e8Smrgdocumentation for any purpose is hereby granted without fee, provided that 7c27c18e8Smrgthe above copyright notice appear in all copies and that both that 8c27c18e8Smrgcopyright notice and this permission notice appear in supporting 9c27c18e8Smrgdocumentation. 10c27c18e8Smrg 11c27c18e8SmrgThe above copyright notice and this permission notice shall be included in 12c27c18e8Smrgall copies or substantial portions of the Software. 13c27c18e8Smrg 14c27c18e8SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15c27c18e8SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16c27c18e8SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17c27c18e8SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18c27c18e8SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19c27c18e8SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20c27c18e8Smrg 21c27c18e8SmrgExcept as contained in this notice, the name of The Open Group shall not be 22c27c18e8Smrgused in advertising or otherwise to promote the sale, use or other dealings 23c27c18e8Smrgin this Software without prior written authorization from The Open Group. 24c27c18e8Smrg 25c27c18e8Smrg*/ 26c27c18e8Smrg 27c27c18e8Smrg/*********************************************************************** 28c27c18e8Smrg * 29c27c18e8Smrg * XIGetClientPointer - Get the clientPointer setting for a client. 30c27c18e8Smrg * 31c27c18e8Smrg */ 32f1ee322dSmrg#if HAVE_CONFIG_H 33f1ee322dSmrg#include <config.h> 34f1ee322dSmrg#endif 35c27c18e8Smrg 36c27c18e8Smrg#include <stdint.h> 37c27c18e8Smrg#include <X11/extensions/XI2proto.h> 38c27c18e8Smrg#include <X11/Xlibint.h> 39c27c18e8Smrg#include <X11/extensions/XInput2.h> 40c27c18e8Smrg#include <X11/extensions/extutil.h> 41c27c18e8Smrg#include "XIint.h" 42c27c18e8Smrg 43c27c18e8SmrgBool 44c27c18e8SmrgXIGetClientPointer(Display* dpy, Window win, int *deviceid) 45c27c18e8Smrg{ 46c27c18e8Smrg xXIGetClientPointerReq *req; 47c27c18e8Smrg xXIGetClientPointerReply rep; 48c27c18e8Smrg XExtDisplayInfo *info = XInput_find_display(dpy); 49c27c18e8Smrg 50c27c18e8Smrg LockDisplay(dpy); 51c27c18e8Smrg if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) 5244584a44Smrg return False; 53c27c18e8Smrg 54c27c18e8Smrg GetReq(XIGetClientPointer, req); 55c27c18e8Smrg req->reqType = info->codes->major_opcode; 56c27c18e8Smrg req->ReqType = X_XIGetClientPointer; 57c27c18e8Smrg req->win = win; 58c27c18e8Smrg 59c27c18e8Smrg if (!_XReply(dpy, (xReply*) &rep, 0, xFalse)) { 60c27c18e8Smrg UnlockDisplay(dpy); 61c27c18e8Smrg SyncHandle(); 62c27c18e8Smrg return False; 63c27c18e8Smrg } 64c27c18e8Smrg 65c27c18e8Smrg *deviceid = rep.deviceid; 66c27c18e8Smrg 67c27c18e8Smrg UnlockDisplay(dpy); 68c27c18e8Smrg SyncHandle(); 69c27c18e8Smrg return rep.set; 70c27c18e8Smrg} 71