|
@@ -570,6 +570,10 @@ bool Window::is_in_edited_scene_root() const {
|
|
void Window::_make_window() {
|
|
void Window::_make_window() {
|
|
ERR_FAIL_COND(window_id != DisplayServer::INVALID_WINDOW_ID);
|
|
ERR_FAIL_COND(window_id != DisplayServer::INVALID_WINDOW_ID);
|
|
|
|
|
|
|
|
+ if (transient && transient_to_focused) {
|
|
|
|
+ _make_transient();
|
|
|
|
+ }
|
|
|
|
+
|
|
uint32_t f = 0;
|
|
uint32_t f = 0;
|
|
for (int i = 0; i < FLAG_MAX; i++) {
|
|
for (int i = 0; i < FLAG_MAX; i++) {
|
|
if (flags[i]) {
|
|
if (flags[i]) {
|
|
@@ -662,6 +666,10 @@ void Window::_clear_window() {
|
|
|
|
|
|
_update_viewport_size();
|
|
_update_viewport_size();
|
|
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
|
|
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
|
|
|
|
+
|
|
|
|
+ if (transient && transient_to_focused) {
|
|
|
|
+ _clear_transient();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void Window::_rect_changed_callback(const Rect2i &p_callback) {
|
|
void Window::_rect_changed_callback(const Rect2i &p_callback) {
|
|
@@ -861,18 +869,29 @@ void Window::_make_transient() {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//find transient parent
|
|
//find transient parent
|
|
- Viewport *vp = get_parent()->get_viewport();
|
|
|
|
|
|
+
|
|
Window *window = nullptr;
|
|
Window *window = nullptr;
|
|
- while (vp) {
|
|
|
|
- window = Object::cast_to<Window>(vp);
|
|
|
|
- if (window) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (!vp->get_parent()) {
|
|
|
|
- break;
|
|
|
|
|
|
+
|
|
|
|
+ if (!is_embedded() && transient_to_focused) {
|
|
|
|
+ DisplayServer::WindowID focused_window_id = DisplayServer::get_singleton()->get_focused_window();
|
|
|
|
+ if (focused_window_id != DisplayServer::INVALID_WINDOW_ID) {
|
|
|
|
+ window = Object::cast_to<Window>(ObjectDB::get_instance(DisplayServer::get_singleton()->window_get_attached_instance_id(focused_window_id)));
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- vp = vp->get_parent()->get_viewport();
|
|
|
|
|
|
+ if (!window) {
|
|
|
|
+ Viewport *vp = get_parent()->get_viewport();
|
|
|
|
+ while (vp) {
|
|
|
|
+ window = Object::cast_to<Window>(vp);
|
|
|
|
+ if (window) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (!vp->get_parent()) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ vp = vp->get_parent()->get_viewport();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (window) {
|
|
if (window) {
|
|
@@ -916,17 +935,32 @@ void Window::set_transient(bool p_transient) {
|
|
}
|
|
}
|
|
|
|
|
|
if (transient) {
|
|
if (transient) {
|
|
- _make_transient();
|
|
|
|
|
|
+ if (!transient_to_focused) {
|
|
|
|
+ _make_transient();
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
_clear_transient();
|
|
_clear_transient();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
bool Window::is_transient() const {
|
|
bool Window::is_transient() const {
|
|
- ERR_READ_THREAD_GUARD_V(false);
|
|
|
|
return transient;
|
|
return transient;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void Window::set_transient_to_focused(bool p_transient_to_focused) {
|
|
|
|
+ ERR_MAIN_THREAD_GUARD;
|
|
|
|
+ if (transient_to_focused == p_transient_to_focused) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ transient_to_focused = p_transient_to_focused;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Window::is_transient_to_focused() const {
|
|
|
|
+ ERR_READ_THREAD_GUARD_V(false);
|
|
|
|
+ return transient_to_focused;
|
|
|
|
+}
|
|
|
|
+
|
|
void Window::set_exclusive(bool p_exclusive) {
|
|
void Window::set_exclusive(bool p_exclusive) {
|
|
ERR_MAIN_THREAD_GUARD;
|
|
ERR_MAIN_THREAD_GUARD;
|
|
if (exclusive == p_exclusive) {
|
|
if (exclusive == p_exclusive) {
|
|
@@ -1259,7 +1293,7 @@ void Window::_notification(int p_what) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (transient) {
|
|
|
|
|
|
+ if (transient && !transient_to_focused) {
|
|
_make_transient();
|
|
_make_transient();
|
|
}
|
|
}
|
|
if (visible) {
|
|
if (visible) {
|
|
@@ -2755,6 +2789,9 @@ void Window::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("set_transient", "transient"), &Window::set_transient);
|
|
ClassDB::bind_method(D_METHOD("set_transient", "transient"), &Window::set_transient);
|
|
ClassDB::bind_method(D_METHOD("is_transient"), &Window::is_transient);
|
|
ClassDB::bind_method(D_METHOD("is_transient"), &Window::is_transient);
|
|
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_transient_to_focused", "enable"), &Window::set_transient_to_focused);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("is_transient_to_focused"), &Window::is_transient_to_focused);
|
|
|
|
+
|
|
ClassDB::bind_method(D_METHOD("set_exclusive", "exclusive"), &Window::set_exclusive);
|
|
ClassDB::bind_method(D_METHOD("set_exclusive", "exclusive"), &Window::set_exclusive);
|
|
ClassDB::bind_method(D_METHOD("is_exclusive"), &Window::is_exclusive);
|
|
ClassDB::bind_method(D_METHOD("is_exclusive"), &Window::is_exclusive);
|
|
|
|
|
|
@@ -2883,6 +2920,7 @@ void Window::_bind_methods() {
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transient"), "set_transient", "is_transient");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transient"), "set_transient", "is_transient");
|
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transient_to_focused"), "set_transient_to_focused", "is_transient_to_focused");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclusive"), "set_exclusive", "is_exclusive");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclusive"), "set_exclusive", "is_exclusive");
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unresizable"), "set_flag", "get_flag", FLAG_RESIZE_DISABLED);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unresizable"), "set_flag", "get_flag", FLAG_RESIZE_DISABLED);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "borderless"), "set_flag", "get_flag", FLAG_BORDERLESS);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "borderless"), "set_flag", "get_flag", FLAG_BORDERLESS);
|