* @brief Handles mouse press interactions for initiating window drag or resize. */
| 1958 | * @brief Handles mouse press interactions for initiating window drag or resize. |
| 1959 | */ |
| 1960 | void UI::WindowManager::mousePressEvent(QMouseEvent* event) |
| 1961 | { |
| 1962 | if (!autoLayoutEnabled()) { |
| 1963 | if (startManualPress(event->pos(), event->button())) { |
| 1964 | event->accept(); |
| 1965 | return; |
| 1966 | } |
| 1967 | |
| 1968 | if (!m_focusedWindow) { |
| 1969 | if (m_taskbar) |
| 1970 | m_taskbar->setActiveWindow(nullptr); |
| 1971 | |
| 1972 | if (event->button() == Qt::RightButton) { |
| 1973 | Q_EMIT rightClicked(event->pos().x(), event->pos().y()); |
| 1974 | event->accept(); |
| 1975 | return; |
| 1976 | } |
| 1977 | } |
| 1978 | |
| 1979 | QQuickItem::mousePressEvent(event); |
| 1980 | return; |
| 1981 | } |
| 1982 | |
| 1983 | m_dragWindow = nullptr; |
| 1984 | m_targetWindow = nullptr; |
| 1985 | m_resizeWindow = nullptr; |
| 1986 | m_focusedWindow = nullptr; |
| 1987 | m_resizeEdge = ResizeEdge::None; |
| 1988 | m_initialMousePos = event->pos(); |
| 1989 | |
| 1990 | if (m_snapIndicatorVisible) { |
| 1991 | m_snapIndicatorVisible = false; |
| 1992 | Q_EMIT snapIndicatorChanged(); |
| 1993 | } |
| 1994 | |
| 1995 | m_focusedWindow = topmostWindowAt(m_initialMousePos); |
| 1996 | |
| 1997 | if (!m_focusedWindow) { |
| 1998 | if (m_taskbar) |
| 1999 | m_taskbar->setActiveWindow(nullptr); |
| 2000 | |
| 2001 | if (event->button() == Qt::RightButton) |
| 2002 | Q_EMIT rightClicked(m_initialMousePos.x(), m_initialMousePos.y()); |
| 2003 | |
| 2004 | return; |
| 2005 | } |
| 2006 | |
| 2007 | if (m_taskbar) |
| 2008 | m_taskbar->setActiveWindow(m_focusedWindow); |
| 2009 | |
| 2010 | bool captionClick = false; |
| 2011 | const int captionH = m_focusedWindow->property("captionHeight").toInt(); |
| 2012 | const int externcW = m_focusedWindow->property("externControlWidth").toInt(); |
| 2013 | const int buttonsW = m_focusedWindow->property("windowControlsWidth").toInt(); |
| 2014 | const auto mouseClick = m_focusedWindow->mapFromItem(this, m_initialMousePos); |
| 2015 | if (mouseClick.y() <= captionH) { |
| 2016 | if (mouseClick.x() <= m_focusedWindow->width() - buttonsW && mouseClick.x() > externcW) |
| 2017 | captionClick = true; |
nothing calls this directly
no test coverage detected