fix: Disable focus handling on the web version since the GLFW_FOCUSED attribute doesn't work

This commit is contained in:
WerWolv 2025-08-17 20:21:36 +02:00
parent 01f24d2f2f
commit cf5b9da45e
1 changed files with 17 additions and 15 deletions

View File

@ -380,25 +380,27 @@ namespace hex {
ImHexApi::Fonts::getDefaultFont().push();
io.FontDefault = ImHexApi::Fonts::getDefaultFont();
{
static bool lastAnyWindowFocused = false;
bool anyWindowFocused = glfwGetWindowAttrib(m_window, GLFW_FOCUSED);
#if !defined(OS_WEB)
{
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 (!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;
}
if (lastAnyWindowFocused != anyWindowFocused)
EventWindowFocused::post(anyWindowFocused);
lastAnyWindowFocused = anyWindowFocused;
}
#endif
// Start new ImGui Frame
ImGui_ImplOpenGL3_NewFrame();