display_server.cpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. /*************************************************************************/
  2. /* display_server.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "display_server.h"
  31. #include "core/input/input.h"
  32. #include "scene/resources/texture.h"
  33. #include "servers/display_server_headless.h"
  34. DisplayServer *DisplayServer::singleton = nullptr;
  35. bool DisplayServer::hidpi_allowed = false;
  36. DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS] = {
  37. { "headless", &DisplayServerHeadless::create_func, &DisplayServerHeadless::get_rendering_drivers_func }
  38. };
  39. int DisplayServer::server_create_count = 1;
  40. void DisplayServer::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  41. WARN_PRINT("Global menus not supported by this display server.");
  42. }
  43. void DisplayServer::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  44. WARN_PRINT("Global menus not supported by this display server.");
  45. }
  46. void DisplayServer::global_menu_add_icon_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  47. WARN_PRINT("Global menus not supported by this display server.");
  48. }
  49. void DisplayServer::global_menu_add_icon_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  50. WARN_PRINT("Global menus not supported by this display server.");
  51. }
  52. void DisplayServer::global_menu_add_radio_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  53. WARN_PRINT("Global menus not supported by this display server.");
  54. }
  55. void DisplayServer::global_menu_add_icon_radio_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  56. WARN_PRINT("Global menus not supported by this display server.");
  57. }
  58. void DisplayServer::global_menu_add_multistate_item(const String &p_menu_root, const String &p_label, int p_max_states, int p_default_state, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) {
  59. WARN_PRINT("Global menus not supported by this display server.");
  60. }
  61. void DisplayServer::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu, int p_index) {
  62. WARN_PRINT("Global menus not supported by this display server.");
  63. }
  64. void DisplayServer::global_menu_add_separator(const String &p_menu_root, int p_index) {
  65. WARN_PRINT("Global menus not supported by this display server.");
  66. }
  67. int DisplayServer::global_menu_get_item_index_from_text(const String &p_menu_root, const String &p_text) const {
  68. WARN_PRINT("Global menus not supported by this display server.");
  69. return -1;
  70. }
  71. int DisplayServer::global_menu_get_item_index_from_tag(const String &p_menu_root, const Variant &p_tag) const {
  72. WARN_PRINT("Global menus not supported by this display server.");
  73. return -1;
  74. }
  75. void DisplayServer::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) {
  76. WARN_PRINT("Global menus not supported by this display server.");
  77. }
  78. bool DisplayServer::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const {
  79. WARN_PRINT("Global menus not supported by this display server.");
  80. return false;
  81. }
  82. bool DisplayServer::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const {
  83. WARN_PRINT("Global menus not supported by this display server.");
  84. return false;
  85. }
  86. bool DisplayServer::global_menu_is_item_radio_checkable(const String &p_menu_root, int p_idx) const {
  87. WARN_PRINT("Global menus not supported by this display server.");
  88. return false;
  89. }
  90. Callable DisplayServer::global_menu_get_item_callback(const String &p_menu_root, int p_idx) const {
  91. WARN_PRINT("Global menus not supported by this display server.");
  92. return Callable();
  93. }
  94. Variant DisplayServer::global_menu_get_item_tag(const String &p_menu_root, int p_idx) const {
  95. WARN_PRINT("Global menus not supported by this display server.");
  96. return Variant();
  97. }
  98. String DisplayServer::global_menu_get_item_text(const String &p_menu_root, int p_idx) const {
  99. WARN_PRINT("Global menus not supported by this display server.");
  100. return String();
  101. }
  102. String DisplayServer::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) const {
  103. WARN_PRINT("Global menus not supported by this display server.");
  104. return String();
  105. }
  106. Key DisplayServer::global_menu_get_item_accelerator(const String &p_menu_root, int p_idx) const {
  107. WARN_PRINT("Global menus not supported by this display server.");
  108. return Key::NONE;
  109. }
  110. bool DisplayServer::global_menu_is_item_disabled(const String &p_menu_root, int p_idx) const {
  111. WARN_PRINT("Global menus not supported by this display server.");
  112. return false;
  113. }
  114. String DisplayServer::global_menu_get_item_tooltip(const String &p_menu_root, int p_idx) const {
  115. WARN_PRINT("Global menus not supported by this display server.");
  116. return String();
  117. }
  118. int DisplayServer::global_menu_get_item_state(const String &p_menu_root, int p_idx) const {
  119. WARN_PRINT("Global menus not supported by this display server.");
  120. return -1;
  121. }
  122. int DisplayServer::global_menu_get_item_max_states(const String &p_menu_root, int p_idx) const {
  123. WARN_PRINT("Global menus not supported by this display server.");
  124. return -1;
  125. }
  126. Ref<Texture2D> DisplayServer::global_menu_get_item_icon(const String &p_menu_root, int p_idx) const {
  127. WARN_PRINT("Global menus not supported by this display server.");
  128. return Ref<Texture2D>();
  129. }
  130. void DisplayServer::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) {
  131. WARN_PRINT("Global menus not supported by this display server.");
  132. }
  133. void DisplayServer::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) {
  134. WARN_PRINT("Global menus not supported by this display server.");
  135. }
  136. void DisplayServer::global_menu_set_item_radio_checkable(const String &p_menu_root, int p_idx, bool p_checkable) {
  137. WARN_PRINT("Global menus not supported by this display server.");
  138. }
  139. void DisplayServer::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) {
  140. WARN_PRINT("Global menus not supported by this display server.");
  141. }
  142. void DisplayServer::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) {
  143. WARN_PRINT("Global menus not supported by this display server.");
  144. }
  145. void DisplayServer::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) {
  146. WARN_PRINT("Global menus not supported by this display server.");
  147. }
  148. void DisplayServer::global_menu_set_item_accelerator(const String &p_menu_root, int p_idx, Key p_keycode) {
  149. WARN_PRINT("Global menus not supported by this display server.");
  150. }
  151. void DisplayServer::global_menu_set_item_disabled(const String &p_menu_root, int p_idx, bool p_disabled) {
  152. WARN_PRINT("Global menus not supported by this display server.");
  153. }
  154. void DisplayServer::global_menu_set_item_tooltip(const String &p_menu_root, int p_idx, const String &p_tooltip) {
  155. WARN_PRINT("Global menus not supported by this display server.");
  156. }
  157. void DisplayServer::global_menu_set_item_state(const String &p_menu_root, int p_idx, int p_state) {
  158. WARN_PRINT("Global menus not supported by this display server.");
  159. }
  160. void DisplayServer::global_menu_set_item_max_states(const String &p_menu_root, int p_idx, int p_max_states) {
  161. WARN_PRINT("Global menus not supported by this display server.");
  162. }
  163. void DisplayServer::global_menu_set_item_icon(const String &p_menu_root, int p_idx, const Ref<Texture2D> &p_icon) {
  164. WARN_PRINT("Global menus not supported by this display server.");
  165. }
  166. int DisplayServer::global_menu_get_item_count(const String &p_menu_root) const {
  167. WARN_PRINT("Global menus not supported by this display server.");
  168. return 0;
  169. }
  170. void DisplayServer::global_menu_remove_item(const String &p_menu_root, int p_idx) {
  171. WARN_PRINT("Global menus not supported by this display server.");
  172. }
  173. void DisplayServer::global_menu_clear(const String &p_menu_root) {
  174. WARN_PRINT("Global menus not supported by this display server.");
  175. }
  176. bool DisplayServer::tts_is_speaking() const {
  177. WARN_PRINT("TTS is not supported by this display server.");
  178. return false;
  179. }
  180. bool DisplayServer::tts_is_paused() const {
  181. WARN_PRINT("TTS is not supported by this display server.");
  182. return false;
  183. }
  184. void DisplayServer::tts_pause() {
  185. WARN_PRINT("TTS is not supported by this display server.");
  186. }
  187. void DisplayServer::tts_resume() {
  188. WARN_PRINT("TTS is not supported by this display server.");
  189. }
  190. Array DisplayServer::tts_get_voices() const {
  191. WARN_PRINT("TTS is not supported by this display server.");
  192. return Array();
  193. }
  194. PackedStringArray DisplayServer::tts_get_voices_for_language(const String &p_language) const {
  195. PackedStringArray ret;
  196. Array voices = tts_get_voices();
  197. for (int i = 0; i < voices.size(); i++) {
  198. const Dictionary &voice = voices[i];
  199. if (voice.has("id") && voice.has("language") && voice["language"].operator String().begins_with(p_language)) {
  200. ret.push_back(voice["id"]);
  201. }
  202. }
  203. return ret;
  204. }
  205. void DisplayServer::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
  206. WARN_PRINT("TTS is not supported by this display server.");
  207. }
  208. void DisplayServer::tts_stop() {
  209. WARN_PRINT("TTS is not supported by this display server.");
  210. }
  211. void DisplayServer::tts_set_utterance_callback(TTSUtteranceEvent p_event, const Callable &p_callable) {
  212. ERR_FAIL_INDEX(p_event, DisplayServer::TTS_UTTERANCE_MAX);
  213. utterance_callback[p_event] = p_callable;
  214. }
  215. void DisplayServer::tts_post_utterance_event(TTSUtteranceEvent p_event, int p_id, int p_pos) {
  216. ERR_FAIL_INDEX(p_event, DisplayServer::TTS_UTTERANCE_MAX);
  217. switch (p_event) {
  218. case DisplayServer::TTS_UTTERANCE_STARTED:
  219. case DisplayServer::TTS_UTTERANCE_ENDED:
  220. case DisplayServer::TTS_UTTERANCE_CANCELED: {
  221. if (utterance_callback[p_event].is_valid()) {
  222. Variant args[1];
  223. args[0] = p_id;
  224. const Variant *argp[] = { &args[0] };
  225. utterance_callback[p_event].call_deferred(argp, 1); // Should be deferred, on some platforms utterance events can be called from different threads in a rapid succession.
  226. }
  227. } break;
  228. case DisplayServer::TTS_UTTERANCE_BOUNDARY: {
  229. if (utterance_callback[p_event].is_valid()) {
  230. Variant args[2];
  231. args[0] = p_pos;
  232. args[1] = p_id;
  233. const Variant *argp[] = { &args[0], &args[1] };
  234. utterance_callback[p_event].call_deferred(argp, 2); // Should be deferred, on some platforms utterance events can be called from different threads in a rapid succession.
  235. }
  236. } break;
  237. default:
  238. break;
  239. }
  240. }
  241. void DisplayServer::mouse_set_mode(MouseMode p_mode) {
  242. WARN_PRINT("Mouse is not supported by this display server.");
  243. }
  244. DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
  245. return MOUSE_MODE_VISIBLE;
  246. }
  247. void DisplayServer::warp_mouse(const Point2i &p_position) {
  248. WARN_PRINT("Mouse warping is not supported by this display server.");
  249. }
  250. Point2i DisplayServer::mouse_get_position() const {
  251. ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
  252. }
  253. MouseButton DisplayServer::mouse_get_button_state() const {
  254. ERR_FAIL_V_MSG(MouseButton::NONE, "Mouse is not supported by this display server.");
  255. }
  256. void DisplayServer::clipboard_set(const String &p_text) {
  257. WARN_PRINT("Clipboard is not supported by this display server.");
  258. }
  259. String DisplayServer::clipboard_get() const {
  260. ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
  261. }
  262. bool DisplayServer::clipboard_has() const {
  263. return !clipboard_get().is_empty();
  264. }
  265. void DisplayServer::clipboard_set_primary(const String &p_text) {
  266. WARN_PRINT("Primary clipboard is not supported by this display server.");
  267. }
  268. String DisplayServer::clipboard_get_primary() const {
  269. ERR_FAIL_V_MSG(String(), "Primary clipboard is not supported by this display server.");
  270. }
  271. void DisplayServer::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
  272. WARN_PRINT("Orientation not supported by this display server.");
  273. }
  274. DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_screen) const {
  275. return SCREEN_LANDSCAPE;
  276. }
  277. float DisplayServer::screen_get_scale(int p_screen) const {
  278. return 1.0f;
  279. };
  280. bool DisplayServer::screen_is_touchscreen(int p_screen) const {
  281. //return false;
  282. return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse();
  283. }
  284. void DisplayServer::screen_set_keep_on(bool p_enable) {
  285. WARN_PRINT("Keeping screen on not supported by this display server.");
  286. }
  287. bool DisplayServer::screen_is_kept_on() const {
  288. return false;
  289. }
  290. DisplayServer::WindowID DisplayServer::create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect) {
  291. ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Sub-windows not supported by this display server.");
  292. }
  293. void DisplayServer::show_window(WindowID p_id) {
  294. ERR_FAIL_MSG("Sub-windows not supported by this display server.");
  295. }
  296. void DisplayServer::delete_sub_window(WindowID p_id) {
  297. ERR_FAIL_MSG("Sub-windows not supported by this display server.");
  298. }
  299. void DisplayServer::window_set_exclusive(WindowID p_window, bool p_exclusive) {
  300. // Do nothing, if not supported.
  301. }
  302. void DisplayServer::window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window) {
  303. ERR_FAIL_MSG("Mouse passthrough not supported by this display server.");
  304. }
  305. void DisplayServer::gl_window_make_current(DisplayServer::WindowID p_window_id) {
  306. // noop except in gles
  307. }
  308. void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) {
  309. WARN_PRINT("IME not supported by this display server.");
  310. }
  311. void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
  312. WARN_PRINT("IME not supported by this display server.");
  313. }
  314. Point2i DisplayServer::ime_get_selection() const {
  315. ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
  316. }
  317. String DisplayServer::ime_get_text() const {
  318. ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server.");
  319. }
  320. void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_length, int p_cursor_start, int p_cursor_end) {
  321. WARN_PRINT("Virtual keyboard not supported by this display server.");
  322. }
  323. void DisplayServer::virtual_keyboard_hide() {
  324. WARN_PRINT("Virtual keyboard not supported by this display server.");
  325. }
  326. // returns height of the currently shown keyboard (0 if keyboard is hidden)
  327. int DisplayServer::virtual_keyboard_get_height() const {
  328. ERR_FAIL_V_MSG(0, "Virtual keyboard not supported by this display server.");
  329. }
  330. void DisplayServer::cursor_set_shape(CursorShape p_shape) {
  331. WARN_PRINT("Cursor shape not supported by this display server.");
  332. }
  333. DisplayServer::CursorShape DisplayServer::cursor_get_shape() const {
  334. return CURSOR_ARROW;
  335. }
  336. void DisplayServer::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
  337. WARN_PRINT("Custom cursor shape not supported by this display server.");
  338. }
  339. bool DisplayServer::get_swap_cancel_ok() {
  340. return false;
  341. }
  342. void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
  343. }
  344. Error DisplayServer::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
  345. WARN_PRINT("Native dialogs not supported by this display server.");
  346. return OK;
  347. }
  348. Error DisplayServer::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
  349. WARN_PRINT("Native dialogs not supported by this display server.");
  350. return OK;
  351. }
  352. int DisplayServer::keyboard_get_layout_count() const {
  353. return 0;
  354. }
  355. int DisplayServer::keyboard_get_current_layout() const {
  356. return -1;
  357. }
  358. void DisplayServer::keyboard_set_current_layout(int p_index) {
  359. }
  360. String DisplayServer::keyboard_get_layout_language(int p_index) const {
  361. return "";
  362. }
  363. String DisplayServer::keyboard_get_layout_name(int p_index) const {
  364. return "Not supported";
  365. }
  366. Key DisplayServer::keyboard_get_keycode_from_physical(Key p_keycode) const {
  367. ERR_FAIL_V_MSG(p_keycode, "Not supported by this display server.");
  368. }
  369. void DisplayServer::force_process_and_drop_events() {
  370. }
  371. void DisplayServer::release_rendering_thread() {
  372. WARN_PRINT("Rendering thread not supported by this display server.");
  373. }
  374. void DisplayServer::make_rendering_thread() {
  375. WARN_PRINT("Rendering thread not supported by this display server.");
  376. }
  377. void DisplayServer::swap_buffers() {
  378. WARN_PRINT("Swap buffers not supported by this display server.");
  379. }
  380. void DisplayServer::set_native_icon(const String &p_filename) {
  381. WARN_PRINT("Native icon not supported by this display server.");
  382. }
  383. void DisplayServer::set_icon(const Ref<Image> &p_icon) {
  384. WARN_PRINT("Icon not supported by this display server.");
  385. }
  386. int64_t DisplayServer::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
  387. WARN_PRINT("Native handle not supported by this display server.");
  388. return 0;
  389. }
  390. void DisplayServer::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
  391. WARN_PRINT("Changing the VSync mode is not supported by this display server.");
  392. }
  393. DisplayServer::VSyncMode DisplayServer::window_get_vsync_mode(WindowID p_window) const {
  394. WARN_PRINT("Changing the VSync mode is not supported by this display server.");
  395. return VSyncMode::VSYNC_ENABLED;
  396. }
  397. void DisplayServer::set_context(Context p_context) {
  398. }
  399. void DisplayServer::_bind_methods() {
  400. ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature);
  401. ClassDB::bind_method(D_METHOD("get_name"), &DisplayServer::get_name);
  402. ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu_root", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  403. ClassDB::bind_method(D_METHOD("global_menu_add_check_item", "menu_root", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_check_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  404. ClassDB::bind_method(D_METHOD("global_menu_add_icon_item", "menu_root", "icon", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_icon_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  405. ClassDB::bind_method(D_METHOD("global_menu_add_icon_check_item", "menu_root", "icon", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_icon_check_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  406. ClassDB::bind_method(D_METHOD("global_menu_add_radio_check_item", "menu_root", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_radio_check_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  407. ClassDB::bind_method(D_METHOD("global_menu_add_icon_radio_check_item", "menu_root", "icon", "label", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_icon_radio_check_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  408. ClassDB::bind_method(D_METHOD("global_menu_add_multistate_item", "menu_root", "labe", "max_states", "default_state", "callback", "tag", "accelerator", "index"), &DisplayServer::global_menu_add_multistate_item, DEFVAL(Callable()), DEFVAL(Variant()), DEFVAL(Key::NONE), DEFVAL(-1));
  409. ClassDB::bind_method(D_METHOD("global_menu_add_submenu_item", "menu_root", "label", "submenu", "index"), &DisplayServer::global_menu_add_submenu_item, DEFVAL(-1));
  410. ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu_root", "index"), &DisplayServer::global_menu_add_separator, DEFVAL(-1));
  411. ClassDB::bind_method(D_METHOD("global_menu_get_item_index_from_text", "menu_root", "text"), &DisplayServer::global_menu_get_item_index_from_text);
  412. ClassDB::bind_method(D_METHOD("global_menu_get_item_index_from_tag", "menu_root", "tag"), &DisplayServer::global_menu_get_item_index_from_tag);
  413. ClassDB::bind_method(D_METHOD("global_menu_is_item_checked", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checked);
  414. ClassDB::bind_method(D_METHOD("global_menu_is_item_checkable", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checkable);
  415. ClassDB::bind_method(D_METHOD("global_menu_is_item_radio_checkable", "menu_root", "idx"), &DisplayServer::global_menu_is_item_radio_checkable);
  416. ClassDB::bind_method(D_METHOD("global_menu_get_item_callback", "menu_root", "idx"), &DisplayServer::global_menu_get_item_callback);
  417. ClassDB::bind_method(D_METHOD("global_menu_get_item_tag", "menu_root", "idx"), &DisplayServer::global_menu_get_item_tag);
  418. ClassDB::bind_method(D_METHOD("global_menu_get_item_text", "menu_root", "idx"), &DisplayServer::global_menu_get_item_text);
  419. ClassDB::bind_method(D_METHOD("global_menu_get_item_submenu", "menu_root", "idx"), &DisplayServer::global_menu_get_item_submenu);
  420. ClassDB::bind_method(D_METHOD("global_menu_get_item_accelerator", "menu_root", "idx"), &DisplayServer::global_menu_get_item_accelerator);
  421. ClassDB::bind_method(D_METHOD("global_menu_is_item_disabled", "menu_root", "idx"), &DisplayServer::global_menu_is_item_disabled);
  422. ClassDB::bind_method(D_METHOD("global_menu_get_item_tooltip", "menu_root", "idx"), &DisplayServer::global_menu_get_item_tooltip);
  423. ClassDB::bind_method(D_METHOD("global_menu_get_item_state", "menu_root", "idx"), &DisplayServer::global_menu_get_item_state);
  424. ClassDB::bind_method(D_METHOD("global_menu_get_item_max_states", "menu_root", "idx"), &DisplayServer::global_menu_get_item_max_states);
  425. ClassDB::bind_method(D_METHOD("global_menu_get_item_icon", "menu_root", "idx"), &DisplayServer::global_menu_get_item_icon);
  426. ClassDB::bind_method(D_METHOD("global_menu_set_item_checked", "menu_root", "idx", "checked"), &DisplayServer::global_menu_set_item_checked);
  427. ClassDB::bind_method(D_METHOD("global_menu_set_item_checkable", "menu_root", "idx", "checkable"), &DisplayServer::global_menu_set_item_checkable);
  428. ClassDB::bind_method(D_METHOD("global_menu_set_item_radio_checkable", "menu_root", "idx", "checkable"), &DisplayServer::global_menu_set_item_radio_checkable);
  429. ClassDB::bind_method(D_METHOD("global_menu_set_item_callback", "menu_root", "idx", "callback"), &DisplayServer::global_menu_set_item_callback);
  430. ClassDB::bind_method(D_METHOD("global_menu_set_item_tag", "menu_root", "idx", "tag"), &DisplayServer::global_menu_set_item_tag);
  431. ClassDB::bind_method(D_METHOD("global_menu_set_item_text", "menu_root", "idx", "text"), &DisplayServer::global_menu_set_item_text);
  432. ClassDB::bind_method(D_METHOD("global_menu_set_item_submenu", "menu_root", "idx", "submenu"), &DisplayServer::global_menu_set_item_submenu);
  433. ClassDB::bind_method(D_METHOD("global_menu_set_item_accelerator", "menu_root", "idx", "keycode"), &DisplayServer::global_menu_set_item_accelerator);
  434. ClassDB::bind_method(D_METHOD("global_menu_set_item_disabled", "menu_root", "idx", "disabled"), &DisplayServer::global_menu_set_item_disabled);
  435. ClassDB::bind_method(D_METHOD("global_menu_set_item_tooltip", "menu_root", "idx", "tooltip"), &DisplayServer::global_menu_set_item_tooltip);
  436. ClassDB::bind_method(D_METHOD("global_menu_set_item_state", "menu_root", "idx", "state"), &DisplayServer::global_menu_set_item_state);
  437. ClassDB::bind_method(D_METHOD("global_menu_set_item_max_states", "menu_root", "idx", "max_states"), &DisplayServer::global_menu_set_item_max_states);
  438. ClassDB::bind_method(D_METHOD("global_menu_set_item_icon", "menu_root", "idx", "icon"), &DisplayServer::global_menu_set_item_icon);
  439. ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu_root", "idx"), &DisplayServer::global_menu_remove_item);
  440. ClassDB::bind_method(D_METHOD("global_menu_clear", "menu_root"), &DisplayServer::global_menu_clear);
  441. ClassDB::bind_method(D_METHOD("tts_is_speaking"), &DisplayServer::tts_is_speaking);
  442. ClassDB::bind_method(D_METHOD("tts_is_paused"), &DisplayServer::tts_is_paused);
  443. ClassDB::bind_method(D_METHOD("tts_get_voices"), &DisplayServer::tts_get_voices);
  444. ClassDB::bind_method(D_METHOD("tts_get_voices_for_language", "language"), &DisplayServer::tts_get_voices_for_language);
  445. ClassDB::bind_method(D_METHOD("tts_speak", "text", "voice", "volume", "pitch", "rate", "utterance_id", "interrupt"), &DisplayServer::tts_speak, DEFVAL(50), DEFVAL(1.f), DEFVAL(1.f), DEFVAL(0), DEFVAL(false));
  446. ClassDB::bind_method(D_METHOD("tts_pause"), &DisplayServer::tts_pause);
  447. ClassDB::bind_method(D_METHOD("tts_resume"), &DisplayServer::tts_resume);
  448. ClassDB::bind_method(D_METHOD("tts_stop"), &DisplayServer::tts_stop);
  449. ClassDB::bind_method(D_METHOD("tts_set_utterance_callback", "event", "callable"), &DisplayServer::tts_set_utterance_callback);
  450. ClassDB::bind_method(D_METHOD("_tts_post_utterance_event", "event", "id", "char_pos"), &DisplayServer::tts_post_utterance_event);
  451. ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode);
  452. ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode);
  453. ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &DisplayServer::warp_mouse);
  454. ClassDB::bind_method(D_METHOD("mouse_get_position"), &DisplayServer::mouse_get_position);
  455. ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
  456. ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
  457. ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
  458. ClassDB::bind_method(D_METHOD("clipboard_has"), &DisplayServer::clipboard_has);
  459. ClassDB::bind_method(D_METHOD("clipboard_set_primary", "clipboard_primary"), &DisplayServer::clipboard_set_primary);
  460. ClassDB::bind_method(D_METHOD("clipboard_get_primary"), &DisplayServer::clipboard_get_primary);
  461. ClassDB::bind_method(D_METHOD("get_display_cutouts"), &DisplayServer::get_display_cutouts);
  462. ClassDB::bind_method(D_METHOD("get_display_safe_area"), &DisplayServer::get_display_safe_area);
  463. ClassDB::bind_method(D_METHOD("get_screen_count"), &DisplayServer::get_screen_count);
  464. ClassDB::bind_method(D_METHOD("screen_get_position", "screen"), &DisplayServer::screen_get_position, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  465. ClassDB::bind_method(D_METHOD("screen_get_size", "screen"), &DisplayServer::screen_get_size, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  466. ClassDB::bind_method(D_METHOD("screen_get_usable_rect", "screen"), &DisplayServer::screen_get_usable_rect, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  467. ClassDB::bind_method(D_METHOD("screen_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  468. ClassDB::bind_method(D_METHOD("screen_get_scale", "screen"), &DisplayServer::screen_get_scale, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  469. ClassDB::bind_method(D_METHOD("screen_is_touchscreen", "screen"), &DisplayServer::screen_is_touchscreen, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  470. ClassDB::bind_method(D_METHOD("screen_get_max_scale"), &DisplayServer::screen_get_max_scale);
  471. ClassDB::bind_method(D_METHOD("screen_get_refresh_rate", "screen"), &DisplayServer::screen_get_refresh_rate, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  472. ClassDB::bind_method(D_METHOD("screen_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  473. ClassDB::bind_method(D_METHOD("screen_get_orientation", "screen"), &DisplayServer::screen_get_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
  474. ClassDB::bind_method(D_METHOD("screen_set_keep_on", "enable"), &DisplayServer::screen_set_keep_on);
  475. ClassDB::bind_method(D_METHOD("screen_is_kept_on"), &DisplayServer::screen_is_kept_on);
  476. ClassDB::bind_method(D_METHOD("get_window_list"), &DisplayServer::get_window_list);
  477. ClassDB::bind_method(D_METHOD("get_window_at_screen_position", "position"), &DisplayServer::get_window_at_screen_position);
  478. ClassDB::bind_method(D_METHOD("create_sub_window", "mode", "vsync_mode", "flags", "rect"), &DisplayServer::create_sub_window, DEFVAL(Rect2i()));
  479. ClassDB::bind_method(D_METHOD("delete_sub_window", "window_id"), &DisplayServer::delete_sub_window);
  480. ClassDB::bind_method(D_METHOD("window_get_native_handle", "handle_type", "window_id"), &DisplayServer::window_get_native_handle, DEFVAL(MAIN_WINDOW_ID));
  481. ClassDB::bind_method(D_METHOD("window_get_active_popup"), &DisplayServer::window_get_active_popup);
  482. ClassDB::bind_method(D_METHOD("window_set_popup_safe_rect", "window", "rect"), &DisplayServer::window_set_popup_safe_rect);
  483. ClassDB::bind_method(D_METHOD("window_get_popup_safe_rect", "window"), &DisplayServer::window_get_popup_safe_rect);
  484. ClassDB::bind_method(D_METHOD("window_set_title", "title", "window_id"), &DisplayServer::window_set_title, DEFVAL(MAIN_WINDOW_ID));
  485. ClassDB::bind_method(D_METHOD("window_set_mouse_passthrough", "region", "window_id"), &DisplayServer::window_set_mouse_passthrough, DEFVAL(MAIN_WINDOW_ID));
  486. ClassDB::bind_method(D_METHOD("window_get_current_screen", "window_id"), &DisplayServer::window_get_current_screen, DEFVAL(MAIN_WINDOW_ID));
  487. ClassDB::bind_method(D_METHOD("window_set_current_screen", "screen", "window_id"), &DisplayServer::window_set_current_screen, DEFVAL(MAIN_WINDOW_ID));
  488. ClassDB::bind_method(D_METHOD("window_get_position", "window_id"), &DisplayServer::window_get_position, DEFVAL(MAIN_WINDOW_ID));
  489. ClassDB::bind_method(D_METHOD("window_set_position", "position", "window_id"), &DisplayServer::window_set_position, DEFVAL(MAIN_WINDOW_ID));
  490. ClassDB::bind_method(D_METHOD("window_get_size", "window_id"), &DisplayServer::window_get_size, DEFVAL(MAIN_WINDOW_ID));
  491. ClassDB::bind_method(D_METHOD("window_set_size", "size", "window_id"), &DisplayServer::window_set_size, DEFVAL(MAIN_WINDOW_ID));
  492. ClassDB::bind_method(D_METHOD("window_set_rect_changed_callback", "callback", "window_id"), &DisplayServer::window_set_rect_changed_callback, DEFVAL(MAIN_WINDOW_ID));
  493. ClassDB::bind_method(D_METHOD("window_set_window_event_callback", "callback", "window_id"), &DisplayServer::window_set_window_event_callback, DEFVAL(MAIN_WINDOW_ID));
  494. ClassDB::bind_method(D_METHOD("window_set_input_event_callback", "callback", "window_id"), &DisplayServer::window_set_input_event_callback, DEFVAL(MAIN_WINDOW_ID));
  495. ClassDB::bind_method(D_METHOD("window_set_input_text_callback", "callback", "window_id"), &DisplayServer::window_set_input_text_callback, DEFVAL(MAIN_WINDOW_ID));
  496. ClassDB::bind_method(D_METHOD("window_set_drop_files_callback", "callback", "window_id"), &DisplayServer::window_set_drop_files_callback, DEFVAL(MAIN_WINDOW_ID));
  497. ClassDB::bind_method(D_METHOD("window_attach_instance_id", "instance_id", "window_id"), &DisplayServer::window_attach_instance_id, DEFVAL(MAIN_WINDOW_ID));
  498. ClassDB::bind_method(D_METHOD("window_get_attached_instance_id", "window_id"), &DisplayServer::window_get_attached_instance_id, DEFVAL(MAIN_WINDOW_ID));
  499. ClassDB::bind_method(D_METHOD("window_get_max_size", "window_id"), &DisplayServer::window_get_max_size, DEFVAL(MAIN_WINDOW_ID));
  500. ClassDB::bind_method(D_METHOD("window_set_max_size", "max_size", "window_id"), &DisplayServer::window_set_max_size, DEFVAL(MAIN_WINDOW_ID));
  501. ClassDB::bind_method(D_METHOD("window_get_min_size", "window_id"), &DisplayServer::window_get_min_size, DEFVAL(MAIN_WINDOW_ID));
  502. ClassDB::bind_method(D_METHOD("window_set_min_size", "min_size", "window_id"), &DisplayServer::window_set_min_size, DEFVAL(MAIN_WINDOW_ID));
  503. ClassDB::bind_method(D_METHOD("window_get_real_size", "window_id"), &DisplayServer::window_get_real_size, DEFVAL(MAIN_WINDOW_ID));
  504. ClassDB::bind_method(D_METHOD("window_get_mode", "window_id"), &DisplayServer::window_get_mode, DEFVAL(MAIN_WINDOW_ID));
  505. ClassDB::bind_method(D_METHOD("window_set_mode", "mode", "window_id"), &DisplayServer::window_set_mode, DEFVAL(MAIN_WINDOW_ID));
  506. ClassDB::bind_method(D_METHOD("window_set_flag", "flag", "enabled", "window_id"), &DisplayServer::window_set_flag, DEFVAL(MAIN_WINDOW_ID));
  507. ClassDB::bind_method(D_METHOD("window_get_flag", "flag", "window_id"), &DisplayServer::window_get_flag, DEFVAL(MAIN_WINDOW_ID));
  508. ClassDB::bind_method(D_METHOD("window_request_attention", "window_id"), &DisplayServer::window_request_attention, DEFVAL(MAIN_WINDOW_ID));
  509. ClassDB::bind_method(D_METHOD("window_move_to_foreground", "window_id"), &DisplayServer::window_move_to_foreground, DEFVAL(MAIN_WINDOW_ID));
  510. ClassDB::bind_method(D_METHOD("window_can_draw", "window_id"), &DisplayServer::window_can_draw, DEFVAL(MAIN_WINDOW_ID));
  511. ClassDB::bind_method(D_METHOD("window_set_transient", "window_id", "parent_window_id"), &DisplayServer::window_set_transient);
  512. ClassDB::bind_method(D_METHOD("window_set_exclusive", "window_id", "exclusive"), &DisplayServer::window_set_exclusive);
  513. ClassDB::bind_method(D_METHOD("window_set_ime_active", "active", "window_id"), &DisplayServer::window_set_ime_active, DEFVAL(MAIN_WINDOW_ID));
  514. ClassDB::bind_method(D_METHOD("window_set_ime_position", "position", "window_id"), &DisplayServer::window_set_ime_position, DEFVAL(MAIN_WINDOW_ID));
  515. ClassDB::bind_method(D_METHOD("window_set_vsync_mode", "vsync_mode", "window_id"), &DisplayServer::window_set_vsync_mode, DEFVAL(MAIN_WINDOW_ID));
  516. ClassDB::bind_method(D_METHOD("window_get_vsync_mode", "window_id"), &DisplayServer::window_get_vsync_mode, DEFVAL(MAIN_WINDOW_ID));
  517. ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
  518. ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
  519. ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "multiline", "max_length", "cursor_start", "cursor_end"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2()), DEFVAL(false), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1));
  520. ClassDB::bind_method(D_METHOD("virtual_keyboard_hide"), &DisplayServer::virtual_keyboard_hide);
  521. ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
  522. ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
  523. ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
  524. ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
  525. ClassDB::bind_method(D_METHOD("get_swap_cancel_ok"), &DisplayServer::get_swap_cancel_ok);
  526. ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);
  527. ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show);
  528. ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_input_text);
  529. ClassDB::bind_method(D_METHOD("keyboard_get_layout_count"), &DisplayServer::keyboard_get_layout_count);
  530. ClassDB::bind_method(D_METHOD("keyboard_get_current_layout"), &DisplayServer::keyboard_get_current_layout);
  531. ClassDB::bind_method(D_METHOD("keyboard_set_current_layout", "index"), &DisplayServer::keyboard_set_current_layout);
  532. ClassDB::bind_method(D_METHOD("keyboard_get_layout_language", "index"), &DisplayServer::keyboard_get_layout_language);
  533. ClassDB::bind_method(D_METHOD("keyboard_get_layout_name", "index"), &DisplayServer::keyboard_get_layout_name);
  534. ClassDB::bind_method(D_METHOD("keyboard_get_keycode_from_physical", "keycode"), &DisplayServer::keyboard_get_keycode_from_physical);
  535. ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
  536. ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
  537. ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &DisplayServer::set_native_icon);
  538. ClassDB::bind_method(D_METHOD("set_icon", "image"), &DisplayServer::set_icon);
  539. ClassDB::bind_method(D_METHOD("tablet_get_driver_count"), &DisplayServer::tablet_get_driver_count);
  540. ClassDB::bind_method(D_METHOD("tablet_get_driver_name", "idx"), &DisplayServer::tablet_get_driver_name);
  541. ClassDB::bind_method(D_METHOD("tablet_get_current_driver"), &DisplayServer::tablet_get_current_driver);
  542. ClassDB::bind_method(D_METHOD("tablet_set_current_driver", "name"), &DisplayServer::tablet_set_current_driver);
  543. BIND_ENUM_CONSTANT(FEATURE_GLOBAL_MENU);
  544. BIND_ENUM_CONSTANT(FEATURE_SUBWINDOWS);
  545. BIND_ENUM_CONSTANT(FEATURE_TOUCHSCREEN);
  546. BIND_ENUM_CONSTANT(FEATURE_MOUSE);
  547. BIND_ENUM_CONSTANT(FEATURE_MOUSE_WARP);
  548. BIND_ENUM_CONSTANT(FEATURE_CLIPBOARD);
  549. BIND_ENUM_CONSTANT(FEATURE_VIRTUAL_KEYBOARD);
  550. BIND_ENUM_CONSTANT(FEATURE_CURSOR_SHAPE);
  551. BIND_ENUM_CONSTANT(FEATURE_CUSTOM_CURSOR_SHAPE);
  552. BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG);
  553. BIND_ENUM_CONSTANT(FEATURE_IME);
  554. BIND_ENUM_CONSTANT(FEATURE_WINDOW_TRANSPARENCY);
  555. BIND_ENUM_CONSTANT(FEATURE_HIDPI);
  556. BIND_ENUM_CONSTANT(FEATURE_ICON);
  557. BIND_ENUM_CONSTANT(FEATURE_NATIVE_ICON);
  558. BIND_ENUM_CONSTANT(FEATURE_ORIENTATION);
  559. BIND_ENUM_CONSTANT(FEATURE_SWAP_BUFFERS);
  560. BIND_ENUM_CONSTANT(FEATURE_CLIPBOARD_PRIMARY);
  561. BIND_ENUM_CONSTANT(FEATURE_TEXT_TO_SPEECH);
  562. BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
  563. BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
  564. BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
  565. BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
  566. BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED_HIDDEN);
  567. BIND_CONSTANT(SCREEN_OF_MAIN_WINDOW);
  568. BIND_CONSTANT(MAIN_WINDOW_ID);
  569. BIND_CONSTANT(INVALID_WINDOW_ID);
  570. BIND_ENUM_CONSTANT(SCREEN_LANDSCAPE);
  571. BIND_ENUM_CONSTANT(SCREEN_PORTRAIT);
  572. BIND_ENUM_CONSTANT(SCREEN_REVERSE_LANDSCAPE);
  573. BIND_ENUM_CONSTANT(SCREEN_REVERSE_PORTRAIT);
  574. BIND_ENUM_CONSTANT(SCREEN_SENSOR_LANDSCAPE);
  575. BIND_ENUM_CONSTANT(SCREEN_SENSOR_PORTRAIT);
  576. BIND_ENUM_CONSTANT(SCREEN_SENSOR);
  577. BIND_ENUM_CONSTANT(CURSOR_ARROW);
  578. BIND_ENUM_CONSTANT(CURSOR_IBEAM);
  579. BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
  580. BIND_ENUM_CONSTANT(CURSOR_CROSS);
  581. BIND_ENUM_CONSTANT(CURSOR_WAIT);
  582. BIND_ENUM_CONSTANT(CURSOR_BUSY);
  583. BIND_ENUM_CONSTANT(CURSOR_DRAG);
  584. BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
  585. BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
  586. BIND_ENUM_CONSTANT(CURSOR_VSIZE);
  587. BIND_ENUM_CONSTANT(CURSOR_HSIZE);
  588. BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
  589. BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
  590. BIND_ENUM_CONSTANT(CURSOR_MOVE);
  591. BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
  592. BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
  593. BIND_ENUM_CONSTANT(CURSOR_HELP);
  594. BIND_ENUM_CONSTANT(CURSOR_MAX);
  595. BIND_ENUM_CONSTANT(WINDOW_MODE_WINDOWED);
  596. BIND_ENUM_CONSTANT(WINDOW_MODE_MINIMIZED);
  597. BIND_ENUM_CONSTANT(WINDOW_MODE_MAXIMIZED);
  598. BIND_ENUM_CONSTANT(WINDOW_MODE_FULLSCREEN);
  599. BIND_ENUM_CONSTANT(WINDOW_MODE_EXCLUSIVE_FULLSCREEN);
  600. BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED);
  601. BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS);
  602. BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP);
  603. BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT);
  604. BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS);
  605. BIND_ENUM_CONSTANT(WINDOW_FLAG_POPUP);
  606. BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
  607. BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);
  608. BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_EXIT);
  609. BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_IN);
  610. BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_OUT);
  611. BIND_ENUM_CONSTANT(WINDOW_EVENT_CLOSE_REQUEST);
  612. BIND_ENUM_CONSTANT(WINDOW_EVENT_GO_BACK_REQUEST);
  613. BIND_ENUM_CONSTANT(WINDOW_EVENT_DPI_CHANGE);
  614. BIND_ENUM_CONSTANT(VSYNC_DISABLED);
  615. BIND_ENUM_CONSTANT(VSYNC_ENABLED);
  616. BIND_ENUM_CONSTANT(VSYNC_ADAPTIVE);
  617. BIND_ENUM_CONSTANT(VSYNC_MAILBOX);
  618. BIND_ENUM_CONSTANT(DISPLAY_HANDLE);
  619. BIND_ENUM_CONSTANT(WINDOW_HANDLE);
  620. BIND_ENUM_CONSTANT(WINDOW_VIEW);
  621. BIND_ENUM_CONSTANT(TTS_UTTERANCE_STARTED);
  622. BIND_ENUM_CONSTANT(TTS_UTTERANCE_ENDED);
  623. BIND_ENUM_CONSTANT(TTS_UTTERANCE_CANCELED);
  624. BIND_ENUM_CONSTANT(TTS_UTTERANCE_BOUNDARY);
  625. }
  626. void DisplayServer::register_create_function(const char *p_name, CreateFunction p_function, GetRenderingDriversFunction p_get_drivers) {
  627. ERR_FAIL_COND(server_create_count == MAX_SERVERS);
  628. // Headless display server is always last
  629. server_create_functions[server_create_count] = server_create_functions[server_create_count - 1];
  630. server_create_functions[server_create_count - 1].name = p_name;
  631. server_create_functions[server_create_count - 1].create_function = p_function;
  632. server_create_functions[server_create_count - 1].get_rendering_drivers_function = p_get_drivers;
  633. server_create_count++;
  634. }
  635. int DisplayServer::get_create_function_count() {
  636. return server_create_count;
  637. }
  638. const char *DisplayServer::get_create_function_name(int p_index) {
  639. ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
  640. return server_create_functions[p_index].name;
  641. }
  642. Vector<String> DisplayServer::get_create_function_rendering_drivers(int p_index) {
  643. ERR_FAIL_INDEX_V(p_index, server_create_count, Vector<String>());
  644. return server_create_functions[p_index].get_rendering_drivers_function();
  645. }
  646. DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
  647. ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
  648. return server_create_functions[p_index].create_function(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error);
  649. }
  650. void DisplayServer::_input_set_mouse_mode(Input::MouseMode p_mode) {
  651. singleton->mouse_set_mode(MouseMode(p_mode));
  652. }
  653. Input::MouseMode DisplayServer::_input_get_mouse_mode() {
  654. return Input::MouseMode(singleton->mouse_get_mode());
  655. }
  656. void DisplayServer::_input_warp(const Vector2 &p_to_pos) {
  657. singleton->warp_mouse(p_to_pos);
  658. }
  659. Input::CursorShape DisplayServer::_input_get_current_cursor_shape() {
  660. return (Input::CursorShape)singleton->cursor_get_shape();
  661. }
  662. void DisplayServer::_input_set_custom_mouse_cursor_func(const Ref<Resource> &p_image, Input::CursorShape p_shape, const Vector2 &p_hostspot) {
  663. singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot);
  664. }
  665. DisplayServer::DisplayServer() {
  666. singleton = this;
  667. Input::set_mouse_mode_func = _input_set_mouse_mode;
  668. Input::get_mouse_mode_func = _input_get_mouse_mode;
  669. Input::warp_mouse_func = _input_warp;
  670. Input::get_current_cursor_shape_func = _input_get_current_cursor_shape;
  671. Input::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func;
  672. }
  673. DisplayServer::~DisplayServer() {
  674. singleton = nullptr;
  675. }