xichangecursor.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright 2007-2008 Peter Hutterer
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Author: Peter Hutterer, University of South Australia, NICTA
  24. */
  25. /***********************************************************************
  26. *
  27. * Request to change a given device pointer's cursor.
  28. *
  29. */
  30. #ifdef HAVE_DIX_CONFIG_H
  31. #include <dix-config.h>
  32. #endif
  33. #include <X11/X.h> /* for inputstr.h */
  34. #include <X11/Xproto.h> /* Request macro */
  35. #include "inputstr.h" /* DeviceIntPtr */
  36. #include "windowstr.h" /* window structure */
  37. #include "scrnintstr.h" /* screen structure */
  38. #include <X11/extensions/XI.h>
  39. #include <X11/extensions/XI2proto.h>
  40. #include "extnsionst.h"
  41. #include "exevents.h"
  42. #include "exglobals.h"
  43. #include "input.h"
  44. #include "xichangecursor.h"
  45. /***********************************************************************
  46. *
  47. * This procedure allows a client to set one pointer's cursor.
  48. *
  49. */
  50. int
  51. SProcXIChangeCursor(ClientPtr client)
  52. {
  53. REQUEST(xXIChangeCursorReq);
  54. REQUEST_SIZE_MATCH(xXIChangeCursorReq);
  55. swaps(&stuff->length);
  56. swapl(&stuff->win);
  57. swapl(&stuff->cursor);
  58. swaps(&stuff->deviceid);
  59. return (ProcXIChangeCursor(client));
  60. }
  61. int
  62. ProcXIChangeCursor(ClientPtr client)
  63. {
  64. int rc;
  65. WindowPtr pWin = NULL;
  66. DeviceIntPtr pDev = NULL;
  67. CursorPtr pCursor = NULL;
  68. REQUEST(xXIChangeCursorReq);
  69. REQUEST_SIZE_MATCH(xXIChangeCursorReq);
  70. rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess);
  71. if (rc != Success)
  72. return rc;
  73. if (!IsMaster(pDev) || !IsPointerDevice(pDev))
  74. return BadDevice;
  75. if (stuff->win != None) {
  76. rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess);
  77. if (rc != Success)
  78. return rc;
  79. }
  80. if (stuff->cursor == None) {
  81. if (pWin == pWin->drawable.pScreen->root)
  82. pCursor = rootCursor;
  83. else
  84. pCursor = (CursorPtr) None;
  85. }
  86. else {
  87. rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
  88. RT_CURSOR, client, DixUseAccess);
  89. if (rc != Success)
  90. return rc;
  91. }
  92. ChangeWindowDeviceCursor(pWin, pDev, pCursor);
  93. return Success;
  94. }