fix: Focus restoring not working correctly
This commit is contained in:
parent
91dcfefc5c
commit
61fd327aa1
@ -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");
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user