display_server.cpp 52 KB

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