Merge pull request #80952 from bruvzg/nfdlg_refocus

[Native File Dialogs] Refocus last focused window on close.
This commit is contained in:
Rémi Verschelde 2023-10-03 17:13:58 +02:00
commit 31dbbc2c5a
No known key found for this signature in database
GPG key ID: C3336907360768E1
5 changed files with 22 additions and 4 deletions

View file

@ -240,6 +240,8 @@ Error DisplayServerWindows::file_dialog_show(const String &p_title, const String
filters.push_back({ (LPCWSTR)filter_names[i].ptr(), (LPCWSTR)filter_exts[i].ptr() });
}
WindowID prev_focus = last_focused_window;
HRESULT hr = S_OK;
IFileDialog *pfd = nullptr;
if (p_mode == FILE_DIALOG_MODE_SAVE_FILE) {
@ -340,6 +342,9 @@ Error DisplayServerWindows::file_dialog_show(const String &p_title, const String
}
}
pfd->Release();
if (prev_focus != INVALID_WINDOW_ID) {
callable_mp(DisplayServer::get_singleton(), &DisplayServer::window_move_to_foreground).call_deferred(prev_focus);
}
return OK;
} else {