Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation notice to a duplicate method of class Window #83014

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/classes/Window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,11 @@
Centers a native window on the current screen and an embedded window on its embedder [Viewport].
</description>
</method>
<method name="move_to_foreground">
<method name="move_to_foreground" is_deprecated="true">
<return type="void" />
<description>
Moves the [Window] on top of other windows and focuses it.
[i]Deprecated.[/i] Use [method Window.grab_focus] instead.
</description>
</method>
<method name="popup">
Expand Down
2 changes: 1 addition & 1 deletion editor/project_converter_3_to_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
line = line.replace("OS.is_window_focused", "get_window().has_focus");
}
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")) {
line = line.replace("OS.request_attention", "get_window().request_attention");
Expand Down
13 changes: 6 additions & 7 deletions scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,12 @@ void Window::request_attention() {
}
}

#ifndef DISABLE_DEPRECATED
void Window::move_to_foreground() {
Chubercik marked this conversation as resolved.
Show resolved Hide resolved
ERR_MAIN_THREAD_GUARD;
if (embedder) {
embedder->_sub_window_grab_focus(this);

} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
DisplayServer::get_singleton()->window_move_to_foreground(window_id);
}
WARN_DEPRECATED_MSG(R"*(The "move_to_foreground()" method is deprecated, use "grab_focus()" instead.)*");
grab_focus();
}
#endif // DISABLE_DEPRECATED

bool Window::can_draw() const {
ERR_READ_THREAD_GUARD_V(false);
Expand Down Expand Up @@ -2745,7 +2742,9 @@ void Window::_bind_methods() {

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);
#endif // DISABLE_DEPRECATED

ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Window::set_visible);
ClassDB::bind_method(D_METHOD("is_visible"), &Window::is_visible);
Expand Down
2 changes: 2 additions & 0 deletions scene/main/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ class Window : public Viewport {
bool is_maximize_allowed() const;

void request_attention();
#ifndef DISABLE_DEPRECATED
void move_to_foreground();
#endif // DISABLE_DEPRECATED

virtual void set_visible(bool p_visible);
bool is_visible() const;
Expand Down
Loading