From 018d904ca49cdcbc9996987550a3571c33999f71 Mon Sep 17 00:00:00 2001 From: Altair Wei Date: Fri, 13 Aug 2021 11:32:09 +0800 Subject: [PATCH] fix resize indicator position on 4K screen Linux (#71) --- .gitignore | 2 ++ framelesshelper.cpp | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a1e9d95..556f8ab 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,5 @@ Thumbs.db *.run .qmake.conf *.res + +.vscode/ \ No newline at end of file diff --git a/framelesshelper.cpp b/framelesshelper.cpp index c8637e7..9197a4f 100644 --- a/framelesshelper.cpp +++ b/framelesshelper.cpp @@ -80,11 +80,8 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) const int titleBarHeight = FramelessWindowsManager::getTitleBarHeight(window); const bool resizable = FramelessWindowsManager::getResizable(window); const int windowWidth = window->width(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const QPointF localMousePosition = window->mapFromGlobal(Utilities::getGlobalMousePosition(window)); -#else - const QPoint localMousePosition = window->mapFromGlobal(Utilities::getGlobalMousePosition(window).toPoint()); -#endif + const auto mouseEvent = static_cast(event); + const QPoint localMousePosition = mouseEvent->localPos().toPoint(); const Qt::Edges edges = [window, resizeBorderWidth, resizeBorderHeight, windowWidth, &localMousePosition] { const int windowHeight = window->height(); if (localMousePosition.y() <= resizeBorderHeight) { @@ -130,7 +127,6 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) && (localMousePosition.x() < (windowWidth - resizeBorderWidth)) && !hitTestVisible; } - const auto mouseEvent = static_cast(event); if (type == QEvent::MouseButtonDblClick) { if (mouseEvent->button() != Qt::MouseButton::LeftButton) { return false;