xichangecursor.c revision 6747b715
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/*********************************************************************** 276747b715Smrg * 286747b715Smrg * Request to change a given device pointer's cursor. 296747b715Smrg * 306747b715Smrg */ 316747b715Smrg 326747b715Smrg#ifdef HAVE_DIX_CONFIG_H 336747b715Smrg#include <dix-config.h> 346747b715Smrg#endif 356747b715Smrg 366747b715Smrg#include <X11/X.h> /* for inputstr.h */ 376747b715Smrg#include <X11/Xproto.h> /* Request macro */ 386747b715Smrg#include "inputstr.h" /* DeviceIntPtr */ 396747b715Smrg#include "windowstr.h" /* window structure */ 406747b715Smrg#include "scrnintstr.h" /* screen structure */ 416747b715Smrg#include <X11/extensions/XI.h> 426747b715Smrg#include <X11/extensions/XI2proto.h> 436747b715Smrg#include "extnsionst.h" 446747b715Smrg#include "exevents.h" 456747b715Smrg#include "exglobals.h" 466747b715Smrg#include "input.h" 476747b715Smrg 486747b715Smrg#include "xichangecursor.h" 496747b715Smrg 506747b715Smrg/*********************************************************************** 516747b715Smrg * 526747b715Smrg * This procedure allows a client to set one pointer's cursor. 536747b715Smrg * 546747b715Smrg */ 556747b715Smrg 566747b715Smrgint 576747b715SmrgSProcXIChangeCursor(ClientPtr client) 586747b715Smrg{ 596747b715Smrg char n; 606747b715Smrg 616747b715Smrg REQUEST(xXIChangeCursorReq); 626747b715Smrg swaps(&stuff->length, n); 636747b715Smrg swapl(&stuff->win, n); 646747b715Smrg swapl(&stuff->cursor, n); 656747b715Smrg swaps(&stuff->deviceid, n); 666747b715Smrg REQUEST_SIZE_MATCH(xXIChangeCursorReq); 676747b715Smrg return (ProcXIChangeCursor(client)); 686747b715Smrg} 696747b715Smrg 706747b715Smrgint ProcXIChangeCursor(ClientPtr client) 716747b715Smrg{ 726747b715Smrg int rc; 736747b715Smrg WindowPtr pWin = NULL; 746747b715Smrg DeviceIntPtr pDev = NULL; 756747b715Smrg CursorPtr pCursor = NULL; 766747b715Smrg 776747b715Smrg REQUEST(xXIChangeCursorReq); 786747b715Smrg REQUEST_SIZE_MATCH(xXIChangeCursorReq); 796747b715Smrg 806747b715Smrg rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess); 816747b715Smrg if (rc != Success) 826747b715Smrg return rc; 836747b715Smrg 846747b715Smrg if (!IsMaster(pDev) || !IsPointerDevice(pDev)) 856747b715Smrg return BadDevice; 866747b715Smrg 876747b715Smrg if (stuff->win != None) 886747b715Smrg { 896747b715Smrg rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess); 906747b715Smrg if (rc != Success) 916747b715Smrg return rc; 926747b715Smrg } 936747b715Smrg 946747b715Smrg if (stuff->cursor == None) 956747b715Smrg { 966747b715Smrg if (pWin == pWin->drawable.pScreen->root) 976747b715Smrg pCursor = rootCursor; 986747b715Smrg else 996747b715Smrg pCursor = (CursorPtr)None; 1006747b715Smrg } 1016747b715Smrg else 1026747b715Smrg { 1036747b715Smrg rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, 1046747b715Smrg RT_CURSOR, client, DixUseAccess); 1056747b715Smrg if (rc != Success) 1066747b715Smrg return rc; 1076747b715Smrg } 1086747b715Smrg 1096747b715Smrg ChangeWindowDeviceCursor(pWin, pDev, pCursor); 1106747b715Smrg 1116747b715Smrg return Success; 1126747b715Smrg} 1136747b715Smrg 114