1706f2543Smrg/* 2706f2543Smrg * Copyright 2007-2008 Peter Hutterer 3706f2543Smrg * 4706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5706f2543Smrg * copy of this software and associated documentation files (the "Software"), 6706f2543Smrg * to deal in the Software without restriction, including without limitation 7706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 9706f2543Smrg * Software is furnished to do so, subject to the following conditions: 10706f2543Smrg * 11706f2543Smrg * The above copyright notice and this permission notice (including the next 12706f2543Smrg * paragraph) shall be included in all copies or substantial portions of the 13706f2543Smrg * Software. 14706f2543Smrg * 15706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18706f2543Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19706f2543Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20706f2543Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21706f2543Smrg * DEALINGS IN THE SOFTWARE. 22706f2543Smrg * 23706f2543Smrg * Author: Peter Hutterer, University of South Australia, NICTA 24706f2543Smrg */ 25706f2543Smrg 26706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 27706f2543Smrg#include <dix-config.h> 28706f2543Smrg#endif 29706f2543Smrg 30706f2543Smrg#include <X11/X.h> /* for inputstr.h */ 31706f2543Smrg#include <X11/Xproto.h> /* Request macro */ 32706f2543Smrg#include "inputstr.h" /* DeviceIntPtr */ 33706f2543Smrg#include "windowstr.h" /* window structure */ 34706f2543Smrg#include "scrnintstr.h" /* screen structure */ 35706f2543Smrg#include <X11/extensions/XI.h> 36706f2543Smrg#include <X11/extensions/XI2proto.h> 37706f2543Smrg#include "extnsionst.h" 38706f2543Smrg#include "extinit.h" /* LookupDeviceIntRec */ 39706f2543Smrg#include "exevents.h" 40706f2543Smrg#include "exglobals.h" 41706f2543Smrg 42706f2543Smrg#include "xigetclientpointer.h" 43706f2543Smrg 44706f2543Smrg/*********************************************************************** 45706f2543Smrg * This procedure allows a client to query another client's client pointer 46706f2543Smrg * setting. 47706f2543Smrg */ 48706f2543Smrg 49706f2543Smrgint 50706f2543SmrgSProcXIGetClientPointer(ClientPtr client) 51706f2543Smrg{ 52706f2543Smrg char n; 53706f2543Smrg REQUEST(xXIGetClientPointerReq); 54706f2543Smrg REQUEST_SIZE_MATCH(xXIGetClientPointerReq); 55706f2543Smrg 56706f2543Smrg swaps(&stuff->length, n); 57706f2543Smrg swapl(&stuff->win, n); 58706f2543Smrg return ProcXIGetClientPointer(client); 59706f2543Smrg} 60706f2543Smrg 61706f2543Smrgint ProcXIGetClientPointer(ClientPtr client) 62706f2543Smrg{ 63706f2543Smrg int rc; 64706f2543Smrg ClientPtr winclient; 65706f2543Smrg xXIGetClientPointerReply rep; 66706f2543Smrg REQUEST(xXIGetClientPointerReq); 67706f2543Smrg REQUEST_SIZE_MATCH(xXIGetClientPointerReq); 68706f2543Smrg 69706f2543Smrg if (stuff->win != None) 70706f2543Smrg { 71706f2543Smrg rc = dixLookupClient(&winclient, stuff->win, client, 72706f2543Smrg DixGetAttrAccess); 73706f2543Smrg 74706f2543Smrg if (rc != Success) 75706f2543Smrg return BadWindow; 76706f2543Smrg } else 77706f2543Smrg winclient = client; 78706f2543Smrg 79706f2543Smrg rep.repType = X_Reply; 80706f2543Smrg rep.RepType = X_XIGetClientPointer; 81706f2543Smrg rep.length = 0; 82706f2543Smrg rep.sequenceNumber = client->sequence; 83706f2543Smrg rep.set = (winclient->clientPtr != NULL); 84706f2543Smrg rep.deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0; 85706f2543Smrg 86706f2543Smrg WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep); 87706f2543Smrg return Success; 88706f2543Smrg} 89706f2543Smrg 90706f2543Smrg/*********************************************************************** 91706f2543Smrg * 92706f2543Smrg * This procedure writes the reply for the XGetClientPointer function, 93706f2543Smrg * if the client and server have a different byte ordering. 94706f2543Smrg * 95706f2543Smrg */ 96706f2543Smrg 97706f2543Smrgvoid 98706f2543SmrgSRepXIGetClientPointer(ClientPtr client, int size, 99706f2543Smrg xXIGetClientPointerReply* rep) 100706f2543Smrg{ 101706f2543Smrg char n; 102706f2543Smrg swaps(&rep->sequenceNumber, n); 103706f2543Smrg swapl(&rep->length, n); 104706f2543Smrg swaps(&rep->deviceid, n); 105706f2543Smrg WriteToClient(client, size, (char *)rep); 106706f2543Smrg} 107706f2543Smrg 108