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