DisplayServer

Inherits: Object

Methods

String

clipboard_get ( ) const

String

clipboard_get_primary ( ) const

bool

clipboard_has ( ) const

void

clipboard_set ( String clipboard )

void

clipboard_set_primary ( String clipboard_primary )

int

create_sub_window ( WindowMode mode, VSyncMode vsync_mode, int flags, Rect2i rect=Rect2i(0, 0, 0, 0) )

CursorShape

cursor_get_shape ( ) const

void

cursor_set_custom_image ( Resource cursor, CursorShape shape=0, Vector2 hotspot=Vector2(0, 0) )

void

cursor_set_shape ( CursorShape shape )

void

delete_sub_window ( int window_id )

Error

dialog_input_text ( String title, String description, String existing_text, Callable callback )

Error

dialog_show ( String title, String description, PackedStringArray buttons, Callable callback )

void

enable_for_stealing_focus ( int process_id )

void

force_process_and_drop_events ( )

Color

get_accent_color ( ) const

Rect2[]

get_display_cutouts ( ) const

Rect2i

get_display_safe_area ( ) const

String

get_name ( ) const

int

get_screen_count ( ) const

bool

get_swap_cancel_ok ( )

int

get_window_at_screen_position ( Vector2i position ) const

PackedInt32Array

get_window_list ( ) const

int

global_menu_add_check_item ( String menu_root, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_icon_check_item ( String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_icon_item ( String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_icon_radio_check_item ( String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_item ( String menu_root, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_multistate_item ( String menu_root, String labe, int max_states, int default_state, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_radio_check_item ( String menu_root, String label, Callable callback, Callable key_callback, Variant tag=null, Key accelerator=0, int index=-1 )

int

global_menu_add_separator ( String menu_root, int index=-1 )

int

global_menu_add_submenu_item ( String menu_root, String label, String submenu, int index=-1 )

void

global_menu_clear ( String menu_root )

Key

global_menu_get_item_accelerator ( String menu_root, int idx ) const

Callable

global_menu_get_item_callback ( String menu_root, int idx ) const

Texture2D

global_menu_get_item_icon ( String menu_root, int idx ) const

int

global_menu_get_item_indentation_level ( String menu_root, int idx ) const

int

global_menu_get_item_index_from_tag ( String menu_root, Variant tag ) const

int

global_menu_get_item_index_from_text ( String menu_root, String text ) const

Callable

global_menu_get_item_key_callback ( String menu_root, int idx ) const

int

global_menu_get_item_max_states ( String menu_root, int idx ) const

int

global_menu_get_item_state ( String menu_root, int idx ) const

String

global_menu_get_item_submenu ( String menu_root, int idx ) const

Variant

global_menu_get_item_tag ( String menu_root, int idx ) const

String

global_menu_get_item_text ( String menu_root, int idx ) const

String

global_menu_get_item_tooltip ( String menu_root, int idx ) const

bool

global_menu_is_item_checkable ( String menu_root, int idx ) const

bool

global_menu_is_item_checked ( String menu_root, int idx ) const

bool

global_menu_is_item_disabled ( String menu_root, int idx ) const

bool

global_menu_is_item_radio_checkable ( String menu_root, int idx ) const

void

global_menu_remove_item ( String menu_root, int idx )

void

global_menu_set_item_accelerator ( String menu_root, int idx, Key keycode )

void

global_menu_set_item_callback ( String menu_root, int idx, Callable callback )

void

global_menu_set_item_checkable ( String menu_root, int idx, bool checkable )

void

global_menu_set_item_checked ( String menu_root, int idx, bool checked )

void

global_menu_set_item_disabled ( String menu_root, int idx, bool disabled )

void

global_menu_set_item_icon ( String menu_root, int idx, Texture2D icon )

void

global_menu_set_item_indentation_level ( String menu_root, int idx, int level )

void

global_menu_set_item_key_callback ( String menu_root, int idx, Callable key_callback )

void

global_menu_set_item_max_states ( String menu_root, int idx, int max_states )

void

global_menu_set_item_radio_checkable ( String menu_root, int idx, bool checkable )

void

global_menu_set_item_state ( String menu_root, int idx, int state )

void

global_menu_set_item_submenu ( String menu_root, int idx, String submenu )

void

global_menu_set_item_tag ( String menu_root, int idx, Variant tag )

void

global_menu_set_item_text ( String menu_root, int idx, String text )

void

global_menu_set_item_tooltip ( String menu_root, int idx, String tooltip )

bool

has_feature ( Feature feature ) const

Vector2i

ime_get_selection ( ) const

String

ime_get_text ( ) const

bool

is_dark_mode ( ) const

bool

is_dark_mode_supported ( ) const

int

keyboard_get_current_layout ( ) const

Key

keyboard_get_keycode_from_physical ( Key keycode ) const

int

keyboard_get_layout_count ( ) const

String

keyboard_get_layout_language ( int index ) const

String

keyboard_get_layout_name ( int index ) const

void

keyboard_set_current_layout ( int index )

MouseButton

mouse_get_button_state ( ) const

MouseMode

mouse_get_mode ( ) const

Vector2i

mouse_get_position ( ) const

void

mouse_set_mode ( MouseMode mouse_mode )

void

process_events ( )

int

screen_get_dpi ( int screen=-1 ) const

float

screen_get_max_scale ( ) const

ScreenOrientation

screen_get_orientation ( int screen=-1 ) const

Vector2i

screen_get_position ( int screen=-1 ) const

float

screen_get_refresh_rate ( int screen=-1 ) const

float

screen_get_scale ( int screen=-1 ) const

Vector2i

screen_get_size ( int screen=-1 ) const

Rect2i

screen_get_usable_rect ( int screen=-1 ) const

bool

screen_is_kept_on ( ) const

bool

screen_is_touchscreen ( int screen=-1 ) const

void

screen_set_keep_on ( bool enable )

void

screen_set_orientation ( ScreenOrientation orientation, int screen=-1 )

void

set_icon ( Image image )

void

set_native_icon ( String filename )

String

tablet_get_current_driver ( ) const

int

tablet_get_driver_count ( ) const

String

tablet_get_driver_name ( int idx ) const

void

tablet_set_current_driver ( String name )

Dictionary[]

tts_get_voices ( ) const

PackedStringArray

tts_get_voices_for_language ( String language ) const

bool

tts_is_paused ( ) const

bool

tts_is_speaking ( ) const

void

tts_pause ( )

void

tts_resume ( )

void

tts_set_utterance_callback ( TTSUtteranceEvent event, Callable callable )

void

tts_speak ( String text, String voice, int volume=50, float pitch=1.0, float rate=1.0, int utterance_id=0, bool interrupt=false )

void

tts_stop ( )

int

virtual_keyboard_get_height ( ) const

void

virtual_keyboard_hide ( )

void

virtual_keyboard_show ( String existing_text, Rect2 position=Rect2(0, 0, 0, 0), VirtualKeyboardType type=0, int max_length=-1, int cursor_start=-1, int cursor_end=-1 )

void

warp_mouse ( Vector2i position )

void

window_attach_instance_id ( int instance_id, int window_id=0 )

bool

window_can_draw ( int window_id=0 ) const

int

window_get_active_popup ( ) const

int

window_get_attached_instance_id ( int window_id=0 ) const

int

window_get_current_screen ( int window_id=0 ) const

bool

window_get_flag ( WindowFlags flag, int window_id=0 ) const

Vector2i

window_get_max_size ( int window_id=0 ) const

Vector2i

window_get_min_size ( int window_id=0 ) const

WindowMode

window_get_mode ( int window_id=0 ) const

int

window_get_native_handle ( HandleType handle_type, int window_id=0 ) const

Rect2i

window_get_popup_safe_rect ( int window ) const

Vector2i

window_get_position ( int window_id=0 ) const

Vector2i

window_get_real_size ( int window_id=0 ) const

Vector2i

window_get_safe_title_margins ( int window_id=0 ) const

Vector2i

window_get_size ( int window_id=0 ) const

VSyncMode

window_get_vsync_mode ( int window_id=0 ) const

bool

window_maximize_on_title_dbl_click ( ) const

bool

window_minimize_on_title_dbl_click ( ) const

void

window_move_to_foreground ( int window_id=0 )

void

window_request_attention ( int window_id=0 )

void

window_set_current_screen ( int screen, int window_id=0 )

void

window_set_drop_files_callback ( Callable callback, int window_id=0 )

void

window_set_exclusive ( int window_id, bool exclusive )

void

window_set_flag ( WindowFlags flag, bool enabled, int window_id=0 )

void

window_set_ime_active ( bool active, int window_id=0 )

void

window_set_ime_position ( Vector2i position, int window_id=0 )

void

window_set_input_event_callback ( Callable callback, int window_id=0 )

void

window_set_input_text_callback ( Callable callback, int window_id=0 )

void

window_set_max_size ( Vector2i max_size, int window_id=0 )

void

window_set_min_size ( Vector2i min_size, int window_id=0 )

void

window_set_mode ( WindowMode mode, int window_id=0 )

void

window_set_mouse_passthrough ( PackedVector2Array region, int window_id=0 )

void

window_set_popup_safe_rect ( int window, Rect2i rect )

void

window_set_position ( Vector2i position, int window_id=0 )

void

window_set_rect_changed_callback ( Callable callback, int window_id=0 )

void

window_set_size ( Vector2i size, int window_id=0 )

void

window_set_title ( String title, int window_id=0 )

void

window_set_transient ( int window_id, int parent_window_id )

void

window_set_vsync_mode ( VSyncMode vsync_mode, int window_id=0 )

void

window_set_window_event_callback ( Callable callback, int window_id=0 )

Enumerations

enum Feature:

  • FEATURE_GLOBAL_MENU = 0

  • FEATURE_SUBWINDOWS = 1

  • FEATURE_TOUCHSCREEN = 2

  • FEATURE_MOUSE = 3

  • FEATURE_MOUSE_WARP = 4

  • FEATURE_CLIPBOARD = 5

  • FEATURE_VIRTUAL_KEYBOARD = 6

  • FEATURE_CURSOR_SHAPE = 7

  • FEATURE_CUSTOM_CURSOR_SHAPE = 8

  • FEATURE_NATIVE_DIALOG = 9

  • FEATURE_IME = 10

  • FEATURE_WINDOW_TRANSPARENCY = 11

  • FEATURE_HIDPI = 12

  • FEATURE_ICON = 13

  • FEATURE_NATIVE_ICON = 14

  • FEATURE_ORIENTATION = 15

  • FEATURE_SWAP_BUFFERS = 16

  • FEATURE_CLIPBOARD_PRIMARY = 18

  • FEATURE_TEXT_TO_SPEECH = 19 --- Display server supports text-to-speech. See tts_* methods.

  • FEATURE_EXTEND_TO_TITLE = 20 --- Display server supports expanding window content to the title. See WINDOW_FLAG_EXTEND_TO_TITLE.


enum MouseMode:

  • MOUSE_MODE_VISIBLE = 0 --- Makes the mouse cursor visible if it is hidden.

  • MOUSE_MODE_HIDDEN = 1 --- Makes the mouse cursor hidden if it is visible.

  • MOUSE_MODE_CAPTURED = 2 --- Captures the mouse. The mouse will be hidden and its position locked at the center of the screen.

Note: If you want to process the mouse's movement in this mode, you need to use InputEventMouseMotion.relative.

  • MOUSE_MODE_CONFINED = 3 --- Confines the mouse cursor to the game window, and make it visible.

  • MOUSE_MODE_CONFINED_HIDDEN = 4 --- Confines the mouse cursor to the game window, and make it hidden.


enum ScreenOrientation:

  • SCREEN_LANDSCAPE = 0

  • SCREEN_PORTRAIT = 1

  • SCREEN_REVERSE_LANDSCAPE = 2

  • SCREEN_REVERSE_PORTRAIT = 3

  • SCREEN_SENSOR_LANDSCAPE = 4

  • SCREEN_SENSOR_PORTRAIT = 5

  • SCREEN_SENSOR = 6


enum VirtualKeyboardType:

  • KEYBOARD_TYPE_DEFAULT = 0 --- Default text virtual keyboard.

  • KEYBOARD_TYPE_MULTILINE = 1 --- Multiline virtual keyboard.

  • KEYBOARD_TYPE_NUMBER = 2 --- Virtual number keypad, useful for PIN entry.

  • KEYBOARD_TYPE_NUMBER_DECIMAL = 3 --- Virtual number keypad, useful for entering fractional numbers.

  • KEYBOARD_TYPE_PHONE = 4 --- Virtual phone number keypad.

  • KEYBOARD_TYPE_EMAIL_ADDRESS = 5 --- Virtual keyboard with additional keys to assist with typing email addresses.

  • KEYBOARD_TYPE_PASSWORD = 6 --- Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.

Note: This is not supported on Web. Instead, this behaves identically to KEYBOARD_TYPE_DEFAULT.

  • KEYBOARD_TYPE_URL = 7 --- Virtual keyboard with additional keys to assist with typing URLs.


enum CursorShape:

  • CURSOR_ARROW = 0

  • CURSOR_IBEAM = 1

  • CURSOR_POINTING_HAND = 2

  • CURSOR_CROSS = 3

  • CURSOR_WAIT = 4

  • CURSOR_BUSY = 5

  • CURSOR_DRAG = 6

  • CURSOR_CAN_DROP = 7

  • CURSOR_FORBIDDEN = 8

  • CURSOR_VSIZE = 9

  • CURSOR_HSIZE = 10

  • CURSOR_BDIAGSIZE = 11

  • CURSOR_FDIAGSIZE = 12

  • CURSOR_MOVE = 13

  • CURSOR_VSPLIT = 14

  • CURSOR_HSPLIT = 15

  • CURSOR_HELP = 16

  • CURSOR_MAX = 17


enum WindowMode:

  • WINDOW_MODE_WINDOWED = 0

  • WINDOW_MODE_MINIMIZED = 1

  • WINDOW_MODE_MAXIMIZED = 2

  • WINDOW_MODE_FULLSCREEN = 3 --- Fullscreen window mode. Note that this is not exclusive fullscreen. On Windows and Linux, a borderless window is used to emulate fullscreen. On macOS, a new desktop is used to display the running project.

Regardless of the platform, enabling fullscreen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling fullscreen mode.

  • WINDOW_MODE_EXCLUSIVE_FULLSCREEN = 4 --- Exclusive fullscreen window mode. This mode is implemented on Windows only. On other platforms, it is equivalent to WINDOW_MODE_FULLSCREEN.

Only one window in exclusive fullscreen mode can be visible on a given screen at a time. If multiple windows are in exclusive fullscreen mode for the same screen, the last one being set to this mode takes precedence.

Regardless of the platform, enabling fullscreen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling fullscreen mode.


enum WindowFlags:

  • WINDOW_FLAG_RESIZE_DISABLED = 0 --- Window can't be resizing by dragging its resize grip. It's still possible to resize the window using window_set_size. This flag is ignored for full screen windows.

  • WINDOW_FLAG_BORDERLESS = 1 --- Window do not have native title bar and other decorations. This flag is ignored for full-screen windows.

  • WINDOW_FLAG_ALWAYS_ON_TOP = 2 --- Window is floating above other regular windows. This flag is ignored for full-screen windows.

  • WINDOW_FLAG_TRANSPARENT = 3 --- Window is will be destroyed with its transient parent and displayed on top of non-exclusive full-screen parent window. Transient windows can't enter full-screen mode.

  • WINDOW_FLAG_NO_FOCUS = 4 --- Window can't be focused. No-focus window will ignore all input, except mouse clicks.

  • WINDOW_FLAG_POPUP = 5 --- Window is part of menu or OptionButton dropdown. This flag can't be changed when window is visible. An active popup window will exclusively receive all input, without stealing focus from its parent. Popup windows are automatically closed when uses click outside it, or when an application is switched. Popup window must have WINDOW_FLAG_TRANSPARENT set.

  • WINDOW_FLAG_EXTEND_TO_TITLE = 6 --- Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons.

Note: This flag is implemented on macOS.

  • WINDOW_FLAG_MAX = 7


enum WindowEvent:

  • WINDOW_EVENT_MOUSE_ENTER = 0

  • WINDOW_EVENT_MOUSE_EXIT = 1

  • WINDOW_EVENT_FOCUS_IN = 2

  • WINDOW_EVENT_FOCUS_OUT = 3

  • WINDOW_EVENT_CLOSE_REQUEST = 4

  • WINDOW_EVENT_GO_BACK_REQUEST = 5

  • WINDOW_EVENT_DPI_CHANGE = 6


enum VSyncMode:

  • VSYNC_DISABLED = 0 --- No vertical synchronization, which means the engine will display frames as fast as possible (tearing may be visible).

  • VSYNC_ENABLED = 1 --- Default vertical synchronization mode, the image is displayed only on vertical blanking intervals (no tearing is visible).

  • VSYNC_ADAPTIVE = 2 --- Behaves like VSYNC_DISABLED when the framerate drops below the screen's refresh rate to reduce stuttering (tearing may be visible), otherwise vertical synchronization is enabled to avoid tearing.

  • VSYNC_MAILBOX = 3 --- Displays the most recent image in the queue on vertical blanking intervals, while rendering to the other images (no tearing is visible).

Although not guaranteed, the images can be rendered as fast as possible, which may reduce input lag.


enum HandleType:

  • DISPLAY_HANDLE = 0 --- Display handle:

    • Linux: X11::Display* for the display.

  • WINDOW_HANDLE = 1 --- Window handle:

    • Windows: HWND for the window.

    • Linux: X11::Window* for the window.

    • macOS: NSWindow* for the window.

    • iOS: UIViewController* for the view controller.

    • Android: jObject for the activity.

  • WINDOW_VIEW = 2 --- Window view:

    • macOS: NSView* for the window main view.

    • iOS: UIView* for the window main view.


enum TTSUtteranceEvent:

  • TTS_UTTERANCE_STARTED = 0 --- Utterance has begun to be spoken.

  • TTS_UTTERANCE_ENDED = 1 --- Utterance was successfully finished.

  • TTS_UTTERANCE_CANCELED = 2 --- Utterance was canceled, or TTS service was unable to process it.

  • TTS_UTTERANCE_BOUNDARY = 3 --- Utterance reached a word or sentence boundary.

Constants

  • SCREEN_OF_MAIN_WINDOW = -1

  • MAIN_WINDOW_ID = 0

  • INVALID_WINDOW_ID = -1

Method Descriptions

  • String clipboard_get ( ) const

Returns the user's clipboard as a string if possible.


  • String clipboard_get_primary ( ) const

Returns the user's primary clipboard as a string if possible.

Note: This method is only implemented on Linux.


  • bool clipboard_has ( ) const

Returns true if there is content on the user's clipboard.


  • void clipboard_set ( String clipboard )

Sets the user's clipboard content to the given string.


  • void clipboard_set_primary ( String clipboard_primary )

Sets the user's primary clipboard content to the given string.

Note: This method is only implemented on Linux.






  • void delete_sub_window ( int window_id )




  • void enable_for_stealing_focus ( int process_id )


  • void force_process_and_drop_events ( )


  • Color get_accent_color ( ) const

Returns OS theme accent color. Returns Color(0, 0, 0, 0), if accent color is unknown.

Note: This method is implemented on macOS and Windows.


  • Rect2[] get_display_cutouts ( ) const

Returns an Array of Rect2, each of which is the bounding rectangle for a display cutout or notch. These are non-functional areas on edge-to-edge screens used by cameras and sensors. Returns an empty array if the device does not have cutouts. See also get_display_safe_area.

Note: Currently only implemented on Android. Other platforms will return an empty array even if they do have display cutouts or notches.


  • Rect2i get_display_safe_area ( ) const

Returns the unobscured area of the display where interactive controls should be rendered. See also get_display_cutouts.



  • int get_screen_count ( ) const


  • bool get_swap_cancel_ok ( )


  • int get_window_at_screen_position ( Vector2i position ) const



Adds a new checkable item with text label to the global menu with ID menu_root.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).

Adds a new checkable item with text label and icon icon to the global menu with ID menu_root.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).

Adds a new item with text label and icon icon to the global menu with ID menu_root.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).

Adds a new radio-checkable item with text label and icon icon to the global menu with ID menu_root.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See global_menu_set_item_checked for more info on how to control it.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).

Adds a new item with text label to the global menu with ID menu_root.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).

Adds a new item with text labe to the global menu with ID menu_root.

Contrarily to normal binary items, multistate items can have more than two states, as defined by max_states. Each press or activate of the item will increase the state by one. The default value is defined by default_state.

Returns index of the inserted item, it's not guaranteed to be the same as index value.

Note: By default, there's no indication of the current item state, it should be changed manually.

Note: This method is implemented on macOS.

Supported system menu IDs:

"_main" - Main menu