xisetclientpointer.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 set the client pointer for the owner of the given window.
  28. * All subsequent calls that are ambiguous will choose the client pointer as
  29. * default value.
  30. */
  31. #ifdef HAVE_DIX_CONFIG_H
  32. #include <dix-config.h>
  33. #endif
  34. #include <X11/X.h> /* for inputstr.h */
  35. #include <X11/Xproto.h> /* Request macro */
  36. #include "inputstr.h" /* DeviceIntPtr */
  37. #include "windowstr.h" /* window structure */
  38. #include "scrnintstr.h" /* screen structure */
  39. #include <X11/extensions/XI.h>
  40. #include <X11/extensions/XI2proto.h>
  41. #include "extnsionst.h"
  42. #include "exevents.h"
  43. #include "exglobals.h"
  44. #include "xisetclientpointer.h"
  45. int
  46. SProcXISetClientPointer(ClientPtr client)
  47. {
  48. REQUEST(xXISetClientPointerReq);
  49. REQUEST_SIZE_MATCH(xXISetClientPointerReq);
  50. swaps(&stuff->length);
  51. swapl(&stuff->win);
  52. swaps(&stuff->deviceid);
  53. return (ProcXISetClientPointer(client));
  54. }
  55. int
  56. ProcXISetClientPointer(ClientPtr client)
  57. {
  58. DeviceIntPtr pDev;
  59. ClientPtr targetClient;
  60. int rc;
  61. REQUEST(xXISetClientPointerReq);
  62. REQUEST_SIZE_MATCH(xXISetClientPointerReq);
  63. rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixManageAccess);
  64. if (rc != Success) {
  65. client->errorValue = stuff->deviceid;
  66. return rc;
  67. }
  68. if (!IsMaster(pDev)) {
  69. client->errorValue = stuff->deviceid;
  70. return BadDevice;
  71. }
  72. pDev = GetMaster(pDev, MASTER_POINTER);
  73. if (stuff->win != None) {
  74. rc = dixLookupClient(&targetClient, stuff->win, client,
  75. DixManageAccess);
  76. if (rc != Success)
  77. return BadWindow;
  78. }
  79. else
  80. targetClient = client;
  81. rc = SetClientPointer(targetClient, pDev);
  82. if (rc != Success) {
  83. client->errorValue = stuff->deviceid;
  84. return rc;
  85. }
  86. return Success;
  87. }