Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-03-14 20:59:38 +08:00
parent 2dbdca2999
commit f68665298b
5 changed files with 24 additions and 2 deletions

View File

@ -27,8 +27,8 @@
</compatibility> </compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3"> <application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings> <windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM, True</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness> <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor, System</dpiAwareness>
</windowsSettings> </windowsSettings>
</application> </application>
</assembly> </assembly>

View File

@ -70,6 +70,9 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
return false; return false;
} }
const auto window = qobject_cast<QWindow *>(object); const auto window = qobject_cast<QWindow *>(object);
if (Utilities::isWindowFixedSize(window)) {
return false;
}
const auto mouseEvent = static_cast<QMouseEvent *>(event); const auto mouseEvent = static_cast<QMouseEvent *>(event);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const QPointF localPos = mouseEvent->position(); const QPointF localPos = mouseEvent->position();

View File

@ -584,6 +584,10 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
// another branch, if you are interested in it, you can give it a // another branch, if you are interested in it, you can give it a
// try. // try.
if (Utilities::isWindowFixedSize(window)) {
*result = HTCLIENT;
return true;
}
const POINT globalPos = {GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam)}; const POINT globalPos = {GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam)};
POINT localPos = globalPos; POINT localPos = globalPos;
if (ScreenToClient(msg->hwnd, &localPos) == FALSE) { if (ScreenToClient(msg->hwnd, &localPos) == FALSE) {

View File

@ -79,4 +79,18 @@ Qt::Edges Utilities::calculateWindowEdges(const QWindow *window, const QPointF &
return edges; return edges;
} }
bool Utilities::isWindowFixedSize(const QWindow *window)
{
Q_ASSERT(window);
if (!window) {
return false;
}
if (window->flags() & Qt::MSWindowsFixedSizeDialogHint) {
return true;
}
const QSize minSize = window->minimumSize();
const QSize maxSize = window->maximumSize();
return (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize));
}
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -36,6 +36,7 @@ namespace Utilities
[[nodiscard]] FRAMELESSHELPER_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPointF &pos); [[nodiscard]] FRAMELESSHELPER_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPointF &pos);
FRAMELESSHELPER_API void startSystemMove(QWindow *window); FRAMELESSHELPER_API void startSystemMove(QWindow *window);
FRAMELESSHELPER_API void startSystemResize(QWindow *window, const Qt::Edges edges); FRAMELESSHELPER_API void startSystemResize(QWindow *window, const Qt::Edges edges);
[[nodiscard]] FRAMELESSHELPER_API bool isWindowFixedSize(const QWindow *window);
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
[[nodiscard]] FRAMELESSHELPER_API bool isWin8OrGreater(); [[nodiscard]] FRAMELESSHELPER_API bool isWin8OrGreater();