1
0
mirror of synced 2024-11-28 09:30:51 +01:00

fix: Focus restoring not working correctly

This commit is contained in:
WerWolv 2024-02-23 17:48:37 +01:00
parent 91dcfefc5c
commit 61fd327aa1

View File

@ -233,22 +233,24 @@ namespace hex::plugin::builtin {
if (ctx == nullptr) if (ctx == nullptr)
return; return;
// Get the currently focused window static ImGuiWindow *lastFocusedWindow = nullptr;
const auto window = ctx->NavWindow;
if (window == nullptr)
return;
static ImGuiWindow *lastFocusedWindow = window;
if (focused) { if (focused) {
// If the main window gains focus again, restore the last focused window // If the main window gains focus again, restore the last focused window
ImGui::FocusWindow(lastFocusedWindow);
ImGui::FocusWindow(lastFocusedWindow, ImGuiFocusRequestFlags_RestoreFocusedChild); ImGui::FocusWindow(lastFocusedWindow, ImGuiFocusRequestFlags_RestoreFocusedChild);
if (lastFocusedWindow != nullptr)
log::debug("Restoring focus on window '{}'", lastFocusedWindow->Name ? lastFocusedWindow->Name : "Unknown Window");
} else { } else {
// If the main window loses focus, store the currently focused window // If the main window loses focus, store the currently focused window
// and remove focus from it so it doesn't look like it's focused and // and remove focus from it so it doesn't look like it's focused and
// cursor blink animations don't play // cursor blink animations don't play
lastFocusedWindow = window; lastFocusedWindow = ctx->NavWindow;
ImGui::FocusWindow(nullptr); ImGui::FocusWindow(nullptr);
if (lastFocusedWindow != nullptr)
log::debug("Removing focus from window '{}'", lastFocusedWindow->Name ? lastFocusedWindow->Name : "Unknown Window");
} }
}); });