Add macOS DisplayServer implementation.
Change global menu to use Callable, add support for check items and submenus.
This commit is contained in:
parent
197cb4e771
commit
15a9f94346
@ -44,8 +44,6 @@ void MainLoop::_bind_methods() {
|
|||||||
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta")));
|
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta")));
|
||||||
BIND_VMETHOD(MethodInfo("_finalize"));
|
BIND_VMETHOD(MethodInfo("_finalize"));
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
|
|
||||||
|
|
||||||
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
|
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
|
||||||
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
|
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
|
||||||
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
|
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
|
||||||
@ -91,12 +89,6 @@ bool MainLoop::idle(float p_time) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainLoop::global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
|
||||||
|
|
||||||
if (get_script_instance())
|
|
||||||
get_script_instance()->call("_global_menu_action", p_id, p_meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainLoop::finish() {
|
void MainLoop::finish() {
|
||||||
|
|
||||||
if (get_script_instance()) {
|
if (get_script_instance()) {
|
||||||
|
@ -62,8 +62,6 @@ public:
|
|||||||
virtual bool idle(float p_time);
|
virtual bool idle(float p_time);
|
||||||
virtual void finish();
|
virtual void finish();
|
||||||
|
|
||||||
virtual void global_menu_action(const Variant &p_id, const Variant &p_meta);
|
|
||||||
|
|
||||||
void set_init_script(const Ref<Script> &p_init_script);
|
void set_init_script(const Ref<Script> &p_init_script);
|
||||||
|
|
||||||
MainLoop();
|
MainLoop();
|
||||||
|
@ -146,6 +146,9 @@ public:
|
|||||||
virtual List<String> get_cmdline_args() const { return _cmdline; }
|
virtual List<String> get_cmdline_args() const { return _cmdline; }
|
||||||
virtual String get_model_name() const;
|
virtual String get_model_name() const;
|
||||||
|
|
||||||
|
bool is_layered_allowed() const { return _allow_layered; }
|
||||||
|
bool is_hidpi_allowed() const { return _allow_hidpi; }
|
||||||
|
|
||||||
void ensure_user_data_dir();
|
void ensure_user_data_dir();
|
||||||
|
|
||||||
virtual MainLoop *get_main_loop() const = 0;
|
virtual MainLoop *get_main_loop() const = 0;
|
||||||
@ -286,7 +289,6 @@ public:
|
|||||||
virtual bool request_permissions() { return true; }
|
virtual bool request_permissions() { return true; }
|
||||||
virtual Vector<String> get_granted_permissions() const { return Vector<String>(); }
|
virtual Vector<String> get_granted_permissions() const { return Vector<String>(); }
|
||||||
|
|
||||||
bool is_hidpi_allowed() const { return _allow_hidpi; }
|
|
||||||
virtual void process_and_drop_events() {}
|
virtual void process_and_drop_events() {}
|
||||||
OS();
|
OS();
|
||||||
virtual ~OS();
|
virtual ~OS();
|
||||||
|
@ -199,7 +199,7 @@ void EditorNode::_update_scene_tabs() {
|
|||||||
scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
|
scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
|
||||||
|
|
||||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
|
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
|
||||||
DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), GLOBAL_SCENE, i);
|
DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), callable_mp(this, &EditorNode::_global_menu_scene), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_rb && editor_data.get_scene_root_script(i).is_valid()) {
|
if (show_rb && editor_data.get_scene_root_script(i).is_valid()) {
|
||||||
@ -209,7 +209,7 @@ void EditorNode::_update_scene_tabs() {
|
|||||||
|
|
||||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
|
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
|
||||||
DisplayServer::get_singleton()->global_menu_add_separator("_dock");
|
DisplayServer::get_singleton()->global_menu_add_separator("_dock");
|
||||||
DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
|
DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &EditorNode::_global_menu_new_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_tabs->set_current_tab(editor_data.get_edited_scene());
|
scene_tabs->set_current_tab(editor_data.get_edited_scene());
|
||||||
@ -378,7 +378,6 @@ void EditorNode::_notification(int p_what) {
|
|||||||
get_tree()->get_root()->set_as_audio_listener_2d(false);
|
get_tree()->get_root()->set_as_audio_listener_2d(false);
|
||||||
get_tree()->set_auto_accept_quit(false);
|
get_tree()->set_auto_accept_quit(false);
|
||||||
get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files));
|
get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files));
|
||||||
get_tree()->connect("global_menu_action", callable_mp(this, &EditorNode::_global_menu_action));
|
|
||||||
|
|
||||||
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
|
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
|
||||||
} break;
|
} break;
|
||||||
@ -5105,22 +5104,20 @@ void EditorNode::remove_tool_menu_item(const String &p_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
void EditorNode::_global_menu_scene(const Variant &p_tag) {
|
||||||
|
int idx = (int)p_tag;
|
||||||
|
scene_tabs->set_current_tab(idx);
|
||||||
|
}
|
||||||
|
|
||||||
int id = (int)p_id;
|
void EditorNode::_global_menu_new_window(const Variant &p_tag) {
|
||||||
if (id == GLOBAL_NEW_WINDOW) {
|
|
||||||
if (OS::get_singleton()->get_main_loop()) {
|
if (OS::get_singleton()->get_main_loop()) {
|
||||||
List<String> args;
|
List<String> args;
|
||||||
args.push_back("-e");
|
args.push_back("-p");
|
||||||
String exec = OS::get_singleton()->get_executable_path();
|
String exec = OS::get_singleton()->get_executable_path();
|
||||||
|
|
||||||
OS::ProcessID pid = 0;
|
OS::ProcessID pid = 0;
|
||||||
OS::get_singleton()->execute(exec, args, false, &pid);
|
OS::get_singleton()->execute(exec, args, false, &pid);
|
||||||
}
|
}
|
||||||
} else if (id == GLOBAL_SCENE) {
|
|
||||||
int idx = (int)p_meta;
|
|
||||||
scene_tabs->set_current_tab(idx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
|
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
|
||||||
@ -5439,6 +5436,7 @@ void EditorNode::_bind_methods() {
|
|||||||
ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);
|
ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);
|
||||||
|
|
||||||
ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
|
ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
|
||||||
|
|
||||||
ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);
|
ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
|
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
|
||||||
@ -5590,7 +5588,11 @@ EditorNode::EditorNode() {
|
|||||||
case 0: {
|
case 0: {
|
||||||
// Try applying a suitable display scale automatically
|
// Try applying a suitable display scale automatically
|
||||||
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
||||||
|
#ifdef OSX_ENABLED
|
||||||
|
editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen));
|
||||||
|
#else
|
||||||
editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
|
editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
|
||||||
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 1: {
|
case 1: {
|
||||||
|
@ -498,7 +498,8 @@ private:
|
|||||||
void _add_to_recent_scenes(const String &p_scene);
|
void _add_to_recent_scenes(const String &p_scene);
|
||||||
void _update_recent_scenes();
|
void _update_recent_scenes();
|
||||||
void _open_recent_scene(int p_idx);
|
void _open_recent_scene(int p_idx);
|
||||||
void _global_menu_action(const Variant &p_id, const Variant &p_meta);
|
void _global_menu_scene(const Variant &p_tag);
|
||||||
|
void _global_menu_new_window(const Variant &p_tag);
|
||||||
void _dropped_files(const Vector<String> &p_files, int p_screen);
|
void _dropped_files(const Vector<String> &p_files, int p_screen);
|
||||||
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
|
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
|
||||||
String _recent_scene;
|
String _recent_scene;
|
||||||
|
@ -121,7 +121,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||||||
case 1: { // centered
|
case 1: { // centered
|
||||||
int display_scale = 1;
|
int display_scale = 1;
|
||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000) {
|
display_scale = DisplayServer::get_singleton()->screen_get_scale(screen);
|
||||||
|
#else
|
||||||
|
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000) {
|
||||||
display_scale = 2;
|
display_scale = 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1047,6 +1047,9 @@ public:
|
|||||||
ProjectList();
|
ProjectList();
|
||||||
~ProjectList();
|
~ProjectList();
|
||||||
|
|
||||||
|
void _global_menu_new_window(const Variant &p_tag);
|
||||||
|
void _global_menu_open_project(const Variant &p_tag);
|
||||||
|
|
||||||
void update_dock_menu();
|
void update_dock_menu();
|
||||||
void load_projects();
|
void load_projects();
|
||||||
void set_search_term(String p_search_term);
|
void set_search_term(String p_search_term);
|
||||||
@ -1304,14 +1307,37 @@ void ProjectList::update_dock_menu() {
|
|||||||
}
|
}
|
||||||
favs_added = 0;
|
favs_added = 0;
|
||||||
}
|
}
|
||||||
DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot")));
|
DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", callable_mp(this, &ProjectList::_global_menu_open_project), i);
|
||||||
total_added++;
|
total_added++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total_added != 0) {
|
if (total_added != 0) {
|
||||||
DisplayServer::get_singleton()->global_menu_add_separator("_dock");
|
DisplayServer::get_singleton()->global_menu_add_separator("_dock");
|
||||||
}
|
}
|
||||||
DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
|
DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &ProjectList::_global_menu_new_window));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectList::_global_menu_new_window(const Variant &p_tag) {
|
||||||
|
List<String> args;
|
||||||
|
args.push_back("-p");
|
||||||
|
String exec = OS::get_singleton()->get_executable_path();
|
||||||
|
|
||||||
|
OS::ProcessID pid = 0;
|
||||||
|
OS::get_singleton()->execute(exec, args, false, &pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectList::_global_menu_open_project(const Variant &p_tag) {
|
||||||
|
int idx = (int)p_tag;
|
||||||
|
|
||||||
|
if (idx >= 0 && idx < _projects.size()) {
|
||||||
|
String conf = _projects[idx].path.plus_file("project.godot");
|
||||||
|
List<String> args;
|
||||||
|
args.push_back(conf);
|
||||||
|
String exec = OS::get_singleton()->get_executable_path();
|
||||||
|
|
||||||
|
OS::ProcessID pid = 0;
|
||||||
|
OS::get_singleton()->execute(exec, args, false, &pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectList::create_project_item_control(int p_index) {
|
void ProjectList::create_project_item_control(int p_index) {
|
||||||
@ -2024,30 +2050,6 @@ void ProjectManager::_confirm_update_settings() {
|
|||||||
_open_selected_projects();
|
_open_selected_projects();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
|
||||||
|
|
||||||
int id = (int)p_id;
|
|
||||||
if (id == ProjectList::GLOBAL_NEW_WINDOW) {
|
|
||||||
List<String> args;
|
|
||||||
args.push_back("-p");
|
|
||||||
String exec = OS::get_singleton()->get_executable_path();
|
|
||||||
|
|
||||||
OS::ProcessID pid = 0;
|
|
||||||
OS::get_singleton()->execute(exec, args, false, &pid);
|
|
||||||
} else if (id == ProjectList::GLOBAL_OPEN_PROJECT) {
|
|
||||||
String conf = (String)p_meta;
|
|
||||||
|
|
||||||
if (conf != String()) {
|
|
||||||
List<String> args;
|
|
||||||
args.push_back(conf);
|
|
||||||
String exec = OS::get_singleton()->get_executable_path();
|
|
||||||
|
|
||||||
OS::ProcessID pid = 0;
|
|
||||||
OS::get_singleton()->execute(exec, args, false, &pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectManager::_open_selected_projects() {
|
void ProjectManager::_open_selected_projects() {
|
||||||
|
|
||||||
const Set<String> &selected_list = _project_list->get_selected_project_keys();
|
const Set<String> &selected_list = _project_list->get_selected_project_keys();
|
||||||
@ -2420,7 +2422,11 @@ ProjectManager::ProjectManager() {
|
|||||||
case 0: {
|
case 0: {
|
||||||
// Try applying a suitable display scale automatically
|
// Try applying a suitable display scale automatically
|
||||||
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
||||||
|
#ifdef OSX_ENABLED
|
||||||
|
editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen));
|
||||||
|
#else
|
||||||
editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
|
editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
|
||||||
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 1: editor_set_scale(0.75); break;
|
case 1: editor_set_scale(0.75); break;
|
||||||
@ -2696,7 +2702,6 @@ ProjectManager::ProjectManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
|
SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
|
||||||
SceneTree::get_singleton()->connect("global_menu_action", callable_mp(this, &ProjectManager::_global_menu_action));
|
|
||||||
|
|
||||||
run_error_diag = memnew(AcceptDialog);
|
run_error_diag = memnew(AcceptDialog);
|
||||||
gui_base->add_child(run_error_diag);
|
gui_base->add_child(run_error_diag);
|
||||||
|
@ -97,7 +97,6 @@ class ProjectManager : public Control {
|
|||||||
void _restart_confirm();
|
void _restart_confirm();
|
||||||
void _exit_dialog();
|
void _exit_dialog();
|
||||||
void _scan_begin(const String &p_base);
|
void _scan_begin(const String &p_base);
|
||||||
void _global_menu_action(const Variant &p_id, const Variant &p_meta);
|
|
||||||
|
|
||||||
void _confirm_update_settings();
|
void _confirm_update_settings();
|
||||||
|
|
||||||
|
@ -1964,7 +1964,7 @@ bool Main::start() {
|
|||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
String mac_iconpath = GLOBAL_DEF("application/config/macos_native_icon", "Variant()");
|
String mac_iconpath = GLOBAL_DEF("application/config/macos_native_icon", "Variant()");
|
||||||
if (mac_iconpath != "") {
|
if (mac_iconpath != "") {
|
||||||
OS::get_singleton()->set_native_icon(mac_iconpath);
|
DisplayServer::get_singleton()->set_native_icon(mac_iconpath);
|
||||||
hasicon = true;
|
hasicon = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -421,9 +421,27 @@ void DisplayServerX11::mouse_warp_to_position(const Point2i &p_to) {
|
|||||||
0, 0, 0, 0, (int)p_to.x, (int)p_to.y);
|
0, 0, 0, 0, (int)p_to.x, (int)p_to.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2i DisplayServerX11::mouse_get_position() const {
|
Point2i DisplayServerX11::mouse_get_position() const {
|
||||||
return last_mouse_pos;
|
return last_mouse_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point2i DisplayServerX11::mouse_get_absolute_position() const {
|
||||||
|
int number_of_screens = XScreenCount(x11_display);
|
||||||
|
for (int i = 0; i < number_of_screens; i++) {
|
||||||
|
Window root, child;
|
||||||
|
int root_x, root_y, win_x, win_y;
|
||||||
|
unsigned int mask;
|
||||||
|
if (XQueryPointer(x11_display, XRootWindow(x11_display, i), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask)) {
|
||||||
|
XWindowAttributes root_attrs;
|
||||||
|
XGetWindowAttributes(x11_display, root, &root_attrs);
|
||||||
|
|
||||||
|
return Vector2i(root_attrs.x + root_x, root_attrs.y + root_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Vector2i();
|
||||||
|
}
|
||||||
|
|
||||||
int DisplayServerX11::mouse_get_button_state() const {
|
int DisplayServerX11::mouse_get_button_state() const {
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
}
|
}
|
||||||
|
@ -254,6 +254,7 @@ public:
|
|||||||
|
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
|
virtual Point2i mouse_get_absolute_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual int mouse_get_button_state() const;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text);
|
virtual void clipboard_set(const String &p_text);
|
||||||
|
@ -8,6 +8,7 @@ import platform_osx_builders
|
|||||||
files = [
|
files = [
|
||||||
'crash_handler_osx.mm',
|
'crash_handler_osx.mm',
|
||||||
'os_osx.mm',
|
'os_osx.mm',
|
||||||
|
'display_server_osx.mm',
|
||||||
'godot_main_osx.mm',
|
'godot_main_osx.mm',
|
||||||
'dir_access_osx.mm',
|
'dir_access_osx.mm',
|
||||||
'joypad_osx.cpp',
|
'joypad_osx.cpp',
|
||||||
|
306
platform/osx/display_server_osx.h
Normal file
306
platform/osx/display_server_osx.h
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* display_server_osx.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_OSX_H
|
||||||
|
#define DISPLAY_SERVER_OSX_H
|
||||||
|
|
||||||
|
#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
|
||||||
|
|
||||||
|
#include "core/input/input_filter.h"
|
||||||
|
#include "servers/display_server.h"
|
||||||
|
|
||||||
|
#if defined(OPENGL_ENABLED)
|
||||||
|
#include "context_gl_osx.h"
|
||||||
|
//TODO - reimplement OpenGLES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VULKAN_ENABLED)
|
||||||
|
#include "drivers/vulkan/rendering_device_vulkan.h"
|
||||||
|
#include "platform/osx/vulkan_context_osx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
#include <AppKit/NSCursor.h>
|
||||||
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#include <CoreVideo/CoreVideo.h>
|
||||||
|
|
||||||
|
#undef BitMap
|
||||||
|
#undef CursorShape
|
||||||
|
|
||||||
|
class DisplayServerOSX : public DisplayServer {
|
||||||
|
GDCLASS(DisplayServerOSX, DisplayServer)
|
||||||
|
|
||||||
|
_THREAD_SAFE_CLASS_
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if defined(OPENGL_ENABLED)
|
||||||
|
ContextGL_OSX *context_gles2;
|
||||||
|
#endif
|
||||||
|
#if defined(VULKAN_ENABLED)
|
||||||
|
VulkanContextOSX *context_vulkan;
|
||||||
|
RenderingDeviceVulkan *rendering_device_vulkan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const NSMenu *_get_menu_root(const String &p_menu_root) const;
|
||||||
|
NSMenu *_get_menu_root(const String &p_menu_root);
|
||||||
|
|
||||||
|
NSMenu *apple_menu = NULL;
|
||||||
|
NSMenu *dock_menu = NULL;
|
||||||
|
Map<String, NSMenu *> submenu;
|
||||||
|
|
||||||
|
struct KeyEvent {
|
||||||
|
WindowID window_id;
|
||||||
|
unsigned int osx_state;
|
||||||
|
bool pressed;
|
||||||
|
bool echo;
|
||||||
|
bool raw;
|
||||||
|
uint32_t keycode;
|
||||||
|
uint32_t physical_keycode;
|
||||||
|
uint32_t unicode;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector<KeyEvent> key_event_buffer;
|
||||||
|
int key_event_pos;
|
||||||
|
|
||||||
|
struct WindowData {
|
||||||
|
id window_delegate;
|
||||||
|
id window_object;
|
||||||
|
id window_view;
|
||||||
|
|
||||||
|
#if defined(OPENGL_ENABLED)
|
||||||
|
ContextGL_OSX *context_gles2 = NULL;
|
||||||
|
#endif
|
||||||
|
Point2i mouse_pos;
|
||||||
|
|
||||||
|
Size2i min_size;
|
||||||
|
Size2i max_size;
|
||||||
|
Size2i size;
|
||||||
|
|
||||||
|
bool mouse_down_control = false;
|
||||||
|
|
||||||
|
bool im_active = false;
|
||||||
|
Size2i im_position;
|
||||||
|
|
||||||
|
Callable rect_changed_callback;
|
||||||
|
Callable event_callback;
|
||||||
|
Callable input_event_callback;
|
||||||
|
Callable input_text_callback;
|
||||||
|
Callable drop_files_callback;
|
||||||
|
|
||||||
|
ObjectID instance_id;
|
||||||
|
|
||||||
|
WindowID transient_parent = INVALID_WINDOW_ID;
|
||||||
|
Set<WindowID> transient_children;
|
||||||
|
|
||||||
|
bool layered_window = false;
|
||||||
|
bool fullscreen = false;
|
||||||
|
bool on_top = false;
|
||||||
|
bool borderless = false;
|
||||||
|
bool resize_disabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Point2i im_selection;
|
||||||
|
String im_text;
|
||||||
|
|
||||||
|
Map<WindowID, WindowData> windows;
|
||||||
|
|
||||||
|
WindowID window_id_counter = MAIN_WINDOW_ID;
|
||||||
|
|
||||||
|
WindowID _create_window(WindowMode p_mode, const Rect2i &p_rect);
|
||||||
|
void _update_window(WindowData p_wd);
|
||||||
|
void _send_window_event(const WindowData &wd, WindowEvent p_event);
|
||||||
|
static void _dispatch_input_events(const Ref<InputEvent> &p_event);
|
||||||
|
void _dispatch_input_event(const Ref<InputEvent> &p_event);
|
||||||
|
WindowID _find_window_id(id p_window);
|
||||||
|
|
||||||
|
void _set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window);
|
||||||
|
|
||||||
|
float _display_scale(id screen) const;
|
||||||
|
Point2i _get_screens_origin() const;
|
||||||
|
Point2i _get_native_screen_position(int p_screen) const;
|
||||||
|
|
||||||
|
void _push_input(const Ref<InputEvent> &p_event);
|
||||||
|
void _process_key_events();
|
||||||
|
|
||||||
|
String rendering_driver;
|
||||||
|
|
||||||
|
id delegate;
|
||||||
|
id autoreleasePool;
|
||||||
|
CGEventSourceRef eventSource;
|
||||||
|
|
||||||
|
CursorShape cursor_shape;
|
||||||
|
NSCursor *cursors[CURSOR_MAX];
|
||||||
|
Map<CursorShape, Vector<Variant>> cursors_cache;
|
||||||
|
|
||||||
|
MouseMode mouse_mode;
|
||||||
|
Point2i last_mouse_pos;
|
||||||
|
uint32_t last_button_state;
|
||||||
|
|
||||||
|
bool window_focused;
|
||||||
|
bool drop_events;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool has_feature(Feature p_feature) const;
|
||||||
|
virtual String get_name() const;
|
||||||
|
|
||||||
|
virtual void global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
|
||||||
|
virtual void global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
|
||||||
|
virtual void global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu);
|
||||||
|
virtual void global_menu_add_separator(const String &p_menu_root);
|
||||||
|
|
||||||
|
virtual bool global_menu_is_item_checked(const String &p_menu_root, int p_idx) const;
|
||||||
|
virtual bool global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const;
|
||||||
|
virtual Callable global_menu_get_item_callback(const String &p_menu_root, int p_idx);
|
||||||
|
virtual Variant global_menu_get_item_tag(const String &p_menu_root, int p_idx);
|
||||||
|
virtual String global_menu_get_item_text(const String &p_menu_root, int p_idx);
|
||||||
|
virtual String global_menu_get_item_submenu(const String &p_menu_root, int p_idx);
|
||||||
|
|
||||||
|
virtual void global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked);
|
||||||
|
virtual void global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable);
|
||||||
|
virtual void global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback);
|
||||||
|
virtual void global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag);
|
||||||
|
virtual void global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text);
|
||||||
|
virtual void global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu);
|
||||||
|
|
||||||
|
virtual int global_menu_get_item_count(const String &p_menu_root) const;
|
||||||
|
|
||||||
|
virtual void global_menu_remove_item(const String &p_menu_root, int p_idx);
|
||||||
|
virtual void global_menu_clear(const String &p_menu_root);
|
||||||
|
|
||||||
|
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
||||||
|
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);
|
||||||
|
|
||||||
|
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 Point2i mouse_get_absolute_position() const;
|
||||||
|
virtual int mouse_get_button_state() const;
|
||||||
|
|
||||||
|
virtual void clipboard_set(const String &p_text);
|
||||||
|
virtual String clipboard_get() const;
|
||||||
|
|
||||||
|
virtual int get_screen_count() const;
|
||||||
|
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
|
||||||
|
virtual Vector<int> get_window_list() const;
|
||||||
|
|
||||||
|
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_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual void window_set_transient(WindowID p_window, WindowID p_parent);
|
||||||
|
|
||||||
|
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual bool can_any_window_draw() const;
|
||||||
|
|
||||||
|
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 WindowID get_window_at_screen_position(const Point2i &p_position) const;
|
||||||
|
|
||||||
|
virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual Point2i ime_get_selection() const;
|
||||||
|
virtual String ime_get_text() const;
|
||||||
|
|
||||||
|
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 = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
|
||||||
|
|
||||||
|
virtual bool get_swap_ok_cancel();
|
||||||
|
|
||||||
|
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||||
|
|
||||||
|
virtual void process_events();
|
||||||
|
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);
|
||||||
|
|
||||||
|
virtual void console_set_visible(bool p_enabled);
|
||||||
|
virtual bool is_console_visible() const;
|
||||||
|
|
||||||
|
static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
|
static Vector<String> get_rendering_drivers_func();
|
||||||
|
|
||||||
|
static void register_osx_driver();
|
||||||
|
|
||||||
|
DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
|
~DisplayServerOSX();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DISPLAY_SERVER_OSX_H
|
3587
platform/osx/display_server_osx.mm
Normal file
3587
platform/osx/display_server_osx.mm
Normal file
File diff suppressed because it is too large
Load Diff
@ -395,38 +395,38 @@ bool joypad::check_ff_features() {
|
|||||||
static int process_hat_value(int p_min, int p_max, int p_value) {
|
static int process_hat_value(int p_min, int p_max, int p_value) {
|
||||||
int range = (p_max - p_min + 1);
|
int range = (p_max - p_min + 1);
|
||||||
int value = p_value - p_min;
|
int value = p_value - p_min;
|
||||||
int hat_value = InputDefault::HAT_MASK_CENTER;
|
int hat_value = InputFilter::HAT_MASK_CENTER;
|
||||||
if (range == 4) {
|
if (range == 4) {
|
||||||
value *= 2;
|
value *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0:
|
case 0:
|
||||||
hat_value = InputDefault::HAT_MASK_UP;
|
hat_value = InputFilter::HAT_MASK_UP;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
hat_value = InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_RIGHT;
|
hat_value = InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_RIGHT;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
hat_value = InputDefault::HAT_MASK_RIGHT;
|
hat_value = InputFilter::HAT_MASK_RIGHT;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
hat_value = InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_RIGHT;
|
hat_value = InputFilter::HAT_MASK_DOWN | InputFilter::HAT_MASK_RIGHT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
hat_value = InputDefault::HAT_MASK_DOWN;
|
hat_value = InputFilter::HAT_MASK_DOWN;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
hat_value = InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_LEFT;
|
hat_value = InputFilter::HAT_MASK_DOWN | InputFilter::HAT_MASK_LEFT;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
hat_value = InputDefault::HAT_MASK_LEFT;
|
hat_value = InputFilter::HAT_MASK_LEFT;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
hat_value = InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_LEFT;
|
hat_value = InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_LEFT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
hat_value = InputDefault::HAT_MASK_CENTER;
|
hat_value = InputFilter::HAT_MASK_CENTER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return hat_value;
|
return hat_value;
|
||||||
@ -438,8 +438,8 @@ void JoypadOSX::poll_joypads() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const InputDefault::JoyAxis axis_correct(int p_value, int p_min, int p_max) {
|
static const InputFilter::JoyAxis axis_correct(int p_value, int p_min, int p_max) {
|
||||||
InputDefault::JoyAxis jx;
|
InputFilter::JoyAxis jx;
|
||||||
if (p_min < 0) {
|
if (p_min < 0) {
|
||||||
jx.min = -1;
|
jx.min = -1;
|
||||||
if (p_value < 0) {
|
if (p_value < 0) {
|
||||||
@ -571,9 +571,9 @@ void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JoypadOSX::JoypadOSX() {
|
JoypadOSX::JoypadOSX(InputFilter *in) {
|
||||||
self = this;
|
self = this;
|
||||||
input = (InputDefault *)InputFilter::get_singleton();
|
input = in;
|
||||||
|
|
||||||
int okay = 1;
|
int okay = 1;
|
||||||
const void *vals[] = {
|
const void *vals[] = {
|
||||||
|
@ -94,7 +94,7 @@ class JoypadOSX {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InputDefault *input;
|
InputFilter *input;
|
||||||
IOHIDManagerRef hid_manager;
|
IOHIDManagerRef hid_manager;
|
||||||
|
|
||||||
Vector<joypad> device_list;
|
Vector<joypad> device_list;
|
||||||
@ -118,7 +118,7 @@ public:
|
|||||||
void _device_added(IOReturn p_res, IOHIDDeviceRef p_device);
|
void _device_added(IOReturn p_res, IOHIDDeviceRef p_device);
|
||||||
void _device_removed(IOReturn p_res, IOHIDDeviceRef p_device);
|
void _device_removed(IOReturn p_res, IOHIDDeviceRef p_device);
|
||||||
|
|
||||||
JoypadOSX();
|
JoypadOSX(InputFilter *in);
|
||||||
~JoypadOSX();
|
~JoypadOSX();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,56 +31,20 @@
|
|||||||
#ifndef OS_OSX_H
|
#ifndef OS_OSX_H
|
||||||
#define OS_OSX_H
|
#define OS_OSX_H
|
||||||
|
|
||||||
#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
|
#include "core/input/input_filter.h"
|
||||||
|
|
||||||
#include "core/input/inpu_filter.h"
|
|
||||||
#include "crash_handler_osx.h"
|
#include "crash_handler_osx.h"
|
||||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||||
#include "drivers/coremidi/midi_driver_coremidi.h"
|
#include "drivers/coremidi/midi_driver_coremidi.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "joypad_osx.h"
|
#include "joypad_osx.h"
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
|
||||||
#include "servers/visual/visual_server_wrap_mt.h"
|
|
||||||
#include "servers/visual_server.h"
|
|
||||||
|
|
||||||
#if defined(OPENGL_ENABLED)
|
|
||||||
#include "context_gl_osx.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VULKAN_ENABLED)
|
|
||||||
#include "drivers/vulkan/rendering_device_vulkan.h"
|
|
||||||
#include "platform/osx/vulkan_context_osx.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
|
||||||
#include <AppKit/NSCursor.h>
|
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
#include <CoreVideo/CoreVideo.h>
|
|
||||||
|
|
||||||
#undef BitMap
|
|
||||||
#undef CursorShape
|
|
||||||
|
|
||||||
class OS_OSX : public OS_Unix {
|
class OS_OSX : public OS_Unix {
|
||||||
public:
|
virtual void delete_main_loop();
|
||||||
struct KeyEvent {
|
|
||||||
unsigned int osx_state;
|
|
||||||
bool pressed;
|
|
||||||
bool echo;
|
|
||||||
bool raw;
|
|
||||||
uint32_t keycode;
|
|
||||||
uint32_t physical_keycode;
|
|
||||||
uint32_t unicode;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector<KeyEvent> key_event_buffer;
|
|
||||||
int key_event_pos;
|
|
||||||
|
|
||||||
bool force_quit;
|
bool force_quit;
|
||||||
VisualServer *visual_server;
|
|
||||||
|
|
||||||
List<String> args;
|
JoypadOSX *joypad_osx;
|
||||||
MainLoop *main_loop;
|
|
||||||
|
|
||||||
#ifdef COREAUDIO_ENABLED
|
#ifdef COREAUDIO_ENABLED
|
||||||
AudioDriverCoreAudio audio_driver;
|
AudioDriverCoreAudio audio_driver;
|
||||||
@ -89,143 +53,27 @@ public:
|
|||||||
MIDIDriverCoreMidi midi_driver;
|
MIDIDriverCoreMidi midi_driver;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InputDefault *input;
|
|
||||||
JoypadOSX *joypad_osx;
|
|
||||||
|
|
||||||
/* objc */
|
|
||||||
|
|
||||||
CGEventSourceRef eventSource;
|
|
||||||
|
|
||||||
void process_events();
|
|
||||||
void process_key_events();
|
|
||||||
|
|
||||||
// pthread_key_t current;
|
|
||||||
bool mouse_grab;
|
|
||||||
Point2 mouse_pos;
|
|
||||||
|
|
||||||
id delegate;
|
|
||||||
id window_delegate;
|
|
||||||
id window_object;
|
|
||||||
id window_view;
|
|
||||||
id autoreleasePool;
|
|
||||||
id cursor;
|
|
||||||
|
|
||||||
#if defined(OPENGL_ENABLED)
|
|
||||||
ContextGL_OSX *context_gles2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VULKAN_ENABLED)
|
|
||||||
VulkanContextOSX *context_vulkan;
|
|
||||||
RenderingDeviceVulkan *rendering_device_vulkan;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool layered_window;
|
|
||||||
|
|
||||||
CursorShape cursor_shape;
|
|
||||||
NSCursor *cursors[CURSOR_MAX];
|
|
||||||
Map<CursorShape, Vector<Variant>> cursors_cache;
|
|
||||||
MouseMode mouse_mode;
|
|
||||||
|
|
||||||
String title;
|
|
||||||
bool minimized;
|
|
||||||
bool maximized;
|
|
||||||
bool zoomed;
|
|
||||||
bool resizable;
|
|
||||||
bool window_focused;
|
|
||||||
|
|
||||||
Size2 window_size;
|
|
||||||
Rect2 restore_rect;
|
|
||||||
|
|
||||||
String open_with_filename;
|
|
||||||
|
|
||||||
Point2 im_position;
|
|
||||||
bool im_active;
|
|
||||||
String im_text;
|
|
||||||
Point2 im_selection;
|
|
||||||
|
|
||||||
Size2 min_size;
|
|
||||||
Size2 max_size;
|
|
||||||
|
|
||||||
CrashHandler crash_handler;
|
CrashHandler crash_handler;
|
||||||
|
|
||||||
float _mouse_scale(float p_scale) {
|
MainLoop *main_loop;
|
||||||
if (_display_scale() > 1.0)
|
|
||||||
return p_scale;
|
|
||||||
else
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float _display_scale() const;
|
public:
|
||||||
float _display_scale(id screen) const;
|
String open_with_filename;
|
||||||
|
|
||||||
void _update_window();
|
|
||||||
|
|
||||||
int video_driver_index;
|
|
||||||
virtual int get_current_video_driver() const;
|
|
||||||
|
|
||||||
struct GlobalMenuItem {
|
|
||||||
String label;
|
|
||||||
Variant signal;
|
|
||||||
Variant meta;
|
|
||||||
|
|
||||||
GlobalMenuItem() {
|
|
||||||
//NOP
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalMenuItem(const String &p_label, const Variant &p_signal, const Variant &p_meta) {
|
|
||||||
label = p_label;
|
|
||||||
signal = p_signal;
|
|
||||||
meta = p_meta;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<String, Vector<GlobalMenuItem>> global_menus;
|
|
||||||
|
|
||||||
void _update_global_menu();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initialize_core();
|
virtual void initialize_core();
|
||||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
virtual void initialize();
|
||||||
virtual void finalize();
|
virtual void finalize();
|
||||||
|
|
||||||
|
virtual void initialize_joypads();
|
||||||
|
|
||||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
virtual void set_main_loop(MainLoop *p_main_loop);
|
||||||
virtual void delete_main_loop();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static OS_OSX *singleton;
|
|
||||||
|
|
||||||
void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
|
|
||||||
void global_menu_add_separator(const String &p_menu);
|
|
||||||
void global_menu_remove_item(const String &p_menu, int p_idx);
|
|
||||||
void global_menu_clear(const String &p_menu);
|
|
||||||
|
|
||||||
void wm_minimized(bool p_minimized);
|
|
||||||
|
|
||||||
virtual String get_name() const;
|
virtual String get_name() const;
|
||||||
|
|
||||||
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
|
||||||
|
|
||||||
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
|
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
|
||||||
|
|
||||||
virtual void set_cursor_shape(CursorShape p_shape);
|
|
||||||
virtual CursorShape get_cursor_shape() const;
|
|
||||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
|
|
||||||
|
|
||||||
virtual void set_mouse_show(bool p_show);
|
|
||||||
virtual void set_mouse_grab(bool p_grab);
|
|
||||||
virtual bool is_mouse_grab_enabled() const;
|
|
||||||
virtual void warp_mouse_position(const Point2 &p_to);
|
|
||||||
virtual Point2 get_mouse_position() const;
|
|
||||||
virtual int get_mouse_button_state() const;
|
|
||||||
void update_real_mouse_position();
|
|
||||||
virtual void set_window_title(const String &p_title);
|
|
||||||
|
|
||||||
virtual Size2 get_window_size() const;
|
|
||||||
virtual Size2 get_real_window_size() const;
|
|
||||||
|
|
||||||
virtual void set_native_icon(const String &p_filename);
|
|
||||||
virtual void set_icon(const Ref<Image> &p_icon);
|
|
||||||
|
|
||||||
virtual MainLoop *get_main_loop() const;
|
virtual MainLoop *get_main_loop() const;
|
||||||
|
|
||||||
virtual String get_config_path() const;
|
virtual String get_config_path() const;
|
||||||
@ -236,95 +84,24 @@ public:
|
|||||||
|
|
||||||
virtual String get_system_dir(SystemDir p_dir) const;
|
virtual String get_system_dir(SystemDir p_dir) const;
|
||||||
|
|
||||||
virtual bool can_draw() const;
|
|
||||||
|
|
||||||
virtual void set_clipboard(const String &p_text);
|
|
||||||
virtual String get_clipboard() const;
|
|
||||||
|
|
||||||
virtual void release_rendering_thread();
|
|
||||||
virtual void make_rendering_thread();
|
|
||||||
virtual void swap_buffers();
|
|
||||||
|
|
||||||
Error shell_open(String p_uri);
|
Error shell_open(String p_uri);
|
||||||
void push_input(const Ref<InputEvent> &p_event);
|
|
||||||
|
|
||||||
String get_locale() const;
|
String get_locale() const;
|
||||||
|
|
||||||
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
|
||||||
virtual VideoMode get_video_mode(int p_screen = 0) const;
|
|
||||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
|
|
||||||
|
|
||||||
virtual String get_executable_path() const;
|
virtual String get_executable_path() const;
|
||||||
|
|
||||||
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
virtual String get_unique_id() const; //++
|
||||||
|
|
||||||
virtual void move_window_to_foreground();
|
|
||||||
|
|
||||||
virtual int get_screen_count() const;
|
|
||||||
virtual int get_current_screen() const;
|
|
||||||
virtual void set_current_screen(int p_screen);
|
|
||||||
virtual Point2 get_screen_position(int p_screen = -1) const;
|
|
||||||
virtual Size2 get_screen_size(int p_screen = -1) const;
|
|
||||||
virtual int get_screen_dpi(int p_screen = -1) const;
|
|
||||||
|
|
||||||
virtual Point2 get_window_position() const;
|
|
||||||
virtual void set_window_position(const Point2 &p_position);
|
|
||||||
virtual Size2 get_max_window_size() const;
|
|
||||||
virtual Size2 get_min_window_size() const;
|
|
||||||
virtual void set_min_window_size(const Size2 p_size);
|
|
||||||
virtual void set_max_window_size(const Size2 p_size);
|
|
||||||
virtual void set_window_size(const Size2 p_size);
|
|
||||||
virtual void set_window_fullscreen(bool p_enabled);
|
|
||||||
virtual bool is_window_fullscreen() const;
|
|
||||||
virtual void set_window_resizable(bool p_enabled);
|
|
||||||
virtual bool is_window_resizable() const;
|
|
||||||
virtual void set_window_minimized(bool p_enabled);
|
|
||||||
virtual bool is_window_minimized() const;
|
|
||||||
virtual void set_window_maximized(bool p_enabled);
|
|
||||||
virtual bool is_window_maximized() const;
|
|
||||||
virtual void set_window_always_on_top(bool p_enabled);
|
|
||||||
virtual bool is_window_always_on_top() const;
|
|
||||||
virtual bool is_window_focused() const;
|
|
||||||
virtual void request_attention();
|
|
||||||
virtual String get_joy_guid(int p_device) const;
|
|
||||||
|
|
||||||
virtual void set_borderless_window(bool p_borderless);
|
|
||||||
virtual bool get_borderless_window();
|
|
||||||
|
|
||||||
virtual bool get_window_per_pixel_transparency_enabled() const;
|
|
||||||
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
|
|
||||||
|
|
||||||
virtual void set_ime_active(const bool p_active);
|
|
||||||
virtual void set_ime_position(const Point2 &p_pos);
|
|
||||||
virtual Point2 get_ime_selection() const;
|
|
||||||
virtual String get_ime_text() const;
|
|
||||||
|
|
||||||
virtual String get_unique_id() const;
|
|
||||||
|
|
||||||
virtual bool _check_internal_feature_support(const String &p_feature);
|
virtual bool _check_internal_feature_support(const String &p_feature);
|
||||||
|
|
||||||
virtual void _set_use_vsync(bool p_enable);
|
|
||||||
//virtual bool is_vsync_enabled() const;
|
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
void set_mouse_mode(MouseMode p_mode);
|
|
||||||
MouseMode get_mouse_mode() const;
|
|
||||||
|
|
||||||
void disable_crash_handler();
|
void disable_crash_handler();
|
||||||
bool is_disable_crash_handler() const;
|
bool is_disable_crash_handler() const;
|
||||||
|
|
||||||
virtual Error move_to_trash(const String &p_path);
|
virtual Error move_to_trash(const String &p_path);
|
||||||
|
|
||||||
void force_process_input();
|
|
||||||
|
|
||||||
OS_OSX();
|
OS_OSX();
|
||||||
|
|
||||||
private:
|
|
||||||
Point2 get_native_screen_position(int p_screen) const;
|
|
||||||
Point2 get_native_window_position() const;
|
|
||||||
void set_native_window_position(const Point2 &p_position);
|
|
||||||
Point2 get_screens_origin() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ class VulkanContextOSX : public VulkanContext {
|
|||||||
virtual const char *_get_platform_surface_extension() const;
|
virtual const char *_get_platform_surface_extension() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int window_create(id p_window, int p_width, int p_height);
|
Error window_create(DisplayServer::WindowID p_window_id, id p_window, int p_width, int p_height);
|
||||||
|
|
||||||
VulkanContextOSX();
|
VulkanContextOSX();
|
||||||
~VulkanContextOSX();
|
~VulkanContextOSX();
|
||||||
|
@ -35,7 +35,7 @@ const char *VulkanContextOSX::_get_platform_surface_extension() const {
|
|||||||
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;
|
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VulkanContextOSX::window_create(id p_window, int p_width, int p_height) {
|
Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, id p_window, int p_width, int p_height) {
|
||||||
|
|
||||||
VkMacOSSurfaceCreateInfoMVK createInfo;
|
VkMacOSSurfaceCreateInfoMVK createInfo;
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
||||||
@ -45,8 +45,8 @@ int VulkanContextOSX::window_create(id p_window, int p_width, int p_height) {
|
|||||||
|
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
VkResult err = vkCreateMacOSSurfaceMVK(_get_instance(), &createInfo, NULL, &surface);
|
VkResult err = vkCreateMacOSSurfaceMVK(_get_instance(), &createInfo, NULL, &surface);
|
||||||
ERR_FAIL_COND_V(err, -1);
|
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
|
||||||
return _window_create(surface, p_width, p_height);
|
return _window_create(p_window_id, surface, p_width, p_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanContextOSX::VulkanContextOSX() {
|
VulkanContextOSX::VulkanContextOSX() {
|
||||||
|
@ -913,10 +913,11 @@ void LineEdit::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has_focus()) {
|
if (has_focus()) {
|
||||||
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_FOCUS_ENTER: {
|
case NOTIFICATION_FOCUS_ENTER: {
|
||||||
|
|
||||||
@ -926,9 +927,11 @@ void LineEdit::_notification(int p_what) {
|
|||||||
draw_caret = true;
|
draw_caret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
||||||
Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
|
Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
|
||||||
|
}
|
||||||
|
|
||||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
|
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
|
||||||
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
|
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
|
||||||
@ -940,8 +943,10 @@ void LineEdit::_notification(int p_what) {
|
|||||||
caret_blink_timer->stop();
|
caret_blink_timer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
|
DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
|
||||||
|
}
|
||||||
ime_text = "";
|
ime_text = "";
|
||||||
ime_selection = Point2();
|
ime_selection = Point2();
|
||||||
|
|
||||||
|
@ -1754,8 +1754,10 @@ void TextEdit::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has_focus()) {
|
if (has_focus()) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(true);
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
|
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
||||||
|
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()), get_viewport()->get_window_id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_FOCUS_ENTER: {
|
case NOTIFICATION_FOCUS_ENTER: {
|
||||||
@ -1766,9 +1768,11 @@ void TextEdit::_notification(int p_what) {
|
|||||||
draw_caret = true;
|
draw_caret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(true);
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
|
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
|
||||||
Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
|
Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos);
|
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
|
||||||
|
}
|
||||||
|
|
||||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
|
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
|
||||||
DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
|
DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
|
||||||
@ -1779,8 +1783,10 @@ void TextEdit::_notification(int p_what) {
|
|||||||
caret_blink_timer->stop();
|
caret_blink_timer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayServer::get_singleton()->window_set_ime_position(Point2());
|
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_ime_active(false);
|
DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
|
||||||
|
DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
|
||||||
|
}
|
||||||
ime_text = "";
|
ime_text = "";
|
||||||
ime_selection = Point2();
|
ime_selection = Point2();
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ public:
|
|||||||
NOTIFICATION_WM_CLOSE_REQUEST = 1006,
|
NOTIFICATION_WM_CLOSE_REQUEST = 1006,
|
||||||
NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
|
NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
|
||||||
NOTIFICATION_WM_SIZE_CHANGED = 1008,
|
NOTIFICATION_WM_SIZE_CHANGED = 1008,
|
||||||
|
NOTIFICATION_WM_DPI_CHANGE = 1009,
|
||||||
|
|
||||||
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
|
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
|
||||||
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
|
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
|
||||||
|
@ -1104,12 +1104,6 @@ void SceneTree::add_current_scene(Node *p_current) {
|
|||||||
root->add_child(p_current);
|
root->add_child(p_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTree::global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
|
||||||
|
|
||||||
emit_signal("global_menu_action", p_id, p_meta);
|
|
||||||
MainLoop::global_menu_action(p_id, p_meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
|
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
|
||||||
|
|
||||||
Ref<SceneTreeTimer> stt;
|
Ref<SceneTreeTimer> stt;
|
||||||
@ -1315,7 +1309,6 @@ void SceneTree::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("physics_frame"));
|
ADD_SIGNAL(MethodInfo("physics_frame"));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
|
ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
|
||||||
ADD_SIGNAL(MethodInfo("global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
|
|
||||||
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
|
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
|
||||||
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
|
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
|
||||||
ADD_SIGNAL(MethodInfo("connected_to_server"));
|
ADD_SIGNAL(MethodInfo("connected_to_server"));
|
||||||
|
@ -331,7 +331,6 @@ public:
|
|||||||
|
|
||||||
static SceneTree *get_singleton() { return singleton; }
|
static SceneTree *get_singleton() { return singleton; }
|
||||||
|
|
||||||
void global_menu_action(const Variant &p_id, const Variant &p_meta);
|
|
||||||
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
||||||
|
|
||||||
//network API
|
//network API
|
||||||
|
@ -104,19 +104,22 @@ void Window::set_max_size(const Size2i &p_max_size) {
|
|||||||
}
|
}
|
||||||
_update_window_size();
|
_update_window_size();
|
||||||
}
|
}
|
||||||
Size2i Window::get_max_size() const {
|
|
||||||
|
|
||||||
return min_size;
|
Size2i Window::get_max_size() const {
|
||||||
|
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
|
max_size = DisplayServer::get_singleton()->window_get_max_size(window_id);
|
||||||
|
}
|
||||||
|
return max_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::set_min_size(const Size2i &p_min_size) {
|
void Window::set_min_size(const Size2i &p_min_size) {
|
||||||
|
|
||||||
min_size = p_min_size;
|
min_size = p_min_size;
|
||||||
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
|
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
DisplayServer::get_singleton()->window_set_min_size(max_size, window_id);
|
DisplayServer::get_singleton()->window_set_min_size(min_size, window_id);
|
||||||
}
|
}
|
||||||
_update_window_size();
|
_update_window_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2i Window::get_min_size() const {
|
Size2i Window::get_min_size() const {
|
||||||
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
|
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
min_size = DisplayServer::get_singleton()->window_get_min_size(window_id);
|
min_size = DisplayServer::get_singleton()->window_get_min_size(window_id);
|
||||||
@ -338,6 +341,10 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) {
|
|||||||
_propagate_window_notification(this, NOTIFICATION_WM_GO_BACK_REQUEST);
|
_propagate_window_notification(this, NOTIFICATION_WM_GO_BACK_REQUEST);
|
||||||
emit_signal("go_back_requested");
|
emit_signal("go_back_requested");
|
||||||
} break;
|
} break;
|
||||||
|
case DisplayServer::WINDOW_EVENT_DPI_CHANGE: {
|
||||||
|
_propagate_window_notification(this, NOTIFICATION_WM_DPI_CHANGE);
|
||||||
|
emit_signal("dpi_changed");
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1360,7 +1367,6 @@ void Window::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("close_requested"));
|
ADD_SIGNAL(MethodInfo("close_requested"));
|
||||||
ADD_SIGNAL(MethodInfo("go_back_requested"));
|
ADD_SIGNAL(MethodInfo("go_back_requested"));
|
||||||
ADD_SIGNAL(MethodInfo("visibility_changed"));
|
ADD_SIGNAL(MethodInfo("visibility_changed"));
|
||||||
ADD_SIGNAL(MethodInfo("files_dropped"));
|
|
||||||
ADD_SIGNAL(MethodInfo("about_to_popup"));
|
ADD_SIGNAL(MethodInfo("about_to_popup"));
|
||||||
|
|
||||||
BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
|
BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "display_server.h"
|
#include "display_server.h"
|
||||||
#include "core/input/input_filter.h"
|
#include "core/input/input_filter.h"
|
||||||
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
DisplayServer *DisplayServer::singleton = nullptr;
|
DisplayServer *DisplayServer::singleton = nullptr;
|
||||||
DisplayServer::SwitchVSyncCallbackInThread DisplayServer::switch_vsync_function = nullptr;
|
DisplayServer::SwitchVSyncCallbackInThread DisplayServer::switch_vsync_function = nullptr;
|
||||||
@ -39,16 +40,86 @@ bool DisplayServer::hidpi_allowed = false;
|
|||||||
DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS];
|
DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS];
|
||||||
int DisplayServer::server_create_count = 0;
|
int DisplayServer::server_create_count = 0;
|
||||||
|
|
||||||
void DisplayServer::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
|
void DisplayServer::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
|
||||||
WARN_PRINT("Global menus not supported by this display server.");
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
}
|
}
|
||||||
void DisplayServer::global_menu_add_separator(const String &p_menu) {
|
|
||||||
|
void DisplayServer::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
|
||||||
WARN_PRINT("Global menus not supported by this display server.");
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
}
|
}
|
||||||
void DisplayServer::global_menu_remove_item(const String &p_menu, int p_idx) {
|
|
||||||
|
void DisplayServer::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu) {
|
||||||
WARN_PRINT("Global menus not supported by this display server.");
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
}
|
}
|
||||||
void DisplayServer::global_menu_clear(const String &p_menu) {
|
|
||||||
|
void DisplayServer::global_menu_add_separator(const String &p_menu_root) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayServer::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayServer::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Callable DisplayServer::global_menu_get_item_callback(const String &p_menu_root, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return Callable();
|
||||||
|
}
|
||||||
|
|
||||||
|
Variant DisplayServer::global_menu_get_item_tag(const String &p_menu_root, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return Variant();
|
||||||
|
}
|
||||||
|
|
||||||
|
String DisplayServer::global_menu_get_item_text(const String &p_menu_root, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return String();
|
||||||
|
}
|
||||||
|
|
||||||
|
String DisplayServer::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisplayServer::global_menu_get_item_count(const String &p_menu_root) const {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_remove_item(const String &p_menu_root, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_clear(const String &p_menu_root) {
|
||||||
WARN_PRINT("Global menus not supported by this display server.");
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +133,9 @@ DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
|
|||||||
void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
|
void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
|
||||||
WARN_PRINT("Mouse warping is not supported by this display server.");
|
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 {
|
Point2i DisplayServer::mouse_get_position() const {
|
||||||
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
|
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
|
||||||
}
|
}
|
||||||
@ -83,6 +157,10 @@ DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_scr
|
|||||||
return SCREEN_LANDSCAPE;
|
return SCREEN_LANDSCAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float DisplayServer::screen_get_scale(int p_screen) const {
|
||||||
|
return 1.0f;
|
||||||
|
};
|
||||||
|
|
||||||
bool DisplayServer::screen_is_touchscreen(int p_screen) const {
|
bool DisplayServer::screen_is_touchscreen(int p_screen) const {
|
||||||
//return false;
|
//return false;
|
||||||
return InputFilter::get_singleton() && InputFilter::get_singleton()->is_emulating_touch_from_mouse();
|
return InputFilter::get_singleton() && InputFilter::get_singleton()->is_emulating_touch_from_mouse();
|
||||||
@ -232,10 +310,27 @@ void DisplayServer::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature);
|
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("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_item", "menu_root", "label", "callback", "tag"), &DisplayServer::global_menu_add_item, DEFVAL(Variant()));
|
||||||
ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu"), &DisplayServer::global_menu_add_separator);
|
ClassDB::bind_method(D_METHOD("global_menu_add_check_item", "menu_root", "label", "callback", "tag"), &DisplayServer::global_menu_add_check_item, DEFVAL(Variant()));
|
||||||
ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu", "idx"), &DisplayServer::global_menu_remove_item);
|
ClassDB::bind_method(D_METHOD("global_menu_add_submenu_item", "menu_root", "label", "submenu"), &DisplayServer::global_menu_add_submenu_item);
|
||||||
ClassDB::bind_method(D_METHOD("global_menu_clear", "menu"), &DisplayServer::global_menu_clear);
|
ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu_root"), &DisplayServer::global_menu_add_separator);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_is_item_checked", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checked);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_is_item_checkable", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checkable);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_get_item_callback", "menu_root", "idx"), &DisplayServer::global_menu_get_item_callback);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_get_item_tag", "menu_root", "idx"), &DisplayServer::global_menu_get_item_tag);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_get_item_text", "menu_root", "idx"), &DisplayServer::global_menu_get_item_text);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_get_item_submenu", "menu_root", "idx"), &DisplayServer::global_menu_get_item_submenu);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_checked", "menu_root", "idx", "checked"), &DisplayServer::global_menu_set_item_checked);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_checkable", "menu_root", "idx", "checkable"), &DisplayServer::global_menu_set_item_checkable);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_callback", "menu_root", "idx", "callback"), &DisplayServer::global_menu_set_item_callback);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_tag", "menu_root", "idx", "tag"), &DisplayServer::global_menu_set_item_tag);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_text", "menu_root", "idx", "text"), &DisplayServer::global_menu_set_item_text);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_set_item_submenu", "menu_root", "idx", "submenu"), &DisplayServer::global_menu_set_item_submenu);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu_root", "idx"), &DisplayServer::global_menu_remove_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_clear", "menu_root"), &DisplayServer::global_menu_clear);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!"));
|
ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!"));
|
||||||
|
|
||||||
@ -244,6 +339,7 @@ void DisplayServer::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("mouse_warp_to_position", "position"), &DisplayServer::mouse_warp_to_position);
|
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_position"), &DisplayServer::mouse_get_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_get_absolute_position"), &DisplayServer::mouse_get_absolute_position);
|
||||||
ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
|
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_set", "clipboard"), &DisplayServer::clipboard_set);
|
||||||
@ -254,6 +350,7 @@ void DisplayServer::_bind_methods() {
|
|||||||
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_size", "screen"), &DisplayServer::screen_get_size, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
ClassDB::bind_method(D_METHOD("screen_get_usable_rect", "screen"), &DisplayServer::screen_get_usable_rect, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
ClassDB::bind_method(D_METHOD("screen_get_usable_rect", "screen"), &DisplayServer::screen_get_usable_rect, 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_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_get_scale", "screen"), &DisplayServer::screen_get_scale, 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_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_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
@ -440,6 +537,7 @@ void DisplayServer::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_OUT);
|
BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_OUT);
|
||||||
BIND_ENUM_CONSTANT(WINDOW_EVENT_CLOSE_REQUEST);
|
BIND_ENUM_CONSTANT(WINDOW_EVENT_CLOSE_REQUEST);
|
||||||
BIND_ENUM_CONSTANT(WINDOW_EVENT_GO_BACK_REQUEST);
|
BIND_ENUM_CONSTANT(WINDOW_EVENT_GO_BACK_REQUEST);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_EVENT_DPI_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServer::register_create_function(const char *p_name, CreateFunction p_function, GetVideoDriversFunction p_get_drivers) {
|
void DisplayServer::register_create_function(const char *p_name, CreateFunction p_function, GetVideoDriversFunction p_get_drivers) {
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
|
|
||||||
|
class Texture2D;
|
||||||
|
|
||||||
class DisplayServer : public Object {
|
class DisplayServer : public Object {
|
||||||
GDCLASS(DisplayServer, Object)
|
GDCLASS(DisplayServer, Object)
|
||||||
|
|
||||||
@ -47,6 +49,7 @@ public:
|
|||||||
_FORCE_INLINE_ static DisplayServer *get_singleton() {
|
_FORCE_INLINE_ static DisplayServer *get_singleton() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum WindowMode {
|
enum WindowMode {
|
||||||
WINDOW_MODE_WINDOWED,
|
WINDOW_MODE_WINDOWED,
|
||||||
WINDOW_MODE_MINIMIZED,
|
WINDOW_MODE_MINIMIZED,
|
||||||
@ -103,16 +106,34 @@ public:
|
|||||||
FEATURE_ORIENTATION,
|
FEATURE_ORIENTATION,
|
||||||
FEATURE_SWAP_BUFFERS,
|
FEATURE_SWAP_BUFFERS,
|
||||||
FEATURE_KEEP_SCREEN_ON,
|
FEATURE_KEEP_SCREEN_ON,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool has_feature(Feature p_feature) const = 0;
|
virtual bool has_feature(Feature p_feature) const = 0;
|
||||||
virtual String get_name() 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_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
|
||||||
virtual void global_menu_add_separator(const String &p_menu);
|
virtual void global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
|
||||||
virtual void global_menu_remove_item(const String &p_menu, int p_idx);
|
virtual void global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu);
|
||||||
virtual void global_menu_clear(const String &p_menu);
|
virtual void global_menu_add_separator(const String &p_menu_root);
|
||||||
|
|
||||||
|
virtual bool global_menu_is_item_checked(const String &p_menu_root, int p_idx) const;
|
||||||
|
virtual bool global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const;
|
||||||
|
virtual Callable global_menu_get_item_callback(const String &p_menu_root, int p_idx);
|
||||||
|
virtual Variant global_menu_get_item_tag(const String &p_menu_root, int p_idx);
|
||||||
|
virtual String global_menu_get_item_text(const String &p_menu_root, int p_idx);
|
||||||
|
virtual String global_menu_get_item_submenu(const String &p_menu_root, int p_idx);
|
||||||
|
|
||||||
|
virtual void global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked);
|
||||||
|
virtual void global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable);
|
||||||
|
virtual void global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback);
|
||||||
|
virtual void global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag);
|
||||||
|
virtual void global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text);
|
||||||
|
virtual void global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu);
|
||||||
|
|
||||||
|
virtual int global_menu_get_item_count(const String &p_menu_root) const;
|
||||||
|
|
||||||
|
virtual void global_menu_remove_item(const String &p_menu_root, int p_idx);
|
||||||
|
virtual void global_menu_clear(const String &p_menu_root);
|
||||||
|
|
||||||
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
|
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
|
||||||
|
|
||||||
@ -128,6 +149,7 @@ public:
|
|||||||
|
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
|
virtual Point2i mouse_get_absolute_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual int mouse_get_button_state() const;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text);
|
virtual void clipboard_set(const String &p_text);
|
||||||
@ -142,6 +164,7 @@ public:
|
|||||||
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
|
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
enum ScreenOrientation {
|
enum ScreenOrientation {
|
||||||
|
|
||||||
@ -199,6 +222,7 @@ public:
|
|||||||
WINDOW_EVENT_FOCUS_OUT,
|
WINDOW_EVENT_FOCUS_OUT,
|
||||||
WINDOW_EVENT_CLOSE_REQUEST,
|
WINDOW_EVENT_CLOSE_REQUEST,
|
||||||
WINDOW_EVENT_GO_BACK_REQUEST,
|
WINDOW_EVENT_GO_BACK_REQUEST,
|
||||||
|
WINDOW_EVENT_DPI_CHANGE,
|
||||||
};
|
};
|
||||||
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user