1
0
mirror of synced 2024-12-01 02:37:18 +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)
return;
// Get the currently focused window
const auto window = ctx->NavWindow;
if (window == nullptr)
return;
static ImGuiWindow *lastFocusedWindow = window;
static ImGuiWindow *lastFocusedWindow = nullptr;
if (focused) {
// If the main window gains focus again, restore the last focused window
ImGui::FocusWindow(lastFocusedWindow);
ImGui::FocusWindow(lastFocusedWindow, ImGuiFocusRequestFlags_RestoreFocusedChild);
if (lastFocusedWindow != nullptr)
log::debug("Restoring focus on window '{}'", lastFocusedWindow->Name ? lastFocusedWindow->Name : "Unknown Window");
} else {
// 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
// cursor blink animations don't play
lastFocusedWindow = window;
lastFocusedWindow = ctx->NavWindow;
ImGui::FocusWindow(nullptr);
if (lastFocusedWindow != nullptr)
log::debug("Removing focus from window '{}'", lastFocusedWindow->Name ? lastFocusedWindow->Name : "Unknown Window");
}
});