* @brief Applies a drag delta to the focused window and updates snap indicators. */
| 1738 | * @brief Applies a drag delta to the focused window and updates snap indicators. |
| 1739 | */ |
| 1740 | void UI::WindowManager::handleDragMove(QMouseEvent* event, const QPoint& delta) |
| 1741 | { |
| 1742 | int newX = m_initialGeometry.x() + delta.x(); |
| 1743 | int newY = m_initialGeometry.y() + delta.y(); |
| 1744 | int w = static_cast<int>(m_dragWindow->width()); |
| 1745 | int h = static_cast<int>(m_dragWindow->height()); |
| 1746 | const int canvasW = static_cast<int>(width()); |
| 1747 | const int canvasH = static_cast<int>(height()); |
| 1748 | |
| 1749 | if ((w >= canvasW - 20 || h >= canvasH - 20) && !autoLayoutEnabled()) { |
| 1750 | w = static_cast<int>(m_dragWindow->implicitWidth()); |
| 1751 | h = static_cast<int>(m_dragWindow->implicitHeight()); |
| 1752 | m_dragWindow->setWidth(w); |
| 1753 | m_dragWindow->setHeight(h); |
| 1754 | } |
| 1755 | |
| 1756 | newX = qBound(0, newX, canvasW - w); |
| 1757 | newY = qBound(0, newY, canvasH - h); |
| 1758 | m_dragWindow->setX(newX); |
| 1759 | m_dragWindow->setY(newY); |
| 1760 | |
| 1761 | if (!autoLayoutEnabled()) { |
| 1762 | updateManualSnapIndicator(newX, newY, w, h, canvasW, canvasH); |
| 1763 | event->accept(); |
| 1764 | return; |
| 1765 | } |
| 1766 | |
| 1767 | const QRect dragRect(newX, newY, w, h); |
| 1768 | m_targetWindow = findOverlapTarget(dragRect); |
| 1769 | |
| 1770 | if (m_targetWindow && m_targetWindow != m_dragWindow) { |
| 1771 | m_dragWindow->setWidth(qMin(w, static_cast<int>(m_targetWindow->width()))); |
| 1772 | m_dragWindow->setHeight(qMin(h, static_cast<int>(m_targetWindow->height()))); |
| 1773 | m_snapIndicator = liftSnapBottom(extractGeometry(m_targetWindow), canvasH); |
| 1774 | m_snapIndicatorVisible = true; |
| 1775 | Q_EMIT snapIndicatorChanged(); |
| 1776 | event->accept(); |
| 1777 | return; |
| 1778 | } |
| 1779 | |
| 1780 | if (m_snapIndicatorVisible) { |
| 1781 | m_snapIndicatorVisible = false; |
| 1782 | Q_EMIT snapIndicatorChanged(); |
| 1783 | } |
| 1784 | |
| 1785 | event->accept(); |
| 1786 | } |
| 1787 | |
| 1788 | /** |
| 1789 | * @brief Computes the new geometry for the active resize window from the mouse delta. |
nothing calls this directly
no test coverage detected