Merge pull request #83014 from Chubercik/window_method_duplicate_fix

Add deprecation notice to a duplicate method of class `Window`
This commit is contained in:
Rémi Verschelde 2024-01-15 13:22:02 +01:00
commit fb5ad1af3d
No known key found for this signature in database
GPG key ID: C3336907360768E1
4 changed files with 11 additions and 9 deletions

View file

@ -357,10 +357,11 @@
Centers a native window on the current screen and an embedded window on its embedder [Viewport]. Centers a native window on the current screen and an embedded window on its embedder [Viewport].
</description> </description>
</method> </method>
<method name="move_to_foreground"> <method name="move_to_foreground" is_deprecated="true">
<return type="void" /> <return type="void" />
<description> <description>
Moves the [Window] on top of other windows and focuses it. Moves the [Window] on top of other windows and focuses it.
[i]Deprecated.[/i] Use [method Window.grab_focus] instead.
</description> </description>
</method> </method>
<method name="popup"> <method name="popup">

View file

@ -2350,7 +2350,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
line = line.replace("OS.is_window_focused", "get_window().has_focus"); line = line.replace("OS.is_window_focused", "get_window().has_focus");
} }
if (line.contains("OS.move_window_to_foreground")) { if (line.contains("OS.move_window_to_foreground")) {
line = line.replace("OS.move_window_to_foreground", "get_window().move_to_foreground"); line = line.replace("OS.move_window_to_foreground", "get_window().grab_focus");
} }
if (line.contains("OS.request_attention")) { if (line.contains("OS.request_attention")) {
line = line.replace("OS.request_attention", "get_window().request_attention"); line = line.replace("OS.request_attention", "get_window().request_attention");

View file

@ -520,15 +520,12 @@ void Window::request_attention() {
} }
} }
#ifndef DISABLE_DEPRECATED
void Window::move_to_foreground() { void Window::move_to_foreground() {
ERR_MAIN_THREAD_GUARD; WARN_DEPRECATED_MSG(R"*(The "move_to_foreground()" method is deprecated, use "grab_focus()" instead.)*");
if (embedder) { grab_focus();
embedder->_sub_window_grab_focus(this);
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
DisplayServer::get_singleton()->window_move_to_foreground(window_id);
}
} }
#endif // DISABLE_DEPRECATED
bool Window::can_draw() const { bool Window::can_draw() const {
ERR_READ_THREAD_GUARD_V(false); ERR_READ_THREAD_GUARD_V(false);
@ -2745,7 +2742,9 @@ void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("request_attention"), &Window::request_attention); ClassDB::bind_method(D_METHOD("request_attention"), &Window::request_attention);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("move_to_foreground"), &Window::move_to_foreground); ClassDB::bind_method(D_METHOD("move_to_foreground"), &Window::move_to_foreground);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Window::set_visible); ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Window::set_visible);
ClassDB::bind_method(D_METHOD("is_visible"), &Window::is_visible); ClassDB::bind_method(D_METHOD("is_visible"), &Window::is_visible);

View file

@ -301,7 +301,9 @@ public:
bool is_maximize_allowed() const; bool is_maximize_allowed() const;
void request_attention(); void request_attention();
#ifndef DISABLE_DEPRECATED
void move_to_foreground(); void move_to_foreground();
#endif // DISABLE_DEPRECATED
virtual void set_visible(bool p_visible); virtual void set_visible(bool p_visible);
bool is_visible() const; bool is_visible() const;