Improve Windows build config and reduce CPU load

Enable MinSizeRel builds to produce a Windows executable. Added a sleep interval in the focus monitor loop to decrease CPU usage during execution, improving performance efficiency.
This commit is contained in:
2024-12-09 12:08:17 +01:00
parent 8951e05ad3
commit cb6cbe4352
2 changed files with 7 additions and 3 deletions

View File

@@ -46,6 +46,6 @@ add_executable(Toolbox main.cpp ${SOURCES} ${RESOURCE_FILES} ${PLATFORM_SOURCES}
target_include_directories(${PROJECT_NAME} PRIVATE "out_embed")
target_link_libraries(Toolbox PRIVATE saucer::saucer sol2::sol2 lua tray nlohmann_json cppcodec)
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release")
if(WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"))
set_target_properties(Toolbox PROPERTIES WIN32_EXECUTABLE TRUE)
endif()

View File

@@ -273,11 +273,15 @@ ToolboxWindow::~ToolboxWindow() {
m_runningMonitor = false;
}
void ToolboxWindow::monitor_focus() {
while(m_runningMonitor){
if(m_bShow && !m_webview.focused()) {
while (m_runningMonitor) {
if (m_bShow && !m_webview.focused()) {
this->hide();
}
// Schlafpause hinzufügen, um die CPU-Last zu reduzieren
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Beispielhaft 100 ms Pause
}
}