forked from github_mirror/framelesshelper
Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
f18468dcca
commit
523e35fdb1
|
@ -562,8 +562,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPointF globalMouse = Utilities::getGlobalMousePosition(window);
|
POINT winLocalMouse = {0, 0};
|
||||||
POINT winLocalMouse = {qRound(globalMouse.x()), qRound(globalMouse.y())};
|
GetCursorPos(&winLocalMouse); // Or {GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam)}
|
||||||
ScreenToClient(msg->hwnd, &winLocalMouse);
|
ScreenToClient(msg->hwnd, &winLocalMouse);
|
||||||
const QPointF localMouse = {static_cast<qreal>(winLocalMouse.x), static_cast<qreal>(winLocalMouse.y)};
|
const QPointF localMouse = {static_cast<qreal>(winLocalMouse.x), static_cast<qreal>(winLocalMouse.y)};
|
||||||
RECT clientRect = {0, 0, 0, 0};
|
RECT clientRect = {0, 0, 0, 0};
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/qvariant.h>
|
#include <QtCore/qvariant.h>
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
#include <QtGui/qscreen.h>
|
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -71,15 +70,6 @@ bool Utilities::isWindowFixedSize(const QWindow *window)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF Utilities::getGlobalMousePosition(const QWindow *window)
|
|
||||||
{
|
|
||||||
if (window) {
|
|
||||||
return QPointF(QCursor::pos(window->screen())) * window->devicePixelRatio();
|
|
||||||
} else {
|
|
||||||
return QPointF(QCursor::pos()) * QGuiApplication::primaryScreen()->devicePixelRatio();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utilities::isHitTestVisibleInChrome(const QWindow *window)
|
bool Utilities::isHitTestVisibleInChrome(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(window);
|
Q_ASSERT(window);
|
||||||
|
@ -100,9 +90,8 @@ bool Utilities::isHitTestVisibleInChrome(const QWindow *window)
|
||||||
const QPointF originPoint = mapOriginPointToWindow(obj);
|
const QPointF originPoint = mapOriginPointToWindow(obj);
|
||||||
const qreal width = obj->property("width").toReal();
|
const qreal width = obj->property("width").toReal();
|
||||||
const qreal height = obj->property("height").toReal();
|
const qreal height = obj->property("height").toReal();
|
||||||
const qreal dpr = window->devicePixelRatio();
|
const QRectF rect = {originPoint.x(), originPoint.y(), width, height};
|
||||||
const QRectF rect = {originPoint.x() * dpr, originPoint.y() * dpr, width * dpr, height * dpr};
|
if (rect.contains(QCursor::pos(window->screen()))) {
|
||||||
if (rect.contains(getGlobalMousePosition(window))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ namespace Utilities
|
||||||
[[nodiscard]] FRAMELESSHELPER_API QWindow *findWindow(const WId winId);
|
[[nodiscard]] FRAMELESSHELPER_API QWindow *findWindow(const WId winId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_API bool shouldUseNativeTitleBar();
|
[[nodiscard]] FRAMELESSHELPER_API bool shouldUseNativeTitleBar();
|
||||||
[[nodiscard]] FRAMELESSHELPER_API bool isWindowFixedSize(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_API bool isWindowFixedSize(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_API QPointF getGlobalMousePosition(const QWindow *window);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_API bool isHitTestVisibleInChrome(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_API bool isHitTestVisibleInChrome(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_API QPointF mapOriginPointToWindow(const QObject *object);
|
[[nodiscard]] FRAMELESSHELPER_API QPointF mapOriginPointToWindow(const QObject *object);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue