mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Task finished notification showing up regardless of focus state on Windows
This commit is contained in:
@@ -62,6 +62,7 @@ EXPORT_MODULE namespace hex {
|
||||
void setMainWindowSize(u32 width, u32 height);
|
||||
void setMainDockSpaceId(ImGuiID id);
|
||||
void setMainWindowHandle(GLFWwindow *window);
|
||||
void setMainWindowFocusState(bool focused);
|
||||
|
||||
void setGlobalScale(float scale);
|
||||
void setNativeScale(float scale);
|
||||
@@ -161,6 +162,12 @@ EXPORT_MODULE namespace hex {
|
||||
*/
|
||||
GLFWwindow* getMainWindowHandle();
|
||||
|
||||
/**
|
||||
* @brief Checks if the main window is currently focused
|
||||
* @return Whether the main window is focused
|
||||
*/
|
||||
bool isMainWindowFocused();
|
||||
|
||||
/**
|
||||
* @brief Checks if borderless window mode is enabled currently
|
||||
* @return Whether borderless window mode is enabled
|
||||
|
||||
@@ -538,6 +538,11 @@ namespace hex {
|
||||
s_mainWindowHandle = window;
|
||||
}
|
||||
|
||||
static bool s_mainWindowFocused = false;
|
||||
void setMainWindowFocusState(bool focused) {
|
||||
s_mainWindowFocused = focused;
|
||||
}
|
||||
|
||||
|
||||
static float s_globalScale = 1.0;
|
||||
void setGlobalScale(float scale) {
|
||||
@@ -708,6 +713,10 @@ namespace hex {
|
||||
return impl::s_mainWindowHandle;
|
||||
}
|
||||
|
||||
bool isMainWindowFocused() {
|
||||
return impl::s_mainWindowFocused;
|
||||
}
|
||||
|
||||
bool isBorderlessWindowModeEnabled() {
|
||||
return impl::s_borderlessWindowMode;
|
||||
}
|
||||
|
||||
@@ -1166,7 +1166,10 @@ namespace hex {
|
||||
glfwSetCursorPosCallback(m_window, unlockFrameRate);
|
||||
glfwSetMouseButtonCallback(m_window, unlockFrameRate);
|
||||
glfwSetScrollCallback(m_window, unlockFrameRate);
|
||||
glfwSetWindowFocusCallback(m_window, unlockFrameRate);
|
||||
glfwSetWindowFocusCallback(m_window, [](GLFWwindow *window, int focused) {
|
||||
unlockFrameRate(window);
|
||||
ImHexApi::System::impl::setMainWindowFocusState(focused);
|
||||
});
|
||||
|
||||
glfwSetWindowMaximizeCallback(m_window, [](GLFWwindow *window, int) {
|
||||
glfwShowWindow(window);
|
||||
|
||||
@@ -432,7 +432,8 @@ namespace hex::plugin::builtin {
|
||||
if (!taskFinishedNotificationEnabled)
|
||||
return;
|
||||
|
||||
if (!glfwGetWindowAttrib(ImHexApi::System::getMainWindowHandle(), GLFW_FOCUSED) && !task.isBackgroundTask())
|
||||
|
||||
if (!ImHexApi::System::isMainWindowFocused() && !task.isBackgroundTask())
|
||||
hex::showToastMessage("ImHex", fmt::format("hex.builtin.os_toast_message.task_finished"_lang, Lang(task.getUnlocalizedName())));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user