|
|
@ -54,9 +54,9 @@ bool containsCursorToItem(QQuickItem *item) {
|
|
|
|
if (!item || !item->isVisible()) {
|
|
|
|
if (!item || !item->isVisible()) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto point = QCursor::pos();
|
|
|
|
auto point = item->window()->mapFromGlobal(QCursor::pos());
|
|
|
|
auto rect = QRectF(item->mapToGlobal(QPoint(0, 0)), item->size());
|
|
|
|
auto rect = QRectF(item->mapToItem(item->window()->contentItem(), QPointF(0, 0)), item->size());
|
|
|
|
if (point.x() > rect.x() && point.x() < (rect.x() + rect.width()) && point.y() > rect.y() && point.y() < (rect.y() + rect.height())) {
|
|
|
|
if (rect.contains(point)) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -105,14 +105,22 @@ void FluFrameless::componentComplete() {
|
|
|
|
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
|
|
|
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
|
|
|
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
|
|
|
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
|
|
|
if (_fixSize) {
|
|
|
|
if (_fixSize) {
|
|
|
|
|
|
|
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
|
|
|
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);;
|
|
|
|
|
|
|
|
#else
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
|
|
|
|
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
|
|
|
|
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
|
|
|
|
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
|
|
|
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
|
|
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
|
|
|
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
|
|
|
|
|
|
|
#else
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
|
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
|
|
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
|
|
|
|
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
|
|
|
@ -162,7 +170,6 @@ void FluFrameless::componentComplete() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else if (uMsg == WM_NCCALCSIZE) {
|
|
|
|
} else if (uMsg == WM_NCCALCSIZE) {
|
|
|
|
bool isMaximum = ::IsZoomed(hwnd);
|
|
|
|
|
|
|
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
|
|
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
|
|
|
const LONG originalTop = clientRect->top;
|
|
|
|
const LONG originalTop = clientRect->top;
|
|
|
|
const LONG originalLeft = clientRect->left;
|
|
|
|
const LONG originalLeft = clientRect->left;
|
|
|
@ -176,6 +183,13 @@ void FluFrameless::componentComplete() {
|
|
|
|
if (clientRect->left - originalLeft != 0) {
|
|
|
|
if (clientRect->left - originalLeft != 0) {
|
|
|
|
offsetXY = clientRect->left - originalLeft;
|
|
|
|
offsetXY = clientRect->left - originalLeft;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
|
|
|
|
|
|
|
clientRect->top = originalTop;
|
|
|
|
|
|
|
|
clientRect->bottom = originalBottom;
|
|
|
|
|
|
|
|
clientRect->left = originalLeft;
|
|
|
|
|
|
|
|
clientRect->right = originalRight;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
bool isMaximum = ::IsZoomed(hwnd);
|
|
|
|
if (!isMaximum) {
|
|
|
|
if (!isMaximum) {
|
|
|
|
clientRect->top = originalTop;
|
|
|
|
clientRect->top = originalTop;
|
|
|
|
clientRect->bottom = originalBottom;
|
|
|
|
clientRect->bottom = originalBottom;
|
|
|
@ -186,10 +200,8 @@ void FluFrameless::componentComplete() {
|
|
|
|
clientRect->bottom = originalBottom - offsetXY;
|
|
|
|
clientRect->bottom = originalBottom - offsetXY;
|
|
|
|
clientRect->left = originalLeft + offsetXY;
|
|
|
|
clientRect->left = originalLeft + offsetXY;
|
|
|
|
clientRect->right = originalRight - offsetXY;
|
|
|
|
clientRect->right = originalRight - offsetXY;
|
|
|
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
|
|
|
|
|
|
|
qWarning("This issue is Qt's own bug, which currently only exists in 6.5.3 and 6.6.0, and has been fixed in later versions");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
_setMaximizeHovered(false);
|
|
|
|
_setMaximizeHovered(false);
|
|
|
|
*result = WVR_REDRAW;
|
|
|
|
*result = WVR_REDRAW;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -258,6 +270,17 @@ void FluFrameless::componentComplete() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*result = TRUE;
|
|
|
|
*result = TRUE;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else if (uMsg == WM_GETMINMAXINFO) {
|
|
|
|
|
|
|
|
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
|
|
|
|
|
|
|
auto pixelRatio = window()->devicePixelRatio();
|
|
|
|
|
|
|
|
auto geometry = window()->screen()->availableGeometry();
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
|
|
|
|
|
|
|
minmaxInfo->ptMaxPosition.x = rect.left;
|
|
|
|
|
|
|
|
minmaxInfo->ptMaxPosition.y = rect.top;
|
|
|
|
|
|
|
|
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
|
|
|
|
|
|
|
|
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
|
|
|
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
|
|
|
if (_hitMaximizeButton()) {
|
|
|
|
if (_hitMaximizeButton()) {
|
|
|
|
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
|
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
@ -274,7 +297,9 @@ void FluFrameless::componentComplete() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (uMsg == WM_NCRBUTTONDOWN) {
|
|
|
|
} else if (uMsg == WM_NCRBUTTONDOWN) {
|
|
|
|
if (wParam == HTCAPTION) {
|
|
|
|
if (wParam == HTCAPTION) {
|
|
|
|
_showSystemMenu(QCursor::pos());
|
|
|
|
auto pos = window()->position();
|
|
|
|
|
|
|
|
auto offset = window()->mapFromGlobal(QCursor::pos());
|
|
|
|
|
|
|
|
_showSystemMenu(QPoint(pos.x() + offset.x(), pos.y() + offset.y()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) {
|
|
|
|
} else if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) {
|
|
|
|
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
|
|
|
|
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
|
|
|
@ -312,6 +337,15 @@ bool FluFrameless::_isFullScreen() {
|
|
|
|
|
|
|
|
|
|
|
|
void FluFrameless::_showSystemMenu(QPoint point) {
|
|
|
|
void FluFrameless::_showSystemMenu(QPoint point) {
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
|
|
|
QScreen *screen = window()->screen();
|
|
|
|
|
|
|
|
if (!screen) {
|
|
|
|
|
|
|
|
screen = QGuiApplication::primaryScreen();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!screen) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const QPoint origin = screen->geometry().topLeft();
|
|
|
|
|
|
|
|
auto nativePos = QPointF(QPointF(point - origin) * window()->devicePixelRatio()).toPoint() + origin;
|
|
|
|
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
|
|
|
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
|
|
|
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
|
|
|
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
|
|
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
|
|
@ -330,8 +364,8 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
|
|
|
::EnableMenuItem(hMenu, SC_SIZE, MFS_DISABLED);
|
|
|
|
::EnableMenuItem(hMenu, SC_SIZE, MFS_DISABLED);
|
|
|
|
::EnableMenuItem(hMenu, SC_MAXIMIZE, MFS_DISABLED);
|
|
|
|
::EnableMenuItem(hMenu, SC_MAXIMIZE, MFS_DISABLED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), qRound(point.x() * window()->devicePixelRatio()),
|
|
|
|
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
|
|
|
|
qRound(point.y() * window()->devicePixelRatio()), 0, hwnd, nullptr);
|
|
|
|
nativePos.y(), 0, hwnd, nullptr);
|
|
|
|
if (result != FALSE) {
|
|
|
|
if (result != FALSE) {
|
|
|
|
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
|
|
|
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|