| | |
| | | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
| | | if (QPlatformWindow *platformWindow = window->handle()) { |
| | | if (const auto ni = QGuiApplication::platformNativeInterface()) { |
| | | ni->setWindowProperty(platformWindow, QStringLiteral("_q_windowsCustomMargins"), |
| | | ni->setWindowProperty(platformWindow, QStringLiteral("WindowsCustomMargins"), |
| | | marginsVar); |
| | | } |
| | | } |
| | |
| | | } |
| | | ::SetMenuDefaultItem(hMenu, defaultItemId.value_or(UINT_MAX), FALSE); |
| | | |
| | | ::DrawMenuBar(hWnd); |
| | | //::DrawMenuBar(hWnd); |
| | | |
| | | // Popup the system menu at the required position. |
| | | const auto result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x, pos.y, 0, hWnd, nullptr); |
| | |
| | | return false; |
| | | } |
| | | |
| | | if (systemMenuHandler(hWnd, message, wParam, lParam, result)) { |
| | | return true; |
| | | } |
| | | |
| | | // Test snap layout |
| | | if (snapLayoutHandler(hWnd, message, wParam, lParam, result)) { |
| | | return true; |
| | |
| | | |
| | | // Main implementation |
| | | if (customWindowHandler(hWnd, message, wParam, lParam, result)) { |
| | | return true; |
| | | } |
| | | |
| | | if (systemMenuHandler(hWnd, message, wParam, lParam, result)) { |
| | | return true; |
| | | } |
| | | |
| | |
| | | // this is also the normal behavior of a native Win32 window (but only when the |
| | | // window is not maximized/fullscreen/minimized, of course). |
| | | if (isWindowNoState(hWnd)) { |
| | | static constexpr const int kBorderSize = 2; |
| | | static constexpr const auto kBorderSize = quint8{2}; |
| | | bool isTop = (nativeLocalPos.y <= kBorderSize); |
| | | bool isLeft = nativeLocalPos.x <= kBorderSize; |
| | | bool isRight = (nativeLocalPos.x >= (clientWidth - kBorderSize)); |
| | | if (isTop || isRight) { |
| | | if (isTop || isLeft || isRight) { |
| | | if (dontOverrideCursor) { |
| | | // The user doesn't want the window to be resized, so we tell |
| | | // Windows we are in the client area so that the controls beneath |
| | | // the mouse cursor can still be hovered or clicked. |
| | | *result = (isTitleBar ? HTCAPTION : HTCLIENT); |
| | | } else { |
| | | if (isTop && isRight) { |
| | | *result = HTTOPRIGHT; |
| | | } else if (isTop) { |
| | | *result = HTTOP; |
| | | if (isTop) { |
| | | if (isLeft) { |
| | | *result = HTTOPLEFT; |
| | | } else if (isRight) { |
| | | *result = HTTOPRIGHT; |
| | | } else { |
| | | *result = HTTOP; |
| | | } |
| | | } else { |
| | | *result = HTRIGHT; |
| | | if (isLeft) { |
| | | *result = HTLEFT; |
| | | } else { |
| | | *result = HTRIGHT; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | const bool isBottom = (nativeLocalPos.y >= (clientHeight - frameSize)); |
| | | // Make the border a little wider to let the user easy to resize on corners. |
| | | const auto scaleFactor = ((isTop || isBottom) ? qreal(2) : qreal(1)); |
| | | const int scaledFrameSizeX = std::round(qreal(frameSize) * scaleFactor); |
| | | const bool isLeft = (nativeLocalPos.x < scaledFrameSizeX); |
| | | const bool isRight = (nativeLocalPos.x >= (clientWidth - scaledFrameSizeX)); |
| | | const int scaledFrameSize = std::round(qreal(frameSize) * scaleFactor); |
| | | const bool isLeft = (nativeLocalPos.x < scaledFrameSize); |
| | | const bool isRight = (nativeLocalPos.x >= (clientWidth - scaledFrameSize)); |
| | | if (dontOverrideCursor && (isTop || isBottom || isLeft || isRight)) { |
| | | // Return HTCLIENT instead of HTBORDER here, because the mouse is |
| | | // inside the window now, return HTCLIENT to let the controls |