display_server.cpp 48 KB

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