Add get_native_handle to OS

This commit is contained in:
Bastiaan Olij
2020-10-03 22:13:39 +10:00
parent a16a1ead49
commit 1ea7358405
12 changed files with 122 additions and 0 deletions

View File

@@ -1144,6 +1144,11 @@ void _OS::move_window_to_foreground() {
OS::get_singleton()->move_window_to_foreground();
}
int64_t _OS::get_native_handle(HandleType p_handle_type) {
return (int64_t)OS::get_singleton()->get_native_handle(p_handle_type);
}
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
@@ -1292,6 +1297,8 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("center_window"), &_OS::center_window);
ClassDB::bind_method(D_METHOD("move_window_to_foreground"), &_OS::move_window_to_foreground);
ClassDB::bind_method(D_METHOD("get_native_handle", "handle_type"), &_OS::get_native_handle);
ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window);
@@ -1503,6 +1510,12 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(MONTH_NOVEMBER);
BIND_ENUM_CONSTANT(MONTH_DECEMBER);
BIND_ENUM_CONSTANT(APPLICATION_HANDLE);
BIND_ENUM_CONSTANT(DISPLAY_HANDLE);
BIND_ENUM_CONSTANT(WINDOW_HANDLE);
BIND_ENUM_CONSTANT(WINDOW_VIEW);
BIND_ENUM_CONSTANT(OPENGL_CONTEXT);
BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_LANDSCAPE);
BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_PORTRAIT);
BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);

View File

@@ -143,6 +143,14 @@ public:
MONTH_DECEMBER
};
enum HandleType {
APPLICATION_HANDLE, // HINSTANCE, NSApplication*, UIApplication*, JNIEnv* ...
DISPLAY_HANDLE, // X11::Display* ...
WINDOW_HANDLE, // HWND, X11::Window*, NSWindow*, UIWindow*, Android activity ...
WINDOW_VIEW, // HDC, NSView*, UIView*, Android surface ...
OPENGL_CONTEXT, // HGLRC, X11::GLXContext, NSOpenGLContext*, EGLContext* ...
};
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);
@@ -206,6 +214,8 @@ public:
virtual void center_window();
virtual void move_window_to_foreground();
virtual int64_t get_native_handle(HandleType p_handle_type);
virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window() const;
@@ -383,6 +393,7 @@ VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
VARIANT_ENUM_CAST(_OS::SystemDir);
VARIANT_ENUM_CAST(_OS::ScreenOrientation);
VARIANT_ENUM_CAST(_OS::HandleType);
class _Geometry : public Object {