koffi 0.9.5 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (882) hide show
  1. package/LICENSE.txt +661 -0
  2. package/README.md +74 -9
  3. package/package.json +27 -7
  4. package/src/call.hh +2 -1
  5. package/src/call_arm32.cc +525 -0
  6. package/src/call_arm32_fwd.S +108 -0
  7. package/src/call_arm64.cc +90 -63
  8. package/src/call_arm64_fwd.S +24 -29
  9. package/src/call_x64_sysv.cc +61 -48
  10. package/src/call_x64_win.cc +69 -43
  11. package/src/call_x86.cc +83 -62
  12. package/src/ffi.cc +166 -37
  13. package/src/ffi.hh +43 -12
  14. package/src/util.cc +72 -32
  15. package/src/util.hh +127 -18
  16. package/test/files/node32.cmd +6 -0
  17. package/test/files/node64.cmd +6 -0
  18. package/test/registry/machines.json +185 -0
  19. package/test/registry/sha256sum.txt +24 -0
  20. package/test/test.js +625 -0
  21. package/test/tests/misc.c +40 -0
  22. package/test/tests/misc.js +54 -0
  23. package/test/tests/raylib.js +167 -0
  24. package/vendor/dragonbox/include/dragonbox/dragonbox.h +6 -2
  25. package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
  26. package/vendor/libcc/libcc.cc +36 -18
  27. package/vendor/libcc/libcc.hh +23 -1
  28. package/vendor/raylib/BINDINGS.md +123 -0
  29. package/vendor/raylib/CHANGELOG +1495 -0
  30. package/vendor/raylib/CMakeLists.txt +33 -0
  31. package/vendor/raylib/CMakeOptions.txt +87 -0
  32. package/vendor/raylib/CONTRIBUTING.md +76 -0
  33. package/vendor/raylib/CONTRIBUTORS.md +63 -0
  34. package/vendor/raylib/CONVENTIONS.md +95 -0
  35. package/vendor/raylib/HISTORY.md +364 -0
  36. package/vendor/raylib/LICENSE +16 -0
  37. package/vendor/raylib/README.md +141 -0
  38. package/vendor/raylib/ROADMAP.md +76 -0
  39. package/vendor/raylib/SPONSORS.md +68 -0
  40. package/vendor/raylib/cmake/AddIfFlagCompiles.cmake +12 -0
  41. package/vendor/raylib/cmake/BuildOptions.cmake +18 -0
  42. package/vendor/raylib/cmake/CompileDefinitions.cmake +110 -0
  43. package/vendor/raylib/cmake/CompilerFlags.cmake +79 -0
  44. package/vendor/raylib/cmake/EnumOption.cmake +9 -0
  45. package/vendor/raylib/cmake/GlfwImport.cmake +34 -0
  46. package/vendor/raylib/cmake/InstallConfigurations.cmake +29 -0
  47. package/vendor/raylib/cmake/JoinPaths.cmake +26 -0
  48. package/vendor/raylib/cmake/LibraryConfigurations.cmake +108 -0
  49. package/vendor/raylib/cmake/LibraryPathToLinkerFlags.cmake +24 -0
  50. package/vendor/raylib/cmake/PackConfigurations.cmake +13 -0
  51. package/vendor/raylib/cmake/PopulateConfigVariablesLocally.cmake +11 -0
  52. package/vendor/raylib/cmake/raylib-config-version.cmake +21 -0
  53. package/vendor/raylib/cmake/raylib-config.cmake +76 -0
  54. package/vendor/raylib/examples/CMakeLists.txt +139 -0
  55. package/vendor/raylib/examples/Makefile +565 -0
  56. package/vendor/raylib/examples/Makefile.Android +405 -0
  57. package/vendor/raylib/examples/Makefile.Web +1053 -0
  58. package/vendor/raylib/examples/README.md +203 -0
  59. package/vendor/raylib/examples/audio/audio_module_playing.c +146 -0
  60. package/vendor/raylib/examples/audio/audio_module_playing.png +0 -0
  61. package/vendor/raylib/examples/audio/audio_multichannel_sound.c +73 -0
  62. package/vendor/raylib/examples/audio/audio_multichannel_sound.png +0 -0
  63. package/vendor/raylib/examples/audio/audio_music_stream.c +93 -0
  64. package/vendor/raylib/examples/audio/audio_music_stream.png +0 -0
  65. package/vendor/raylib/examples/audio/audio_raw_stream.c +167 -0
  66. package/vendor/raylib/examples/audio/audio_raw_stream.png +0 -0
  67. package/vendor/raylib/examples/audio/audio_sound_loading.c +64 -0
  68. package/vendor/raylib/examples/audio/audio_sound_loading.png +0 -0
  69. package/vendor/raylib/examples/audio/resources/LICENSE.md +10 -0
  70. package/vendor/raylib/examples/audio/resources/coin.wav +0 -0
  71. package/vendor/raylib/examples/audio/resources/country.mp3 +0 -0
  72. package/vendor/raylib/examples/audio/resources/mini1111.xm +0 -0
  73. package/vendor/raylib/examples/audio/resources/sound.wav +0 -0
  74. package/vendor/raylib/examples/audio/resources/spring.wav +0 -0
  75. package/vendor/raylib/examples/audio/resources/target.flac +0 -0
  76. package/vendor/raylib/examples/audio/resources/target.ogg +0 -0
  77. package/vendor/raylib/examples/audio/resources/weird.wav +0 -0
  78. package/vendor/raylib/examples/build.zig +86 -0
  79. package/vendor/raylib/examples/core/core_2d_camera.c +132 -0
  80. package/vendor/raylib/examples/core/core_2d_camera.png +0 -0
  81. package/vendor/raylib/examples/core/core_2d_camera_platformer.c +293 -0
  82. package/vendor/raylib/examples/core/core_2d_camera_platformer.png +0 -0
  83. package/vendor/raylib/examples/core/core_2d_camera_smooth_pixelperfect.png +0 -0
  84. package/vendor/raylib/examples/core/core_3d_camera_first_person.c +97 -0
  85. package/vendor/raylib/examples/core/core_3d_camera_first_person.png +0 -0
  86. package/vendor/raylib/examples/core/core_3d_camera_free.c +83 -0
  87. package/vendor/raylib/examples/core/core_3d_camera_free.png +0 -0
  88. package/vendor/raylib/examples/core/core_3d_camera_mode.c +73 -0
  89. package/vendor/raylib/examples/core/core_3d_camera_mode.png +0 -0
  90. package/vendor/raylib/examples/core/core_3d_picking.c +107 -0
  91. package/vendor/raylib/examples/core/core_3d_picking.png +0 -0
  92. package/vendor/raylib/examples/core/core_basic_screen_manager.c +150 -0
  93. package/vendor/raylib/examples/core/core_basic_screen_manager.png +0 -0
  94. package/vendor/raylib/examples/core/core_basic_window.c +62 -0
  95. package/vendor/raylib/examples/core/core_basic_window.png +0 -0
  96. package/vendor/raylib/examples/core/core_basic_window_web.c +85 -0
  97. package/vendor/raylib/examples/core/core_custom_frame_control.c +125 -0
  98. package/vendor/raylib/examples/core/core_custom_frame_control.png +0 -0
  99. package/vendor/raylib/examples/core/core_custom_logging.c +84 -0
  100. package/vendor/raylib/examples/core/core_custom_logging.png +0 -0
  101. package/vendor/raylib/examples/core/core_drop_files.c +76 -0
  102. package/vendor/raylib/examples/core/core_drop_files.png +0 -0
  103. package/vendor/raylib/examples/core/core_input_gamepad.c +195 -0
  104. package/vendor/raylib/examples/core/core_input_gamepad.png +0 -0
  105. package/vendor/raylib/examples/core/core_input_gestures.c +115 -0
  106. package/vendor/raylib/examples/core/core_input_gestures.png +0 -0
  107. package/vendor/raylib/examples/core/core_input_keys.c +59 -0
  108. package/vendor/raylib/examples/core/core_input_keys.png +0 -0
  109. package/vendor/raylib/examples/core/core_input_mouse.c +65 -0
  110. package/vendor/raylib/examples/core/core_input_mouse.png +0 -0
  111. package/vendor/raylib/examples/core/core_input_mouse_wheel.c +58 -0
  112. package/vendor/raylib/examples/core/core_input_mouse_wheel.png +0 -0
  113. package/vendor/raylib/examples/core/core_input_multitouch.c +70 -0
  114. package/vendor/raylib/examples/core/core_input_multitouch.png +0 -0
  115. package/vendor/raylib/examples/core/core_loading_thread.c +147 -0
  116. package/vendor/raylib/examples/core/core_loading_thread.png +0 -0
  117. package/vendor/raylib/examples/core/core_quat_conversion.c +132 -0
  118. package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
  119. package/vendor/raylib/examples/core/core_random_values.c +67 -0
  120. package/vendor/raylib/examples/core/core_random_values.png +0 -0
  121. package/vendor/raylib/examples/core/core_scissor_test.c +71 -0
  122. package/vendor/raylib/examples/core/core_scissor_test.png +0 -0
  123. package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +117 -0
  124. package/vendor/raylib/examples/core/core_smooth_pixelperfect.png +0 -0
  125. package/vendor/raylib/examples/core/core_split_screen.c +155 -0
  126. package/vendor/raylib/examples/core/core_split_screen.png +0 -0
  127. package/vendor/raylib/examples/core/core_storage_values.c +87 -0
  128. package/vendor/raylib/examples/core/core_storage_values.png +0 -0
  129. package/vendor/raylib/examples/core/core_vr_simulator.c +143 -0
  130. package/vendor/raylib/examples/core/core_vr_simulator.png +0 -0
  131. package/vendor/raylib/examples/core/core_window_flags.c +191 -0
  132. package/vendor/raylib/examples/core/core_window_flags.png +0 -0
  133. package/vendor/raylib/examples/core/core_window_letterbox.c +112 -0
  134. package/vendor/raylib/examples/core/core_window_letterbox.png +0 -0
  135. package/vendor/raylib/examples/core/core_world_screen.c +78 -0
  136. package/vendor/raylib/examples/core/core_world_screen.png +0 -0
  137. package/vendor/raylib/examples/core/resources/LICENSE.md +4 -0
  138. package/vendor/raylib/examples/core/resources/distortion100.fs +52 -0
  139. package/vendor/raylib/examples/core/resources/distortion330.fs +53 -0
  140. package/vendor/raylib/examples/core/resources/ps3.png +0 -0
  141. package/vendor/raylib/examples/core/resources/xbox.png +0 -0
  142. package/vendor/raylib/examples/examples_template.c +100 -0
  143. package/vendor/raylib/examples/models/models_animation.c +114 -0
  144. package/vendor/raylib/examples/models/models_animation.png +0 -0
  145. package/vendor/raylib/examples/models/models_billboard.c +75 -0
  146. package/vendor/raylib/examples/models/models_billboard.png +0 -0
  147. package/vendor/raylib/examples/models/models_box_collisions.c +121 -0
  148. package/vendor/raylib/examples/models/models_box_collisions.png +0 -0
  149. package/vendor/raylib/examples/models/models_cubicmap.c +87 -0
  150. package/vendor/raylib/examples/models/models_cubicmap.png +0 -0
  151. package/vendor/raylib/examples/models/models_first_person_maze.c +122 -0
  152. package/vendor/raylib/examples/models/models_first_person_maze.png +0 -0
  153. package/vendor/raylib/examples/models/models_geometric_shapes.c +80 -0
  154. package/vendor/raylib/examples/models/models_geometric_shapes.png +0 -0
  155. package/vendor/raylib/examples/models/models_heightmap.c +82 -0
  156. package/vendor/raylib/examples/models/models_heightmap.png +0 -0
  157. package/vendor/raylib/examples/models/models_loading.c +146 -0
  158. package/vendor/raylib/examples/models/models_loading.png +0 -0
  159. package/vendor/raylib/examples/models/models_loading_gltf.c +105 -0
  160. package/vendor/raylib/examples/models/models_loading_gltf.png +0 -0
  161. package/vendor/raylib/examples/models/models_loading_vox.c +130 -0
  162. package/vendor/raylib/examples/models/models_loading_vox.png +0 -0
  163. package/vendor/raylib/examples/models/models_mesh_generation.c +179 -0
  164. package/vendor/raylib/examples/models/models_mesh_generation.png +0 -0
  165. package/vendor/raylib/examples/models/models_mesh_picking.c +223 -0
  166. package/vendor/raylib/examples/models/models_mesh_picking.png +0 -0
  167. package/vendor/raylib/examples/models/models_orthographic_projection.c +99 -0
  168. package/vendor/raylib/examples/models/models_orthographic_projection.png +0 -0
  169. package/vendor/raylib/examples/models/models_rlgl_solar_system.c +172 -0
  170. package/vendor/raylib/examples/models/models_rlgl_solar_system.png +0 -0
  171. package/vendor/raylib/examples/models/models_skybox.c +262 -0
  172. package/vendor/raylib/examples/models/models_skybox.png +0 -0
  173. package/vendor/raylib/examples/models/models_waving_cubes.c +112 -0
  174. package/vendor/raylib/examples/models/models_waving_cubes.png +0 -0
  175. package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +117 -0
  176. package/vendor/raylib/examples/models/models_yaw_pitch_roll.png +0 -0
  177. package/vendor/raylib/examples/models/resources/LICENSE.md +23 -0
  178. package/vendor/raylib/examples/models/resources/billboard.png +0 -0
  179. package/vendor/raylib/examples/models/resources/cubicmap.png +0 -0
  180. package/vendor/raylib/examples/models/resources/cubicmap_atlas.png +0 -0
  181. package/vendor/raylib/examples/models/resources/dresden_square_1k.hdr +0 -0
  182. package/vendor/raylib/examples/models/resources/dresden_square_2k.hdr +0 -0
  183. package/vendor/raylib/examples/models/resources/heightmap.png +0 -0
  184. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
  185. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +118 -0
  186. package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
  187. package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +23 -0
  188. package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
  189. package/vendor/raylib/examples/models/resources/models/gltf/raylib_32x32.glb +0 -0
  190. package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
  191. package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
  192. package/vendor/raylib/examples/models/resources/models/iqm/guy.blend +0 -0
  193. package/vendor/raylib/examples/models/resources/models/iqm/guy.iqm +0 -0
  194. package/vendor/raylib/examples/models/resources/models/iqm/guyanim.iqm +0 -0
  195. package/vendor/raylib/examples/models/resources/models/iqm/guytex.png +0 -0
  196. package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
  197. package/vendor/raylib/examples/models/resources/models/obj/bridge.obj +1725 -0
  198. package/vendor/raylib/examples/models/resources/models/obj/bridge_diffuse.png +0 -0
  199. package/vendor/raylib/examples/models/resources/models/obj/castle.obj +12919 -0
  200. package/vendor/raylib/examples/models/resources/models/obj/castle_diffuse.png +0 -0
  201. package/vendor/raylib/examples/models/resources/models/obj/cube.obj +68 -0
  202. package/vendor/raylib/examples/models/resources/models/obj/cube_diffuse.png +0 -0
  203. package/vendor/raylib/examples/models/resources/models/obj/house.obj +4564 -0
  204. package/vendor/raylib/examples/models/resources/models/obj/house_diffuse.png +0 -0
  205. package/vendor/raylib/examples/models/resources/models/obj/market.obj +7301 -0
  206. package/vendor/raylib/examples/models/resources/models/obj/market_diffuse.png +0 -0
  207. package/vendor/raylib/examples/models/resources/models/obj/plane.obj +10858 -0
  208. package/vendor/raylib/examples/models/resources/models/obj/plane_diffuse.png +0 -0
  209. package/vendor/raylib/examples/models/resources/models/obj/turret.obj +1888 -0
  210. package/vendor/raylib/examples/models/resources/models/obj/turret_diffuse.png +0 -0
  211. package/vendor/raylib/examples/models/resources/models/obj/well.obj +1030 -0
  212. package/vendor/raylib/examples/models/resources/models/obj/well_diffuse.png +0 -0
  213. package/vendor/raylib/examples/models/resources/models/vox/LICENSE +9 -0
  214. package/vendor/raylib/examples/models/resources/models/vox/chr_knight.vox +0 -0
  215. package/vendor/raylib/examples/models/resources/models/vox/chr_sword.vox +0 -0
  216. package/vendor/raylib/examples/models/resources/models/vox/monu9.vox +0 -0
  217. package/vendor/raylib/examples/models/resources/shaders/glsl100/cubemap.fs +29 -0
  218. package/vendor/raylib/examples/models/resources/shaders/glsl100/cubemap.vs +20 -0
  219. package/vendor/raylib/examples/models/resources/shaders/glsl100/skybox.fs +31 -0
  220. package/vendor/raylib/examples/models/resources/shaders/glsl100/skybox.vs +24 -0
  221. package/vendor/raylib/examples/models/resources/shaders/glsl330/cubemap.fs +30 -0
  222. package/vendor/raylib/examples/models/resources/shaders/glsl330/cubemap.vs +20 -0
  223. package/vendor/raylib/examples/models/resources/shaders/glsl330/skybox.fs +30 -0
  224. package/vendor/raylib/examples/models/resources/shaders/glsl330/skybox.vs +24 -0
  225. package/vendor/raylib/examples/models/resources/skybox.png +0 -0
  226. package/vendor/raylib/examples/models/rlights.h +183 -0
  227. package/vendor/raylib/examples/others/easings.h +263 -0
  228. package/vendor/raylib/examples/others/easings_testbed.c +227 -0
  229. package/vendor/raylib/examples/others/embedded_files_loading.c +103 -0
  230. package/vendor/raylib/examples/others/external/include/GLFW/glfw3.h +5538 -0
  231. package/vendor/raylib/examples/others/external/include/GLFW/glfw3native.h +572 -0
  232. package/vendor/raylib/examples/others/external/include/glad.h +5466 -0
  233. package/vendor/raylib/examples/others/external/lib/libglfw3.a +0 -0
  234. package/vendor/raylib/examples/others/raudio_standalone.c +152 -0
  235. package/vendor/raylib/examples/others/raylib_opengl_interop.c +152 -0
  236. package/vendor/raylib/examples/others/raylib_opengl_interop.png +0 -0
  237. package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
  238. package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
  239. package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
  240. package/vendor/raylib/examples/others/resources/audio_data.h +4893 -0
  241. package/vendor/raylib/examples/others/resources/image_data.h +9848 -0
  242. package/vendor/raylib/examples/others/resources/shaders/glsl100/point_particle.fs +16 -0
  243. package/vendor/raylib/examples/others/resources/shaders/glsl100/point_particle.vs +24 -0
  244. package/vendor/raylib/examples/others/resources/shaders/glsl330/point_particle.fs +17 -0
  245. package/vendor/raylib/examples/others/resources/shaders/glsl330/point_particle.vs +24 -0
  246. package/vendor/raylib/examples/others/resources/shaders/glsl430/gol.glsl +41 -0
  247. package/vendor/raylib/examples/others/resources/shaders/glsl430/gol_render.glsl +29 -0
  248. package/vendor/raylib/examples/others/resources/shaders/glsl430/gol_transfert.glsl +51 -0
  249. package/vendor/raylib/examples/others/rlgl_compute_shader.c +173 -0
  250. package/vendor/raylib/examples/others/rlgl_standalone.c +469 -0
  251. package/vendor/raylib/examples/physics/physics_demo.c +128 -0
  252. package/vendor/raylib/examples/physics/physics_demo.png +0 -0
  253. package/vendor/raylib/examples/physics/physics_friction.c +142 -0
  254. package/vendor/raylib/examples/physics/physics_friction.png +0 -0
  255. package/vendor/raylib/examples/physics/physics_movement.c +128 -0
  256. package/vendor/raylib/examples/physics/physics_movement.png +0 -0
  257. package/vendor/raylib/examples/physics/physics_restitution.c +129 -0
  258. package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
  259. package/vendor/raylib/examples/physics/physics_shatter.c +111 -0
  260. package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
  261. package/vendor/raylib/examples/raylib_compile_execute.bat +32 -0
  262. package/vendor/raylib/examples/raylib_makefile_example.bat +27 -0
  263. package/vendor/raylib/examples/shaders/resources/LICENSE.md +11 -0
  264. package/vendor/raylib/examples/shaders/resources/fudesumi.png +0 -0
  265. package/vendor/raylib/examples/shaders/resources/mask.png +0 -0
  266. package/vendor/raylib/examples/shaders/resources/models/barracks.obj +22251 -0
  267. package/vendor/raylib/examples/shaders/resources/models/barracks_diffuse.png +0 -0
  268. package/vendor/raylib/examples/shaders/resources/models/church.obj +5116 -0
  269. package/vendor/raylib/examples/shaders/resources/models/church_diffuse.png +0 -0
  270. package/vendor/raylib/examples/shaders/resources/models/watermill.obj +5316 -0
  271. package/vendor/raylib/examples/shaders/resources/models/watermill_diffuse.png +0 -0
  272. package/vendor/raylib/examples/shaders/resources/plasma.png +0 -0
  273. package/vendor/raylib/examples/shaders/resources/raysan.png +0 -0
  274. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/base.fs +23 -0
  275. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/base.vs +26 -0
  276. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/base_lighting.vs +59 -0
  277. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/base_lighting_instanced.vs +36 -0
  278. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/bloom.fs +39 -0
  279. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/blur.fs +34 -0
  280. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/color_mix.fs +26 -0
  281. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/cross_hatching.fs +47 -0
  282. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/cross_stitching.fs +57 -0
  283. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/cubes_panning.fs +60 -0
  284. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/depth.fs +26 -0
  285. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/distortion.fs +54 -0
  286. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/dream_vision.fs +37 -0
  287. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/eratosthenes.fs +60 -0
  288. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/fisheye.fs +43 -0
  289. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/fog.fs +94 -0
  290. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/grayscale.fs +25 -0
  291. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/julia_set.fs +83 -0
  292. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/lighting.fs +81 -0
  293. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/mask.fs +24 -0
  294. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/outline.fs +34 -0
  295. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/palette_switch.fs +41 -0
  296. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/pixelizer.fs +32 -0
  297. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/posterization.fs +29 -0
  298. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/predator.fs +31 -0
  299. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/raymarching.fs +431 -0
  300. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/reload.fs +39 -0
  301. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/scanlines.fs +44 -0
  302. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/sobel.fs +40 -0
  303. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/spotlight.fs +77 -0
  304. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/swirl.fs +46 -0
  305. package/vendor/raylib/examples/shaders/resources/shaders/glsl100/wave.fs +36 -0
  306. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/base.fs +22 -0
  307. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/base.vs +26 -0
  308. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/base_lighting.vs +59 -0
  309. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs +37 -0
  310. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/blur.fs +32 -0
  311. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/cross_hatching.fs +45 -0
  312. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/cross_stitching.fs +55 -0
  313. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/distortion.fs +52 -0
  314. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/dream_vision.fs +35 -0
  315. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/fisheye.fs +41 -0
  316. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/fog.fs +92 -0
  317. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/grayscale.fs +23 -0
  318. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/palette_switch.fs +27 -0
  319. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/pixelizer.fs +30 -0
  320. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/posterization.fs +27 -0
  321. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/predator.fs +29 -0
  322. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/scanlines.fs +42 -0
  323. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/sobel.fs +38 -0
  324. package/vendor/raylib/examples/shaders/resources/shaders/glsl120/swirl.fs +44 -0
  325. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/base.fs +25 -0
  326. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/base.vs +26 -0
  327. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/base_lighting.vs +32 -0
  328. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/base_lighting_instanced.vs +36 -0
  329. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/bloom.fs +40 -0
  330. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/blur.fs +35 -0
  331. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/color_mix.fs +27 -0
  332. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/cross_hatching.fs +48 -0
  333. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/cross_stitching.fs +59 -0
  334. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/cubes_panning.fs +61 -0
  335. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/depth.fs +27 -0
  336. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/distortion.fs +56 -0
  337. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/dream_vision.fs +34 -0
  338. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/eratosthenes.fs +59 -0
  339. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/fisheye.fs +40 -0
  340. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/fog.fs +95 -0
  341. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/grayscale.fs +26 -0
  342. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/julia_set.fs +81 -0
  343. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +82 -0
  344. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/mask.fs +22 -0
  345. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/outline.fs +35 -0
  346. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/overdraw.fs +26 -0
  347. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/palette_switch.fs +30 -0
  348. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/pixelizer.fs +33 -0
  349. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/posterization.fs +31 -0
  350. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/predator.fs +32 -0
  351. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/raymarching.fs +430 -0
  352. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/reload.fs +40 -0
  353. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/scanlines.fs +49 -0
  354. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/sobel.fs +41 -0
  355. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/spotlight.fs +65 -0
  356. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/swirl.fs +47 -0
  357. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/wave.fs +37 -0
  358. package/vendor/raylib/examples/shaders/resources/space.png +0 -0
  359. package/vendor/raylib/examples/shaders/resources/texel_checker.png +0 -0
  360. package/vendor/raylib/examples/shaders/rlights.h +183 -0
  361. package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +152 -0
  362. package/vendor/raylib/examples/shaders/shaders_basic_lighting.png +0 -0
  363. package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +127 -0
  364. package/vendor/raylib/examples/shaders/shaders_custom_uniform.png +0 -0
  365. package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +92 -0
  366. package/vendor/raylib/examples/shaders/shaders_eratosthenes.png +0 -0
  367. package/vendor/raylib/examples/shaders/shaders_fog.c +160 -0
  368. package/vendor/raylib/examples/shaders/shaders_fog.png +0 -0
  369. package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +130 -0
  370. package/vendor/raylib/examples/shaders/shaders_hot_reloading.png +0 -0
  371. package/vendor/raylib/examples/shaders/shaders_julia_set.c +191 -0
  372. package/vendor/raylib/examples/shaders/shaders_julia_set.png +0 -0
  373. package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +224 -0
  374. package/vendor/raylib/examples/shaders/shaders_mesh_instancing.png +0 -0
  375. package/vendor/raylib/examples/shaders/shaders_model_shader.c +103 -0
  376. package/vendor/raylib/examples/shaders/shaders_model_shader.png +0 -0
  377. package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +105 -0
  378. package/vendor/raylib/examples/shaders/shaders_multi_sample2d.png +0 -0
  379. package/vendor/raylib/examples/shaders/shaders_palette_switch.c +147 -0
  380. package/vendor/raylib/examples/shaders/shaders_palette_switch.png +0 -0
  381. package/vendor/raylib/examples/shaders/shaders_postprocessing.c +170 -0
  382. package/vendor/raylib/examples/shaders/shaders_postprocessing.png +0 -0
  383. package/vendor/raylib/examples/shaders/shaders_raymarching.c +113 -0
  384. package/vendor/raylib/examples/shaders/shaders_raymarching.png +0 -0
  385. package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +116 -0
  386. package/vendor/raylib/examples/shaders/shaders_shapes_textures.png +0 -0
  387. package/vendor/raylib/examples/shaders/shaders_simple_mask.c +144 -0
  388. package/vendor/raylib/examples/shaders/shaders_simple_mask.png +0 -0
  389. package/vendor/raylib/examples/shaders/shaders_spotlight.c +254 -0
  390. package/vendor/raylib/examples/shaders/shaders_spotlight.png +0 -0
  391. package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +80 -0
  392. package/vendor/raylib/examples/shaders/shaders_texture_drawing.png +0 -0
  393. package/vendor/raylib/examples/shaders/shaders_texture_outline.c +97 -0
  394. package/vendor/raylib/examples/shaders/shaders_texture_outline.png +0 -0
  395. package/vendor/raylib/examples/shaders/shaders_texture_waves.c +110 -0
  396. package/vendor/raylib/examples/shaders/shaders_texture_waves.png +0 -0
  397. package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +78 -0
  398. package/vendor/raylib/examples/shapes/shapes_basic_shapes.png +0 -0
  399. package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +76 -0
  400. package/vendor/raylib/examples/shapes/shapes_bouncing_ball.png +0 -0
  401. package/vendor/raylib/examples/shapes/shapes_collision_area.c +108 -0
  402. package/vendor/raylib/examples/shapes/shapes_collision_area.png +0 -0
  403. package/vendor/raylib/examples/shapes/shapes_colors_palette.c +99 -0
  404. package/vendor/raylib/examples/shapes/shapes_colors_palette.png +0 -0
  405. package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +83 -0
  406. package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.png +0 -0
  407. package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +89 -0
  408. package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.png +0 -0
  409. package/vendor/raylib/examples/shapes/shapes_draw_ring.c +96 -0
  410. package/vendor/raylib/examples/shapes/shapes_draw_ring.png +0 -0
  411. package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +110 -0
  412. package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.png +0 -0
  413. package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +136 -0
  414. package/vendor/raylib/examples/shapes/shapes_easings_box_anim.png +0 -0
  415. package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +118 -0
  416. package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.png +0 -0
  417. package/vendor/raylib/examples/shapes/shapes_following_eyes.c +104 -0
  418. package/vendor/raylib/examples/shapes/shapes_following_eyes.png +0 -0
  419. package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +59 -0
  420. package/vendor/raylib/examples/shapes/shapes_lines_bezier.png +0 -0
  421. package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +56 -0
  422. package/vendor/raylib/examples/shapes/shapes_logo_raylib.png +0 -0
  423. package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +160 -0
  424. package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.png +0 -0
  425. package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +94 -0
  426. package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.png +0 -0
  427. package/vendor/raylib/examples/text/resources/KAISG.ttf +0 -0
  428. package/vendor/raylib/examples/text/resources/LICENSE.md +20 -0
  429. package/vendor/raylib/examples/text/resources/anonymous_pro_bold.ttf +0 -0
  430. package/vendor/raylib/examples/text/resources/custom_alagard.png +0 -0
  431. package/vendor/raylib/examples/text/resources/custom_jupiter_crash.png +0 -0
  432. package/vendor/raylib/examples/text/resources/custom_mecha.png +0 -0
  433. package/vendor/raylib/examples/text/resources/dejavu.fnt +1115 -0
  434. package/vendor/raylib/examples/text/resources/dejavu.png +0 -0
  435. package/vendor/raylib/examples/text/resources/fonts/alagard.png +0 -0
  436. package/vendor/raylib/examples/text/resources/fonts/alpha_beta.png +0 -0
  437. package/vendor/raylib/examples/text/resources/fonts/jupiter_crash.png +0 -0
  438. package/vendor/raylib/examples/text/resources/fonts/mecha.png +0 -0
  439. package/vendor/raylib/examples/text/resources/fonts/pixantiqua.png +0 -0
  440. package/vendor/raylib/examples/text/resources/fonts/pixelplay.png +0 -0
  441. package/vendor/raylib/examples/text/resources/fonts/romulus.png +0 -0
  442. package/vendor/raylib/examples/text/resources/fonts/setback.png +0 -0
  443. package/vendor/raylib/examples/text/resources/noto_cjk.fnt +580 -0
  444. package/vendor/raylib/examples/text/resources/noto_cjk.png +0 -0
  445. package/vendor/raylib/examples/text/resources/pixantiqua.fnt +188 -0
  446. package/vendor/raylib/examples/text/resources/pixantiqua.png +0 -0
  447. package/vendor/raylib/examples/text/resources/pixantiqua.ttf +0 -0
  448. package/vendor/raylib/examples/text/resources/shaders/glsl100/alpha_discard.fs +20 -0
  449. package/vendor/raylib/examples/text/resources/shaders/glsl100/sdf.fs +25 -0
  450. package/vendor/raylib/examples/text/resources/shaders/glsl330/alpha_discard.fs +19 -0
  451. package/vendor/raylib/examples/text/resources/shaders/glsl330/sdf.fs +26 -0
  452. package/vendor/raylib/examples/text/resources/symbola.fnt +191 -0
  453. package/vendor/raylib/examples/text/resources/symbola.png +0 -0
  454. package/vendor/raylib/examples/text/text_draw_3d.c +739 -0
  455. package/vendor/raylib/examples/text/text_draw_3d.png +0 -0
  456. package/vendor/raylib/examples/text/text_font_filters.c +134 -0
  457. package/vendor/raylib/examples/text/text_font_filters.png +0 -0
  458. package/vendor/raylib/examples/text/text_font_loading.c +91 -0
  459. package/vendor/raylib/examples/text/text_font_loading.png +0 -0
  460. package/vendor/raylib/examples/text/text_font_sdf.c +141 -0
  461. package/vendor/raylib/examples/text/text_font_sdf.png +0 -0
  462. package/vendor/raylib/examples/text/text_font_spritefont.c +85 -0
  463. package/vendor/raylib/examples/text/text_font_spritefont.png +0 -0
  464. package/vendor/raylib/examples/text/text_format_text.c +62 -0
  465. package/vendor/raylib/examples/text/text_format_text.png +0 -0
  466. package/vendor/raylib/examples/text/text_input_box.c +127 -0
  467. package/vendor/raylib/examples/text/text_input_box.png +0 -0
  468. package/vendor/raylib/examples/text/text_raylib_fonts.c +105 -0
  469. package/vendor/raylib/examples/text/text_raylib_fonts.png +0 -0
  470. package/vendor/raylib/examples/text/text_rectangle_bounds.c +264 -0
  471. package/vendor/raylib/examples/text/text_rectangle_bounds.png +0 -0
  472. package/vendor/raylib/examples/text/text_unicode.c +465 -0
  473. package/vendor/raylib/examples/text/text_unicode.png +0 -0
  474. package/vendor/raylib/examples/text/text_writing_anim.c +62 -0
  475. package/vendor/raylib/examples/text/text_writing_anim.png +0 -0
  476. package/vendor/raylib/examples/textures/resources/KAISG.ttf +0 -0
  477. package/vendor/raylib/examples/textures/resources/LICENSE.md +18 -0
  478. package/vendor/raylib/examples/textures/resources/boom.wav +0 -0
  479. package/vendor/raylib/examples/textures/resources/button.png +0 -0
  480. package/vendor/raylib/examples/textures/resources/buttonfx.wav +0 -0
  481. package/vendor/raylib/examples/textures/resources/cat.png +0 -0
  482. package/vendor/raylib/examples/textures/resources/custom_jupiter_crash.png +0 -0
  483. package/vendor/raylib/examples/textures/resources/cyberpunk_street_background.png +0 -0
  484. package/vendor/raylib/examples/textures/resources/cyberpunk_street_foreground.png +0 -0
  485. package/vendor/raylib/examples/textures/resources/cyberpunk_street_midground.png +0 -0
  486. package/vendor/raylib/examples/textures/resources/explosion.png +0 -0
  487. package/vendor/raylib/examples/textures/resources/fudesumi.png +0 -0
  488. package/vendor/raylib/examples/textures/resources/fudesumi.raw +0 -0
  489. package/vendor/raylib/examples/textures/resources/ninepatch_button.png +0 -0
  490. package/vendor/raylib/examples/textures/resources/parrots.png +0 -0
  491. package/vendor/raylib/examples/textures/resources/patterns.png +0 -0
  492. package/vendor/raylib/examples/textures/resources/raylib_logo.png +0 -0
  493. package/vendor/raylib/examples/textures/resources/scarfy.png +0 -0
  494. package/vendor/raylib/examples/textures/resources/spark_flame.png +0 -0
  495. package/vendor/raylib/examples/textures/resources/wabbit_alpha.png +0 -0
  496. package/vendor/raylib/examples/textures/textures_background_scrolling.c +87 -0
  497. package/vendor/raylib/examples/textures/textures_background_scrolling.png +0 -0
  498. package/vendor/raylib/examples/textures/textures_blend_modes.c +93 -0
  499. package/vendor/raylib/examples/textures/textures_blend_modes.png +0 -0
  500. package/vendor/raylib/examples/textures/textures_bunnymark.c +120 -0
  501. package/vendor/raylib/examples/textures/textures_bunnymark.png +0 -0
  502. package/vendor/raylib/examples/textures/textures_draw_tiled.c +165 -0
  503. package/vendor/raylib/examples/textures/textures_draw_tiled.png +0 -0
  504. package/vendor/raylib/examples/textures/textures_image_drawing.c +91 -0
  505. package/vendor/raylib/examples/textures/textures_image_drawing.png +0 -0
  506. package/vendor/raylib/examples/textures/textures_image_generation.c +102 -0
  507. package/vendor/raylib/examples/textures/textures_image_generation.png +0 -0
  508. package/vendor/raylib/examples/textures/textures_image_loading.c +64 -0
  509. package/vendor/raylib/examples/textures/textures_image_loading.png +0 -0
  510. package/vendor/raylib/examples/textures/textures_image_processing.c +169 -0
  511. package/vendor/raylib/examples/textures/textures_image_processing.png +0 -0
  512. package/vendor/raylib/examples/textures/textures_image_text.c +83 -0
  513. package/vendor/raylib/examples/textures/textures_image_text.png +0 -0
  514. package/vendor/raylib/examples/textures/textures_logo_raylib.c +57 -0
  515. package/vendor/raylib/examples/textures/textures_logo_raylib.png +0 -0
  516. package/vendor/raylib/examples/textures/textures_mouse_painting.c +221 -0
  517. package/vendor/raylib/examples/textures/textures_mouse_painting.png +0 -0
  518. package/vendor/raylib/examples/textures/textures_npatch_drawing.c +109 -0
  519. package/vendor/raylib/examples/textures/textures_npatch_drawing.png +0 -0
  520. package/vendor/raylib/examples/textures/textures_particles_blending.c +135 -0
  521. package/vendor/raylib/examples/textures/textures_particles_blending.png +0 -0
  522. package/vendor/raylib/examples/textures/textures_polygon.c +100 -0
  523. package/vendor/raylib/examples/textures/textures_polygon.png +0 -0
  524. package/vendor/raylib/examples/textures/textures_raw_data.c +99 -0
  525. package/vendor/raylib/examples/textures/textures_raw_data.png +0 -0
  526. package/vendor/raylib/examples/textures/textures_rectangle.c +99 -0
  527. package/vendor/raylib/examples/textures/textures_rectangle.png +0 -0
  528. package/vendor/raylib/examples/textures/textures_sprite_button.c +97 -0
  529. package/vendor/raylib/examples/textures/textures_sprite_button.png +0 -0
  530. package/vendor/raylib/examples/textures/textures_sprite_explosion.c +120 -0
  531. package/vendor/raylib/examples/textures/textures_sprite_explosion.png +0 -0
  532. package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +82 -0
  533. package/vendor/raylib/examples/textures/textures_srcrec_dstrec.png +0 -0
  534. package/vendor/raylib/examples/textures/textures_to_image.c +68 -0
  535. package/vendor/raylib/examples/textures/textures_to_image.png +0 -0
  536. package/vendor/raylib/logo/raylib.ico +0 -0
  537. package/vendor/raylib/logo/raylib_128x128.png +0 -0
  538. package/vendor/raylib/logo/raylib_144x144.png +0 -0
  539. package/vendor/raylib/logo/raylib_16x16.png +0 -0
  540. package/vendor/raylib/logo/raylib_180x180.png +0 -0
  541. package/vendor/raylib/logo/raylib_24x24.png +0 -0
  542. package/vendor/raylib/logo/raylib_256x256.png +0 -0
  543. package/vendor/raylib/logo/raylib_32x32.png +0 -0
  544. package/vendor/raylib/logo/raylib_36x36.png +0 -0
  545. package/vendor/raylib/logo/raylib_48x48.png +0 -0
  546. package/vendor/raylib/logo/raylib_512x512.png +0 -0
  547. package/vendor/raylib/logo/raylib_64x64.png +0 -0
  548. package/vendor/raylib/logo/raylib_72x72.png +0 -0
  549. package/vendor/raylib/logo/raylib_96x96.png +0 -0
  550. package/vendor/raylib/logo/raylib_logo_animation.gif +0 -0
  551. package/vendor/raylib/parser/LICENSE +16 -0
  552. package/vendor/raylib/parser/README.md +63 -0
  553. package/vendor/raylib/parser/raylib_api.json +6668 -0
  554. package/vendor/raylib/parser/raylib_api.txt +3568 -0
  555. package/vendor/raylib/parser/raylib_api.xml +2509 -0
  556. package/vendor/raylib/parser/raylib_parser.c +1003 -0
  557. package/vendor/raylib/projects/4coder/Makefile +401 -0
  558. package/vendor/raylib/projects/4coder/Makefile.Android +300 -0
  559. package/vendor/raylib/projects/4coder/main.c +39 -0
  560. package/vendor/raylib/projects/4coder/project.4coder +54 -0
  561. package/vendor/raylib/projects/Builder/README.md +24 -0
  562. package/vendor/raylib/projects/Builder/examples/README.md +1 -0
  563. package/vendor/raylib/projects/Builder/examples/meson.build +25 -0
  564. package/vendor/raylib/projects/Builder/meson.build +25 -0
  565. package/vendor/raylib/projects/CMake/CMakeLists.txt +44 -0
  566. package/vendor/raylib/projects/CMake/core_basic_window.c +62 -0
  567. package/vendor/raylib/projects/CodeBlocks/README.md +22 -0
  568. package/vendor/raylib/projects/CodeBlocks/compiler_settings.png +0 -0
  569. package/vendor/raylib/projects/CodeBlocks/core_basic_window.c +58 -0
  570. package/vendor/raylib/projects/CodeBlocks/core_basic_window.cbp +137 -0
  571. package/vendor/raylib/projects/Geany/core_basic_window.c +52 -0
  572. package/vendor/raylib/projects/Geany/raylib.c.tags +452 -0
  573. package/vendor/raylib/projects/Geany/raylib_compile_execute.bat +21 -0
  574. package/vendor/raylib/projects/Geany/raylib_compile_sources.bat +42 -0
  575. package/vendor/raylib/projects/Geany/raylib_project.geany +41 -0
  576. package/vendor/raylib/projects/Notepad++/README.md +19 -0
  577. package/vendor/raylib/projects/Notepad++/c_raylib.xml +3104 -0
  578. package/vendor/raylib/projects/Notepad++/npes_saved_mingw.txt +0 -0
  579. package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
  580. package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
  581. package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
  582. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +3060 -0
  583. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp_parser.c +150 -0
  584. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +631 -0
  585. package/vendor/raylib/projects/README.md +18 -0
  586. package/vendor/raylib/projects/SublimeText/README.md +13 -0
  587. package/vendor/raylib/projects/SublimeText/raylib.sublime-build +13 -0
  588. package/vendor/raylib/projects/SublimeText/raylib.sublime-project +8 -0
  589. package/vendor/raylib/projects/VS2019/examples/audio_module_playing.vcxproj +387 -0
  590. package/vendor/raylib/projects/VS2019/examples/audio_multichannel_sound.vcxproj +387 -0
  591. package/vendor/raylib/projects/VS2019/examples/audio_music_stream.vcxproj +387 -0
  592. package/vendor/raylib/projects/VS2019/examples/audio_raw_stream.vcxproj +387 -0
  593. package/vendor/raylib/projects/VS2019/examples/audio_sound_loading.vcxproj +387 -0
  594. package/vendor/raylib/projects/VS2019/examples/core_2d_camera.vcxproj +387 -0
  595. package/vendor/raylib/projects/VS2019/examples/core_2d_camera_platformer.vcxproj +387 -0
  596. package/vendor/raylib/projects/VS2019/examples/core_3d_camera_first_person.vcxproj +387 -0
  597. package/vendor/raylib/projects/VS2019/examples/core_3d_camera_free.vcxproj +387 -0
  598. package/vendor/raylib/projects/VS2019/examples/core_3d_camera_mode.vcxproj +387 -0
  599. package/vendor/raylib/projects/VS2019/examples/core_3d_picking.vcxproj +387 -0
  600. package/vendor/raylib/projects/VS2019/examples/core_basic_window.vcxproj +387 -0
  601. package/vendor/raylib/projects/VS2019/examples/core_custom_logging.vcxproj +387 -0
  602. package/vendor/raylib/projects/VS2019/examples/core_drop_files.vcxproj +387 -0
  603. package/vendor/raylib/projects/VS2019/examples/core_input_gamepad.vcxproj +387 -0
  604. package/vendor/raylib/projects/VS2019/examples/core_input_gestures.vcxproj +387 -0
  605. package/vendor/raylib/projects/VS2019/examples/core_input_keys.vcxproj +387 -0
  606. package/vendor/raylib/projects/VS2019/examples/core_input_mouse.vcxproj +387 -0
  607. package/vendor/raylib/projects/VS2019/examples/core_input_mouse_wheel.vcxproj +387 -0
  608. package/vendor/raylib/projects/VS2019/examples/core_input_multitouch.vcxproj +387 -0
  609. package/vendor/raylib/projects/VS2019/examples/core_loading_thread.vcxproj +387 -0
  610. package/vendor/raylib/projects/VS2019/examples/core_quat_conversion.vcxproj +387 -0
  611. package/vendor/raylib/projects/VS2019/examples/core_random_values.vcxproj +387 -0
  612. package/vendor/raylib/projects/VS2019/examples/core_scissor_test.vcxproj +387 -0
  613. package/vendor/raylib/projects/VS2019/examples/core_split_screen.vcxproj +387 -0
  614. package/vendor/raylib/projects/VS2019/examples/core_storage_values.vcxproj +387 -0
  615. package/vendor/raylib/projects/VS2019/examples/core_vr_simulator.vcxproj +387 -0
  616. package/vendor/raylib/projects/VS2019/examples/core_window_flags.vcxproj +387 -0
  617. package/vendor/raylib/projects/VS2019/examples/core_window_letterbox.vcxproj +387 -0
  618. package/vendor/raylib/projects/VS2019/examples/core_world_screen.vcxproj +387 -0
  619. package/vendor/raylib/projects/VS2019/examples/easings_testbed.vcxproj +387 -0
  620. package/vendor/raylib/projects/VS2019/examples/embedded_files_loading.vcxproj +387 -0
  621. package/vendor/raylib/projects/VS2019/examples/models_animation.vcxproj +387 -0
  622. package/vendor/raylib/projects/VS2019/examples/models_billboard.vcxproj +387 -0
  623. package/vendor/raylib/projects/VS2019/examples/models_box_collisions.vcxproj +387 -0
  624. package/vendor/raylib/projects/VS2019/examples/models_cubicmap.vcxproj +387 -0
  625. package/vendor/raylib/projects/VS2019/examples/models_first_person_maze.vcxproj +387 -0
  626. package/vendor/raylib/projects/VS2019/examples/models_geometric_shapes.vcxproj +387 -0
  627. package/vendor/raylib/projects/VS2019/examples/models_heightmap.vcxproj +387 -0
  628. package/vendor/raylib/projects/VS2019/examples/models_loading.vcxproj +387 -0
  629. package/vendor/raylib/projects/VS2019/examples/models_loading_gltf.vcxproj +387 -0
  630. package/vendor/raylib/projects/VS2019/examples/models_loading_vox.vcxproj +387 -0
  631. package/vendor/raylib/projects/VS2019/examples/models_mesh_generation.vcxproj +387 -0
  632. package/vendor/raylib/projects/VS2019/examples/models_mesh_picking.vcxproj +387 -0
  633. package/vendor/raylib/projects/VS2019/examples/models_orthographic_projection.vcxproj +387 -0
  634. package/vendor/raylib/projects/VS2019/examples/models_rlgl_solar_system.vcxproj +387 -0
  635. package/vendor/raylib/projects/VS2019/examples/models_skybox.vcxproj +387 -0
  636. package/vendor/raylib/projects/VS2019/examples/models_waving_cubes.vcxproj +387 -0
  637. package/vendor/raylib/projects/VS2019/examples/models_yaw_pitch_roll.vcxproj +387 -0
  638. package/vendor/raylib/projects/VS2019/examples/physics_demo.vcxproj +387 -0
  639. package/vendor/raylib/projects/VS2019/examples/physics_friction.vcxproj +387 -0
  640. package/vendor/raylib/projects/VS2019/examples/physics_movement.vcxproj +387 -0
  641. package/vendor/raylib/projects/VS2019/examples/physics_restitution.vcxproj +387 -0
  642. package/vendor/raylib/projects/VS2019/examples/physics_shatter.vcxproj +387 -0
  643. package/vendor/raylib/projects/VS2019/examples/raudio_standalone.vcxproj +387 -0
  644. package/vendor/raylib/projects/VS2019/examples/rlgl_standalone.vcxproj +391 -0
  645. package/vendor/raylib/projects/VS2019/examples/shaders_basic_lighting.vcxproj +387 -0
  646. package/vendor/raylib/projects/VS2019/examples/shaders_custom_uniform.vcxproj +387 -0
  647. package/vendor/raylib/projects/VS2019/examples/shaders_eratosthenes.vcxproj +387 -0
  648. package/vendor/raylib/projects/VS2019/examples/shaders_fog.vcxproj +387 -0
  649. package/vendor/raylib/projects/VS2019/examples/shaders_hot_reloading.vcxproj +387 -0
  650. package/vendor/raylib/projects/VS2019/examples/shaders_julia_set.vcxproj +387 -0
  651. package/vendor/raylib/projects/VS2019/examples/shaders_mesh_instancing.vcxproj +387 -0
  652. package/vendor/raylib/projects/VS2019/examples/shaders_model_shader.vcxproj +387 -0
  653. package/vendor/raylib/projects/VS2019/examples/shaders_multi_sample2d.vcxproj +387 -0
  654. package/vendor/raylib/projects/VS2019/examples/shaders_palette_switch.vcxproj +387 -0
  655. package/vendor/raylib/projects/VS2019/examples/shaders_postprocessing.vcxproj +387 -0
  656. package/vendor/raylib/projects/VS2019/examples/shaders_raymarching.vcxproj +387 -0
  657. package/vendor/raylib/projects/VS2019/examples/shaders_shapes_textures.vcxproj +387 -0
  658. package/vendor/raylib/projects/VS2019/examples/shaders_simple_mask.vcxproj +387 -0
  659. package/vendor/raylib/projects/VS2019/examples/shaders_spotlight.vcxproj +387 -0
  660. package/vendor/raylib/projects/VS2019/examples/shaders_texture_drawing.vcxproj +387 -0
  661. package/vendor/raylib/projects/VS2019/examples/shaders_texture_waves.vcxproj +387 -0
  662. package/vendor/raylib/projects/VS2019/examples/shapes_basic_shapes.vcxproj +387 -0
  663. package/vendor/raylib/projects/VS2019/examples/shapes_bouncing_ball.vcxproj +387 -0
  664. package/vendor/raylib/projects/VS2019/examples/shapes_collision_area.vcxproj +387 -0
  665. package/vendor/raylib/projects/VS2019/examples/shapes_colors_palette.vcxproj +387 -0
  666. package/vendor/raylib/projects/VS2019/examples/shapes_draw_circle_sector.vcxproj +387 -0
  667. package/vendor/raylib/projects/VS2019/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
  668. package/vendor/raylib/projects/VS2019/examples/shapes_draw_ring.vcxproj +387 -0
  669. package/vendor/raylib/projects/VS2019/examples/shapes_easings_ball_anim.vcxproj +387 -0
  670. package/vendor/raylib/projects/VS2019/examples/shapes_easings_box_anim.vcxproj +387 -0
  671. package/vendor/raylib/projects/VS2019/examples/shapes_easings_rectangle_array.vcxproj +387 -0
  672. package/vendor/raylib/projects/VS2019/examples/shapes_following_eyes.vcxproj +387 -0
  673. package/vendor/raylib/projects/VS2019/examples/shapes_lines_bezier.vcxproj +387 -0
  674. package/vendor/raylib/projects/VS2019/examples/shapes_logo_raylib.vcxproj +387 -0
  675. package/vendor/raylib/projects/VS2019/examples/shapes_logo_raylib_anim.vcxproj +387 -0
  676. package/vendor/raylib/projects/VS2019/examples/shapes_rectangle_scaling.vcxproj +387 -0
  677. package/vendor/raylib/projects/VS2019/examples/text_font_filters.vcxproj +387 -0
  678. package/vendor/raylib/projects/VS2019/examples/text_font_loading.vcxproj +387 -0
  679. package/vendor/raylib/projects/VS2019/examples/text_font_sdf.vcxproj +387 -0
  680. package/vendor/raylib/projects/VS2019/examples/text_font_spritefont.vcxproj +387 -0
  681. package/vendor/raylib/projects/VS2019/examples/text_format_text.vcxproj +387 -0
  682. package/vendor/raylib/projects/VS2019/examples/text_input_box.vcxproj +387 -0
  683. package/vendor/raylib/projects/VS2019/examples/text_raylib_fonts.vcxproj +387 -0
  684. package/vendor/raylib/projects/VS2019/examples/text_rectangle_bounds.vcxproj +387 -0
  685. package/vendor/raylib/projects/VS2019/examples/text_unicode.vcxproj +387 -0
  686. package/vendor/raylib/projects/VS2019/examples/text_writing_anim.vcxproj +387 -0
  687. package/vendor/raylib/projects/VS2019/examples/textures_background_scrolling.vcxproj +387 -0
  688. package/vendor/raylib/projects/VS2019/examples/textures_blend_modes.vcxproj +387 -0
  689. package/vendor/raylib/projects/VS2019/examples/textures_bunnymark.vcxproj +387 -0
  690. package/vendor/raylib/projects/VS2019/examples/textures_draw_tiled.vcxproj +387 -0
  691. package/vendor/raylib/projects/VS2019/examples/textures_image_drawing.vcxproj +387 -0
  692. package/vendor/raylib/projects/VS2019/examples/textures_image_generation.vcxproj +387 -0
  693. package/vendor/raylib/projects/VS2019/examples/textures_image_loading.vcxproj +387 -0
  694. package/vendor/raylib/projects/VS2019/examples/textures_image_processing.vcxproj +387 -0
  695. package/vendor/raylib/projects/VS2019/examples/textures_image_text.vcxproj +387 -0
  696. package/vendor/raylib/projects/VS2019/examples/textures_logo_raylib.vcxproj +387 -0
  697. package/vendor/raylib/projects/VS2019/examples/textures_mouse_painting.vcxproj +387 -0
  698. package/vendor/raylib/projects/VS2019/examples/textures_npatch_drawing.vcxproj +387 -0
  699. package/vendor/raylib/projects/VS2019/examples/textures_particles_blending.vcxproj +387 -0
  700. package/vendor/raylib/projects/VS2019/examples/textures_raw_data.vcxproj +387 -0
  701. package/vendor/raylib/projects/VS2019/examples/textures_rectangle.vcxproj +387 -0
  702. package/vendor/raylib/projects/VS2019/examples/textures_sprite_button.vcxproj +387 -0
  703. package/vendor/raylib/projects/VS2019/examples/textures_sprite_explosion.vcxproj +387 -0
  704. package/vendor/raylib/projects/VS2019/examples/textures_srcrec_dstrec.vcxproj +387 -0
  705. package/vendor/raylib/projects/VS2019/examples/textures_to_image.vcxproj +387 -0
  706. package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
  707. package/vendor/raylib/projects/VS2019/raylib/raylib.vcxproj +341 -0
  708. package/vendor/raylib/projects/VS2019/raylib/resource.h +14 -0
  709. package/vendor/raylib/projects/VS2019/raylib.sln +2274 -0
  710. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/android_native_app_glue.c +437 -0
  711. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/android_native_app_glue.h +344 -0
  712. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/main.c +64 -0
  713. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
  714. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
  715. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
  716. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.Packaging/AndroidManifest.xml +22 -0
  717. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.Packaging/build.xml +90 -0
  718. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.Packaging/project.properties +3 -0
  719. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.Packaging/raylib_android.Packaging.androidproj +134 -0
  720. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.Packaging/res/values/strings.xml +4 -0
  721. package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
  722. package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +63 -0
  723. package/vendor/raylib/projects/VSCode/.vscode/launch.json +60 -0
  724. package/vendor/raylib/projects/VSCode/.vscode/settings.json +11 -0
  725. package/vendor/raylib/projects/VSCode/.vscode/tasks.json +71 -0
  726. package/vendor/raylib/projects/VSCode/Makefile +408 -0
  727. package/vendor/raylib/projects/VSCode/Makefile.Android +300 -0
  728. package/vendor/raylib/projects/VSCode/main.c +83 -0
  729. package/vendor/raylib/projects/VSCode/main.code-workspace +16 -0
  730. package/vendor/raylib/projects/scripts/README.md +68 -0
  731. package/vendor/raylib/projects/scripts/build-linux.sh +169 -0
  732. package/vendor/raylib/projects/scripts/build-osx.sh +171 -0
  733. package/vendor/raylib/projects/scripts/build-rpi.sh +169 -0
  734. package/vendor/raylib/projects/scripts/build-windows.bat +219 -0
  735. package/vendor/raylib/projects/scripts/core_basic_window.c +61 -0
  736. package/vendor/raylib/raylib.pc.in +13 -0
  737. package/vendor/raylib/src/CMakeLists.txt +121 -0
  738. package/vendor/raylib/src/Makefile +696 -0
  739. package/vendor/raylib/src/build.zig +60 -0
  740. package/vendor/raylib/src/config.h +230 -0
  741. package/vendor/raylib/src/external/cgltf.h +6501 -0
  742. package/vendor/raylib/src/external/dirent.h +183 -0
  743. package/vendor/raylib/src/external/dr_flac.h +12269 -0
  744. package/vendor/raylib/src/external/dr_mp3.h +4787 -0
  745. package/vendor/raylib/src/external/dr_wav.h +8019 -0
  746. package/vendor/raylib/src/external/glad.h +8640 -0
  747. package/vendor/raylib/src/external/glfw/.mailmap +10 -0
  748. package/vendor/raylib/src/external/glfw/CMake/GenerateMappings.cmake +33 -0
  749. package/vendor/raylib/src/external/glfw/CMake/Info.plist.in +38 -0
  750. package/vendor/raylib/src/external/glfw/CMake/MacOSXBundleInfo.plist.in +38 -0
  751. package/vendor/raylib/src/external/glfw/CMake/cmake_uninstall.cmake.in +29 -0
  752. package/vendor/raylib/src/external/glfw/CMake/glfw3.pc.in +13 -0
  753. package/vendor/raylib/src/external/glfw/CMake/glfw3Config.cmake.in +3 -0
  754. package/vendor/raylib/src/external/glfw/CMake/i686-w64-mingw32-clang.cmake +13 -0
  755. package/vendor/raylib/src/external/glfw/CMake/i686-w64-mingw32.cmake +13 -0
  756. package/vendor/raylib/src/external/glfw/CMake/modules/FindEpollShim.cmake +17 -0
  757. package/vendor/raylib/src/external/glfw/CMake/modules/FindOSMesa.cmake +18 -0
  758. package/vendor/raylib/src/external/glfw/CMake/modules/FindWaylandProtocols.cmake +26 -0
  759. package/vendor/raylib/src/external/glfw/CMake/modules/FindXKBCommon.cmake +34 -0
  760. package/vendor/raylib/src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake +13 -0
  761. package/vendor/raylib/src/external/glfw/CMake/x86_64-w64-mingw32.cmake +13 -0
  762. package/vendor/raylib/src/external/glfw/CMakeLists.txt +323 -0
  763. package/vendor/raylib/src/external/glfw/LICENSE.md +23 -0
  764. package/vendor/raylib/src/external/glfw/README.md +477 -0
  765. package/vendor/raylib/src/external/glfw/deps/getopt.c +230 -0
  766. package/vendor/raylib/src/external/glfw/deps/getopt.h +57 -0
  767. package/vendor/raylib/src/external/glfw/deps/glad/gl.h +3840 -0
  768. package/vendor/raylib/src/external/glfw/deps/glad/khrplatform.h +282 -0
  769. package/vendor/raylib/src/external/glfw/deps/glad/vk_platform.h +92 -0
  770. package/vendor/raylib/src/external/glfw/deps/glad/vulkan.h +3480 -0
  771. package/vendor/raylib/src/external/glfw/deps/glad_gl.c +1791 -0
  772. package/vendor/raylib/src/external/glfw/deps/glad_vulkan.c +593 -0
  773. package/vendor/raylib/src/external/glfw/deps/mingw/_mingw_dxhelper.h +117 -0
  774. package/vendor/raylib/src/external/glfw/deps/mingw/dinput.h +2467 -0
  775. package/vendor/raylib/src/external/glfw/deps/mingw/xinput.h +239 -0
  776. package/vendor/raylib/src/external/glfw/deps/vs2008/stdint.h +247 -0
  777. package/vendor/raylib/src/external/glfw/include/GLFW/glfw3.h +6075 -0
  778. package/vendor/raylib/src/external/glfw/include/GLFW/glfw3native.h +530 -0
  779. package/vendor/raylib/src/external/glfw/src/CMakeLists.txt +246 -0
  780. package/vendor/raylib/src/external/glfw/src/cocoa_init.m +620 -0
  781. package/vendor/raylib/src/external/glfw/src/cocoa_joystick.h +46 -0
  782. package/vendor/raylib/src/external/glfw/src/cocoa_joystick.m +483 -0
  783. package/vendor/raylib/src/external/glfw/src/cocoa_monitor.m +631 -0
  784. package/vendor/raylib/src/external/glfw/src/cocoa_platform.h +206 -0
  785. package/vendor/raylib/src/external/glfw/src/cocoa_time.c +62 -0
  786. package/vendor/raylib/src/external/glfw/src/cocoa_window.m +1923 -0
  787. package/vendor/raylib/src/external/glfw/src/context.c +756 -0
  788. package/vendor/raylib/src/external/glfw/src/egl_context.c +846 -0
  789. package/vendor/raylib/src/external/glfw/src/egl_context.h +229 -0
  790. package/vendor/raylib/src/external/glfw/src/glfw.rc.in +30 -0
  791. package/vendor/raylib/src/external/glfw/src/glfw_config.h.in +58 -0
  792. package/vendor/raylib/src/external/glfw/src/glx_context.c +699 -0
  793. package/vendor/raylib/src/external/glfw/src/glx_context.h +181 -0
  794. package/vendor/raylib/src/external/glfw/src/init.c +357 -0
  795. package/vendor/raylib/src/external/glfw/src/input.c +1406 -0
  796. package/vendor/raylib/src/external/glfw/src/internal.h +799 -0
  797. package/vendor/raylib/src/external/glfw/src/linux_joystick.c +428 -0
  798. package/vendor/raylib/src/external/glfw/src/linux_joystick.h +59 -0
  799. package/vendor/raylib/src/external/glfw/src/mappings.h +1550 -0
  800. package/vendor/raylib/src/external/glfw/src/mappings.h.in +73 -0
  801. package/vendor/raylib/src/external/glfw/src/monitor.c +542 -0
  802. package/vendor/raylib/src/external/glfw/src/nsgl_context.h +66 -0
  803. package/vendor/raylib/src/external/glfw/src/nsgl_context.m +369 -0
  804. package/vendor/raylib/src/external/glfw/src/null_init.c +57 -0
  805. package/vendor/raylib/src/external/glfw/src/null_joystick.c +53 -0
  806. package/vendor/raylib/src/external/glfw/src/null_joystick.h +31 -0
  807. package/vendor/raylib/src/external/glfw/src/null_monitor.c +159 -0
  808. package/vendor/raylib/src/external/glfw/src/null_platform.h +89 -0
  809. package/vendor/raylib/src/external/glfw/src/null_window.c +670 -0
  810. package/vendor/raylib/src/external/glfw/src/osmesa_context.c +372 -0
  811. package/vendor/raylib/src/external/glfw/src/osmesa_context.h +90 -0
  812. package/vendor/raylib/src/external/glfw/src/posix_thread.c +105 -0
  813. package/vendor/raylib/src/external/glfw/src/posix_thread.h +51 -0
  814. package/vendor/raylib/src/external/glfw/src/posix_time.c +90 -0
  815. package/vendor/raylib/src/external/glfw/src/posix_time.h +44 -0
  816. package/vendor/raylib/src/external/glfw/src/vulkan.c +332 -0
  817. package/vendor/raylib/src/external/glfw/src/wgl_context.c +798 -0
  818. package/vendor/raylib/src/external/glfw/src/wgl_context.h +160 -0
  819. package/vendor/raylib/src/external/glfw/src/win32_init.c +636 -0
  820. package/vendor/raylib/src/external/glfw/src/win32_joystick.c +753 -0
  821. package/vendor/raylib/src/external/glfw/src/win32_joystick.h +53 -0
  822. package/vendor/raylib/src/external/glfw/src/win32_monitor.c +537 -0
  823. package/vendor/raylib/src/external/glfw/src/win32_platform.h +462 -0
  824. package/vendor/raylib/src/external/glfw/src/win32_thread.c +99 -0
  825. package/vendor/raylib/src/external/glfw/src/win32_time.c +76 -0
  826. package/vendor/raylib/src/external/glfw/src/win32_window.c +2405 -0
  827. package/vendor/raylib/src/external/glfw/src/window.c +1114 -0
  828. package/vendor/raylib/src/external/glfw/src/wl_init.c +1310 -0
  829. package/vendor/raylib/src/external/glfw/src/wl_monitor.c +231 -0
  830. package/vendor/raylib/src/external/glfw/src/wl_platform.h +352 -0
  831. package/vendor/raylib/src/external/glfw/src/wl_window.c +1814 -0
  832. package/vendor/raylib/src/external/glfw/src/x11_init.c +1500 -0
  833. package/vendor/raylib/src/external/glfw/src/x11_monitor.c +614 -0
  834. package/vendor/raylib/src/external/glfw/src/x11_platform.h +798 -0
  835. package/vendor/raylib/src/external/glfw/src/x11_window.c +3310 -0
  836. package/vendor/raylib/src/external/glfw/src/xkb_unicode.c +942 -0
  837. package/vendor/raylib/src/external/glfw/src/xkb_unicode.h +28 -0
  838. package/vendor/raylib/src/external/jar_mod.h +1596 -0
  839. package/vendor/raylib/src/external/jar_xm.h +2470 -0
  840. package/vendor/raylib/src/external/miniaudio.h +70273 -0
  841. package/vendor/raylib/src/external/msf_gif.h +717 -0
  842. package/vendor/raylib/src/external/par_shapes.h +2155 -0
  843. package/vendor/raylib/src/external/sdefl.h +696 -0
  844. package/vendor/raylib/src/external/sinfl.h +584 -0
  845. package/vendor/raylib/src/external/stb_image.h +7897 -0
  846. package/vendor/raylib/src/external/stb_image_resize.h +2634 -0
  847. package/vendor/raylib/src/external/stb_image_write.h +1724 -0
  848. package/vendor/raylib/src/external/stb_rect_pack.h +623 -0
  849. package/vendor/raylib/src/external/stb_truetype.h +5077 -0
  850. package/vendor/raylib/src/external/stb_vorbis.h +5475 -0
  851. package/vendor/raylib/src/external/tinyobj_loader_c.h +1589 -0
  852. package/vendor/raylib/src/external/vox_loader.h +710 -0
  853. package/vendor/raylib/src/extras/easings.h +263 -0
  854. package/vendor/raylib/src/extras/physac.h +1977 -0
  855. package/vendor/raylib/src/extras/raygui.h +4342 -0
  856. package/vendor/raylib/src/extras/rmem.h +751 -0
  857. package/vendor/raylib/src/raudio.c +2380 -0
  858. package/vendor/raylib/src/raudio.h +198 -0
  859. package/vendor/raylib/src/raylib.dll.rc +27 -0
  860. package/vendor/raylib/src/raylib.dll.rc.data +0 -0
  861. package/vendor/raylib/src/raylib.h +1536 -0
  862. package/vendor/raylib/src/raylib.ico +0 -0
  863. package/vendor/raylib/src/raylib.rc +27 -0
  864. package/vendor/raylib/src/raylib.rc.data +0 -0
  865. package/vendor/raylib/src/raymath.h +1853 -0
  866. package/vendor/raylib/src/rcamera.h +567 -0
  867. package/vendor/raylib/src/rcore.c +6772 -0
  868. package/vendor/raylib/src/rgestures.h +566 -0
  869. package/vendor/raylib/src/rglfw.c +126 -0
  870. package/vendor/raylib/src/rlgl.h +4677 -0
  871. package/vendor/raylib/src/rmodels.c +5041 -0
  872. package/vendor/raylib/src/rshapes.c +1759 -0
  873. package/vendor/raylib/src/rtext.c +1790 -0
  874. package/vendor/raylib/src/rtextures.c +4761 -0
  875. package/vendor/raylib/src/shell.html +328 -0
  876. package/vendor/raylib/src/utils.c +433 -0
  877. package/vendor/raylib/src/utils.h +81 -0
  878. package/vendor/sqlite3/shell.c +23487 -0
  879. package/vendor/sqlite3/sqlite3.c +239246 -0
  880. package/vendor/sqlite3/sqlite3.h +12802 -0
  881. package/vendor/sqlite3/sqlite3ext.h +689 -0
  882. package/CMakeLists.txt +0 -60
@@ -0,0 +1,3310 @@
1
+ //========================================================================
2
+ // GLFW 3.4 X11 - www.glfw.org
3
+ //------------------------------------------------------------------------
4
+ // Copyright (c) 2002-2006 Marcus Geelnard
5
+ // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6
+ //
7
+ // This software is provided 'as-is', without any express or implied
8
+ // warranty. In no event will the authors be held liable for any damages
9
+ // arising from the use of this software.
10
+ //
11
+ // Permission is granted to anyone to use this software for any purpose,
12
+ // including commercial applications, and to alter it and redistribute it
13
+ // freely, subject to the following restrictions:
14
+ //
15
+ // 1. The origin of this software must not be misrepresented; you must not
16
+ // claim that you wrote the original software. If you use this software
17
+ // in a product, an acknowledgment in the product documentation would
18
+ // be appreciated but is not required.
19
+ //
20
+ // 2. Altered source versions must be plainly marked as such, and must not
21
+ // be misrepresented as being the original software.
22
+ //
23
+ // 3. This notice may not be removed or altered from any source
24
+ // distribution.
25
+ //
26
+ //========================================================================
27
+ // It is fine to use C99 in this file because it will not be built with VS
28
+ //========================================================================
29
+
30
+ #include "internal.h"
31
+
32
+ #include <X11/cursorfont.h>
33
+ #include <X11/Xmd.h>
34
+
35
+ #include <sys/select.h>
36
+
37
+ #include <string.h>
38
+ #include <stdio.h>
39
+ #include <stdlib.h>
40
+ #include <limits.h>
41
+ #include <errno.h>
42
+ #include <assert.h>
43
+
44
+ // Action for EWMH client messages
45
+ #define _NET_WM_STATE_REMOVE 0
46
+ #define _NET_WM_STATE_ADD 1
47
+ #define _NET_WM_STATE_TOGGLE 2
48
+
49
+ // Additional mouse button names for XButtonEvent
50
+ #define Button6 6
51
+ #define Button7 7
52
+
53
+ // Motif WM hints flags
54
+ #define MWM_HINTS_DECORATIONS 2
55
+ #define MWM_DECOR_ALL 1
56
+
57
+ #define _GLFW_XDND_VERSION 5
58
+
59
+
60
+ // Wait for data to arrive using select
61
+ // This avoids blocking other threads via the per-display Xlib lock that also
62
+ // covers GLX functions
63
+ //
64
+ static GLFWbool waitForEvent(double* timeout)
65
+ {
66
+ fd_set fds;
67
+ const int fd = ConnectionNumber(_glfw.x11.display);
68
+ int count = fd + 1;
69
+
70
+ #if defined(__linux__)
71
+ if (_glfw.linjs.inotify > fd)
72
+ count = _glfw.linjs.inotify + 1;
73
+ #endif
74
+ for (;;)
75
+ {
76
+ FD_ZERO(&fds);
77
+ FD_SET(fd, &fds);
78
+ #if defined(__linux__)
79
+ if (_glfw.linjs.inotify > 0)
80
+ FD_SET(_glfw.linjs.inotify, &fds);
81
+ #endif
82
+
83
+ if (timeout)
84
+ {
85
+ const long seconds = (long) *timeout;
86
+ const long microseconds = (long) ((*timeout - seconds) * 1e6);
87
+ struct timeval tv = { seconds, microseconds };
88
+ const uint64_t base = _glfwPlatformGetTimerValue();
89
+
90
+ const int result = select(count, &fds, NULL, NULL, &tv);
91
+ const int error = errno;
92
+
93
+ *timeout -= (_glfwPlatformGetTimerValue() - base) /
94
+ (double) _glfwPlatformGetTimerFrequency();
95
+
96
+ if (result > 0)
97
+ return GLFW_TRUE;
98
+ if ((result == -1 && error == EINTR) || *timeout <= 0.0)
99
+ return GLFW_FALSE;
100
+ }
101
+ else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR)
102
+ return GLFW_TRUE;
103
+ }
104
+ }
105
+
106
+ // Waits until a VisibilityNotify event arrives for the specified window or the
107
+ // timeout period elapses (ICCCM section 4.2.2)
108
+ //
109
+ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
110
+ {
111
+ XEvent dummy;
112
+ double timeout = 0.1;
113
+
114
+ while (!XCheckTypedWindowEvent(_glfw.x11.display,
115
+ window->x11.handle,
116
+ VisibilityNotify,
117
+ &dummy))
118
+ {
119
+ if (!waitForEvent(&timeout))
120
+ return GLFW_FALSE;
121
+ }
122
+
123
+ return GLFW_TRUE;
124
+ }
125
+
126
+ // Returns whether the window is iconified
127
+ //
128
+ static int getWindowState(_GLFWwindow* window)
129
+ {
130
+ int result = WithdrawnState;
131
+ struct {
132
+ CARD32 state;
133
+ Window icon;
134
+ } *state = NULL;
135
+
136
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
137
+ _glfw.x11.WM_STATE,
138
+ _glfw.x11.WM_STATE,
139
+ (unsigned char**) &state) >= 2)
140
+ {
141
+ result = state->state;
142
+ }
143
+
144
+ if (state)
145
+ XFree(state);
146
+
147
+ return result;
148
+ }
149
+
150
+ // Returns whether the event is a selection event
151
+ //
152
+ static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
153
+ {
154
+ if (event->xany.window != _glfw.x11.helperWindowHandle)
155
+ return False;
156
+
157
+ return event->type == SelectionRequest ||
158
+ event->type == SelectionNotify ||
159
+ event->type == SelectionClear;
160
+ }
161
+
162
+ // Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
163
+ //
164
+ static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
165
+ {
166
+ _GLFWwindow* window = (_GLFWwindow*) pointer;
167
+ return event->type == PropertyNotify &&
168
+ event->xproperty.state == PropertyNewValue &&
169
+ event->xproperty.window == window->x11.handle &&
170
+ event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;
171
+ }
172
+
173
+ // Returns whether it is a property event for the specified selection transfer
174
+ //
175
+ static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer)
176
+ {
177
+ XEvent* notification = (XEvent*) pointer;
178
+ return event->type == PropertyNotify &&
179
+ event->xproperty.state == PropertyNewValue &&
180
+ event->xproperty.window == notification->xselection.requestor &&
181
+ event->xproperty.atom == notification->xselection.property;
182
+ }
183
+
184
+ // Translates an X event modifier state mask
185
+ //
186
+ static int translateState(int state)
187
+ {
188
+ int mods = 0;
189
+
190
+ if (state & ShiftMask)
191
+ mods |= GLFW_MOD_SHIFT;
192
+ if (state & ControlMask)
193
+ mods |= GLFW_MOD_CONTROL;
194
+ if (state & Mod1Mask)
195
+ mods |= GLFW_MOD_ALT;
196
+ if (state & Mod4Mask)
197
+ mods |= GLFW_MOD_SUPER;
198
+ if (state & LockMask)
199
+ mods |= GLFW_MOD_CAPS_LOCK;
200
+ if (state & Mod2Mask)
201
+ mods |= GLFW_MOD_NUM_LOCK;
202
+
203
+ return mods;
204
+ }
205
+
206
+ // Translates an X11 key code to a GLFW key token
207
+ //
208
+ static int translateKey(int scancode)
209
+ {
210
+ // Use the pre-filled LUT (see createKeyTables() in x11_init.c)
211
+ if (scancode < 0 || scancode > 255)
212
+ return GLFW_KEY_UNKNOWN;
213
+
214
+ return _glfw.x11.keycodes[scancode];
215
+ }
216
+
217
+ // Sends an EWMH or ICCCM event to the window manager
218
+ //
219
+ static void sendEventToWM(_GLFWwindow* window, Atom type,
220
+ long a, long b, long c, long d, long e)
221
+ {
222
+ XEvent event = { ClientMessage };
223
+ event.xclient.window = window->x11.handle;
224
+ event.xclient.format = 32; // Data is 32-bit longs
225
+ event.xclient.message_type = type;
226
+ event.xclient.data.l[0] = a;
227
+ event.xclient.data.l[1] = b;
228
+ event.xclient.data.l[2] = c;
229
+ event.xclient.data.l[3] = d;
230
+ event.xclient.data.l[4] = e;
231
+
232
+ XSendEvent(_glfw.x11.display, _glfw.x11.root,
233
+ False,
234
+ SubstructureNotifyMask | SubstructureRedirectMask,
235
+ &event);
236
+ }
237
+
238
+ // Updates the normal hints according to the window settings
239
+ //
240
+ static void updateNormalHints(_GLFWwindow* window, int width, int height)
241
+ {
242
+ XSizeHints* hints = XAllocSizeHints();
243
+
244
+ if (!window->monitor)
245
+ {
246
+ if (window->resizable)
247
+ {
248
+ if (window->minwidth != GLFW_DONT_CARE &&
249
+ window->minheight != GLFW_DONT_CARE)
250
+ {
251
+ hints->flags |= PMinSize;
252
+ hints->min_width = window->minwidth;
253
+ hints->min_height = window->minheight;
254
+ }
255
+
256
+ if (window->maxwidth != GLFW_DONT_CARE &&
257
+ window->maxheight != GLFW_DONT_CARE)
258
+ {
259
+ hints->flags |= PMaxSize;
260
+ hints->max_width = window->maxwidth;
261
+ hints->max_height = window->maxheight;
262
+ }
263
+
264
+ if (window->numer != GLFW_DONT_CARE &&
265
+ window->denom != GLFW_DONT_CARE)
266
+ {
267
+ hints->flags |= PAspect;
268
+ hints->min_aspect.x = hints->max_aspect.x = window->numer;
269
+ hints->min_aspect.y = hints->max_aspect.y = window->denom;
270
+ }
271
+ }
272
+ else
273
+ {
274
+ hints->flags |= (PMinSize | PMaxSize);
275
+ hints->min_width = hints->max_width = width;
276
+ hints->min_height = hints->max_height = height;
277
+ }
278
+ }
279
+
280
+ hints->flags |= PWinGravity;
281
+ hints->win_gravity = StaticGravity;
282
+
283
+ XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
284
+ XFree(hints);
285
+ }
286
+
287
+ // Updates the full screen status of the window
288
+ //
289
+ static void updateWindowMode(_GLFWwindow* window)
290
+ {
291
+ if (window->monitor)
292
+ {
293
+ if (_glfw.x11.xinerama.available &&
294
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
295
+ {
296
+ sendEventToWM(window,
297
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS,
298
+ window->monitor->x11.index,
299
+ window->monitor->x11.index,
300
+ window->monitor->x11.index,
301
+ window->monitor->x11.index,
302
+ 0);
303
+ }
304
+
305
+ if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
306
+ {
307
+ sendEventToWM(window,
308
+ _glfw.x11.NET_WM_STATE,
309
+ _NET_WM_STATE_ADD,
310
+ _glfw.x11.NET_WM_STATE_FULLSCREEN,
311
+ 0, 1, 0);
312
+ }
313
+ else
314
+ {
315
+ // This is the butcher's way of removing window decorations
316
+ // Setting the override-redirect attribute on a window makes the
317
+ // window manager ignore the window completely (ICCCM, section 4)
318
+ // The good thing is that this makes undecorated full screen windows
319
+ // easy to do; the bad thing is that we have to do everything
320
+ // manually and some things (like iconify/restore) won't work at
321
+ // all, as those are tasks usually performed by the window manager
322
+
323
+ XSetWindowAttributes attributes;
324
+ attributes.override_redirect = True;
325
+ XChangeWindowAttributes(_glfw.x11.display,
326
+ window->x11.handle,
327
+ CWOverrideRedirect,
328
+ &attributes);
329
+
330
+ window->x11.overrideRedirect = GLFW_TRUE;
331
+ }
332
+
333
+ // Enable compositor bypass
334
+ if (!window->x11.transparent)
335
+ {
336
+ const unsigned long value = 1;
337
+
338
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
339
+ _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
340
+ PropModeReplace, (unsigned char*) &value, 1);
341
+ }
342
+ }
343
+ else
344
+ {
345
+ if (_glfw.x11.xinerama.available &&
346
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
347
+ {
348
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
349
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS);
350
+ }
351
+
352
+ if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
353
+ {
354
+ sendEventToWM(window,
355
+ _glfw.x11.NET_WM_STATE,
356
+ _NET_WM_STATE_REMOVE,
357
+ _glfw.x11.NET_WM_STATE_FULLSCREEN,
358
+ 0, 1, 0);
359
+ }
360
+ else
361
+ {
362
+ XSetWindowAttributes attributes;
363
+ attributes.override_redirect = False;
364
+ XChangeWindowAttributes(_glfw.x11.display,
365
+ window->x11.handle,
366
+ CWOverrideRedirect,
367
+ &attributes);
368
+
369
+ window->x11.overrideRedirect = GLFW_FALSE;
370
+ }
371
+
372
+ // Disable compositor bypass
373
+ if (!window->x11.transparent)
374
+ {
375
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
376
+ _glfw.x11.NET_WM_BYPASS_COMPOSITOR);
377
+ }
378
+ }
379
+ }
380
+
381
+ // Splits and translates a text/uri-list into separate file paths
382
+ // NOTE: This function destroys the provided string
383
+ //
384
+ static char** parseUriList(char* text, int* count)
385
+ {
386
+ const char* prefix = "file://";
387
+ char** paths = NULL;
388
+ char* line;
389
+
390
+ *count = 0;
391
+
392
+ while ((line = strtok(text, "\r\n")))
393
+ {
394
+ text = NULL;
395
+
396
+ if (line[0] == '#')
397
+ continue;
398
+
399
+ if (strncmp(line, prefix, strlen(prefix)) == 0)
400
+ {
401
+ line += strlen(prefix);
402
+ // TODO: Validate hostname
403
+ while (*line != '/')
404
+ line++;
405
+ }
406
+
407
+ (*count)++;
408
+
409
+ char* path = calloc(strlen(line) + 1, 1);
410
+ paths = realloc(paths, *count * sizeof(char*));
411
+ paths[*count - 1] = path;
412
+
413
+ while (*line)
414
+ {
415
+ if (line[0] == '%' && line[1] && line[2])
416
+ {
417
+ const char digits[3] = { line[1], line[2], '\0' };
418
+ *path = strtol(digits, NULL, 16);
419
+ line += 2;
420
+ }
421
+ else
422
+ *path = *line;
423
+
424
+ path++;
425
+ line++;
426
+ }
427
+ }
428
+
429
+ return paths;
430
+ }
431
+
432
+ // Encode a Unicode code point to a UTF-8 stream
433
+ // Based on cutef8 by Jeff Bezanson (Public Domain)
434
+ //
435
+ static size_t encodeUTF8(char* s, unsigned int ch)
436
+ {
437
+ size_t count = 0;
438
+
439
+ if (ch < 0x80)
440
+ s[count++] = (char) ch;
441
+ else if (ch < 0x800)
442
+ {
443
+ s[count++] = (ch >> 6) | 0xc0;
444
+ s[count++] = (ch & 0x3f) | 0x80;
445
+ }
446
+ else if (ch < 0x10000)
447
+ {
448
+ s[count++] = (ch >> 12) | 0xe0;
449
+ s[count++] = ((ch >> 6) & 0x3f) | 0x80;
450
+ s[count++] = (ch & 0x3f) | 0x80;
451
+ }
452
+ else if (ch < 0x110000)
453
+ {
454
+ s[count++] = (ch >> 18) | 0xf0;
455
+ s[count++] = ((ch >> 12) & 0x3f) | 0x80;
456
+ s[count++] = ((ch >> 6) & 0x3f) | 0x80;
457
+ s[count++] = (ch & 0x3f) | 0x80;
458
+ }
459
+
460
+ return count;
461
+ }
462
+
463
+ // Decode a Unicode code point from a UTF-8 stream
464
+ // Based on cutef8 by Jeff Bezanson (Public Domain)
465
+ //
466
+ static unsigned int decodeUTF8(const char** s)
467
+ {
468
+ unsigned int ch = 0, count = 0;
469
+ static const unsigned int offsets[] =
470
+ {
471
+ 0x00000000u, 0x00003080u, 0x000e2080u,
472
+ 0x03c82080u, 0xfa082080u, 0x82082080u
473
+ };
474
+
475
+ do
476
+ {
477
+ ch = (ch << 6) + (unsigned char) **s;
478
+ (*s)++;
479
+ count++;
480
+ } while ((**s & 0xc0) == 0x80);
481
+
482
+ assert(count <= 6);
483
+ return ch - offsets[count - 1];
484
+ }
485
+
486
+ // Convert the specified Latin-1 string to UTF-8
487
+ //
488
+ static char* convertLatin1toUTF8(const char* source)
489
+ {
490
+ size_t size = 1;
491
+ const char* sp;
492
+
493
+ for (sp = source; *sp; sp++)
494
+ size += (*sp & 0x80) ? 2 : 1;
495
+
496
+ char* target = calloc(size, 1);
497
+ char* tp = target;
498
+
499
+ for (sp = source; *sp; sp++)
500
+ tp += encodeUTF8(tp, *sp);
501
+
502
+ return target;
503
+ }
504
+
505
+ // Updates the cursor image according to its cursor mode
506
+ //
507
+ static void updateCursorImage(_GLFWwindow* window)
508
+ {
509
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
510
+ {
511
+ if (window->cursor)
512
+ {
513
+ XDefineCursor(_glfw.x11.display, window->x11.handle,
514
+ window->cursor->x11.handle);
515
+ }
516
+ else
517
+ XUndefineCursor(_glfw.x11.display, window->x11.handle);
518
+ }
519
+ else
520
+ {
521
+ XDefineCursor(_glfw.x11.display, window->x11.handle,
522
+ _glfw.x11.hiddenCursorHandle);
523
+ }
524
+ }
525
+
526
+ // Enable XI2 raw mouse motion events
527
+ //
528
+ static void enableRawMouseMotion(_GLFWwindow* window)
529
+ {
530
+ XIEventMask em;
531
+ unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
532
+
533
+ em.deviceid = XIAllMasterDevices;
534
+ em.mask_len = sizeof(mask);
535
+ em.mask = mask;
536
+ XISetMask(mask, XI_RawMotion);
537
+
538
+ XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
539
+ }
540
+
541
+ // Disable XI2 raw mouse motion events
542
+ //
543
+ static void disableRawMouseMotion(_GLFWwindow* window)
544
+ {
545
+ XIEventMask em;
546
+ unsigned char mask[] = { 0 };
547
+
548
+ em.deviceid = XIAllMasterDevices;
549
+ em.mask_len = sizeof(mask);
550
+ em.mask = mask;
551
+
552
+ XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
553
+ }
554
+
555
+ // Apply disabled cursor mode to a focused window
556
+ //
557
+ static void disableCursor(_GLFWwindow* window)
558
+ {
559
+ if (window->rawMouseMotion)
560
+ enableRawMouseMotion(window);
561
+
562
+ _glfw.x11.disabledCursorWindow = window;
563
+ _glfwPlatformGetCursorPos(window,
564
+ &_glfw.x11.restoreCursorPosX,
565
+ &_glfw.x11.restoreCursorPosY);
566
+ updateCursorImage(window);
567
+ _glfwCenterCursorInContentArea(window);
568
+ XGrabPointer(_glfw.x11.display, window->x11.handle, True,
569
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
570
+ GrabModeAsync, GrabModeAsync,
571
+ window->x11.handle,
572
+ _glfw.x11.hiddenCursorHandle,
573
+ CurrentTime);
574
+ }
575
+
576
+ // Exit disabled cursor mode for the specified window
577
+ //
578
+ static void enableCursor(_GLFWwindow* window)
579
+ {
580
+ if (window->rawMouseMotion)
581
+ disableRawMouseMotion(window);
582
+
583
+ _glfw.x11.disabledCursorWindow = NULL;
584
+ XUngrabPointer(_glfw.x11.display, CurrentTime);
585
+ _glfwPlatformSetCursorPos(window,
586
+ _glfw.x11.restoreCursorPosX,
587
+ _glfw.x11.restoreCursorPosY);
588
+ updateCursorImage(window);
589
+ }
590
+
591
+ // Clear its handle when the input context has been destroyed
592
+ //
593
+ static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData)
594
+ {
595
+ _GLFWwindow* window = (_GLFWwindow*) clientData;
596
+ window->x11.ic = NULL;
597
+ }
598
+
599
+ // Create the X11 window (and its colormap)
600
+ //
601
+ static GLFWbool createNativeWindow(_GLFWwindow* window,
602
+ const _GLFWwndconfig* wndconfig,
603
+ Visual* visual, int depth)
604
+ {
605
+ int width = wndconfig->width;
606
+ int height = wndconfig->height;
607
+
608
+ if (wndconfig->scaleToMonitor)
609
+ {
610
+ width *= _glfw.x11.contentScaleX;
611
+ height *= _glfw.x11.contentScaleY;
612
+ }
613
+
614
+ // Create a colormap based on the visual used by the current context
615
+ window->x11.colormap = XCreateColormap(_glfw.x11.display,
616
+ _glfw.x11.root,
617
+ visual,
618
+ AllocNone);
619
+
620
+ window->x11.transparent = _glfwIsVisualTransparentX11(visual);
621
+
622
+ XSetWindowAttributes wa = { 0 };
623
+ wa.colormap = window->x11.colormap;
624
+ wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
625
+ PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
626
+ ExposureMask | FocusChangeMask | VisibilityChangeMask |
627
+ EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
628
+
629
+ _glfwGrabErrorHandlerX11();
630
+
631
+ window->x11.parent = _glfw.x11.root;
632
+ window->x11.handle = XCreateWindow(_glfw.x11.display,
633
+ _glfw.x11.root,
634
+ 0, 0, // Position
635
+ width, height,
636
+ 0, // Border width
637
+ depth, // Color depth
638
+ InputOutput,
639
+ visual,
640
+ CWBorderPixel | CWColormap | CWEventMask,
641
+ &wa);
642
+
643
+ _glfwReleaseErrorHandlerX11();
644
+
645
+ if (!window->x11.handle)
646
+ {
647
+ _glfwInputErrorX11(GLFW_PLATFORM_ERROR,
648
+ "X11: Failed to create window");
649
+ return GLFW_FALSE;
650
+ }
651
+
652
+ XSaveContext(_glfw.x11.display,
653
+ window->x11.handle,
654
+ _glfw.x11.context,
655
+ (XPointer) window);
656
+
657
+ if (!wndconfig->decorated)
658
+ _glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
659
+
660
+ if (_glfw.x11.NET_WM_STATE && !window->monitor)
661
+ {
662
+ Atom states[3];
663
+ int count = 0;
664
+
665
+ if (wndconfig->floating)
666
+ {
667
+ if (_glfw.x11.NET_WM_STATE_ABOVE)
668
+ states[count++] = _glfw.x11.NET_WM_STATE_ABOVE;
669
+ }
670
+
671
+ if (wndconfig->maximized)
672
+ {
673
+ if (_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
674
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
675
+ {
676
+ states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
677
+ states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
678
+ window->x11.maximized = GLFW_TRUE;
679
+ }
680
+ }
681
+
682
+ if (count)
683
+ {
684
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
685
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
686
+ PropModeReplace, (unsigned char*) states, count);
687
+ }
688
+ }
689
+
690
+ // Declare the WM protocols supported by GLFW
691
+ {
692
+ Atom protocols[] =
693
+ {
694
+ _glfw.x11.WM_DELETE_WINDOW,
695
+ _glfw.x11.NET_WM_PING
696
+ };
697
+
698
+ XSetWMProtocols(_glfw.x11.display, window->x11.handle,
699
+ protocols, sizeof(protocols) / sizeof(Atom));
700
+ }
701
+
702
+ // Declare our PID
703
+ {
704
+ const long pid = getpid();
705
+
706
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
707
+ _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,
708
+ PropModeReplace,
709
+ (unsigned char*) &pid, 1);
710
+ }
711
+
712
+ if (_glfw.x11.NET_WM_WINDOW_TYPE && _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL)
713
+ {
714
+ Atom type = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL;
715
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
716
+ _glfw.x11.NET_WM_WINDOW_TYPE, XA_ATOM, 32,
717
+ PropModeReplace, (unsigned char*) &type, 1);
718
+ }
719
+
720
+ // Set ICCCM WM_HINTS property
721
+ {
722
+ XWMHints* hints = XAllocWMHints();
723
+ if (!hints)
724
+ {
725
+ _glfwInputError(GLFW_OUT_OF_MEMORY,
726
+ "X11: Failed to allocate WM hints");
727
+ return GLFW_FALSE;
728
+ }
729
+
730
+ hints->flags = StateHint;
731
+ hints->initial_state = NormalState;
732
+
733
+ XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
734
+ XFree(hints);
735
+ }
736
+
737
+ updateNormalHints(window, width, height);
738
+
739
+ // Set ICCCM WM_CLASS property
740
+ {
741
+ XClassHint* hint = XAllocClassHint();
742
+
743
+ if (strlen(wndconfig->x11.instanceName) &&
744
+ strlen(wndconfig->x11.className))
745
+ {
746
+ hint->res_name = (char*) wndconfig->x11.instanceName;
747
+ hint->res_class = (char*) wndconfig->x11.className;
748
+ }
749
+ else
750
+ {
751
+ const char* resourceName = getenv("RESOURCE_NAME");
752
+ if (resourceName && strlen(resourceName))
753
+ hint->res_name = (char*) resourceName;
754
+ else if (strlen(wndconfig->title))
755
+ hint->res_name = (char*) wndconfig->title;
756
+ else
757
+ hint->res_name = (char*) "glfw-application";
758
+
759
+ if (strlen(wndconfig->title))
760
+ hint->res_class = (char*) wndconfig->title;
761
+ else
762
+ hint->res_class = (char*) "GLFW-Application";
763
+ }
764
+
765
+ XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
766
+ XFree(hint);
767
+ }
768
+
769
+ // Announce support for Xdnd (drag and drop)
770
+ {
771
+ const Atom version = _GLFW_XDND_VERSION;
772
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
773
+ _glfw.x11.XdndAware, XA_ATOM, 32,
774
+ PropModeReplace, (unsigned char*) &version, 1);
775
+ }
776
+
777
+ if (_glfw.x11.im)
778
+ _glfwCreateInputContextX11(window);
779
+
780
+ _glfwPlatformSetWindowTitle(window, wndconfig->title);
781
+ _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
782
+ _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
783
+
784
+ return GLFW_TRUE;
785
+ }
786
+
787
+ // Set the specified property to the selection converted to the requested target
788
+ //
789
+ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
790
+ {
791
+ int i;
792
+ char* selectionString = NULL;
793
+ const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
794
+ const int formatCount = sizeof(formats) / sizeof(formats[0]);
795
+
796
+ if (request->selection == _glfw.x11.PRIMARY)
797
+ selectionString = _glfw.x11.primarySelectionString;
798
+ else
799
+ selectionString = _glfw.x11.clipboardString;
800
+
801
+ if (request->property == None)
802
+ {
803
+ // The requester is a legacy client (ICCCM section 2.2)
804
+ // We don't support legacy clients, so fail here
805
+ return None;
806
+ }
807
+
808
+ if (request->target == _glfw.x11.TARGETS)
809
+ {
810
+ // The list of supported targets was requested
811
+
812
+ const Atom targets[] = { _glfw.x11.TARGETS,
813
+ _glfw.x11.MULTIPLE,
814
+ _glfw.x11.UTF8_STRING,
815
+ XA_STRING };
816
+
817
+ XChangeProperty(_glfw.x11.display,
818
+ request->requestor,
819
+ request->property,
820
+ XA_ATOM,
821
+ 32,
822
+ PropModeReplace,
823
+ (unsigned char*) targets,
824
+ sizeof(targets) / sizeof(targets[0]));
825
+
826
+ return request->property;
827
+ }
828
+
829
+ if (request->target == _glfw.x11.MULTIPLE)
830
+ {
831
+ // Multiple conversions were requested
832
+
833
+ Atom* targets;
834
+ unsigned long i, count;
835
+
836
+ count = _glfwGetWindowPropertyX11(request->requestor,
837
+ request->property,
838
+ _glfw.x11.ATOM_PAIR,
839
+ (unsigned char**) &targets);
840
+
841
+ for (i = 0; i < count; i += 2)
842
+ {
843
+ int j;
844
+
845
+ for (j = 0; j < formatCount; j++)
846
+ {
847
+ if (targets[i] == formats[j])
848
+ break;
849
+ }
850
+
851
+ if (j < formatCount)
852
+ {
853
+ XChangeProperty(_glfw.x11.display,
854
+ request->requestor,
855
+ targets[i + 1],
856
+ targets[i],
857
+ 8,
858
+ PropModeReplace,
859
+ (unsigned char *) selectionString,
860
+ strlen(selectionString));
861
+ }
862
+ else
863
+ targets[i + 1] = None;
864
+ }
865
+
866
+ XChangeProperty(_glfw.x11.display,
867
+ request->requestor,
868
+ request->property,
869
+ _glfw.x11.ATOM_PAIR,
870
+ 32,
871
+ PropModeReplace,
872
+ (unsigned char*) targets,
873
+ count);
874
+
875
+ XFree(targets);
876
+
877
+ return request->property;
878
+ }
879
+
880
+ if (request->target == _glfw.x11.SAVE_TARGETS)
881
+ {
882
+ // The request is a check whether we support SAVE_TARGETS
883
+ // It should be handled as a no-op side effect target
884
+
885
+ XChangeProperty(_glfw.x11.display,
886
+ request->requestor,
887
+ request->property,
888
+ _glfw.x11.NULL_,
889
+ 32,
890
+ PropModeReplace,
891
+ NULL,
892
+ 0);
893
+
894
+ return request->property;
895
+ }
896
+
897
+ // Conversion to a data target was requested
898
+
899
+ for (i = 0; i < formatCount; i++)
900
+ {
901
+ if (request->target == formats[i])
902
+ {
903
+ // The requested target is one we support
904
+
905
+ XChangeProperty(_glfw.x11.display,
906
+ request->requestor,
907
+ request->property,
908
+ request->target,
909
+ 8,
910
+ PropModeReplace,
911
+ (unsigned char *) selectionString,
912
+ strlen(selectionString));
913
+
914
+ return request->property;
915
+ }
916
+ }
917
+
918
+ // The requested target is not supported
919
+
920
+ return None;
921
+ }
922
+
923
+ static void handleSelectionClear(XEvent* event)
924
+ {
925
+ if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
926
+ {
927
+ free(_glfw.x11.primarySelectionString);
928
+ _glfw.x11.primarySelectionString = NULL;
929
+ }
930
+ else
931
+ {
932
+ free(_glfw.x11.clipboardString);
933
+ _glfw.x11.clipboardString = NULL;
934
+ }
935
+ }
936
+
937
+ static void handleSelectionRequest(XEvent* event)
938
+ {
939
+ const XSelectionRequestEvent* request = &event->xselectionrequest;
940
+
941
+ XEvent reply = { SelectionNotify };
942
+ reply.xselection.property = writeTargetToProperty(request);
943
+ reply.xselection.display = request->display;
944
+ reply.xselection.requestor = request->requestor;
945
+ reply.xselection.selection = request->selection;
946
+ reply.xselection.target = request->target;
947
+ reply.xselection.time = request->time;
948
+
949
+ XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
950
+ }
951
+
952
+ static const char* getSelectionString(Atom selection)
953
+ {
954
+ char** selectionString = NULL;
955
+ const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
956
+ const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
957
+
958
+ if (selection == _glfw.x11.PRIMARY)
959
+ selectionString = &_glfw.x11.primarySelectionString;
960
+ else
961
+ selectionString = &_glfw.x11.clipboardString;
962
+
963
+ if (XGetSelectionOwner(_glfw.x11.display, selection) ==
964
+ _glfw.x11.helperWindowHandle)
965
+ {
966
+ // Instead of doing a large number of X round-trips just to put this
967
+ // string into a window property and then read it back, just return it
968
+ return *selectionString;
969
+ }
970
+
971
+ free(*selectionString);
972
+ *selectionString = NULL;
973
+
974
+ for (size_t i = 0; i < targetCount; i++)
975
+ {
976
+ char* data;
977
+ Atom actualType;
978
+ int actualFormat;
979
+ unsigned long itemCount, bytesAfter;
980
+ XEvent notification, dummy;
981
+
982
+ XConvertSelection(_glfw.x11.display,
983
+ selection,
984
+ targets[i],
985
+ _glfw.x11.GLFW_SELECTION,
986
+ _glfw.x11.helperWindowHandle,
987
+ CurrentTime);
988
+
989
+ while (!XCheckTypedWindowEvent(_glfw.x11.display,
990
+ _glfw.x11.helperWindowHandle,
991
+ SelectionNotify,
992
+ &notification))
993
+ {
994
+ waitForEvent(NULL);
995
+ }
996
+
997
+ if (notification.xselection.property == None)
998
+ continue;
999
+
1000
+ XCheckIfEvent(_glfw.x11.display,
1001
+ &dummy,
1002
+ isSelPropNewValueNotify,
1003
+ (XPointer) &notification);
1004
+
1005
+ XGetWindowProperty(_glfw.x11.display,
1006
+ notification.xselection.requestor,
1007
+ notification.xselection.property,
1008
+ 0,
1009
+ LONG_MAX,
1010
+ True,
1011
+ AnyPropertyType,
1012
+ &actualType,
1013
+ &actualFormat,
1014
+ &itemCount,
1015
+ &bytesAfter,
1016
+ (unsigned char**) &data);
1017
+
1018
+ if (actualType == _glfw.x11.INCR)
1019
+ {
1020
+ size_t size = 1;
1021
+ char* string = NULL;
1022
+
1023
+ for (;;)
1024
+ {
1025
+ while (!XCheckIfEvent(_glfw.x11.display,
1026
+ &dummy,
1027
+ isSelPropNewValueNotify,
1028
+ (XPointer) &notification))
1029
+ {
1030
+ waitForEvent(NULL);
1031
+ }
1032
+
1033
+ XFree(data);
1034
+ XGetWindowProperty(_glfw.x11.display,
1035
+ notification.xselection.requestor,
1036
+ notification.xselection.property,
1037
+ 0,
1038
+ LONG_MAX,
1039
+ True,
1040
+ AnyPropertyType,
1041
+ &actualType,
1042
+ &actualFormat,
1043
+ &itemCount,
1044
+ &bytesAfter,
1045
+ (unsigned char**) &data);
1046
+
1047
+ if (itemCount)
1048
+ {
1049
+ size += itemCount;
1050
+ string = realloc(string, size);
1051
+ string[size - itemCount - 1] = '\0';
1052
+ strcat(string, data);
1053
+ }
1054
+
1055
+ if (!itemCount)
1056
+ {
1057
+ if (targets[i] == XA_STRING)
1058
+ {
1059
+ *selectionString = convertLatin1toUTF8(string);
1060
+ free(string);
1061
+ }
1062
+ else
1063
+ *selectionString = string;
1064
+
1065
+ break;
1066
+ }
1067
+ }
1068
+ }
1069
+ else if (actualType == targets[i])
1070
+ {
1071
+ if (targets[i] == XA_STRING)
1072
+ *selectionString = convertLatin1toUTF8(data);
1073
+ else
1074
+ *selectionString = _glfw_strdup(data);
1075
+ }
1076
+
1077
+ XFree(data);
1078
+
1079
+ if (*selectionString)
1080
+ break;
1081
+ }
1082
+
1083
+ if (!*selectionString)
1084
+ {
1085
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
1086
+ "X11: Failed to convert selection to string");
1087
+ }
1088
+
1089
+ return *selectionString;
1090
+ }
1091
+
1092
+ // Make the specified window and its video mode active on its monitor
1093
+ //
1094
+ static void acquireMonitor(_GLFWwindow* window)
1095
+ {
1096
+ if (_glfw.x11.saver.count == 0)
1097
+ {
1098
+ // Remember old screen saver settings
1099
+ XGetScreenSaver(_glfw.x11.display,
1100
+ &_glfw.x11.saver.timeout,
1101
+ &_glfw.x11.saver.interval,
1102
+ &_glfw.x11.saver.blanking,
1103
+ &_glfw.x11.saver.exposure);
1104
+
1105
+ // Disable screen saver
1106
+ XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
1107
+ DefaultExposures);
1108
+ }
1109
+
1110
+ if (!window->monitor->window)
1111
+ _glfw.x11.saver.count++;
1112
+
1113
+ _glfwSetVideoModeX11(window->monitor, &window->videoMode);
1114
+
1115
+ if (window->x11.overrideRedirect)
1116
+ {
1117
+ int xpos, ypos;
1118
+ GLFWvidmode mode;
1119
+
1120
+ // Manually position the window over its monitor
1121
+ _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
1122
+ _glfwPlatformGetVideoMode(window->monitor, &mode);
1123
+
1124
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
1125
+ xpos, ypos, mode.width, mode.height);
1126
+ }
1127
+
1128
+ _glfwInputMonitorWindow(window->monitor, window);
1129
+ }
1130
+
1131
+ // Remove the window and restore the original video mode
1132
+ //
1133
+ static void releaseMonitor(_GLFWwindow* window)
1134
+ {
1135
+ if (window->monitor->window != window)
1136
+ return;
1137
+
1138
+ _glfwInputMonitorWindow(window->monitor, NULL);
1139
+ _glfwRestoreVideoModeX11(window->monitor);
1140
+
1141
+ _glfw.x11.saver.count--;
1142
+
1143
+ if (_glfw.x11.saver.count == 0)
1144
+ {
1145
+ // Restore old screen saver settings
1146
+ XSetScreenSaver(_glfw.x11.display,
1147
+ _glfw.x11.saver.timeout,
1148
+ _glfw.x11.saver.interval,
1149
+ _glfw.x11.saver.blanking,
1150
+ _glfw.x11.saver.exposure);
1151
+ }
1152
+ }
1153
+
1154
+ // Process the specified X event
1155
+ //
1156
+ static void processEvent(XEvent *event)
1157
+ {
1158
+ int keycode = 0;
1159
+ Bool filtered = False;
1160
+
1161
+ // HACK: Save scancode as some IMs clear the field in XFilterEvent
1162
+ if (event->type == KeyPress || event->type == KeyRelease)
1163
+ keycode = event->xkey.keycode;
1164
+
1165
+ filtered = XFilterEvent(event, None);
1166
+
1167
+ if (_glfw.x11.randr.available)
1168
+ {
1169
+ if (event->type == _glfw.x11.randr.eventBase + RRNotify)
1170
+ {
1171
+ XRRUpdateConfiguration(event);
1172
+ _glfwPollMonitorsX11();
1173
+ return;
1174
+ }
1175
+ }
1176
+
1177
+ if (_glfw.x11.xkb.available)
1178
+ {
1179
+ if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
1180
+ {
1181
+ if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
1182
+ (((XkbEvent*) event)->state.changed & XkbGroupStateMask))
1183
+ {
1184
+ _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
1185
+ }
1186
+
1187
+ return;
1188
+ }
1189
+ }
1190
+
1191
+ if (event->type == GenericEvent)
1192
+ {
1193
+ if (_glfw.x11.xi.available)
1194
+ {
1195
+ _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
1196
+
1197
+ if (window &&
1198
+ window->rawMouseMotion &&
1199
+ event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
1200
+ XGetEventData(_glfw.x11.display, &event->xcookie) &&
1201
+ event->xcookie.evtype == XI_RawMotion)
1202
+ {
1203
+ XIRawEvent* re = event->xcookie.data;
1204
+ if (re->valuators.mask_len)
1205
+ {
1206
+ const double* values = re->raw_values;
1207
+ double xpos = window->virtualCursorPosX;
1208
+ double ypos = window->virtualCursorPosY;
1209
+
1210
+ if (XIMaskIsSet(re->valuators.mask, 0))
1211
+ {
1212
+ xpos += *values;
1213
+ values++;
1214
+ }
1215
+
1216
+ if (XIMaskIsSet(re->valuators.mask, 1))
1217
+ ypos += *values;
1218
+
1219
+ _glfwInputCursorPos(window, xpos, ypos);
1220
+ }
1221
+ }
1222
+
1223
+ XFreeEventData(_glfw.x11.display, &event->xcookie);
1224
+ }
1225
+
1226
+ return;
1227
+ }
1228
+
1229
+ if (event->type == SelectionClear)
1230
+ {
1231
+ handleSelectionClear(event);
1232
+ return;
1233
+ }
1234
+ else if (event->type == SelectionRequest)
1235
+ {
1236
+ handleSelectionRequest(event);
1237
+ return;
1238
+ }
1239
+
1240
+ _GLFWwindow* window = NULL;
1241
+ if (XFindContext(_glfw.x11.display,
1242
+ event->xany.window,
1243
+ _glfw.x11.context,
1244
+ (XPointer*) &window) != 0)
1245
+ {
1246
+ // This is an event for a window that has already been destroyed
1247
+ return;
1248
+ }
1249
+
1250
+ switch (event->type)
1251
+ {
1252
+ case ReparentNotify:
1253
+ {
1254
+ window->x11.parent = event->xreparent.parent;
1255
+ return;
1256
+ }
1257
+
1258
+ case KeyPress:
1259
+ {
1260
+ const int key = translateKey(keycode);
1261
+ const int mods = translateState(event->xkey.state);
1262
+ const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
1263
+
1264
+ if (window->x11.ic)
1265
+ {
1266
+ // HACK: Do not report the key press events duplicated by XIM
1267
+ // Duplicate key releases are filtered out implicitly by
1268
+ // the GLFW key repeat logic in _glfwInputKey
1269
+ // A timestamp per key is used to handle simultaneous keys
1270
+ // NOTE: Always allow the first event for each key through
1271
+ // (the server never sends a timestamp of zero)
1272
+ // NOTE: Timestamp difference is compared to handle wrap-around
1273
+ Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
1274
+ if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31)))
1275
+ {
1276
+ if (keycode)
1277
+ _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
1278
+
1279
+ window->x11.keyPressTimes[keycode] = event->xkey.time;
1280
+ }
1281
+
1282
+ if (!filtered)
1283
+ {
1284
+ int count;
1285
+ Status status;
1286
+ char buffer[100];
1287
+ char* chars = buffer;
1288
+
1289
+ count = Xutf8LookupString(window->x11.ic,
1290
+ &event->xkey,
1291
+ buffer, sizeof(buffer) - 1,
1292
+ NULL, &status);
1293
+
1294
+ if (status == XBufferOverflow)
1295
+ {
1296
+ chars = calloc(count + 1, 1);
1297
+ count = Xutf8LookupString(window->x11.ic,
1298
+ &event->xkey,
1299
+ chars, count,
1300
+ NULL, &status);
1301
+ }
1302
+
1303
+ if (status == XLookupChars || status == XLookupBoth)
1304
+ {
1305
+ const char* c = chars;
1306
+ chars[count] = '\0';
1307
+ while (c - chars < count)
1308
+ _glfwInputChar(window, decodeUTF8(&c), mods, plain);
1309
+ }
1310
+
1311
+ if (chars != buffer)
1312
+ free(chars);
1313
+ }
1314
+ }
1315
+ else
1316
+ {
1317
+ KeySym keysym;
1318
+ XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
1319
+
1320
+ _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
1321
+
1322
+ const long character = _glfwKeySym2Unicode(keysym);
1323
+ if (character != -1)
1324
+ _glfwInputChar(window, character, mods, plain);
1325
+ }
1326
+
1327
+ return;
1328
+ }
1329
+
1330
+ case KeyRelease:
1331
+ {
1332
+ const int key = translateKey(keycode);
1333
+ const int mods = translateState(event->xkey.state);
1334
+
1335
+ if (!_glfw.x11.xkb.detectable)
1336
+ {
1337
+ // HACK: Key repeat events will arrive as KeyRelease/KeyPress
1338
+ // pairs with similar or identical time stamps
1339
+ // The key repeat logic in _glfwInputKey expects only key
1340
+ // presses to repeat, so detect and discard release events
1341
+ if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
1342
+ {
1343
+ XEvent next;
1344
+ XPeekEvent(_glfw.x11.display, &next);
1345
+
1346
+ if (next.type == KeyPress &&
1347
+ next.xkey.window == event->xkey.window &&
1348
+ next.xkey.keycode == keycode)
1349
+ {
1350
+ // HACK: The time of repeat events sometimes doesn't
1351
+ // match that of the press event, so add an
1352
+ // epsilon
1353
+ // Toshiyuki Takahashi can press a button
1354
+ // 16 times per second so it's fairly safe to
1355
+ // assume that no human is pressing the key 50
1356
+ // times per second (value is ms)
1357
+ if ((next.xkey.time - event->xkey.time) < 20)
1358
+ {
1359
+ // This is very likely a server-generated key repeat
1360
+ // event, so ignore it
1361
+ return;
1362
+ }
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+ _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);
1368
+ return;
1369
+ }
1370
+
1371
+ case ButtonPress:
1372
+ {
1373
+ const int mods = translateState(event->xbutton.state);
1374
+
1375
+ if (event->xbutton.button == Button1)
1376
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
1377
+ else if (event->xbutton.button == Button2)
1378
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
1379
+ else if (event->xbutton.button == Button3)
1380
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
1381
+
1382
+ // Modern X provides scroll events as mouse button presses
1383
+ else if (event->xbutton.button == Button4)
1384
+ _glfwInputScroll(window, 0.0, 1.0);
1385
+ else if (event->xbutton.button == Button5)
1386
+ _glfwInputScroll(window, 0.0, -1.0);
1387
+ else if (event->xbutton.button == Button6)
1388
+ _glfwInputScroll(window, 1.0, 0.0);
1389
+ else if (event->xbutton.button == Button7)
1390
+ _glfwInputScroll(window, -1.0, 0.0);
1391
+
1392
+ else
1393
+ {
1394
+ // Additional buttons after 7 are treated as regular buttons
1395
+ // We subtract 4 to fill the gap left by scroll input above
1396
+ _glfwInputMouseClick(window,
1397
+ event->xbutton.button - Button1 - 4,
1398
+ GLFW_PRESS,
1399
+ mods);
1400
+ }
1401
+
1402
+ return;
1403
+ }
1404
+
1405
+ case ButtonRelease:
1406
+ {
1407
+ const int mods = translateState(event->xbutton.state);
1408
+
1409
+ if (event->xbutton.button == Button1)
1410
+ {
1411
+ _glfwInputMouseClick(window,
1412
+ GLFW_MOUSE_BUTTON_LEFT,
1413
+ GLFW_RELEASE,
1414
+ mods);
1415
+ }
1416
+ else if (event->xbutton.button == Button2)
1417
+ {
1418
+ _glfwInputMouseClick(window,
1419
+ GLFW_MOUSE_BUTTON_MIDDLE,
1420
+ GLFW_RELEASE,
1421
+ mods);
1422
+ }
1423
+ else if (event->xbutton.button == Button3)
1424
+ {
1425
+ _glfwInputMouseClick(window,
1426
+ GLFW_MOUSE_BUTTON_RIGHT,
1427
+ GLFW_RELEASE,
1428
+ mods);
1429
+ }
1430
+ else if (event->xbutton.button > Button7)
1431
+ {
1432
+ // Additional buttons after 7 are treated as regular buttons
1433
+ // We subtract 4 to fill the gap left by scroll input above
1434
+ _glfwInputMouseClick(window,
1435
+ event->xbutton.button - Button1 - 4,
1436
+ GLFW_RELEASE,
1437
+ mods);
1438
+ }
1439
+
1440
+ return;
1441
+ }
1442
+
1443
+ case EnterNotify:
1444
+ {
1445
+ // XEnterWindowEvent is XCrossingEvent
1446
+ const int x = event->xcrossing.x;
1447
+ const int y = event->xcrossing.y;
1448
+
1449
+ // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
1450
+ // ignore the defined cursor for hidden cursor mode
1451
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
1452
+ updateCursorImage(window);
1453
+
1454
+ _glfwInputCursorEnter(window, GLFW_TRUE);
1455
+ _glfwInputCursorPos(window, x, y);
1456
+
1457
+ window->x11.lastCursorPosX = x;
1458
+ window->x11.lastCursorPosY = y;
1459
+ return;
1460
+ }
1461
+
1462
+ case LeaveNotify:
1463
+ {
1464
+ _glfwInputCursorEnter(window, GLFW_FALSE);
1465
+ return;
1466
+ }
1467
+
1468
+ case MotionNotify:
1469
+ {
1470
+ const int x = event->xmotion.x;
1471
+ const int y = event->xmotion.y;
1472
+
1473
+ if (x != window->x11.warpCursorPosX ||
1474
+ y != window->x11.warpCursorPosY)
1475
+ {
1476
+ // The cursor was moved by something other than GLFW
1477
+
1478
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
1479
+ {
1480
+ if (_glfw.x11.disabledCursorWindow != window)
1481
+ return;
1482
+ if (window->rawMouseMotion)
1483
+ return;
1484
+
1485
+ const int dx = x - window->x11.lastCursorPosX;
1486
+ const int dy = y - window->x11.lastCursorPosY;
1487
+
1488
+ _glfwInputCursorPos(window,
1489
+ window->virtualCursorPosX + dx,
1490
+ window->virtualCursorPosY + dy);
1491
+ }
1492
+ else
1493
+ _glfwInputCursorPos(window, x, y);
1494
+ }
1495
+
1496
+ window->x11.lastCursorPosX = x;
1497
+ window->x11.lastCursorPosY = y;
1498
+ return;
1499
+ }
1500
+
1501
+ case ConfigureNotify:
1502
+ {
1503
+ if (event->xconfigure.width != window->x11.width ||
1504
+ event->xconfigure.height != window->x11.height)
1505
+ {
1506
+ _glfwInputFramebufferSize(window,
1507
+ event->xconfigure.width,
1508
+ event->xconfigure.height);
1509
+
1510
+ _glfwInputWindowSize(window,
1511
+ event->xconfigure.width,
1512
+ event->xconfigure.height);
1513
+
1514
+ window->x11.width = event->xconfigure.width;
1515
+ window->x11.height = event->xconfigure.height;
1516
+ }
1517
+
1518
+ int xpos = event->xconfigure.x;
1519
+ int ypos = event->xconfigure.y;
1520
+
1521
+ // NOTE: ConfigureNotify events from the server are in local
1522
+ // coordinates, so if we are reparented we need to translate
1523
+ // the position into root (screen) coordinates
1524
+ if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
1525
+ {
1526
+ _glfwGrabErrorHandlerX11();
1527
+
1528
+ Window dummy;
1529
+ XTranslateCoordinates(_glfw.x11.display,
1530
+ window->x11.parent,
1531
+ _glfw.x11.root,
1532
+ xpos, ypos,
1533
+ &xpos, &ypos,
1534
+ &dummy);
1535
+
1536
+ _glfwReleaseErrorHandlerX11();
1537
+ if (_glfw.x11.errorCode == BadWindow)
1538
+ return;
1539
+ }
1540
+
1541
+ if (xpos != window->x11.xpos || ypos != window->x11.ypos)
1542
+ {
1543
+ _glfwInputWindowPos(window, xpos, ypos);
1544
+ window->x11.xpos = xpos;
1545
+ window->x11.ypos = ypos;
1546
+ }
1547
+
1548
+ return;
1549
+ }
1550
+
1551
+ case ClientMessage:
1552
+ {
1553
+ // Custom client message, probably from the window manager
1554
+
1555
+ if (filtered)
1556
+ return;
1557
+
1558
+ if (event->xclient.message_type == None)
1559
+ return;
1560
+
1561
+ if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)
1562
+ {
1563
+ const Atom protocol = event->xclient.data.l[0];
1564
+ if (protocol == None)
1565
+ return;
1566
+
1567
+ if (protocol == _glfw.x11.WM_DELETE_WINDOW)
1568
+ {
1569
+ // The window manager was asked to close the window, for
1570
+ // example by the user pressing a 'close' window decoration
1571
+ // button
1572
+ _glfwInputWindowCloseRequest(window);
1573
+ }
1574
+ else if (protocol == _glfw.x11.NET_WM_PING)
1575
+ {
1576
+ // The window manager is pinging the application to ensure
1577
+ // it's still responding to events
1578
+
1579
+ XEvent reply = *event;
1580
+ reply.xclient.window = _glfw.x11.root;
1581
+
1582
+ XSendEvent(_glfw.x11.display, _glfw.x11.root,
1583
+ False,
1584
+ SubstructureNotifyMask | SubstructureRedirectMask,
1585
+ &reply);
1586
+ }
1587
+ }
1588
+ else if (event->xclient.message_type == _glfw.x11.XdndEnter)
1589
+ {
1590
+ // A drag operation has entered the window
1591
+ unsigned long i, count;
1592
+ Atom* formats = NULL;
1593
+ const GLFWbool list = event->xclient.data.l[1] & 1;
1594
+
1595
+ _glfw.x11.xdnd.source = event->xclient.data.l[0];
1596
+ _glfw.x11.xdnd.version = event->xclient.data.l[1] >> 24;
1597
+ _glfw.x11.xdnd.format = None;
1598
+
1599
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1600
+ return;
1601
+
1602
+ if (list)
1603
+ {
1604
+ count = _glfwGetWindowPropertyX11(_glfw.x11.xdnd.source,
1605
+ _glfw.x11.XdndTypeList,
1606
+ XA_ATOM,
1607
+ (unsigned char**) &formats);
1608
+ }
1609
+ else
1610
+ {
1611
+ count = 3;
1612
+ formats = (Atom*) event->xclient.data.l + 2;
1613
+ }
1614
+
1615
+ for (i = 0; i < count; i++)
1616
+ {
1617
+ if (formats[i] == _glfw.x11.text_uri_list)
1618
+ {
1619
+ _glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
1620
+ break;
1621
+ }
1622
+ }
1623
+
1624
+ if (list && formats)
1625
+ XFree(formats);
1626
+ }
1627
+ else if (event->xclient.message_type == _glfw.x11.XdndDrop)
1628
+ {
1629
+ // The drag operation has finished by dropping on the window
1630
+ Time time = CurrentTime;
1631
+
1632
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1633
+ return;
1634
+
1635
+ if (_glfw.x11.xdnd.format)
1636
+ {
1637
+ if (_glfw.x11.xdnd.version >= 1)
1638
+ time = event->xclient.data.l[2];
1639
+
1640
+ // Request the chosen format from the source window
1641
+ XConvertSelection(_glfw.x11.display,
1642
+ _glfw.x11.XdndSelection,
1643
+ _glfw.x11.xdnd.format,
1644
+ _glfw.x11.XdndSelection,
1645
+ window->x11.handle,
1646
+ time);
1647
+ }
1648
+ else if (_glfw.x11.xdnd.version >= 2)
1649
+ {
1650
+ XEvent reply = { ClientMessage };
1651
+ reply.xclient.window = _glfw.x11.xdnd.source;
1652
+ reply.xclient.message_type = _glfw.x11.XdndFinished;
1653
+ reply.xclient.format = 32;
1654
+ reply.xclient.data.l[0] = window->x11.handle;
1655
+ reply.xclient.data.l[1] = 0; // The drag was rejected
1656
+ reply.xclient.data.l[2] = None;
1657
+
1658
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1659
+ False, NoEventMask, &reply);
1660
+ XFlush(_glfw.x11.display);
1661
+ }
1662
+ }
1663
+ else if (event->xclient.message_type == _glfw.x11.XdndPosition)
1664
+ {
1665
+ // The drag operation has moved over the window
1666
+ const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff;
1667
+ const int yabs = (event->xclient.data.l[2]) & 0xffff;
1668
+ Window dummy;
1669
+ int xpos, ypos;
1670
+
1671
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1672
+ return;
1673
+
1674
+ XTranslateCoordinates(_glfw.x11.display,
1675
+ _glfw.x11.root,
1676
+ window->x11.handle,
1677
+ xabs, yabs,
1678
+ &xpos, &ypos,
1679
+ &dummy);
1680
+
1681
+ _glfwInputCursorPos(window, xpos, ypos);
1682
+
1683
+ XEvent reply = { ClientMessage };
1684
+ reply.xclient.window = _glfw.x11.xdnd.source;
1685
+ reply.xclient.message_type = _glfw.x11.XdndStatus;
1686
+ reply.xclient.format = 32;
1687
+ reply.xclient.data.l[0] = window->x11.handle;
1688
+ reply.xclient.data.l[2] = 0; // Specify an empty rectangle
1689
+ reply.xclient.data.l[3] = 0;
1690
+
1691
+ if (_glfw.x11.xdnd.format)
1692
+ {
1693
+ // Reply that we are ready to copy the dragged data
1694
+ reply.xclient.data.l[1] = 1; // Accept with no rectangle
1695
+ if (_glfw.x11.xdnd.version >= 2)
1696
+ reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;
1697
+ }
1698
+
1699
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1700
+ False, NoEventMask, &reply);
1701
+ XFlush(_glfw.x11.display);
1702
+ }
1703
+
1704
+ return;
1705
+ }
1706
+
1707
+ case SelectionNotify:
1708
+ {
1709
+ if (event->xselection.property == _glfw.x11.XdndSelection)
1710
+ {
1711
+ // The converted data from the drag operation has arrived
1712
+ char* data;
1713
+ const unsigned long result =
1714
+ _glfwGetWindowPropertyX11(event->xselection.requestor,
1715
+ event->xselection.property,
1716
+ event->xselection.target,
1717
+ (unsigned char**) &data);
1718
+
1719
+ if (result)
1720
+ {
1721
+ int i, count;
1722
+ char** paths = parseUriList(data, &count);
1723
+
1724
+ _glfwInputDrop(window, count, (const char**) paths);
1725
+
1726
+ for (i = 0; i < count; i++)
1727
+ free(paths[i]);
1728
+ free(paths);
1729
+ }
1730
+
1731
+ if (data)
1732
+ XFree(data);
1733
+
1734
+ if (_glfw.x11.xdnd.version >= 2)
1735
+ {
1736
+ XEvent reply = { ClientMessage };
1737
+ reply.xclient.window = _glfw.x11.xdnd.source;
1738
+ reply.xclient.message_type = _glfw.x11.XdndFinished;
1739
+ reply.xclient.format = 32;
1740
+ reply.xclient.data.l[0] = window->x11.handle;
1741
+ reply.xclient.data.l[1] = result;
1742
+ reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;
1743
+
1744
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1745
+ False, NoEventMask, &reply);
1746
+ XFlush(_glfw.x11.display);
1747
+ }
1748
+ }
1749
+
1750
+ return;
1751
+ }
1752
+
1753
+ case FocusIn:
1754
+ {
1755
+ if (event->xfocus.mode == NotifyGrab ||
1756
+ event->xfocus.mode == NotifyUngrab)
1757
+ {
1758
+ // Ignore focus events from popup indicator windows, window menu
1759
+ // key chords and window dragging
1760
+ return;
1761
+ }
1762
+
1763
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
1764
+ disableCursor(window);
1765
+
1766
+ if (window->x11.ic)
1767
+ XSetICFocus(window->x11.ic);
1768
+
1769
+ _glfwInputWindowFocus(window, GLFW_TRUE);
1770
+ return;
1771
+ }
1772
+
1773
+ case FocusOut:
1774
+ {
1775
+ if (event->xfocus.mode == NotifyGrab ||
1776
+ event->xfocus.mode == NotifyUngrab)
1777
+ {
1778
+ // Ignore focus events from popup indicator windows, window menu
1779
+ // key chords and window dragging
1780
+ return;
1781
+ }
1782
+
1783
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
1784
+ enableCursor(window);
1785
+
1786
+ if (window->x11.ic)
1787
+ XUnsetICFocus(window->x11.ic);
1788
+
1789
+ if (window->monitor && window->autoIconify)
1790
+ _glfwPlatformIconifyWindow(window);
1791
+
1792
+ _glfwInputWindowFocus(window, GLFW_FALSE);
1793
+ return;
1794
+ }
1795
+
1796
+ case Expose:
1797
+ {
1798
+ _glfwInputWindowDamage(window);
1799
+ return;
1800
+ }
1801
+
1802
+ case PropertyNotify:
1803
+ {
1804
+ if (event->xproperty.state != PropertyNewValue)
1805
+ return;
1806
+
1807
+ if (event->xproperty.atom == _glfw.x11.WM_STATE)
1808
+ {
1809
+ const int state = getWindowState(window);
1810
+ if (state != IconicState && state != NormalState)
1811
+ return;
1812
+
1813
+ const GLFWbool iconified = (state == IconicState);
1814
+ if (window->x11.iconified != iconified)
1815
+ {
1816
+ if (window->monitor)
1817
+ {
1818
+ if (iconified)
1819
+ releaseMonitor(window);
1820
+ else
1821
+ acquireMonitor(window);
1822
+ }
1823
+
1824
+ window->x11.iconified = iconified;
1825
+ _glfwInputWindowIconify(window, iconified);
1826
+ }
1827
+ }
1828
+ else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
1829
+ {
1830
+ const GLFWbool maximized = _glfwPlatformWindowMaximized(window);
1831
+ if (window->x11.maximized != maximized)
1832
+ {
1833
+ window->x11.maximized = maximized;
1834
+ _glfwInputWindowMaximize(window, maximized);
1835
+ }
1836
+ }
1837
+
1838
+ return;
1839
+ }
1840
+
1841
+ case DestroyNotify:
1842
+ return;
1843
+ }
1844
+ }
1845
+
1846
+
1847
+ //////////////////////////////////////////////////////////////////////////
1848
+ ////// GLFW internal API //////
1849
+ //////////////////////////////////////////////////////////////////////////
1850
+
1851
+ // Retrieve a single window property of the specified type
1852
+ // Inspired by fghGetWindowProperty from freeglut
1853
+ //
1854
+ unsigned long _glfwGetWindowPropertyX11(Window window,
1855
+ Atom property,
1856
+ Atom type,
1857
+ unsigned char** value)
1858
+ {
1859
+ Atom actualType;
1860
+ int actualFormat;
1861
+ unsigned long itemCount, bytesAfter;
1862
+
1863
+ XGetWindowProperty(_glfw.x11.display,
1864
+ window,
1865
+ property,
1866
+ 0,
1867
+ LONG_MAX,
1868
+ False,
1869
+ type,
1870
+ &actualType,
1871
+ &actualFormat,
1872
+ &itemCount,
1873
+ &bytesAfter,
1874
+ value);
1875
+
1876
+ return itemCount;
1877
+ }
1878
+
1879
+ GLFWbool _glfwIsVisualTransparentX11(Visual* visual)
1880
+ {
1881
+ if (!_glfw.x11.xrender.available)
1882
+ return GLFW_FALSE;
1883
+
1884
+ XRenderPictFormat* pf = XRenderFindVisualFormat(_glfw.x11.display, visual);
1885
+ return pf && pf->direct.alphaMask;
1886
+ }
1887
+
1888
+ // Push contents of our selection to clipboard manager
1889
+ //
1890
+ void _glfwPushSelectionToManagerX11(void)
1891
+ {
1892
+ XConvertSelection(_glfw.x11.display,
1893
+ _glfw.x11.CLIPBOARD_MANAGER,
1894
+ _glfw.x11.SAVE_TARGETS,
1895
+ None,
1896
+ _glfw.x11.helperWindowHandle,
1897
+ CurrentTime);
1898
+
1899
+ for (;;)
1900
+ {
1901
+ XEvent event;
1902
+
1903
+ while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
1904
+ {
1905
+ switch (event.type)
1906
+ {
1907
+ case SelectionRequest:
1908
+ handleSelectionRequest(&event);
1909
+ break;
1910
+
1911
+ case SelectionClear:
1912
+ handleSelectionClear(&event);
1913
+ break;
1914
+
1915
+ case SelectionNotify:
1916
+ {
1917
+ if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
1918
+ {
1919
+ // This means one of two things; either the selection
1920
+ // was not owned, which means there is no clipboard
1921
+ // manager, or the transfer to the clipboard manager has
1922
+ // completed
1923
+ // In either case, it means we are done here
1924
+ return;
1925
+ }
1926
+
1927
+ break;
1928
+ }
1929
+ }
1930
+ }
1931
+
1932
+ waitForEvent(NULL);
1933
+ }
1934
+ }
1935
+
1936
+ void _glfwCreateInputContextX11(_GLFWwindow* window)
1937
+ {
1938
+ XIMCallback callback;
1939
+ callback.callback = (XIMProc) inputContextDestroyCallback;
1940
+ callback.client_data = (XPointer) window;
1941
+
1942
+ window->x11.ic = XCreateIC(_glfw.x11.im,
1943
+ XNInputStyle,
1944
+ XIMPreeditNothing | XIMStatusNothing,
1945
+ XNClientWindow,
1946
+ window->x11.handle,
1947
+ XNFocusWindow,
1948
+ window->x11.handle,
1949
+ XNDestroyCallback,
1950
+ &callback,
1951
+ NULL);
1952
+
1953
+ if (window->x11.ic)
1954
+ {
1955
+ XWindowAttributes attribs;
1956
+ XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
1957
+
1958
+ unsigned long filter = 0;
1959
+ if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL)
1960
+ {
1961
+ XSelectInput(_glfw.x11.display,
1962
+ window->x11.handle,
1963
+ attribs.your_event_mask | filter);
1964
+ }
1965
+ }
1966
+ }
1967
+
1968
+
1969
+ //////////////////////////////////////////////////////////////////////////
1970
+ ////// GLFW platform API //////
1971
+ //////////////////////////////////////////////////////////////////////////
1972
+
1973
+ int _glfwPlatformCreateWindow(_GLFWwindow* window,
1974
+ const _GLFWwndconfig* wndconfig,
1975
+ const _GLFWctxconfig* ctxconfig,
1976
+ const _GLFWfbconfig* fbconfig)
1977
+ {
1978
+ Visual* visual = NULL;
1979
+ int depth;
1980
+
1981
+ if (ctxconfig->client != GLFW_NO_API)
1982
+ {
1983
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
1984
+ {
1985
+ if (!_glfwInitGLX())
1986
+ return GLFW_FALSE;
1987
+ if (!_glfwChooseVisualGLX(wndconfig, ctxconfig, fbconfig, &visual, &depth))
1988
+ return GLFW_FALSE;
1989
+ }
1990
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
1991
+ {
1992
+ if (!_glfwInitEGL())
1993
+ return GLFW_FALSE;
1994
+ if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth))
1995
+ return GLFW_FALSE;
1996
+ }
1997
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
1998
+ {
1999
+ if (!_glfwInitOSMesa())
2000
+ return GLFW_FALSE;
2001
+ }
2002
+ }
2003
+
2004
+ if (!visual)
2005
+ {
2006
+ visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
2007
+ depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
2008
+ }
2009
+
2010
+ if (!createNativeWindow(window, wndconfig, visual, depth))
2011
+ return GLFW_FALSE;
2012
+
2013
+ if (ctxconfig->client != GLFW_NO_API)
2014
+ {
2015
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
2016
+ {
2017
+ if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
2018
+ return GLFW_FALSE;
2019
+ }
2020
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
2021
+ {
2022
+ if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
2023
+ return GLFW_FALSE;
2024
+ }
2025
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
2026
+ {
2027
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
2028
+ return GLFW_FALSE;
2029
+ }
2030
+ }
2031
+
2032
+ if (window->monitor)
2033
+ {
2034
+ _glfwPlatformShowWindow(window);
2035
+ updateWindowMode(window);
2036
+ acquireMonitor(window);
2037
+ }
2038
+
2039
+ XFlush(_glfw.x11.display);
2040
+ return GLFW_TRUE;
2041
+ }
2042
+
2043
+ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
2044
+ {
2045
+ if (_glfw.x11.disabledCursorWindow == window)
2046
+ _glfw.x11.disabledCursorWindow = NULL;
2047
+
2048
+ if (window->monitor)
2049
+ releaseMonitor(window);
2050
+
2051
+ if (window->x11.ic)
2052
+ {
2053
+ XDestroyIC(window->x11.ic);
2054
+ window->x11.ic = NULL;
2055
+ }
2056
+
2057
+ if (window->context.destroy)
2058
+ window->context.destroy(window);
2059
+
2060
+ if (window->x11.handle)
2061
+ {
2062
+ XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
2063
+ XUnmapWindow(_glfw.x11.display, window->x11.handle);
2064
+ XDestroyWindow(_glfw.x11.display, window->x11.handle);
2065
+ window->x11.handle = (Window) 0;
2066
+ }
2067
+
2068
+ if (window->x11.colormap)
2069
+ {
2070
+ XFreeColormap(_glfw.x11.display, window->x11.colormap);
2071
+ window->x11.colormap = (Colormap) 0;
2072
+ }
2073
+
2074
+ XFlush(_glfw.x11.display);
2075
+ }
2076
+
2077
+ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
2078
+ {
2079
+ if (_glfw.x11.xlib.utf8)
2080
+ {
2081
+ Xutf8SetWMProperties(_glfw.x11.display,
2082
+ window->x11.handle,
2083
+ title, title,
2084
+ NULL, 0,
2085
+ NULL, NULL, NULL);
2086
+ }
2087
+
2088
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2089
+ _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
2090
+ PropModeReplace,
2091
+ (unsigned char*) title, strlen(title));
2092
+
2093
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2094
+ _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
2095
+ PropModeReplace,
2096
+ (unsigned char*) title, strlen(title));
2097
+
2098
+ XFlush(_glfw.x11.display);
2099
+ }
2100
+
2101
+ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
2102
+ int count, const GLFWimage* images)
2103
+ {
2104
+ if (count)
2105
+ {
2106
+ int i, j, longCount = 0;
2107
+
2108
+ for (i = 0; i < count; i++)
2109
+ longCount += 2 + images[i].width * images[i].height;
2110
+
2111
+ long* icon = calloc(longCount, sizeof(long));
2112
+ long* target = icon;
2113
+
2114
+ for (i = 0; i < count; i++)
2115
+ {
2116
+ *target++ = images[i].width;
2117
+ *target++ = images[i].height;
2118
+
2119
+ for (j = 0; j < images[i].width * images[i].height; j++)
2120
+ {
2121
+ *target++ = (images[i].pixels[j * 4 + 0] << 16) |
2122
+ (images[i].pixels[j * 4 + 1] << 8) |
2123
+ (images[i].pixels[j * 4 + 2] << 0) |
2124
+ (images[i].pixels[j * 4 + 3] << 24);
2125
+ }
2126
+ }
2127
+
2128
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2129
+ _glfw.x11.NET_WM_ICON,
2130
+ XA_CARDINAL, 32,
2131
+ PropModeReplace,
2132
+ (unsigned char*) icon,
2133
+ longCount);
2134
+
2135
+ free(icon);
2136
+ }
2137
+ else
2138
+ {
2139
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
2140
+ _glfw.x11.NET_WM_ICON);
2141
+ }
2142
+
2143
+ XFlush(_glfw.x11.display);
2144
+ }
2145
+
2146
+ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
2147
+ {
2148
+ Window dummy;
2149
+ int x, y;
2150
+
2151
+ XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
2152
+ 0, 0, &x, &y, &dummy);
2153
+
2154
+ if (xpos)
2155
+ *xpos = x;
2156
+ if (ypos)
2157
+ *ypos = y;
2158
+ }
2159
+
2160
+ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
2161
+ {
2162
+ // HACK: Explicitly setting PPosition to any value causes some WMs, notably
2163
+ // Compiz and Metacity, to honor the position of unmapped windows
2164
+ if (!_glfwPlatformWindowVisible(window))
2165
+ {
2166
+ long supplied;
2167
+ XSizeHints* hints = XAllocSizeHints();
2168
+
2169
+ if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied))
2170
+ {
2171
+ hints->flags |= PPosition;
2172
+ hints->x = hints->y = 0;
2173
+
2174
+ XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
2175
+ }
2176
+
2177
+ XFree(hints);
2178
+ }
2179
+
2180
+ XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
2181
+ XFlush(_glfw.x11.display);
2182
+ }
2183
+
2184
+ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
2185
+ {
2186
+ XWindowAttributes attribs;
2187
+ XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
2188
+
2189
+ if (width)
2190
+ *width = attribs.width;
2191
+ if (height)
2192
+ *height = attribs.height;
2193
+ }
2194
+
2195
+ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
2196
+ {
2197
+ if (window->monitor)
2198
+ {
2199
+ if (window->monitor->window == window)
2200
+ acquireMonitor(window);
2201
+ }
2202
+ else
2203
+ {
2204
+ if (!window->resizable)
2205
+ updateNormalHints(window, width, height);
2206
+
2207
+ XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
2208
+ }
2209
+
2210
+ XFlush(_glfw.x11.display);
2211
+ }
2212
+
2213
+ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
2214
+ int minwidth, int minheight,
2215
+ int maxwidth, int maxheight)
2216
+ {
2217
+ int width, height;
2218
+ _glfwPlatformGetWindowSize(window, &width, &height);
2219
+ updateNormalHints(window, width, height);
2220
+ XFlush(_glfw.x11.display);
2221
+ }
2222
+
2223
+ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
2224
+ {
2225
+ int width, height;
2226
+ _glfwPlatformGetWindowSize(window, &width, &height);
2227
+ updateNormalHints(window, width, height);
2228
+ XFlush(_glfw.x11.display);
2229
+ }
2230
+
2231
+ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
2232
+ {
2233
+ _glfwPlatformGetWindowSize(window, width, height);
2234
+ }
2235
+
2236
+ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
2237
+ int* left, int* top,
2238
+ int* right, int* bottom)
2239
+ {
2240
+ long* extents = NULL;
2241
+
2242
+ if (window->monitor || !window->decorated)
2243
+ return;
2244
+
2245
+ if (_glfw.x11.NET_FRAME_EXTENTS == None)
2246
+ return;
2247
+
2248
+ if (!_glfwPlatformWindowVisible(window) &&
2249
+ _glfw.x11.NET_REQUEST_FRAME_EXTENTS)
2250
+ {
2251
+ XEvent event;
2252
+ double timeout = 0.5;
2253
+
2254
+ // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
2255
+ // function before the window is mapped
2256
+ sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
2257
+ 0, 0, 0, 0, 0);
2258
+
2259
+ // HACK: Use a timeout because earlier versions of some window managers
2260
+ // (at least Unity, Fluxbox and Xfwm) failed to send the reply
2261
+ // They have been fixed but broken versions are still in the wild
2262
+ // If you are affected by this and your window manager is NOT
2263
+ // listed above, PLEASE report it to their and our issue trackers
2264
+ while (!XCheckIfEvent(_glfw.x11.display,
2265
+ &event,
2266
+ isFrameExtentsEvent,
2267
+ (XPointer) window))
2268
+ {
2269
+ if (!waitForEvent(&timeout))
2270
+ {
2271
+ _glfwInputError(GLFW_PLATFORM_ERROR,
2272
+ "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
2273
+ return;
2274
+ }
2275
+ }
2276
+ }
2277
+
2278
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
2279
+ _glfw.x11.NET_FRAME_EXTENTS,
2280
+ XA_CARDINAL,
2281
+ (unsigned char**) &extents) == 4)
2282
+ {
2283
+ if (left)
2284
+ *left = extents[0];
2285
+ if (top)
2286
+ *top = extents[2];
2287
+ if (right)
2288
+ *right = extents[1];
2289
+ if (bottom)
2290
+ *bottom = extents[3];
2291
+ }
2292
+
2293
+ if (extents)
2294
+ XFree(extents);
2295
+ }
2296
+
2297
+ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
2298
+ float* xscale, float* yscale)
2299
+ {
2300
+ if (xscale)
2301
+ *xscale = _glfw.x11.contentScaleX;
2302
+ if (yscale)
2303
+ *yscale = _glfw.x11.contentScaleY;
2304
+ }
2305
+
2306
+ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
2307
+ {
2308
+ if (window->x11.overrideRedirect)
2309
+ {
2310
+ // Override-redirect windows cannot be iconified or restored, as those
2311
+ // tasks are performed by the window manager
2312
+ _glfwInputError(GLFW_PLATFORM_ERROR,
2313
+ "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
2314
+ return;
2315
+ }
2316
+
2317
+ XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
2318
+ XFlush(_glfw.x11.display);
2319
+ }
2320
+
2321
+ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
2322
+ {
2323
+ if (window->x11.overrideRedirect)
2324
+ {
2325
+ // Override-redirect windows cannot be iconified or restored, as those
2326
+ // tasks are performed by the window manager
2327
+ _glfwInputError(GLFW_PLATFORM_ERROR,
2328
+ "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
2329
+ return;
2330
+ }
2331
+
2332
+ if (_glfwPlatformWindowIconified(window))
2333
+ {
2334
+ XMapWindow(_glfw.x11.display, window->x11.handle);
2335
+ waitForVisibilityNotify(window);
2336
+ }
2337
+ else if (_glfwPlatformWindowVisible(window))
2338
+ {
2339
+ if (_glfw.x11.NET_WM_STATE &&
2340
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
2341
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2342
+ {
2343
+ sendEventToWM(window,
2344
+ _glfw.x11.NET_WM_STATE,
2345
+ _NET_WM_STATE_REMOVE,
2346
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2347
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
2348
+ 1, 0);
2349
+ }
2350
+ }
2351
+
2352
+ XFlush(_glfw.x11.display);
2353
+ }
2354
+
2355
+ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
2356
+ {
2357
+ if (!_glfw.x11.NET_WM_STATE ||
2358
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2359
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2360
+ {
2361
+ return;
2362
+ }
2363
+
2364
+ if (_glfwPlatformWindowVisible(window))
2365
+ {
2366
+ sendEventToWM(window,
2367
+ _glfw.x11.NET_WM_STATE,
2368
+ _NET_WM_STATE_ADD,
2369
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2370
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
2371
+ 1, 0);
2372
+ }
2373
+ else
2374
+ {
2375
+ Atom* states = NULL;
2376
+ unsigned long count =
2377
+ _glfwGetWindowPropertyX11(window->x11.handle,
2378
+ _glfw.x11.NET_WM_STATE,
2379
+ XA_ATOM,
2380
+ (unsigned char**) &states);
2381
+
2382
+ // NOTE: We don't check for failure as this property may not exist yet
2383
+ // and that's fine (and we'll create it implicitly with append)
2384
+
2385
+ Atom missing[2] =
2386
+ {
2387
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2388
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
2389
+ };
2390
+ unsigned long missingCount = 2;
2391
+
2392
+ for (unsigned long i = 0; i < count; i++)
2393
+ {
2394
+ for (unsigned long j = 0; j < missingCount; j++)
2395
+ {
2396
+ if (states[i] == missing[j])
2397
+ {
2398
+ missing[j] = missing[missingCount - 1];
2399
+ missingCount--;
2400
+ }
2401
+ }
2402
+ }
2403
+
2404
+ if (states)
2405
+ XFree(states);
2406
+
2407
+ if (!missingCount)
2408
+ return;
2409
+
2410
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2411
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2412
+ PropModeAppend,
2413
+ (unsigned char*) missing,
2414
+ missingCount);
2415
+ }
2416
+
2417
+ XFlush(_glfw.x11.display);
2418
+ }
2419
+
2420
+ void _glfwPlatformShowWindow(_GLFWwindow* window)
2421
+ {
2422
+ if (_glfwPlatformWindowVisible(window))
2423
+ return;
2424
+
2425
+ XMapWindow(_glfw.x11.display, window->x11.handle);
2426
+ waitForVisibilityNotify(window);
2427
+ }
2428
+
2429
+ void _glfwPlatformHideWindow(_GLFWwindow* window)
2430
+ {
2431
+ XUnmapWindow(_glfw.x11.display, window->x11.handle);
2432
+ XFlush(_glfw.x11.display);
2433
+ }
2434
+
2435
+ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
2436
+ {
2437
+ if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION)
2438
+ return;
2439
+
2440
+ sendEventToWM(window,
2441
+ _glfw.x11.NET_WM_STATE,
2442
+ _NET_WM_STATE_ADD,
2443
+ _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION,
2444
+ 0, 1, 0);
2445
+ }
2446
+
2447
+ void _glfwPlatformFocusWindow(_GLFWwindow* window)
2448
+ {
2449
+ if (_glfw.x11.NET_ACTIVE_WINDOW)
2450
+ sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);
2451
+ else if (_glfwPlatformWindowVisible(window))
2452
+ {
2453
+ XRaiseWindow(_glfw.x11.display, window->x11.handle);
2454
+ XSetInputFocus(_glfw.x11.display, window->x11.handle,
2455
+ RevertToParent, CurrentTime);
2456
+ }
2457
+
2458
+ XFlush(_glfw.x11.display);
2459
+ }
2460
+
2461
+ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
2462
+ _GLFWmonitor* monitor,
2463
+ int xpos, int ypos,
2464
+ int width, int height,
2465
+ int refreshRate)
2466
+ {
2467
+ if (window->monitor == monitor)
2468
+ {
2469
+ if (monitor)
2470
+ {
2471
+ if (monitor->window == window)
2472
+ acquireMonitor(window);
2473
+ }
2474
+ else
2475
+ {
2476
+ if (!window->resizable)
2477
+ updateNormalHints(window, width, height);
2478
+
2479
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
2480
+ xpos, ypos, width, height);
2481
+ }
2482
+
2483
+ XFlush(_glfw.x11.display);
2484
+ return;
2485
+ }
2486
+
2487
+ if (window->monitor)
2488
+ {
2489
+ _glfwPlatformSetWindowDecorated(window, window->decorated);
2490
+ _glfwPlatformSetWindowFloating(window, window->floating);
2491
+ releaseMonitor(window);
2492
+ }
2493
+
2494
+ _glfwInputWindowMonitor(window, monitor);
2495
+ updateNormalHints(window, width, height);
2496
+
2497
+ if (window->monitor)
2498
+ {
2499
+ if (!_glfwPlatformWindowVisible(window))
2500
+ {
2501
+ XMapRaised(_glfw.x11.display, window->x11.handle);
2502
+ waitForVisibilityNotify(window);
2503
+ }
2504
+
2505
+ updateWindowMode(window);
2506
+ acquireMonitor(window);
2507
+ }
2508
+ else
2509
+ {
2510
+ updateWindowMode(window);
2511
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
2512
+ xpos, ypos, width, height);
2513
+ }
2514
+
2515
+ XFlush(_glfw.x11.display);
2516
+ }
2517
+
2518
+ int _glfwPlatformWindowFocused(_GLFWwindow* window)
2519
+ {
2520
+ Window focused;
2521
+ int state;
2522
+
2523
+ XGetInputFocus(_glfw.x11.display, &focused, &state);
2524
+ return window->x11.handle == focused;
2525
+ }
2526
+
2527
+ int _glfwPlatformWindowIconified(_GLFWwindow* window)
2528
+ {
2529
+ return getWindowState(window) == IconicState;
2530
+ }
2531
+
2532
+ int _glfwPlatformWindowVisible(_GLFWwindow* window)
2533
+ {
2534
+ XWindowAttributes wa;
2535
+ XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
2536
+ return wa.map_state == IsViewable;
2537
+ }
2538
+
2539
+ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
2540
+ {
2541
+ Atom* states;
2542
+ unsigned long i;
2543
+ GLFWbool maximized = GLFW_FALSE;
2544
+
2545
+ if (!_glfw.x11.NET_WM_STATE ||
2546
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2547
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2548
+ {
2549
+ return maximized;
2550
+ }
2551
+
2552
+ const unsigned long count =
2553
+ _glfwGetWindowPropertyX11(window->x11.handle,
2554
+ _glfw.x11.NET_WM_STATE,
2555
+ XA_ATOM,
2556
+ (unsigned char**) &states);
2557
+
2558
+ for (i = 0; i < count; i++)
2559
+ {
2560
+ if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2561
+ states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2562
+ {
2563
+ maximized = GLFW_TRUE;
2564
+ break;
2565
+ }
2566
+ }
2567
+
2568
+ if (states)
2569
+ XFree(states);
2570
+
2571
+ return maximized;
2572
+ }
2573
+
2574
+ int _glfwPlatformWindowHovered(_GLFWwindow* window)
2575
+ {
2576
+ Window w = _glfw.x11.root;
2577
+ while (w)
2578
+ {
2579
+ Window root;
2580
+ int rootX, rootY, childX, childY;
2581
+ unsigned int mask;
2582
+
2583
+ _glfwGrabErrorHandlerX11();
2584
+
2585
+ const Bool result = XQueryPointer(_glfw.x11.display, w,
2586
+ &root, &w, &rootX, &rootY,
2587
+ &childX, &childY, &mask);
2588
+
2589
+ _glfwReleaseErrorHandlerX11();
2590
+
2591
+ if (_glfw.x11.errorCode == BadWindow)
2592
+ w = _glfw.x11.root;
2593
+ else if (!result)
2594
+ return GLFW_FALSE;
2595
+ else if (w == window->x11.handle)
2596
+ return GLFW_TRUE;
2597
+ }
2598
+
2599
+ return GLFW_FALSE;
2600
+ }
2601
+
2602
+ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
2603
+ {
2604
+ if (!window->x11.transparent)
2605
+ return GLFW_FALSE;
2606
+
2607
+ return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None;
2608
+ }
2609
+
2610
+ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
2611
+ {
2612
+ int width, height;
2613
+ _glfwPlatformGetWindowSize(window, &width, &height);
2614
+ updateNormalHints(window, width, height);
2615
+ }
2616
+
2617
+ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
2618
+ {
2619
+ struct
2620
+ {
2621
+ unsigned long flags;
2622
+ unsigned long functions;
2623
+ unsigned long decorations;
2624
+ long input_mode;
2625
+ unsigned long status;
2626
+ } hints = {0};
2627
+
2628
+ hints.flags = MWM_HINTS_DECORATIONS;
2629
+ hints.decorations = enabled ? MWM_DECOR_ALL : 0;
2630
+
2631
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2632
+ _glfw.x11.MOTIF_WM_HINTS,
2633
+ _glfw.x11.MOTIF_WM_HINTS, 32,
2634
+ PropModeReplace,
2635
+ (unsigned char*) &hints,
2636
+ sizeof(hints) / sizeof(long));
2637
+ }
2638
+
2639
+ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
2640
+ {
2641
+ if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE)
2642
+ return;
2643
+
2644
+ if (_glfwPlatformWindowVisible(window))
2645
+ {
2646
+ const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
2647
+ sendEventToWM(window,
2648
+ _glfw.x11.NET_WM_STATE,
2649
+ action,
2650
+ _glfw.x11.NET_WM_STATE_ABOVE,
2651
+ 0, 1, 0);
2652
+ }
2653
+ else
2654
+ {
2655
+ Atom* states = NULL;
2656
+ unsigned long i, count;
2657
+
2658
+ count = _glfwGetWindowPropertyX11(window->x11.handle,
2659
+ _glfw.x11.NET_WM_STATE,
2660
+ XA_ATOM,
2661
+ (unsigned char**) &states);
2662
+
2663
+ // NOTE: We don't check for failure as this property may not exist yet
2664
+ // and that's fine (and we'll create it implicitly with append)
2665
+
2666
+ if (enabled)
2667
+ {
2668
+ for (i = 0; i < count; i++)
2669
+ {
2670
+ if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
2671
+ break;
2672
+ }
2673
+
2674
+ if (i < count)
2675
+ return;
2676
+
2677
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2678
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2679
+ PropModeAppend,
2680
+ (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
2681
+ 1);
2682
+ }
2683
+ else if (states)
2684
+ {
2685
+ for (i = 0; i < count; i++)
2686
+ {
2687
+ if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
2688
+ break;
2689
+ }
2690
+
2691
+ if (i == count)
2692
+ return;
2693
+
2694
+ states[i] = states[count - 1];
2695
+ count--;
2696
+
2697
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2698
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2699
+ PropModeReplace, (unsigned char*) states, count);
2700
+ }
2701
+
2702
+ if (states)
2703
+ XFree(states);
2704
+ }
2705
+
2706
+ XFlush(_glfw.x11.display);
2707
+ }
2708
+
2709
+ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
2710
+ {
2711
+ if (!_glfw.x11.xshape.available)
2712
+ return;
2713
+
2714
+ if (enabled)
2715
+ {
2716
+ Region region = XCreateRegion();
2717
+ XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
2718
+ ShapeInput, 0, 0, region, ShapeSet);
2719
+ XDestroyRegion(region);
2720
+ }
2721
+ else
2722
+ {
2723
+ XShapeCombineMask(_glfw.x11.display, window->x11.handle,
2724
+ ShapeInput, 0, 0, None, ShapeSet);
2725
+ }
2726
+ }
2727
+
2728
+ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
2729
+ {
2730
+ float opacity = 1.f;
2731
+
2732
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx))
2733
+ {
2734
+ CARD32* value = NULL;
2735
+
2736
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
2737
+ _glfw.x11.NET_WM_WINDOW_OPACITY,
2738
+ XA_CARDINAL,
2739
+ (unsigned char**) &value))
2740
+ {
2741
+ opacity = (float) (*value / (double) 0xffffffffu);
2742
+ }
2743
+
2744
+ if (value)
2745
+ XFree(value);
2746
+ }
2747
+
2748
+ return opacity;
2749
+ }
2750
+
2751
+ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
2752
+ {
2753
+ const CARD32 value = (CARD32) (0xffffffffu * (double) opacity);
2754
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
2755
+ _glfw.x11.NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
2756
+ PropModeReplace, (unsigned char*) &value, 1);
2757
+ }
2758
+
2759
+ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
2760
+ {
2761
+ if (!_glfw.x11.xi.available)
2762
+ return;
2763
+
2764
+ if (_glfw.x11.disabledCursorWindow != window)
2765
+ return;
2766
+
2767
+ if (enabled)
2768
+ enableRawMouseMotion(window);
2769
+ else
2770
+ disableRawMouseMotion(window);
2771
+ }
2772
+
2773
+ GLFWbool _glfwPlatformRawMouseMotionSupported(void)
2774
+ {
2775
+ return _glfw.x11.xi.available;
2776
+ }
2777
+
2778
+ void _glfwPlatformPollEvents(void)
2779
+ {
2780
+ _GLFWwindow* window;
2781
+
2782
+ #if defined(__linux__)
2783
+ if (_glfw.joysticksInitialized)
2784
+ _glfwDetectJoystickConnectionLinux();
2785
+ #endif
2786
+ XPending(_glfw.x11.display);
2787
+
2788
+ while (QLength(_glfw.x11.display))
2789
+ {
2790
+ XEvent event;
2791
+ XNextEvent(_glfw.x11.display, &event);
2792
+ processEvent(&event);
2793
+ }
2794
+
2795
+ window = _glfw.x11.disabledCursorWindow;
2796
+ if (window)
2797
+ {
2798
+ int width, height;
2799
+ _glfwPlatformGetWindowSize(window, &width, &height);
2800
+
2801
+ // NOTE: Re-center the cursor only if it has moved since the last call,
2802
+ // to avoid breaking glfwWaitEvents with MotionNotify
2803
+ if (window->x11.lastCursorPosX != width / 2 ||
2804
+ window->x11.lastCursorPosY != height / 2)
2805
+ {
2806
+ _glfwPlatformSetCursorPos(window, width / 2, height / 2);
2807
+ }
2808
+ }
2809
+
2810
+ XFlush(_glfw.x11.display);
2811
+ }
2812
+
2813
+ void _glfwPlatformWaitEvents(void)
2814
+ {
2815
+ while (!XPending(_glfw.x11.display))
2816
+ waitForEvent(NULL);
2817
+
2818
+ _glfwPlatformPollEvents();
2819
+ }
2820
+
2821
+ void _glfwPlatformWaitEventsTimeout(double timeout)
2822
+ {
2823
+ while (!XPending(_glfw.x11.display))
2824
+ {
2825
+ if (!waitForEvent(&timeout))
2826
+ break;
2827
+ }
2828
+
2829
+ _glfwPlatformPollEvents();
2830
+ }
2831
+
2832
+ void _glfwPlatformPostEmptyEvent(void)
2833
+ {
2834
+ XEvent event = { ClientMessage };
2835
+ event.xclient.window = _glfw.x11.helperWindowHandle;
2836
+ event.xclient.format = 32; // Data is 32-bit longs
2837
+ event.xclient.message_type = _glfw.x11.NULL_;
2838
+
2839
+ XSendEvent(_glfw.x11.display, _glfw.x11.helperWindowHandle, False, 0, &event);
2840
+ XFlush(_glfw.x11.display);
2841
+ }
2842
+
2843
+ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
2844
+ {
2845
+ Window root, child;
2846
+ int rootX, rootY, childX, childY;
2847
+ unsigned int mask;
2848
+
2849
+ XQueryPointer(_glfw.x11.display, window->x11.handle,
2850
+ &root, &child,
2851
+ &rootX, &rootY, &childX, &childY,
2852
+ &mask);
2853
+
2854
+ if (xpos)
2855
+ *xpos = childX;
2856
+ if (ypos)
2857
+ *ypos = childY;
2858
+ }
2859
+
2860
+ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
2861
+ {
2862
+ // Store the new position so it can be recognized later
2863
+ window->x11.warpCursorPosX = (int) x;
2864
+ window->x11.warpCursorPosY = (int) y;
2865
+
2866
+ XWarpPointer(_glfw.x11.display, None, window->x11.handle,
2867
+ 0,0,0,0, (int) x, (int) y);
2868
+ XFlush(_glfw.x11.display);
2869
+ }
2870
+
2871
+ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
2872
+ {
2873
+ if (mode == GLFW_CURSOR_DISABLED)
2874
+ {
2875
+ if (_glfwPlatformWindowFocused(window))
2876
+ disableCursor(window);
2877
+ }
2878
+ else if (_glfw.x11.disabledCursorWindow == window)
2879
+ enableCursor(window);
2880
+ else
2881
+ updateCursorImage(window);
2882
+
2883
+ XFlush(_glfw.x11.display);
2884
+ }
2885
+
2886
+ const char* _glfwPlatformGetScancodeName(int scancode)
2887
+ {
2888
+ if (!_glfw.x11.xkb.available)
2889
+ return NULL;
2890
+
2891
+ if (scancode < 0 || scancode > 0xff ||
2892
+ _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
2893
+ {
2894
+ _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
2895
+ return NULL;
2896
+ }
2897
+
2898
+ const int key = _glfw.x11.keycodes[scancode];
2899
+ const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
2900
+ scancode, _glfw.x11.xkb.group, 0);
2901
+ if (keysym == NoSymbol)
2902
+ return NULL;
2903
+
2904
+ const long ch = _glfwKeySym2Unicode(keysym);
2905
+ if (ch == -1)
2906
+ return NULL;
2907
+
2908
+ const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch);
2909
+ if (count == 0)
2910
+ return NULL;
2911
+
2912
+ _glfw.x11.keynames[key][count] = '\0';
2913
+ return _glfw.x11.keynames[key];
2914
+ }
2915
+
2916
+ int _glfwPlatformGetKeyScancode(int key)
2917
+ {
2918
+ return _glfw.x11.scancodes[key];
2919
+ }
2920
+
2921
+ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
2922
+ const GLFWimage* image,
2923
+ int xhot, int yhot)
2924
+ {
2925
+ cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
2926
+ if (!cursor->x11.handle)
2927
+ return GLFW_FALSE;
2928
+
2929
+ return GLFW_TRUE;
2930
+ }
2931
+
2932
+ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
2933
+ {
2934
+ if (_glfw.x11.xcursor.handle)
2935
+ {
2936
+ char* theme = XcursorGetTheme(_glfw.x11.display);
2937
+ if (theme)
2938
+ {
2939
+ const int size = XcursorGetDefaultSize(_glfw.x11.display);
2940
+ const char* name = NULL;
2941
+
2942
+ switch (shape)
2943
+ {
2944
+ case GLFW_ARROW_CURSOR:
2945
+ name = "default";
2946
+ break;
2947
+ case GLFW_IBEAM_CURSOR:
2948
+ name = "text";
2949
+ break;
2950
+ case GLFW_CROSSHAIR_CURSOR:
2951
+ name = "crosshair";
2952
+ break;
2953
+ case GLFW_POINTING_HAND_CURSOR:
2954
+ name = "pointer";
2955
+ break;
2956
+ case GLFW_RESIZE_EW_CURSOR:
2957
+ name = "ew-resize";
2958
+ break;
2959
+ case GLFW_RESIZE_NS_CURSOR:
2960
+ name = "ns-resize";
2961
+ break;
2962
+ case GLFW_RESIZE_NWSE_CURSOR:
2963
+ name = "nwse-resize";
2964
+ break;
2965
+ case GLFW_RESIZE_NESW_CURSOR:
2966
+ name = "nesw-resize";
2967
+ break;
2968
+ case GLFW_RESIZE_ALL_CURSOR:
2969
+ name = "all-scroll";
2970
+ break;
2971
+ case GLFW_NOT_ALLOWED_CURSOR:
2972
+ name = "not-allowed";
2973
+ break;
2974
+ }
2975
+
2976
+ XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
2977
+ if (image)
2978
+ {
2979
+ cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image);
2980
+ XcursorImageDestroy(image);
2981
+ }
2982
+ }
2983
+ }
2984
+
2985
+ if (!cursor->x11.handle)
2986
+ {
2987
+ unsigned int native = 0;
2988
+
2989
+ switch (shape)
2990
+ {
2991
+ case GLFW_ARROW_CURSOR:
2992
+ native = XC_left_ptr;
2993
+ break;
2994
+ case GLFW_IBEAM_CURSOR:
2995
+ native = XC_xterm;
2996
+ break;
2997
+ case GLFW_CROSSHAIR_CURSOR:
2998
+ native = XC_crosshair;
2999
+ break;
3000
+ case GLFW_POINTING_HAND_CURSOR:
3001
+ native = XC_hand2;
3002
+ break;
3003
+ case GLFW_RESIZE_EW_CURSOR:
3004
+ native = XC_sb_h_double_arrow;
3005
+ break;
3006
+ case GLFW_RESIZE_NS_CURSOR:
3007
+ native = XC_sb_v_double_arrow;
3008
+ break;
3009
+ case GLFW_RESIZE_ALL_CURSOR:
3010
+ native = XC_fleur;
3011
+ break;
3012
+ default:
3013
+ _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
3014
+ "X11: Standard cursor shape unavailable");
3015
+ return GLFW_FALSE;
3016
+ }
3017
+
3018
+ cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
3019
+ if (!cursor->x11.handle)
3020
+ {
3021
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3022
+ "X11: Failed to create standard cursor");
3023
+ return GLFW_FALSE;
3024
+ }
3025
+ }
3026
+
3027
+ return GLFW_TRUE;
3028
+ }
3029
+
3030
+ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
3031
+ {
3032
+ if (cursor->x11.handle)
3033
+ XFreeCursor(_glfw.x11.display, cursor->x11.handle);
3034
+ }
3035
+
3036
+ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
3037
+ {
3038
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
3039
+ {
3040
+ updateCursorImage(window);
3041
+ XFlush(_glfw.x11.display);
3042
+ }
3043
+ }
3044
+
3045
+ void _glfwPlatformSetClipboardString(const char* string)
3046
+ {
3047
+ char* copy = _glfw_strdup(string);
3048
+ free(_glfw.x11.clipboardString);
3049
+ _glfw.x11.clipboardString = copy;
3050
+
3051
+ XSetSelectionOwner(_glfw.x11.display,
3052
+ _glfw.x11.CLIPBOARD,
3053
+ _glfw.x11.helperWindowHandle,
3054
+ CurrentTime);
3055
+
3056
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
3057
+ _glfw.x11.helperWindowHandle)
3058
+ {
3059
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3060
+ "X11: Failed to become owner of clipboard selection");
3061
+ }
3062
+ }
3063
+
3064
+ const char* _glfwPlatformGetClipboardString(void)
3065
+ {
3066
+ return getSelectionString(_glfw.x11.CLIPBOARD);
3067
+ }
3068
+
3069
+ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
3070
+ {
3071
+ if (_glfw.egl.ANGLE_platform_angle)
3072
+ {
3073
+ int type = 0;
3074
+
3075
+ if (_glfw.egl.ANGLE_platform_angle_opengl)
3076
+ {
3077
+ if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
3078
+ type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
3079
+ }
3080
+
3081
+ if (_glfw.egl.ANGLE_platform_angle_vulkan)
3082
+ {
3083
+ if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
3084
+ type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
3085
+ }
3086
+
3087
+ if (type)
3088
+ {
3089
+ *attribs = calloc(5, sizeof(EGLint));
3090
+ (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
3091
+ (*attribs)[1] = type;
3092
+ (*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
3093
+ (*attribs)[3] = EGL_PLATFORM_X11_EXT;
3094
+ (*attribs)[4] = EGL_NONE;
3095
+ return EGL_PLATFORM_ANGLE_ANGLE;
3096
+ }
3097
+ }
3098
+
3099
+ if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_x11)
3100
+ return EGL_PLATFORM_X11_EXT;
3101
+
3102
+ return 0;
3103
+ }
3104
+
3105
+ EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
3106
+ {
3107
+ return _glfw.x11.display;
3108
+ }
3109
+
3110
+ EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
3111
+ {
3112
+ if (_glfw.egl.platform)
3113
+ return &window->x11.handle;
3114
+ else
3115
+ return (EGLNativeWindowType) window->x11.handle;
3116
+ }
3117
+
3118
+ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
3119
+ {
3120
+ if (!_glfw.vk.KHR_surface)
3121
+ return;
3122
+
3123
+ if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
3124
+ {
3125
+ if (!_glfw.vk.KHR_xlib_surface)
3126
+ return;
3127
+ }
3128
+
3129
+ extensions[0] = "VK_KHR_surface";
3130
+
3131
+ // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but
3132
+ // not correctly implementing VK_KHR_xlib_surface
3133
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3134
+ extensions[1] = "VK_KHR_xcb_surface";
3135
+ else
3136
+ extensions[1] = "VK_KHR_xlib_surface";
3137
+ }
3138
+
3139
+ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
3140
+ VkPhysicalDevice device,
3141
+ uint32_t queuefamily)
3142
+ {
3143
+ VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
3144
+ _glfw.x11.screen));
3145
+
3146
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3147
+ {
3148
+ PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
3149
+ vkGetPhysicalDeviceXcbPresentationSupportKHR =
3150
+ (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
3151
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
3152
+ if (!vkGetPhysicalDeviceXcbPresentationSupportKHR)
3153
+ {
3154
+ _glfwInputError(GLFW_API_UNAVAILABLE,
3155
+ "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
3156
+ return GLFW_FALSE;
3157
+ }
3158
+
3159
+ xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
3160
+ if (!connection)
3161
+ {
3162
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3163
+ "X11: Failed to retrieve XCB connection");
3164
+ return GLFW_FALSE;
3165
+ }
3166
+
3167
+ return vkGetPhysicalDeviceXcbPresentationSupportKHR(device,
3168
+ queuefamily,
3169
+ connection,
3170
+ visualID);
3171
+ }
3172
+ else
3173
+ {
3174
+ PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
3175
+ vkGetPhysicalDeviceXlibPresentationSupportKHR =
3176
+ (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
3177
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
3178
+ if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
3179
+ {
3180
+ _glfwInputError(GLFW_API_UNAVAILABLE,
3181
+ "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
3182
+ return GLFW_FALSE;
3183
+ }
3184
+
3185
+ return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
3186
+ queuefamily,
3187
+ _glfw.x11.display,
3188
+ visualID);
3189
+ }
3190
+ }
3191
+
3192
+ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
3193
+ _GLFWwindow* window,
3194
+ const VkAllocationCallbacks* allocator,
3195
+ VkSurfaceKHR* surface)
3196
+ {
3197
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3198
+ {
3199
+ VkResult err;
3200
+ VkXcbSurfaceCreateInfoKHR sci;
3201
+ PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
3202
+
3203
+ xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
3204
+ if (!connection)
3205
+ {
3206
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3207
+ "X11: Failed to retrieve XCB connection");
3208
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
3209
+ }
3210
+
3211
+ vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
3212
+ vkGetInstanceProcAddr(instance, "vkCreateXcbSurfaceKHR");
3213
+ if (!vkCreateXcbSurfaceKHR)
3214
+ {
3215
+ _glfwInputError(GLFW_API_UNAVAILABLE,
3216
+ "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
3217
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
3218
+ }
3219
+
3220
+ memset(&sci, 0, sizeof(sci));
3221
+ sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
3222
+ sci.connection = connection;
3223
+ sci.window = window->x11.handle;
3224
+
3225
+ err = vkCreateXcbSurfaceKHR(instance, &sci, allocator, surface);
3226
+ if (err)
3227
+ {
3228
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3229
+ "X11: Failed to create Vulkan XCB surface: %s",
3230
+ _glfwGetVulkanResultString(err));
3231
+ }
3232
+
3233
+ return err;
3234
+ }
3235
+ else
3236
+ {
3237
+ VkResult err;
3238
+ VkXlibSurfaceCreateInfoKHR sci;
3239
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
3240
+
3241
+ vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
3242
+ vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
3243
+ if (!vkCreateXlibSurfaceKHR)
3244
+ {
3245
+ _glfwInputError(GLFW_API_UNAVAILABLE,
3246
+ "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
3247
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
3248
+ }
3249
+
3250
+ memset(&sci, 0, sizeof(sci));
3251
+ sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
3252
+ sci.dpy = _glfw.x11.display;
3253
+ sci.window = window->x11.handle;
3254
+
3255
+ err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
3256
+ if (err)
3257
+ {
3258
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3259
+ "X11: Failed to create Vulkan X11 surface: %s",
3260
+ _glfwGetVulkanResultString(err));
3261
+ }
3262
+
3263
+ return err;
3264
+ }
3265
+ }
3266
+
3267
+
3268
+ //////////////////////////////////////////////////////////////////////////
3269
+ ////// GLFW native API //////
3270
+ //////////////////////////////////////////////////////////////////////////
3271
+
3272
+ GLFWAPI Display* glfwGetX11Display(void)
3273
+ {
3274
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3275
+ return _glfw.x11.display;
3276
+ }
3277
+
3278
+ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
3279
+ {
3280
+ _GLFWwindow* window = (_GLFWwindow*) handle;
3281
+ _GLFW_REQUIRE_INIT_OR_RETURN(None);
3282
+ return window->x11.handle;
3283
+ }
3284
+
3285
+ GLFWAPI void glfwSetX11SelectionString(const char* string)
3286
+ {
3287
+ _GLFW_REQUIRE_INIT();
3288
+
3289
+ free(_glfw.x11.primarySelectionString);
3290
+ _glfw.x11.primarySelectionString = _glfw_strdup(string);
3291
+
3292
+ XSetSelectionOwner(_glfw.x11.display,
3293
+ _glfw.x11.PRIMARY,
3294
+ _glfw.x11.helperWindowHandle,
3295
+ CurrentTime);
3296
+
3297
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.PRIMARY) !=
3298
+ _glfw.x11.helperWindowHandle)
3299
+ {
3300
+ _glfwInputError(GLFW_PLATFORM_ERROR,
3301
+ "X11: Failed to become owner of primary selection");
3302
+ }
3303
+ }
3304
+
3305
+ GLFWAPI const char* glfwGetX11SelectionString(void)
3306
+ {
3307
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3308
+ return getSelectionString(_glfw.x11.PRIMARY);
3309
+ }
3310
+