summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-03-01 19:14:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-03-26 15:49:32 +0100
commit4396e98834f159da59ec790f2ff64fb65dacd9ce (patch)
treed618e96d7a7b856260fd96e5e727f38a26de0724 /servers
parenta2da99f40cf2123c0906c734a2eb01e9b65a45a2 (diff)
Refactored Input, create DisplayServer and DisplayServerX11
Diffstat (limited to 'servers')
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp2
-rw-r--r--servers/display_server.cpp374
-rw-r--r--servers/display_server.h273
-rw-r--r--servers/register_server_types.cpp3
4 files changed, 651 insertions, 1 deletions
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index a64e36b6a2..69d7c7a2d9 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "arvr_positional_tracker.h"
-#include "core/os/input.h"
+#include "core/input/input.h"
void ARVRPositionalTracker::_bind_methods() {
BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
new file mode 100644
index 0000000000..c3ecf302c3
--- /dev/null
+++ b/servers/display_server.cpp
@@ -0,0 +1,374 @@
+/*************************************************************************/
+/* display_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "display_server.h"
+
+DisplayServer *DisplayServer::singleton = nullptr;
+
+void DisplayServer::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+void DisplayServer::global_menu_add_separator(const String &p_menu) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+void DisplayServer::global_menu_remove_item(const String &p_menu, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+void DisplayServer::global_menu_clear(const String &p_menu) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+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;
+}
+
+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_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.");
+}
+
+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.");
+}
+
+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;
+}
+
+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.");
+}
+
+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.");
+}
+
+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.");
+}
+
+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) {
+ 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.");
+}
+
+// returns height of the currently shown keyboard (0 if keyboard is hidden)
+int DisplayServer::virtual_keyboard_get_height() const {
+ ERR_FAIL_V_MSG(0, "Virtual keyboad not supported by this display server.");
+}
+
+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.");
+}
+
+bool DisplayServer::get_swap_ok_cancel() {
+ return false;
+}
+
+void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
+}
+
+//plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
+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.");
+}
+
+Error DisplayServer::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
+ 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;
+}
+
+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.");
+}
+
+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("Iconnot supported by this display server.");
+}
+
+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);
+
+ ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu", "label", "id", "meta"), &DisplayServer::global_menu_add_item);
+ ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu"), &DisplayServer::global_menu_add_separator);
+ ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu", "idx"), &DisplayServer::global_menu_remove_item);
+ ClassDB::bind_method(D_METHOD("global_menu_clear", "menu"), &DisplayServer::global_menu_clear);
+
+ ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!"));
+
+ ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode);
+ ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode);
+
+ ClassDB::bind_method(D_METHOD("mouse_warp_to_position", "position"), &DisplayServer::mouse_warp_to_position);
+ ClassDB::bind_method(D_METHOD("mouse_get_position"), &DisplayServer::mouse_get_position);
+ ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
+
+ ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
+ ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
+
+ ClassDB::bind_method(D_METHOD("get_screen_count"), &DisplayServer::get_screen_count);
+ ClassDB::bind_method(D_METHOD("screen_get_position", "screen"), &DisplayServer::screen_get_position, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_size", "screen"), &DisplayServer::screen_get_size, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_is_touchscreen", "screen"), &DisplayServer::screen_is_touchscreen, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+
+ ClassDB::bind_method(D_METHOD("screen_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_orientation", "screen"), &DisplayServer::screen_get_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+
+ ClassDB::bind_method(D_METHOD("get_window_list"), &DisplayServer::get_window_list);
+
+ ClassDB::bind_method(D_METHOD("create_sub_window", "mode", "rect"), &DisplayServer::create_sub_window, DEFVAL(Rect2i()));
+ ClassDB::bind_method(D_METHOD("delete_sub_window", "window_id"), &DisplayServer::delete_sub_window);
+
+ ClassDB::bind_method(D_METHOD("window_set_title", "title", "window_id"), &DisplayServer::window_set_title, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_current_screen", "window_id"), &DisplayServer::window_get_current_screen, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_current_screen", "screen", "window_id"), &DisplayServer::window_set_current_screen, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_position", "window_id"), &DisplayServer::window_get_position, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_position", "position", "window_id"), &DisplayServer::window_set_position, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_size", "window_id"), &DisplayServer::window_get_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_size", "size", "window_id"), &DisplayServer::window_set_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_max_size", "window_id"), &DisplayServer::window_get_max_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_max_size", "max_size", "window_id"), &DisplayServer::window_set_max_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_min_size", "window_id"), &DisplayServer::window_get_min_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_min_size", "min_size", "window_id"), &DisplayServer::window_set_min_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_real_size", "window_id"), &DisplayServer::window_get_real_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_mode", "window_id"), &DisplayServer::window_get_mode, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_mode", "mode", "window_id"), &DisplayServer::window_set_mode, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_set_flag", "flag", "enabled", "window_id"), &DisplayServer::window_set_flag, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_get_flag", "flag", "window_id"), &DisplayServer::window_get_flag, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_request_attention", "window_id"), &DisplayServer::window_request_attention, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_move_to_foreground", "window_id"), &DisplayServer::window_move_to_foreground, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_can_draw", "window_id"), &DisplayServer::window_can_draw, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_set_ime_active", "active", "window_id"), &DisplayServer::window_set_ime_active, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_ime_position", "position", "window_id"), &DisplayServer::window_set_ime_position, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
+ ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
+
+ 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"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()));
+ 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);
+
+ ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
+ ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
+ ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image);
+
+ ClassDB::bind_method(D_METHOD("get_swap_ok_cancel"), &DisplayServer::get_swap_ok_cancel);
+
+ ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);
+
+ ClassDB::bind_method(D_METHOD("native_video_play", "path", "volume", "audio_track", "subtitle_track"), &DisplayServer::native_video_play);
+ ClassDB::bind_method(D_METHOD("native_video_is_playing"), &DisplayServer::native_video_is_playing);
+ ClassDB::bind_method(D_METHOD("native_video_stop"), &DisplayServer::native_video_stop);
+ ClassDB::bind_method(D_METHOD("native_video_pause"), &DisplayServer::native_video_pause);
+ ClassDB::bind_method(D_METHOD("native_video_unpause"), &DisplayServer::native_video_unpause);
+
+ 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_show);
+
+ ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant);
+
+ 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);
+
+ ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &DisplayServer::set_native_icon);
+ ClassDB::bind_method(D_METHOD("set_icon", "image"), &DisplayServer::set_icon);
+
+ BIND_ENUM_CONSTANT(FEATURE_GLOBAL_MENU);
+ BIND_ENUM_CONSTANT(FEATURE_SUBWINDOWS);
+ BIND_ENUM_CONSTANT(FEATURE_TOUCHSCREEN);
+ BIND_ENUM_CONSTANT(FEATURE_MOUSE);
+ BIND_ENUM_CONSTANT(FEATURE_MOUSE_WARP);
+ BIND_ENUM_CONSTANT(FEATURE_CLIPBOARD);
+ BIND_ENUM_CONSTANT(FEATURE_VIRTUAL_KEYBOARD);
+ BIND_ENUM_CONSTANT(FEATURE_CURSOR_SHAPE);
+ BIND_ENUM_CONSTANT(FEATURE_CUSTOM_CURSOR_SHAPE);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_VIDEO);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG);
+ BIND_ENUM_CONSTANT(FEATURE_CONSOLE_WINDOW);
+ BIND_ENUM_CONSTANT(FEATURE_IME);
+ BIND_ENUM_CONSTANT(FEATURE_WINDOW_TRANSPARENCY);
+ BIND_ENUM_CONSTANT(FEATURE_HIDPI);
+ BIND_ENUM_CONSTANT(FEATURE_ICON);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_ICON);
+ BIND_ENUM_CONSTANT(FEATURE_ORIENTATION);
+ BIND_ENUM_CONSTANT(FEATURE_SWAP_BUFFERS);
+
+ BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
+
+ BIND_CONSTANT(SCREEN_OF_MAIN_WINDOW);
+ BIND_CONSTANT(MAIN_WINDOW_ID);
+ BIND_CONSTANT(INVALID_WINDOW_ID);
+
+ BIND_ENUM_CONSTANT(SCREEN_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_REVERSE_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_REVERSE_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR);
+
+ BIND_ENUM_CONSTANT(CURSOR_ARROW);
+ BIND_ENUM_CONSTANT(CURSOR_IBEAM);
+ BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_ENUM_CONSTANT(CURSOR_CROSS);
+ BIND_ENUM_CONSTANT(CURSOR_WAIT);
+ BIND_ENUM_CONSTANT(CURSOR_BUSY);
+ BIND_ENUM_CONSTANT(CURSOR_DRAG);
+ BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
+ BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_ENUM_CONSTANT(CURSOR_VSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_HSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_MOVE);
+ BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HELP);
+ BIND_ENUM_CONSTANT(CURSOR_MAX);
+
+ BIND_ENUM_CONSTANT(WINDOW_MODE_WINDOWED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_MINIMIZED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_MAXIMIZED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_FULLSCREEN);
+
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT_BIT);
+
+ 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);
+}
+DisplayServer::DisplayServer() {
+ singleton = this;
+}
+DisplayServer::~DisplayServer() {
+}
diff --git a/servers/display_server.h b/servers/display_server.h
new file mode 100644
index 0000000000..c05a7fadbd
--- /dev/null
+++ b/servers/display_server.h
@@ -0,0 +1,273 @@
+/*************************************************************************/
+/* display_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DISPLAY_SERVER_H
+#define DISPLAY_SERVER_H
+
+#include "core/os/os.h"
+#include "core/resource.h"
+
+class DisplayServer : public Object {
+ GDCLASS(DisplayServer, Object)
+
+ static DisplayServer *singleton;
+
+protected:
+ static void _bind_methods();
+
+public:
+ enum Feature {
+ FEATURE_GLOBAL_MENU,
+ FEATURE_SUBWINDOWS,
+ FEATURE_TOUCHSCREEN,
+ FEATURE_MOUSE,
+ FEATURE_MOUSE_WARP,
+ FEATURE_CLIPBOARD,
+ FEATURE_VIRTUAL_KEYBOARD,
+ FEATURE_CURSOR_SHAPE,
+ FEATURE_CUSTOM_CURSOR_SHAPE,
+ FEATURE_NATIVE_VIDEO,
+ FEATURE_NATIVE_DIALOG,
+ FEATURE_CONSOLE_WINDOW,
+ FEATURE_IME,
+ FEATURE_WINDOW_TRANSPARENCY,
+ FEATURE_HIDPI,
+ FEATURE_ICON,
+ FEATURE_NATIVE_ICON,
+ FEATURE_ORIENTATION,
+ FEATURE_SWAP_BUFFERS
+
+ };
+
+ virtual bool has_feature(Feature p_feature) const = 0;
+ virtual String get_name() const = 0;
+
+ virtual void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
+ virtual void global_menu_add_separator(const String &p_menu);
+ virtual void global_menu_remove_item(const String &p_menu, int p_idx);
+ virtual void global_menu_clear(const String &p_menu);
+
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
+
+ enum MouseMode {
+ MOUSE_MODE_VISIBLE,
+ MOUSE_MODE_HIDDEN,
+ MOUSE_MODE_CAPTURED,
+ MOUSE_MODE_CONFINED
+ };
+
+ virtual void mouse_set_mode(MouseMode p_mode);
+ virtual MouseMode mouse_get_mode() const;
+
+ virtual void mouse_warp_to_position(const Point2i &p_to);
+ virtual Point2i mouse_get_position() const;
+ virtual int mouse_get_button_state() const;
+
+ virtual void clipboard_set(const String &p_text);
+ virtual String clipboard_get() const;
+
+ enum {
+ SCREEN_OF_MAIN_WINDOW = -1
+ };
+
+ virtual int get_screen_count() const = 0;
+ virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+
+ enum ScreenOrientation {
+
+ SCREEN_LANDSCAPE,
+ SCREEN_PORTRAIT,
+ SCREEN_REVERSE_LANDSCAPE,
+ SCREEN_REVERSE_PORTRAIT,
+ SCREEN_SENSOR_LANDSCAPE,
+ SCREEN_SENSOR_PORTRAIT,
+ SCREEN_SENSOR,
+ };
+
+ virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
+ ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ enum {
+ MAIN_WINDOW_ID = 0,
+ INVALID_WINDOW_ID = -1
+ };
+
+ typedef int WindowID;
+
+ virtual Vector<int> get_window_list() const = 0;
+
+ enum WindowMode {
+ WINDOW_MODE_WINDOWED,
+ WINDOW_MODE_MINIMIZED,
+ WINDOW_MODE_MAXIMIZED,
+ WINDOW_MODE_FULLSCREEN
+ };
+
+ enum WindowFlags {
+ WINDOW_FLAG_RESIZE_DISABLED,
+ WINDOW_FLAG_BORDERLESS,
+ WINDOW_FLAG_ALWAYS_ON_TOP,
+ WINDOW_FLAG_TRANSPARENT,
+ WINDOW_FLAG_MAX,
+ WINDOW_FLAG_RESIZE_DISABLED_BIT = (1 << WINDOW_FLAG_RESIZE_DISABLED),
+ WINDOW_FLAG_BORDERLESS_BIT = (1 << WINDOW_FLAG_BORDERLESS),
+ WINDOW_FLAG_ALWAYS_ON_TOP_BIT = (1 << WINDOW_FLAG_ALWAYS_ON_TOP),
+ WINDOW_FLAG_TRANSPARENT_BIT = (1 << WINDOW_FLAG_TRANSPARENT)
+ };
+
+ virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i = Rect2i());
+ virtual void delete_sub_window(WindowID p_id);
+
+ virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const = 0; // FIXME: Find clearer name for this.
+
+ virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual Point2i ime_get_selection() const;
+ virtual String ime_get_text() const;
+
+ virtual void console_set_visible(bool p_enabled);
+ virtual bool is_console_visible() const;
+
+ virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2());
+ virtual void virtual_keyboard_hide();
+
+ // returns height of the currently shown virtual keyboard (0 if keyboard is hidden)
+ virtual int virtual_keyboard_get_height() const;
+
+ enum CursorShape {
+ CURSOR_ARROW,
+ CURSOR_IBEAM,
+ CURSOR_POINTING_HAND,
+ CURSOR_CROSS,
+ CURSOR_WAIT,
+ CURSOR_BUSY,
+ CURSOR_DRAG,
+ CURSOR_CAN_DROP,
+ CURSOR_FORBIDDEN,
+ CURSOR_VSIZE,
+ CURSOR_HSIZE,
+ CURSOR_BDIAGSIZE,
+ CURSOR_FDIAGSIZE,
+ CURSOR_MOVE,
+ CURSOR_VSPLIT,
+ CURSOR_HSPLIT,
+ CURSOR_HELP,
+ CURSOR_MAX
+ };
+ virtual void cursor_set_shape(CursorShape p_shape);
+ virtual CursorShape cursor_get_shape() const;
+ virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
+
+ virtual bool get_swap_ok_cancel();
+
+ virtual void enable_for_stealing_focus(OS::ProcessID pid);
+
+ //plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
+ virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen = SCREEN_OF_MAIN_WINDOW);
+ virtual bool native_video_is_playing() const;
+ virtual void native_video_pause();
+ virtual void native_video_unpause();
+ virtual void native_video_stop();
+
+ virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback);
+ virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback);
+
+ enum LatinKeyboardVariant {
+ LATIN_KEYBOARD_QWERTY,
+ LATIN_KEYBOARD_QWERTZ,
+ LATIN_KEYBOARD_AZERTY,
+ LATIN_KEYBOARD_QZERTY,
+ LATIN_KEYBOARD_DVORAK,
+ LATIN_KEYBOARD_NEO,
+ LATIN_KEYBOARD_COLEMAK,
+ };
+
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
+ virtual void process_events() = 0;
+
+ virtual void force_process_and_drop_events();
+
+ virtual void release_rendering_thread();
+ virtual void make_rendering_thread();
+ virtual void swap_buffers();
+
+ virtual void set_native_icon(const String &p_filename);
+ virtual void set_icon(const Ref<Image> &p_icon);
+
+ typedef Vector<String> *(*GetSupportedVideoDriversFunction)();
+ typedef DisplayServer *(*CreateFunction)(const String &, WindowMode, uint32_t, const Size2i &, Error &r_error); //video driver, window mode, resolution
+
+ DisplayServer();
+ ~DisplayServer();
+};
+
+VARIANT_ENUM_CAST(DisplayServer::Feature)
+VARIANT_ENUM_CAST(DisplayServer::MouseMode)
+VARIANT_ENUM_CAST(DisplayServer::ScreenOrientation)
+VARIANT_ENUM_CAST(DisplayServer::WindowMode)
+VARIANT_ENUM_CAST(DisplayServer::WindowFlags)
+VARIANT_ENUM_CAST(DisplayServer::CursorShape)
+VARIANT_ENUM_CAST(DisplayServer::LatinKeyboardVariant)
+
+#endif // DISPLAY_SERVER_H
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index fd65f57380..574b373c30 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "register_server_types.h"
+
#include "core/engine.h"
#include "core/project_settings.h"
@@ -56,6 +57,7 @@
#include "audio_server.h"
#include "camera/camera_feed.h"
#include "camera_server.h"
+#include "display_server.h"
#include "navigation_2d_server.h"
#include "navigation_server.h"
#include "physics/physics_server_sw.h"
@@ -95,6 +97,7 @@ void register_server_types() {
OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
+ ClassDB::register_virtual_class<DisplayServer>();
ClassDB::register_virtual_class<VisualServer>();
ClassDB::register_class<AudioServer>();
ClassDB::register_virtual_class<PhysicsServer>();