fix: More window focus event issues

This commit is contained in:
WerWolv
2025-08-16 16:47:23 +02:00
parent 23085372a1
commit 8b72ea81c0
2 changed files with 20 additions and 24 deletions

View File

@@ -380,6 +380,26 @@ namespace hex {
ImHexApi::Fonts::getDefaultFont().push();
io.FontDefault = ImHexApi::Fonts::getDefaultFont();
{
static bool lastAnyWindowFocused = false;
bool anyWindowFocused = glfwGetWindowAttrib(m_window, GLFW_FOCUSED);
if (!anyWindowFocused) {
const auto platformIo = ImGui::GetPlatformIO();
for (auto *viewport : platformIo.Viewports) {
if (platformIo.Platform_GetWindowFocus(viewport)) {
anyWindowFocused = true;
break;
}
}
}
if (lastAnyWindowFocused != anyWindowFocused)
EventWindowFocused::post(anyWindowFocused);
lastAnyWindowFocused = anyWindowFocused;
}
// Start new ImGui Frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
@@ -397,12 +417,6 @@ namespace hex {
EventFrameBegin::post();
static bool lastFocusLost = io.AppFocusLost;
if (io.AppFocusLost != lastFocusLost) {
EventWindowFocused::post(!io.AppFocusLost);
}
lastFocusLost = io.AppFocusLost;
// Handle all undocked floating windows
ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);