1
0
mirror of synced 2024-11-28 01:20:51 +01:00

impr: Make window less prone to flickering during resizes on Windows

This commit is contained in:
WerWolv 2024-05-30 16:57:07 +02:00
parent 63f66662ce
commit 08c2f3fc15
3 changed files with 17 additions and 6 deletions

View File

@ -551,6 +551,16 @@ namespace hex {
});
ImGui::GetIO().ConfigDebugIsDebuggerPresent = ::IsDebuggerPresent();
glfwSetFramebufferSizeCallback(m_window, [](GLFWwindow* window, int width, int height) {
auto *win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
glViewport(0, 0, width, height);
ImHexApi::System::impl::setMainWindowSize(width, height);
win->fullFrame();
});
}
void Window::beginNativeWindowFrame() {

View File

@ -820,12 +820,14 @@ namespace hex {
// Register window resize callback
glfwSetWindowSizeCallback(m_window, [](GLFWwindow *window, int width, int height) {
if (!glfwGetWindowAttrib(window, GLFW_ICONIFIED))
ImHexApi::System::impl::setMainWindowSize(width, height);
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
#if !defined(OS_WINDOWS)
if (!glfwGetWindowAttrib(window, GLFW_ICONIFIED))
ImHexApi::System::impl::setMainWindowSize(width, height);
#endif
#if defined(OS_MACOS)
// Stop widgets registering hover effects while the window is being resized
if (macosIsWindowBeingResizedByUser(window)) {

View File

@ -462,7 +462,6 @@ namespace hex::plugin::builtin {
constexpr static ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
// Handle all undocked floating windows
ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(ImHexApi::System::getMainWindowSize() - ImVec2(0, ImGui::GetTextLineHeightWithSpacing()));
@ -490,7 +489,7 @@ namespace hex::plugin::builtin {
footerHeight += ImGui::GetStyle().FramePadding.y * 2;
#endif
const auto dockSpaceSize = ImVec2(ImHexApi::System::getMainWindowSize().x - sidebarWidth, ImGui::GetContentRegionAvail().y - footerHeight);
const auto dockSpaceSize = ImHexApi::System::getMainWindowSize() - ImVec2(sidebarWidth, menuBarHeight * 2 + footerHeight);
ImGui::SetCursorPosX(sidebarWidth);
drawFooter(drawList, dockSpaceSize, footerHeight);