diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b5ba39..4029f8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.20) project(FramelessHelper - VERSION 2.3.3.0 + VERSION 2.4.0.0 DESCRIPTION "Cross-platform window customization framework for Qt Widgets and Qt Quick." HOMEPAGE_URL "https://github.com/wangwenx190/framelesshelper/" LANGUAGES CXX diff --git a/qmake/inc/core/framelesshelper.version b/qmake/inc/core/framelesshelper.version index 285dd97..efe966e 100644 --- a/qmake/inc/core/framelesshelper.version +++ b/qmake/inc/core/framelesshelper.version @@ -34,10 +34,10 @@ #pragma once [[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2; -[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 3; -[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 3; +[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 4; +[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 0; [[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.3.3.0\0"; +[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.4.0.0\0"; [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN\0"; [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN\0"; diff --git a/src/core/cmakehelper.cmake b/src/core/cmakehelper.cmake index a5e85cb..3803a99 100644 --- a/src/core/cmakehelper.cmake +++ b/src/core/cmakehelper.cmake @@ -34,6 +34,7 @@ function(setup_compile_params arg_target) #QT_TYPESAFE_FLAGS # QtQuick private headers prevent us from enabling this flag. QT_USE_QSTRINGBUILDER QT_USE_FAST_OPERATOR_PLUS + #QT_STRICT_ITERATORS # Need Qt itself also compile with this flag enabled. QT_DEPRECATED_WARNINGS # Have no effect since 6.0 QT_DEPRECATED_WARNINGS_SINCE=0x070000 QT_WARN_DEPRECATED_UP_TO=0x070000 # Since 6.5 @@ -52,16 +53,22 @@ function(setup_compile_params arg_target) target_compile_definitions(${arg_target} PRIVATE _CRT_NON_CONFORMING_SWPRINTFS _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS - _CRT_NONSTDC_NO_DEPRECATE _ENABLE_EXTENDED_ALIGNED_STORAGE - NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN + _CRT_NONSTDC_NO_DEPRECATE _SCL_SECURE_NO_WARNINGS + _SCL_SECURE_NO_DEPRECATE _ENABLE_EXTENDED_ALIGNED_STORAGE + _USE_MATH_DEFINES NOMINMAX UNICODE _UNICODE + WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN ) target_compile_options(${arg_target} PRIVATE - /utf-8 /W3 /WX # Can't use /W4 here, Qt's own headers are not warning-clean, especially QtQuick headers. /W4 will trigger too many warnings. + /options:strict # Don't allow unknown parameters. + /permissive- # Make sure we always write standard code. + /utf-8 + /W3 # Can't use /W4 here, Qt's own headers are not warning-clean, especially QtQuick headers. /W4 will trigger too many warnings. + /WX # Make sure we don't ignore any warnings. $<$:/JMC> $<$>:/guard:cf /Gw /Gy /QIntel-jcc-erratum /Zc:inline> # /guard:ehcont? /Qspectre-load? ) target_link_options(${arg_target} PRIVATE - /WX # Make sure we don't use wrong parameters. + /WX # Don't allow unknown parameters. $<$>:/CETCOMPAT /GUARD:CF /OPT:REF /OPT:ICF> # /GUARD:EHCONT? ) else() diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index e2314b0..04ea36d 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -1004,8 +1004,8 @@ static inline void moveWindowToMonitor(const HWND hwnd, const MONITORINFOEXW &ac WARNING << Utils::getSystemErrorMessage(kGetWindowRect); return; } - const int currentWindowWidth = qAbs(currentWindowRect.right - currentWindowRect.left); - const int currentWindowHeight = qAbs(currentWindowRect.bottom - currentWindowRect.top); + const int currentWindowWidth = currentWindowRect.right - currentWindowRect.left; + const int currentWindowHeight = currentWindowRect.bottom - currentWindowRect.top; const int currentWindowOffsetX = (currentWindowRect.left - currentMonitorRect.left); const int currentWindowOffsetY = (currentWindowRect.top - currentMonitorRect.top); const int newWindowX = activeMonitorRect.left + currentWindowOffsetX; @@ -2853,7 +2853,7 @@ void Utils::bringWindowToFront(const WId windowId) const auto hwnd = reinterpret_cast(windowId); const HWND oldForegroundWindow = GetForegroundWindow(); if (!oldForegroundWindow) { - WARNING << getSystemErrorMessage(kGetForegroundWindow); + // The foreground window can be NULL, it's not an API error. return; } const std::optional activeMonitor = getMonitorForWindow(oldForegroundWindow); diff --git a/src/quick/framelessquickhelper.cpp b/src/quick/framelessquickhelper.cpp index 13d9801..16b3f03 100644 --- a/src/quick/framelessquickhelper.cpp +++ b/src/quick/framelessquickhelper.cpp @@ -391,25 +391,21 @@ void FramelessQuickHelperPrivate::bringWindowToFront() if (!window) { return; } - const auto bringWindowToFront_impl = [window]() -> void { - if (window->visibility() == QQuickWindow::Hidden) { - window->show(); - } - if (window->visibility() == QQuickWindow::Minimized) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - window->setWindowStates(window->windowStates() & ~Qt::WindowMinimized); -#else - window->showNormal(); -#endif - } - window->raise(); - window->requestActivate(); - }; #ifdef Q_OS_WINDOWS - Q_UNUSED(bringWindowToFront_impl); Utils::bringWindowToFront(window->winId()); #else - bringWindowToFront_impl(); + if (window->visibility() == QQuickWindow::Hidden) { + window->show(); + } + if (window->visibility() == QQuickWindow::Minimized) { +# if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) + window->setWindowStates(window->windowStates() & ~Qt::WindowMinimized); +# else + window->showNormal(); +# endif + } + window->raise(); + window->requestActivate(); #endif } diff --git a/src/widgets/framelesswidgetshelper.cpp b/src/widgets/framelesswidgetshelper.cpp index 1568f17..02501af 100644 --- a/src/widgets/framelesswidgetshelper.cpp +++ b/src/widgets/framelesswidgetshelper.cpp @@ -780,21 +780,17 @@ void FramelessWidgetsHelperPrivate::bringWindowToFront() if (!m_window) { return; } - const auto bringWindowToFront_impl = [this]() -> void { - if (m_window->isHidden()) { - m_window->show(); - } - if (m_window->isMinimized()) { - m_window->setWindowState(m_window->windowState() & ~Qt::WindowMinimized); - } - m_window->raise(); - m_window->activateWindow(); - }; #ifdef Q_OS_WINDOWS - Q_UNUSED(bringWindowToFront_impl); Utils::bringWindowToFront(m_window->winId()); #else - bringWindowToFront_impl(); + if (m_window->isHidden()) { + m_window->show(); + } + if (m_window->isMinimized()) { + m_window->setWindowState(m_window->windowState() & ~Qt::WindowMinimized); + } + m_window->raise(); + m_window->activateWindow(); #endif }