display_server.cpp 47 KB

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