From 27ca31f359951224a94d8e5b439982b2bc794731 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:44:30 +0200 Subject: [PATCH] [Editor] Save and restore previous window mode when toggling full-screen. --- editor/editor_node.cpp | 9 +++++++-- editor/editor_node.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 32da37ad273..b2a65063a76 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2943,8 +2943,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8); } break; case SETTINGS_TOGGLE_FULLSCREEN: { - DisplayServer::get_singleton()->window_set_mode(DisplayServer::get_singleton()->window_get_mode() == DisplayServer::WINDOW_MODE_FULLSCREEN ? DisplayServer::WINDOW_MODE_WINDOWED : DisplayServer::WINDOW_MODE_FULLSCREEN); - + DisplayServer::WindowMode mode = DisplayServer::get_singleton()->window_get_mode(); + if (mode == DisplayServer::WINDOW_MODE_FULLSCREEN || mode == DisplayServer::WINDOW_MODE_EXCLUSIVE_FULLSCREEN) { + DisplayServer::get_singleton()->window_set_mode(prev_mode); + } else { + prev_mode = mode; + DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_FULLSCREEN); + } } break; case EDITOR_SCREENSHOT: { screenshot_timer->start(); diff --git a/editor/editor_node.h b/editor/editor_node.h index 9c97166456e..a50ea5c69ea 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -332,6 +332,7 @@ private: bool exiting = false; bool dimmed = false; + DisplayServer::WindowMode prev_mode = DisplayServer::WINDOW_MODE_MAXIMIZED; int old_split_ofs = 0; VSplitContainer *top_split = nullptr; HBoxContainer *bottom_hb = nullptr;