diff options
Diffstat (limited to 'servers/display_server.cpp')
-rw-r--r-- | servers/display_server.cpp | 92 |
1 files changed, 65 insertions, 27 deletions
diff --git a/servers/display_server.cpp b/servers/display_server.cpp index da1a68a179..0ea11a2670 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -30,7 +30,7 @@ #include "display_server.h" -#include "core/input/input_filter.h" +#include "core/input/input.h" #include "scene/resources/texture.h" DisplayServer *DisplayServer::singleton = nullptr; @@ -127,6 +127,7 @@ void DisplayServer::global_menu_clear(const String &p_menu_root) { void DisplayServer::mouse_set_mode(MouseMode p_mode) { WARN_PRINT("Mouse is not supported by this display server."); } + DisplayServer::MouseMode DisplayServer::mouse_get_mode() const { return MOUSE_MODE_VISIBLE; } @@ -134,12 +135,15 @@ DisplayServer::MouseMode DisplayServer::mouse_get_mode() const { void DisplayServer::mouse_warp_to_position(const Point2i &p_to) { WARN_PRINT("Mouse warping is not supported by this display server."); } + Point2i DisplayServer::mouse_get_absolute_position() const { ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server."); } + Point2i DisplayServer::mouse_get_position() const { ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server."); } + int DisplayServer::mouse_get_button_state() const { ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server."); } @@ -147,6 +151,7 @@ int DisplayServer::mouse_get_button_state() const { void DisplayServer::clipboard_set(const String &p_text) { WARN_PRINT("Clipboard is not supported by this display server."); } + String DisplayServer::clipboard_get() const { ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server."); } @@ -154,6 +159,7 @@ String DisplayServer::clipboard_get() const { void DisplayServer::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) { WARN_PRINT("Orientation not supported by this display server."); } + DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_screen) const { return SCREEN_LANDSCAPE; } @@ -164,12 +170,13 @@ float DisplayServer::screen_get_scale(int p_screen) const { bool DisplayServer::screen_is_touchscreen(int p_screen) const { //return false; - return InputFilter::get_singleton() && InputFilter::get_singleton()->is_emulating_touch_from_mouse(); + return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse(); } void DisplayServer::screen_set_keep_on(bool p_enable) { WARN_PRINT("Keeping screen on not supported by this display server."); } + bool DisplayServer::screen_is_kept_on() const { return false; } @@ -177,6 +184,7 @@ bool DisplayServer::screen_is_kept_on() const { DisplayServer::WindowID DisplayServer::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &) { ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Sub-windows not supported by this display server."); } + void DisplayServer::delete_sub_window(WindowID p_id) { ERR_FAIL_MSG("Sub-windows not supported by this display server."); } @@ -184,6 +192,7 @@ void DisplayServer::delete_sub_window(WindowID p_id) { void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) { WARN_PRINT("IME not supported by this display server."); } + void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_window) { WARN_PRINT("IME not supported by this display server."); } @@ -191,6 +200,7 @@ void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_win Point2i DisplayServer::ime_get_selection() const { ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server."); } + String DisplayServer::ime_get_text() const { ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server."); } @@ -198,13 +208,15 @@ String DisplayServer::ime_get_text() const { void DisplayServer::console_set_visible(bool p_enabled) { WARN_PRINT("Console window not supported by this display server."); } + bool DisplayServer::is_console_visible() const { return false; } -void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_legth) { +void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_length, int p_cursor_start, int p_cursor_end) { WARN_PRINT("Virtual keyboard not supported by this display server."); } + void DisplayServer::virtual_keyboard_hide() { WARN_PRINT("Virtual keyboard not supported by this display server."); } @@ -217,9 +229,11 @@ int DisplayServer::virtual_keyboard_get_height() const { void DisplayServer::cursor_set_shape(CursorShape p_shape) { WARN_PRINT("Cursor shape not supported by this display server."); } + DisplayServer::CursorShape DisplayServer::cursor_get_shape() const { return CURSOR_ARROW; } + void DisplayServer::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { WARN_PRINT("Custom cursor shape not supported by this display server."); } @@ -235,15 +249,19 @@ void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) { Error DisplayServer::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen) { ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Native video not supported by this display server."); } + bool DisplayServer::native_video_is_playing() const { return false; } + void DisplayServer::native_video_pause() { WARN_PRINT("Native video not supported by this display server."); } + void DisplayServer::native_video_unpause() { WARN_PRINT("Native video not supported by this display server."); } + void DisplayServer::native_video_stop() { WARN_PRINT("Native video not supported by this display server."); } @@ -252,13 +270,29 @@ Error DisplayServer::dialog_show(String p_title, String p_description, Vector<St WARN_PRINT("Native dialogs not supported by this display server."); return OK; } + Error DisplayServer::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) { WARN_PRINT("Native dialogs not supported by this display server."); return OK; } -DisplayServer::LatinKeyboardVariant DisplayServer::get_latin_keyboard_variant() const { - return LATIN_KEYBOARD_QWERTY; +int DisplayServer::keyboard_get_layout_count() const { + return 0; +} + +int DisplayServer::keyboard_get_current_layout() const { + return -1; +} + +void DisplayServer::keyboard_set_current_layout(int p_index) { +} + +String DisplayServer::keyboard_get_layout_language(int p_index) const { + return ""; +} + +String DisplayServer::keyboard_get_layout_name(int p_index) const { + return "Not supported"; } void DisplayServer::force_process_and_drop_events() { @@ -267,9 +301,11 @@ void DisplayServer::force_process_and_drop_events() { void DisplayServer::release_rendering_thread() { WARN_PRINT("Rendering thread not supported by this display server."); } + void DisplayServer::make_rendering_thread() { WARN_PRINT("Rendering thread not supported by this display server."); } + void DisplayServer::swap_buffers() { WARN_PRINT("Swap buffers not supported by this display server."); } @@ -277,6 +313,7 @@ void DisplayServer::swap_buffers() { void DisplayServer::set_native_icon(const String &p_filename) { WARN_PRINT("Native icon not supported by this display server."); } + void DisplayServer::set_icon(const Ref<Image> &p_icon) { WARN_PRINT("Icon not supported by this display server."); } @@ -284,6 +321,7 @@ void DisplayServer::set_icon(const Ref<Image> &p_icon) { void DisplayServer::_set_use_vsync(bool p_enable) { WARN_PRINT("VSync not supported by this display server."); } + void DisplayServer::vsync_set_enabled(bool p_enable) { vsync_enabled = p_enable; if (switch_vsync_function) { //if a function was set, use function @@ -292,6 +330,7 @@ void DisplayServer::vsync_set_enabled(bool p_enable) { _set_use_vsync(p_enable); } } + bool DisplayServer::vsync_is_enabled() const { return vsync_enabled; } @@ -299,6 +338,7 @@ bool DisplayServer::vsync_is_enabled() const { void DisplayServer::vsync_set_use_via_compositor(bool p_enable) { WARN_PRINT("VSync via compositor not supported by this display server."); } + bool DisplayServer::vsync_is_using_via_compositor() const { return false; } @@ -307,7 +347,6 @@ void DisplayServer::set_context(Context p_context) { } void DisplayServer::_bind_methods() { - ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature); ClassDB::bind_method(D_METHOD("get_name"), &DisplayServer::get_name); @@ -415,7 +454,7 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("console_set_visible", "console_visible"), &DisplayServer::console_set_visible); ClassDB::bind_method(D_METHOD("is_console_visible"), &DisplayServer::is_console_visible); - ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "max_length"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "max_length", "cursor_start", "cursor_end"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("virtual_keyboard_hide"), &DisplayServer::virtual_keyboard_hide); ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height); @@ -437,7 +476,11 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show); ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_input_text); - ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant); + ClassDB::bind_method(D_METHOD("keyboard_get_layout_count"), &DisplayServer::keyboard_get_layout_count); + ClassDB::bind_method(D_METHOD("keyboard_get_current_layout"), &DisplayServer::keyboard_get_current_layout); + ClassDB::bind_method(D_METHOD("keyboard_set_current_layout", "index"), &DisplayServer::keyboard_set_current_layout); + ClassDB::bind_method(D_METHOD("keyboard_get_layout_language", "index"), &DisplayServer::keyboard_get_layout_language); + ClassDB::bind_method(D_METHOD("keyboard_get_layout_name", "index"), &DisplayServer::keyboard_get_layout_name); ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events); ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events); @@ -519,14 +562,6 @@ void DisplayServer::_bind_methods() { BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS); BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTY); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTZ); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_AZERTY); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QZERTY); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_DVORAK); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_NEO); - BIND_ENUM_CONSTANT(LATIN_KEYBOARD_COLEMAK); - BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER); BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_EXIT); BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_IN); @@ -563,31 +598,34 @@ DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driv return server_create_functions[p_index].create_function(p_rendering_driver, p_mode, p_flags, p_resolution, r_error); } -void DisplayServer::_input_set_mouse_mode(InputFilter::MouseMode p_mode) { +void DisplayServer::_input_set_mouse_mode(Input::MouseMode p_mode) { singleton->mouse_set_mode(MouseMode(p_mode)); } -InputFilter::MouseMode DisplayServer::_input_get_mouse_mode() { - return InputFilter::MouseMode(singleton->mouse_get_mode()); + +Input::MouseMode DisplayServer::_input_get_mouse_mode() { + return Input::MouseMode(singleton->mouse_get_mode()); } void DisplayServer::_input_warp(const Vector2 &p_to_pos) { singleton->mouse_warp_to_position(p_to_pos); } -InputFilter::CursorShape DisplayServer::_input_get_current_cursor_shape() { - return (InputFilter::CursorShape)singleton->cursor_get_shape(); +Input::CursorShape DisplayServer::_input_get_current_cursor_shape() { + return (Input::CursorShape)singleton->cursor_get_shape(); } -void DisplayServer::_input_set_custom_mouse_cursor_func(const RES &p_image, InputFilter::CursorShape p_shape, const Vector2 &p_hostspot) { + +void DisplayServer::_input_set_custom_mouse_cursor_func(const RES &p_image, Input::CursorShape p_shape, const Vector2 &p_hostspot) { singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot); } DisplayServer::DisplayServer() { singleton = this; - InputFilter::set_mouse_mode_func = _input_set_mouse_mode; - InputFilter::get_mouse_mode_func = _input_get_mouse_mode; - InputFilter::warp_mouse_func = _input_warp; - InputFilter::get_current_cursor_shape_func = _input_get_current_cursor_shape; - InputFilter::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func; + Input::set_mouse_mode_func = _input_set_mouse_mode; + Input::get_mouse_mode_func = _input_get_mouse_mode; + Input::warp_mouse_func = _input_warp; + Input::get_current_cursor_shape_func = _input_get_current_cursor_shape; + Input::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func; } + DisplayServer::~DisplayServer() { } |