Skip to content

Commit

Permalink
impr: Only re-render frame once during window resize or move operations
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jun 28, 2024
1 parent a6e5040 commit 90ac962
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions main/gui/source/window/linux_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ namespace hex {
}
});

glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->fullFrame();
});

if (themeFollowSystem)
EventOSThemeChanged::post();
}
Expand Down
5 changes: 5 additions & 0 deletions main/gui/source/window/macos_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ namespace hex {
});

setupMacosWindowStyle(m_window, ImHexApi::System::isBorderlessWindowModeEnabled());

glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->fullFrame();
});
}

void Window::beginNativeWindowFrame() {
Expand Down
5 changes: 5 additions & 0 deletions main/gui/source/window/web_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ namespace hex {
}
});

glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->fullFrame();
});

if (themeFollowSystem)
EventOSThemeChanged::post();
}
Expand Down
7 changes: 5 additions & 2 deletions main/gui/source/window/win_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,12 @@ namespace hex {

glViewport(0, 0, width, height);
ImHexApi::System::impl::setMainWindowSize(width, height);
});

glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->fullFrame();
DwmFlush();
});
}

Expand All @@ -581,8 +585,7 @@ namespace hex {
}

void Window::endNativeWindowFrame() {
if (!ImHexApi::System::isBorderlessWindowModeEnabled())
return;

}

}
Expand Down
10 changes: 0 additions & 10 deletions main/gui/source/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,6 @@ namespace hex {

auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;

win->fullFrame();
});

// Register window resize callback
Expand All @@ -837,17 +835,9 @@ namespace hex {
ImGui::GetIO().MousePos = ImVec2();
}
#else
win->fullFrame();
#endif
});

#if defined(OS_MACOS)
glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->fullFrame();
});
#endif

glfwSetCursorPosCallback(m_window, [](GLFWwindow *window, double, double) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
Expand Down

0 comments on commit 90ac962

Please sign in to comment.