mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Shortcuts not working in detached windows
This commit is contained in:
@@ -59,7 +59,7 @@ namespace hex {
|
||||
|
||||
std::mutex m_popupMutex;
|
||||
std::list<std::string> m_popupsToOpen;
|
||||
std::vector<int> m_pressedKeys;
|
||||
std::set<int> m_pressedKeys;
|
||||
|
||||
std::atomic<bool> m_unlockFrameRate = false;
|
||||
|
||||
|
||||
@@ -874,19 +874,32 @@ namespace hex {
|
||||
glfwSetWindowSize(m_window, width, height);
|
||||
}
|
||||
|
||||
static const auto unlockFrameRate = [](GLFWwindow *, auto ...) {
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(ImHexApi::System::getMainWindowHandle()));
|
||||
if (win == nullptr)
|
||||
return;
|
||||
|
||||
win->m_unlockFrameRate = true;
|
||||
};
|
||||
|
||||
static const auto isMainWindow = [](GLFWwindow *window) {
|
||||
return window == ImHexApi::System::getMainWindowHandle();
|
||||
};
|
||||
|
||||
// Register window move callback
|
||||
glfwSetWindowPosCallback(m_window, [](GLFWwindow *window, int x, int y) {
|
||||
ImHexApi::System::impl::setMainWindowPosition(x, y);
|
||||
unlockFrameRate(window);
|
||||
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||
win->m_unlockFrameRate = true;
|
||||
win->fullFrame();
|
||||
if (!isMainWindow(window)) return;
|
||||
|
||||
ImHexApi::System::impl::setMainWindowPosition(x, y);
|
||||
});
|
||||
|
||||
// Register window resize callback
|
||||
glfwSetWindowSizeCallback(m_window, [](GLFWwindow *window, [[maybe_unused]] int width, [[maybe_unused]] int height) {
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||
win->m_unlockFrameRate = true;
|
||||
unlockFrameRate(window);
|
||||
|
||||
if (!isMainWindow(window)) return;
|
||||
|
||||
#if !defined(OS_WINDOWS)
|
||||
if (!glfwGetWindowAttrib(window, GLFW_ICONIFIED))
|
||||
@@ -903,11 +916,6 @@ namespace hex {
|
||||
#endif
|
||||
});
|
||||
|
||||
static const auto unlockFrameRate = [](GLFWwindow *window, auto ...) {
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||
win->m_unlockFrameRate = true;
|
||||
};
|
||||
|
||||
glfwSetCursorPosCallback(m_window, unlockFrameRate);
|
||||
glfwSetMouseButtonCallback(m_window, unlockFrameRate);
|
||||
glfwSetScrollCallback(m_window, unlockFrameRate);
|
||||
@@ -971,14 +979,18 @@ namespace hex {
|
||||
}
|
||||
#endif
|
||||
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||
win->m_pressedKeys.push_back(key);
|
||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(ImHexApi::System::getMainWindowHandle()));
|
||||
win->m_pressedKeys.insert(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Register window close callback
|
||||
glfwSetWindowCloseCallback(m_window, [](GLFWwindow *window) {
|
||||
unlockFrameRate(window);
|
||||
|
||||
if (!isMainWindow(window)) return;
|
||||
|
||||
EventWindowClosing::post(window);
|
||||
});
|
||||
|
||||
@@ -1140,6 +1152,8 @@ namespace hex {
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
#endif
|
||||
|
||||
ImGui_ImplGlfw_SetCallbacksChainForAllWindows(true);
|
||||
|
||||
for (const auto &plugin : PluginManager::getPlugins())
|
||||
plugin.setImGuiContext(ImGui::GetCurrentContext());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user