grab.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* Copyright 2001-2003 by Norbert Freudemann, David Frese */
  2. #include "xlib.h"
  3. s48_ref_t scx_grab_mode_binding = NULL;
  4. #define scx_extract_grab_mode(c, x) \
  5. S48_EXTRACT_ENUM(c, x, scx_grab_mode_binding)
  6. s48_ref_t scx_grab_states_binding = NULL;
  7. #define scx_enter_grab_status(c, x) \
  8. S48_ENTER_ENUM(c, x, scx_grab_states_binding)
  9. s48_ref_t scx_Grab_Pointer(s48_call_t call, s48_ref_t dpy, s48_ref_t win,
  10. s48_ref_t ownerp, s48_ref_t events,
  11. s48_ref_t pmode, s48_ref_t kmode,
  12. s48_ref_t confine_to, s48_ref_t cursor,
  13. s48_ref_t time) {
  14. int res;
  15. res = XGrabPointer(scx_extract_display(call, dpy),
  16. scx_extract_window(call, win),
  17. s48_extract_boolean_2(call, ownerp),
  18. scx_extract_event_mask(call, events),
  19. scx_extract_grab_mode(call, pmode),
  20. scx_extract_grab_mode(call, kmode),
  21. scx_extract_window(call, confine_to),
  22. scx_extract_cursor(call, cursor),
  23. scx_extract_time(call, time));
  24. return scx_enter_grab_status(call, res);
  25. }
  26. s48_ref_t scx_Ungrab_Pointer(s48_call_t call, s48_ref_t dpy, s48_ref_t time)
  27. {
  28. XUngrabPointer(scx_extract_display(call, dpy), scx_extract_time(call, time));
  29. return s48_unspecific_2(call);
  30. }
  31. s48_ref_t scx_Change_Active_Pointer_Grab(s48_call_t call, s48_ref_t dpy,
  32. s48_ref_t events, s48_ref_t cursor, s48_ref_t time)
  33. {
  34. XChangeActivePointerGrab(scx_extract_display(call, dpy),
  35. scx_extract_event_mask(call, events),
  36. scx_extract_cursor(call, cursor),
  37. scx_extract_time(call, time));
  38. return s48_unspecific_2(call);
  39. }
  40. s48_ref_t scx_Grab_Button(s48_call_t call, s48_ref_t dpy,
  41. s48_ref_t button, s48_ref_t mods, s48_ref_t win,
  42. s48_ref_t ownerp, s48_ref_t events, s48_ref_t pmode,
  43. s48_ref_t kmode, s48_ref_t confine_to, s48_ref_t cursor) {
  44. XGrabButton(scx_extract_display(call, dpy),
  45. scx_extract_button(call, button),
  46. scx_extract_state_set(call, mods),
  47. scx_extract_window(call, win),
  48. s48_extract_boolean_2(call, ownerp),
  49. scx_extract_event_mask(call, events),
  50. scx_extract_grab_mode(call, pmode),
  51. scx_extract_grab_mode(call, kmode),
  52. scx_extract_window(call, confine_to),
  53. scx_extract_cursor(call, cursor));
  54. return s48_unspecific_2(call);
  55. }
  56. s48_ref_t scx_Ungrab_Button(s48_call_t call, s48_ref_t dpy, s48_ref_t button,
  57. s48_ref_t mods, s48_ref_t win) {
  58. XUngrabButton(scx_extract_display(call, dpy),
  59. scx_extract_button(call, button),
  60. scx_extract_state_set(call, mods),
  61. scx_extract_window(call, win));
  62. return s48_unspecific_2(call);
  63. }
  64. s48_ref_t scx_Grab_Keyboard(s48_call_t call, s48_ref_t dpy,
  65. s48_ref_t win, s48_ref_t ownerp, s48_ref_t pmode,
  66. s48_ref_t kmode, s48_ref_t time) {
  67. int res;
  68. res = XGrabKeyboard( scx_extract_display(call, dpy),
  69. scx_extract_window(call, win),
  70. s48_extract_boolean_2(call, ownerp),
  71. scx_extract_grab_mode(call, pmode),
  72. scx_extract_grab_mode(call, kmode),
  73. scx_extract_time(call, time));
  74. return scx_enter_grab_status(call, res);
  75. }
  76. s48_ref_t scx_Ungrab_Keyboard(s48_call_t call, s48_ref_t dpy, s48_ref_t time)
  77. {
  78. XUngrabKeyboard(scx_extract_display(call, dpy),
  79. scx_extract_time(call, time));
  80. return s48_unspecific_2(call);
  81. }
  82. s48_ref_t scx_Grab_Key(s48_call_t call, s48_ref_t dpy, s48_ref_t key,
  83. s48_ref_t mods, s48_ref_t win, s48_ref_t ownerp,
  84. s48_ref_t pmode, s48_ref_t kmode) {
  85. XGrabKey(scx_extract_display(call, dpy),
  86. s48_extract_long_2(call, key),
  87. scx_extract_state_set(call, mods),
  88. scx_extract_window(call, win),
  89. s48_extract_boolean_2(call, ownerp),
  90. scx_extract_grab_mode(call, pmode),
  91. scx_extract_grab_mode(call, kmode));
  92. return s48_unspecific_2(call);
  93. }
  94. s48_ref_t scx_Ungrab_Key(s48_call_t call, s48_ref_t dpy, s48_ref_t key,
  95. s48_ref_t mods, s48_ref_t win) {
  96. XUngrabKey(scx_extract_display(call, dpy),
  97. s48_extract_long_2(call, key),
  98. scx_extract_state_set(call, mods),
  99. scx_extract_window(call, win));
  100. return s48_unspecific_2(call);
  101. }
  102. s48_ref_t scx_event_mode_binding = NULL;
  103. #define scx_extract_event_mode(c, x) \
  104. S48_EXTRACT_ENUM(c, x, scx_event_mode_binding)
  105. s48_ref_t scx_Allow_Events(s48_call_t call, s48_ref_t dpy,
  106. s48_ref_t event_mode, s48_ref_t time) {
  107. XAllowEvents(scx_extract_display(call, dpy),
  108. scx_extract_event_mode(call, event_mode),
  109. scx_extract_time(call, time));
  110. return s48_unspecific_2(call);
  111. }
  112. s48_ref_t scx_Grab_Server(s48_call_t call, s48_ref_t dpy) {
  113. XGrabServer(scx_extract_display(call, dpy));
  114. return s48_unspecific_2(call);
  115. }
  116. s48_ref_t scx_Ungrab_Server(s48_call_t call, s48_ref_t dpy){
  117. XUngrabServer(scx_extract_display(call, dpy));
  118. return s48_unspecific_2(call);
  119. }
  120. void scx_init_grab(void) {
  121. scx_grab_mode_binding = s48_get_imported_binding_2("scx-grab-mode");
  122. scx_grab_states_binding = s48_get_imported_binding_2("scx-grab-states");
  123. scx_event_mode_binding = s48_get_imported_binding_2("scx-event-mode");
  124. S48_EXPORT_FUNCTION(scx_Grab_Pointer);
  125. S48_EXPORT_FUNCTION(scx_Ungrab_Pointer);
  126. S48_EXPORT_FUNCTION(scx_Grab_Button);
  127. S48_EXPORT_FUNCTION(scx_Ungrab_Button);
  128. S48_EXPORT_FUNCTION(scx_Change_Active_Pointer_Grab);
  129. S48_EXPORT_FUNCTION(scx_Grab_Keyboard);
  130. S48_EXPORT_FUNCTION(scx_Ungrab_Keyboard);
  131. S48_EXPORT_FUNCTION(scx_Grab_Key);
  132. S48_EXPORT_FUNCTION(scx_Ungrab_Key);
  133. S48_EXPORT_FUNCTION(scx_Allow_Events);
  134. S48_EXPORT_FUNCTION(scx_Grab_Server);
  135. S48_EXPORT_FUNCTION(scx_Ungrab_Server);
  136. }