16747b715Smrg/* 26747b715Smrg * Copyright 2007-2008 Peter Hutterer 36747b715Smrg * 46747b715Smrg * Permission is hereby granted, free of charge, to any person obtaining a 56747b715Smrg * copy of this software and associated documentation files (the "Software"), 66747b715Smrg * to deal in the Software without restriction, including without limitation 76747b715Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 86747b715Smrg * and/or sell copies of the Software, and to permit persons to whom the 96747b715Smrg * Software is furnished to do so, subject to the following conditions: 106747b715Smrg * 116747b715Smrg * The above copyright notice and this permission notice (including the next 126747b715Smrg * paragraph) shall be included in all copies or substantial portions of the 136747b715Smrg * Software. 146747b715Smrg * 156747b715Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 166747b715Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 176747b715Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 186747b715Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 196747b715Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 206747b715Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 216747b715Smrg * DEALINGS IN THE SOFTWARE. 226747b715Smrg * 236747b715Smrg * Author: Peter Hutterer, University of South Australia, NICTA 246747b715Smrg */ 256747b715Smrg 266747b715Smrg#ifdef HAVE_DIX_CONFIG_H 276747b715Smrg#include <dix-config.h> 286747b715Smrg#endif 296747b715Smrg 30f7df2e56Smrg#include <X11/X.h> /* for inputstr.h */ 31f7df2e56Smrg#include <X11/Xproto.h> /* Request macro */ 32f7df2e56Smrg#include "inputstr.h" /* DeviceIntPtr */ 33f7df2e56Smrg#include "windowstr.h" /* window structure */ 34f7df2e56Smrg#include "scrnintstr.h" /* screen structure */ 356747b715Smrg#include <X11/extensions/XI.h> 366747b715Smrg#include <X11/extensions/XI2proto.h> 376747b715Smrg#include "extnsionst.h" 38f7df2e56Smrg#include "extinit.h" /* LookupDeviceIntRec */ 396747b715Smrg#include "exevents.h" 406747b715Smrg#include "exglobals.h" 416747b715Smrg 426747b715Smrg#include "xigetclientpointer.h" 436747b715Smrg 446747b715Smrg/*********************************************************************** 456747b715Smrg * This procedure allows a client to query another client's client pointer 466747b715Smrg * setting. 476747b715Smrg */ 486747b715Smrg 497e31ba66Smrgint _X_COLD 506747b715SmrgSProcXIGetClientPointer(ClientPtr client) 516747b715Smrg{ 526747b715Smrg REQUEST(xXIGetClientPointerReq); 530b0d8713Smrg REQUEST_SIZE_MATCH(xXIGetClientPointerReq); 546747b715Smrg 55f7df2e56Smrg swaps(&stuff->length); 56f7df2e56Smrg swapl(&stuff->win); 576747b715Smrg return ProcXIGetClientPointer(client); 586747b715Smrg} 596747b715Smrg 60f7df2e56Smrgint 61f7df2e56SmrgProcXIGetClientPointer(ClientPtr client) 626747b715Smrg{ 636747b715Smrg int rc; 646747b715Smrg ClientPtr winclient; 656747b715Smrg xXIGetClientPointerReply rep; 66f7df2e56Smrg 676747b715Smrg REQUEST(xXIGetClientPointerReq); 686747b715Smrg REQUEST_SIZE_MATCH(xXIGetClientPointerReq); 696747b715Smrg 70f7df2e56Smrg if (stuff->win != None) { 71f7df2e56Smrg rc = dixLookupClient(&winclient, stuff->win, client, DixGetAttrAccess); 726747b715Smrg 736747b715Smrg if (rc != Success) 746747b715Smrg return BadWindow; 75f7df2e56Smrg } 76f7df2e56Smrg else 776747b715Smrg winclient = client; 786747b715Smrg 79f7df2e56Smrg rep = (xXIGetClientPointerReply) { 80f7df2e56Smrg .repType = X_Reply, 81f7df2e56Smrg .RepType = X_XIGetClientPointer, 82f7df2e56Smrg .sequenceNumber = client->sequence, 83f7df2e56Smrg .length = 0, 84f7df2e56Smrg .set = (winclient->clientPtr != NULL), 85f7df2e56Smrg .deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0 86f7df2e56Smrg }; 876747b715Smrg 886747b715Smrg WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep); 896747b715Smrg return Success; 906747b715Smrg} 916747b715Smrg 926747b715Smrg/*********************************************************************** 936747b715Smrg * 946747b715Smrg * This procedure writes the reply for the XGetClientPointer function, 956747b715Smrg * if the client and server have a different byte ordering. 966747b715Smrg * 976747b715Smrg */ 986747b715Smrg 997e31ba66Smrgvoid _X_COLD 1006747b715SmrgSRepXIGetClientPointer(ClientPtr client, int size, 101f7df2e56Smrg xXIGetClientPointerReply * rep) 1026747b715Smrg{ 103f7df2e56Smrg swaps(&rep->sequenceNumber); 104f7df2e56Smrg swapl(&rep->length); 105f7df2e56Smrg swaps(&rep->deviceid); 106f7df2e56Smrg WriteToClient(client, size, rep); 1076747b715Smrg} 108