xigetclientpointer.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifdef HAVE_DIX_CONFIG_H
  26. #include <dix-config.h>
  27. #endif
  28. #include <X11/X.h> /* for inputstr.h */
  29. #include <X11/Xproto.h> /* Request macro */
  30. #include "inputstr.h" /* DeviceIntPtr */
  31. #include "windowstr.h" /* window structure */
  32. #include "scrnintstr.h" /* screen structure */
  33. #include <X11/extensions/XI.h>
  34. #include <X11/extensions/XI2proto.h>
  35. #include "extnsionst.h"
  36. #include "extinit.h" /* LookupDeviceIntRec */
  37. #include "exevents.h"
  38. #include "exglobals.h"
  39. #include "xigetclientpointer.h"
  40. /***********************************************************************
  41. * This procedure allows a client to query another client's client pointer
  42. * setting.
  43. */
  44. int
  45. SProcXIGetClientPointer(ClientPtr client)
  46. {
  47. REQUEST(xXIGetClientPointerReq);
  48. REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
  49. swaps(&stuff->length);
  50. swapl(&stuff->win);
  51. return ProcXIGetClientPointer(client);
  52. }
  53. int
  54. ProcXIGetClientPointer(ClientPtr client)
  55. {
  56. int rc;
  57. ClientPtr winclient;
  58. xXIGetClientPointerReply rep;
  59. REQUEST(xXIGetClientPointerReq);
  60. REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
  61. if (stuff->win != None) {
  62. rc = dixLookupClient(&winclient, stuff->win, client, DixGetAttrAccess);
  63. if (rc != Success)
  64. return BadWindow;
  65. }
  66. else
  67. winclient = client;
  68. rep = (xXIGetClientPointerReply) {
  69. .repType = X_Reply,
  70. .RepType = X_XIGetClientPointer,
  71. .sequenceNumber = client->sequence,
  72. .length = 0,
  73. .set = (winclient->clientPtr != NULL),
  74. .deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0
  75. };
  76. WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep);
  77. return Success;
  78. }
  79. /***********************************************************************
  80. *
  81. * This procedure writes the reply for the XGetClientPointer function,
  82. * if the client and server have a different byte ordering.
  83. *
  84. */
  85. void
  86. SRepXIGetClientPointer(ClientPtr client, int size,
  87. xXIGetClientPointerReply * rep)
  88. {
  89. swaps(&rep->sequenceNumber);
  90. swapl(&rep->length);
  91. swaps(&rep->deviceid);
  92. WriteToClient(client, size, rep);
  93. }