example-code.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /* SCANNER TEST */
  2. /*
  3. * Copyright © 2008-2011 Kristian Høgsberg
  4. * Copyright © 2010-2011 Intel Corporation
  5. * Copyright © 2012-2013 Collabora, Ltd.
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation files
  9. * (the "Software"), to deal in the Software without restriction,
  10. * including without limitation the rights to use, copy, modify, merge,
  11. * publish, distribute, sublicense, and/or sell copies of the Software,
  12. * and to permit persons to whom the Software is furnished to do so,
  13. * subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice (including the
  16. * next paragraph) shall be included in all copies or substantial
  17. * portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  23. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  24. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. * SOFTWARE.
  27. */
  28. #include <stdbool.h>
  29. #include <stdlib.h>
  30. #include <stdint.h>
  31. #include "wayland-util.h"
  32. extern const struct wl_interface wl_buffer_interface;
  33. extern const struct wl_interface wl_callback_interface;
  34. extern const struct wl_interface wl_data_device_interface;
  35. extern const struct wl_interface wl_data_offer_interface;
  36. extern const struct wl_interface wl_data_source_interface;
  37. extern const struct wl_interface wl_keyboard_interface;
  38. extern const struct wl_interface wl_output_interface;
  39. extern const struct wl_interface wl_pointer_interface;
  40. extern const struct wl_interface wl_region_interface;
  41. extern const struct wl_interface wl_registry_interface;
  42. extern const struct wl_interface wl_seat_interface;
  43. extern const struct wl_interface wl_shell_surface_interface;
  44. extern const struct wl_interface wl_shm_pool_interface;
  45. extern const struct wl_interface wl_subsurface_interface;
  46. extern const struct wl_interface wl_surface_interface;
  47. extern const struct wl_interface wl_touch_interface;
  48. static const struct wl_interface *wayland_types[] = {
  49. NULL,
  50. NULL,
  51. NULL,
  52. NULL,
  53. NULL,
  54. NULL,
  55. NULL,
  56. NULL,
  57. &wl_callback_interface,
  58. &wl_registry_interface,
  59. &wl_surface_interface,
  60. &wl_region_interface,
  61. &wl_buffer_interface,
  62. NULL,
  63. NULL,
  64. NULL,
  65. NULL,
  66. NULL,
  67. &wl_shm_pool_interface,
  68. NULL,
  69. NULL,
  70. &wl_data_source_interface,
  71. &wl_surface_interface,
  72. &wl_surface_interface,
  73. NULL,
  74. &wl_data_source_interface,
  75. NULL,
  76. &wl_data_offer_interface,
  77. NULL,
  78. &wl_surface_interface,
  79. NULL,
  80. NULL,
  81. &wl_data_offer_interface,
  82. &wl_data_offer_interface,
  83. &wl_data_source_interface,
  84. &wl_data_device_interface,
  85. &wl_seat_interface,
  86. &wl_shell_surface_interface,
  87. &wl_surface_interface,
  88. &wl_seat_interface,
  89. NULL,
  90. &wl_seat_interface,
  91. NULL,
  92. NULL,
  93. &wl_surface_interface,
  94. NULL,
  95. NULL,
  96. NULL,
  97. NULL,
  98. NULL,
  99. &wl_output_interface,
  100. &wl_seat_interface,
  101. NULL,
  102. &wl_surface_interface,
  103. NULL,
  104. NULL,
  105. NULL,
  106. &wl_output_interface,
  107. &wl_buffer_interface,
  108. NULL,
  109. NULL,
  110. &wl_callback_interface,
  111. &wl_region_interface,
  112. &wl_region_interface,
  113. &wl_output_interface,
  114. &wl_output_interface,
  115. &wl_pointer_interface,
  116. &wl_keyboard_interface,
  117. &wl_touch_interface,
  118. NULL,
  119. &wl_surface_interface,
  120. NULL,
  121. NULL,
  122. NULL,
  123. &wl_surface_interface,
  124. NULL,
  125. NULL,
  126. NULL,
  127. &wl_surface_interface,
  128. NULL,
  129. &wl_surface_interface,
  130. NULL,
  131. NULL,
  132. &wl_surface_interface,
  133. NULL,
  134. NULL,
  135. &wl_surface_interface,
  136. NULL,
  137. NULL,
  138. NULL,
  139. &wl_subsurface_interface,
  140. &wl_surface_interface,
  141. &wl_surface_interface,
  142. &wl_surface_interface,
  143. &wl_surface_interface,
  144. };
  145. static const struct wl_message wl_display_requests[] = {
  146. { "sync", "n", wayland_types + 8 },
  147. { "get_registry", "n", wayland_types + 9 },
  148. };
  149. static const struct wl_message wl_display_events[] = {
  150. { "error", "ous", wayland_types + 0 },
  151. { "delete_id", "u", wayland_types + 0 },
  152. };
  153. WL_EXPORT const struct wl_interface wl_display_interface = {
  154. "wl_display", 1,
  155. 2, wl_display_requests,
  156. 2, wl_display_events,
  157. };
  158. static const struct wl_message wl_registry_requests[] = {
  159. { "bind", "usun", wayland_types + 0 },
  160. };
  161. static const struct wl_message wl_registry_events[] = {
  162. { "global", "usu", wayland_types + 0 },
  163. { "global_remove", "u", wayland_types + 0 },
  164. };
  165. WL_EXPORT const struct wl_interface wl_registry_interface = {
  166. "wl_registry", 1,
  167. 1, wl_registry_requests,
  168. 2, wl_registry_events,
  169. };
  170. static const struct wl_message wl_callback_events[] = {
  171. { "done", "u", wayland_types + 0 },
  172. };
  173. WL_EXPORT const struct wl_interface wl_callback_interface = {
  174. "wl_callback", 1,
  175. 0, NULL,
  176. 1, wl_callback_events,
  177. };
  178. static const struct wl_message wl_compositor_requests[] = {
  179. { "create_surface", "n", wayland_types + 10 },
  180. { "create_region", "n", wayland_types + 11 },
  181. };
  182. WL_EXPORT const struct wl_interface wl_compositor_interface = {
  183. "wl_compositor", 4,
  184. 2, wl_compositor_requests,
  185. 0, NULL,
  186. };
  187. static const struct wl_message wl_shm_pool_requests[] = {
  188. { "create_buffer", "niiiiu", wayland_types + 12 },
  189. { "destroy", "", wayland_types + 0 },
  190. { "resize", "i", wayland_types + 0 },
  191. };
  192. WL_EXPORT const struct wl_interface wl_shm_pool_interface = {
  193. "wl_shm_pool", 1,
  194. 3, wl_shm_pool_requests,
  195. 0, NULL,
  196. };
  197. static const struct wl_message wl_shm_requests[] = {
  198. { "create_pool", "nhi", wayland_types + 18 },
  199. };
  200. static const struct wl_message wl_shm_events[] = {
  201. { "format", "u", wayland_types + 0 },
  202. };
  203. WL_EXPORT const struct wl_interface wl_shm_interface = {
  204. "wl_shm", 1,
  205. 1, wl_shm_requests,
  206. 1, wl_shm_events,
  207. };
  208. static const struct wl_message wl_buffer_requests[] = {
  209. { "destroy", "", wayland_types + 0 },
  210. };
  211. static const struct wl_message wl_buffer_events[] = {
  212. { "release", "", wayland_types + 0 },
  213. };
  214. WL_EXPORT const struct wl_interface wl_buffer_interface = {
  215. "wl_buffer", 1,
  216. 1, wl_buffer_requests,
  217. 1, wl_buffer_events,
  218. };
  219. static const struct wl_message wl_data_offer_requests[] = {
  220. { "accept", "u?s", wayland_types + 0 },
  221. { "receive", "sh", wayland_types + 0 },
  222. { "destroy", "", wayland_types + 0 },
  223. { "finish", "3", wayland_types + 0 },
  224. { "set_actions", "3uu", wayland_types + 0 },
  225. };
  226. static const struct wl_message wl_data_offer_events[] = {
  227. { "offer", "s", wayland_types + 0 },
  228. { "source_actions", "3u", wayland_types + 0 },
  229. { "action", "3u", wayland_types + 0 },
  230. };
  231. WL_EXPORT const struct wl_interface wl_data_offer_interface = {
  232. "wl_data_offer", 3,
  233. 5, wl_data_offer_requests,
  234. 3, wl_data_offer_events,
  235. };
  236. static const struct wl_message wl_data_source_requests[] = {
  237. { "offer", "s", wayland_types + 0 },
  238. { "destroy", "", wayland_types + 0 },
  239. { "set_actions", "3u", wayland_types + 0 },
  240. };
  241. static const struct wl_message wl_data_source_events[] = {
  242. { "target", "?s", wayland_types + 0 },
  243. { "send", "sh", wayland_types + 0 },
  244. { "cancelled", "", wayland_types + 0 },
  245. { "dnd_drop_performed", "3", wayland_types + 0 },
  246. { "dnd_finished", "3", wayland_types + 0 },
  247. { "action", "3u", wayland_types + 0 },
  248. };
  249. WL_EXPORT const struct wl_interface wl_data_source_interface = {
  250. "wl_data_source", 3,
  251. 3, wl_data_source_requests,
  252. 6, wl_data_source_events,
  253. };
  254. static const struct wl_message wl_data_device_requests[] = {
  255. { "start_drag", "?oo?ou", wayland_types + 21 },
  256. { "set_selection", "?ou", wayland_types + 25 },
  257. { "release", "2", wayland_types + 0 },
  258. };
  259. static const struct wl_message wl_data_device_events[] = {
  260. { "data_offer", "n", wayland_types + 27 },
  261. { "enter", "uoff?o", wayland_types + 28 },
  262. { "leave", "", wayland_types + 0 },
  263. { "motion", "uff", wayland_types + 0 },
  264. { "drop", "", wayland_types + 0 },
  265. { "selection", "?o", wayland_types + 33 },
  266. };
  267. WL_EXPORT const struct wl_interface wl_data_device_interface = {
  268. "wl_data_device", 3,
  269. 3, wl_data_device_requests,
  270. 6, wl_data_device_events,
  271. };
  272. static const struct wl_message wl_data_device_manager_requests[] = {
  273. { "create_data_source", "n", wayland_types + 34 },
  274. { "get_data_device", "no", wayland_types + 35 },
  275. };
  276. WL_EXPORT const struct wl_interface wl_data_device_manager_interface = {
  277. "wl_data_device_manager", 3,
  278. 2, wl_data_device_manager_requests,
  279. 0, NULL,
  280. };
  281. static const struct wl_message wl_shell_requests[] = {
  282. { "get_shell_surface", "no", wayland_types + 37 },
  283. };
  284. WL_EXPORT const struct wl_interface wl_shell_interface = {
  285. "wl_shell", 1,
  286. 1, wl_shell_requests,
  287. 0, NULL,
  288. };
  289. static const struct wl_message wl_shell_surface_requests[] = {
  290. { "pong", "u", wayland_types + 0 },
  291. { "move", "ou", wayland_types + 39 },
  292. { "resize", "ouu", wayland_types + 41 },
  293. { "set_toplevel", "", wayland_types + 0 },
  294. { "set_transient", "oiiu", wayland_types + 44 },
  295. { "set_fullscreen", "uu?o", wayland_types + 48 },
  296. { "set_popup", "ouoiiu", wayland_types + 51 },
  297. { "set_maximized", "?o", wayland_types + 57 },
  298. { "set_title", "s", wayland_types + 0 },
  299. { "set_class", "s", wayland_types + 0 },
  300. };
  301. static const struct wl_message wl_shell_surface_events[] = {
  302. { "ping", "u", wayland_types + 0 },
  303. { "configure", "uii", wayland_types + 0 },
  304. { "popup_done", "", wayland_types + 0 },
  305. };
  306. WL_EXPORT const struct wl_interface wl_shell_surface_interface = {
  307. "wl_shell_surface", 1,
  308. 10, wl_shell_surface_requests,
  309. 3, wl_shell_surface_events,
  310. };
  311. static const struct wl_message wl_surface_requests[] = {
  312. { "destroy", "", wayland_types + 0 },
  313. { "attach", "?oii", wayland_types + 58 },
  314. { "damage", "iiii", wayland_types + 0 },
  315. { "frame", "n", wayland_types + 61 },
  316. { "set_opaque_region", "?o", wayland_types + 62 },
  317. { "set_input_region", "?o", wayland_types + 63 },
  318. { "commit", "", wayland_types + 0 },
  319. { "set_buffer_transform", "2i", wayland_types + 0 },
  320. { "set_buffer_scale", "3i", wayland_types + 0 },
  321. { "damage_buffer", "4iiii", wayland_types + 0 },
  322. };
  323. static const struct wl_message wl_surface_events[] = {
  324. { "enter", "o", wayland_types + 64 },
  325. { "leave", "o", wayland_types + 65 },
  326. };
  327. WL_EXPORT const struct wl_interface wl_surface_interface = {
  328. "wl_surface", 4,
  329. 10, wl_surface_requests,
  330. 2, wl_surface_events,
  331. };
  332. static const struct wl_message wl_seat_requests[] = {
  333. { "get_pointer", "n", wayland_types + 66 },
  334. { "get_keyboard", "n", wayland_types + 67 },
  335. { "get_touch", "n", wayland_types + 68 },
  336. { "release", "5", wayland_types + 0 },
  337. };
  338. static const struct wl_message wl_seat_events[] = {
  339. { "capabilities", "u", wayland_types + 0 },
  340. { "name", "2s", wayland_types + 0 },
  341. };
  342. WL_EXPORT const struct wl_interface wl_seat_interface = {
  343. "wl_seat", 6,
  344. 4, wl_seat_requests,
  345. 2, wl_seat_events,
  346. };
  347. static const struct wl_message wl_pointer_requests[] = {
  348. { "set_cursor", "u?oii", wayland_types + 69 },
  349. { "release", "3", wayland_types + 0 },
  350. };
  351. static const struct wl_message wl_pointer_events[] = {
  352. { "enter", "uoff", wayland_types + 73 },
  353. { "leave", "uo", wayland_types + 77 },
  354. { "motion", "uff", wayland_types + 0 },
  355. { "button", "uuuu", wayland_types + 0 },
  356. { "axis", "uuf", wayland_types + 0 },
  357. { "frame", "5", wayland_types + 0 },
  358. { "axis_source", "5u", wayland_types + 0 },
  359. { "axis_stop", "5uu", wayland_types + 0 },
  360. { "axis_discrete", "5ui", wayland_types + 0 },
  361. };
  362. WL_EXPORT const struct wl_interface wl_pointer_interface = {
  363. "wl_pointer", 6,
  364. 2, wl_pointer_requests,
  365. 9, wl_pointer_events,
  366. };
  367. static const struct wl_message wl_keyboard_requests[] = {
  368. { "release", "3", wayland_types + 0 },
  369. };
  370. static const struct wl_message wl_keyboard_events[] = {
  371. { "keymap", "uhu", wayland_types + 0 },
  372. { "enter", "uoa", wayland_types + 79 },
  373. { "leave", "uo", wayland_types + 82 },
  374. { "key", "uuuu", wayland_types + 0 },
  375. { "modifiers", "uuuuu", wayland_types + 0 },
  376. { "repeat_info", "4ii", wayland_types + 0 },
  377. };
  378. WL_EXPORT const struct wl_interface wl_keyboard_interface = {
  379. "wl_keyboard", 6,
  380. 1, wl_keyboard_requests,
  381. 6, wl_keyboard_events,
  382. };
  383. static const struct wl_message wl_touch_requests[] = {
  384. { "release", "3", wayland_types + 0 },
  385. };
  386. static const struct wl_message wl_touch_events[] = {
  387. { "down", "uuoiff", wayland_types + 84 },
  388. { "up", "uui", wayland_types + 0 },
  389. { "motion", "uiff", wayland_types + 0 },
  390. { "frame", "", wayland_types + 0 },
  391. { "cancel", "", wayland_types + 0 },
  392. { "shape", "6iff", wayland_types + 0 },
  393. { "orientation", "6if", wayland_types + 0 },
  394. };
  395. WL_EXPORT const struct wl_interface wl_touch_interface = {
  396. "wl_touch", 6,
  397. 1, wl_touch_requests,
  398. 7, wl_touch_events,
  399. };
  400. static const struct wl_message wl_output_requests[] = {
  401. { "release", "3", wayland_types + 0 },
  402. };
  403. static const struct wl_message wl_output_events[] = {
  404. { "geometry", "iiiiissi", wayland_types + 0 },
  405. { "mode", "uiii", wayland_types + 0 },
  406. { "done", "2", wayland_types + 0 },
  407. { "scale", "2i", wayland_types + 0 },
  408. };
  409. WL_EXPORT const struct wl_interface wl_output_interface = {
  410. "wl_output", 3,
  411. 1, wl_output_requests,
  412. 4, wl_output_events,
  413. };
  414. static const struct wl_message wl_region_requests[] = {
  415. { "destroy", "", wayland_types + 0 },
  416. { "add", "iiii", wayland_types + 0 },
  417. { "subtract", "iiii", wayland_types + 0 },
  418. };
  419. WL_EXPORT const struct wl_interface wl_region_interface = {
  420. "wl_region", 1,
  421. 3, wl_region_requests,
  422. 0, NULL,
  423. };
  424. static const struct wl_message wl_subcompositor_requests[] = {
  425. { "destroy", "", wayland_types + 0 },
  426. { "get_subsurface", "noo", wayland_types + 90 },
  427. };
  428. WL_EXPORT const struct wl_interface wl_subcompositor_interface = {
  429. "wl_subcompositor", 1,
  430. 2, wl_subcompositor_requests,
  431. 0, NULL,
  432. };
  433. static const struct wl_message wl_subsurface_requests[] = {
  434. { "destroy", "", wayland_types + 0 },
  435. { "set_position", "ii", wayland_types + 0 },
  436. { "place_above", "o", wayland_types + 93 },
  437. { "place_below", "o", wayland_types + 94 },
  438. { "set_sync", "", wayland_types + 0 },
  439. { "set_desync", "", wayland_types + 0 },
  440. };
  441. WL_EXPORT const struct wl_interface wl_subsurface_interface = {
  442. "wl_subsurface", 1,
  443. 6, wl_subsurface_requests,
  444. 0, NULL,
  445. };