12#include "DropIndicatorOverlayInterface_p.h"
15#include "DropArea_p.h"
16#include "DockRegistry_p.h"
17#include "DragController_p.h"
22DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(DropArea *dropArea)
23 : QWidgetAdapter(dropArea)
24 , m_dropArea(dropArea)
27 setObjectName(QStringLiteral(
"DropIndicatorOverlayInterface"));
32 connect(DockRegistry::self(), &DockRegistry::dropIndicatorsInhibitedChanged,
this,
33 [
this](
bool inhibited) {
38 if (
auto state = qobject_cast<StateDragging *>(DragController::instance()->activeState())) {
45void DropIndicatorOverlayInterface::setWindowBeingDragged(
bool is)
47 if (is == m_draggedWindowIsHovering)
50 m_draggedWindowIsHovering = is;
52 setGeometry(m_dropArea->QWidgetAdapter::rect());
55 setHoveredFrame(
nullptr);
62QRect DropIndicatorOverlayInterface::hoveredFrameRect()
const
64 return m_hoveredFrameRect;
67void DropIndicatorOverlayInterface::setHoveredFrame(Frame *frame)
69 if (frame == m_hoveredFrame)
72 if (WindowBeingDragged *wbd = DragController::instance()->windowBeingDragged()) {
73 if (wbd->isInWaylandDrag(frame)) {
83 disconnect(m_hoveredFrame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
85 m_hoveredFrame = frame;
87 connect(frame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
88 setHoveredFrameRect(m_hoveredFrame->QWidgetAdapter::geometry());
90 setHoveredFrameRect(
QRect());
94 Q_EMIT hoveredFrameChanged(m_hoveredFrame);
95 onHoveredFrameChanged(m_hoveredFrame);
98bool DropIndicatorOverlayInterface::isHovered()
const
100 return m_draggedWindowIsHovering;
103DropLocation DropIndicatorOverlayInterface::currentDropLocation()
const
105 return m_currentDropLocation;
131 qWarning() << Q_FUNC_INFO <<
"Unexpected drop location" << dropLoc;
138bool DropIndicatorOverlayInterface::dropIndicatorVisible(
DropLocation dropLoc)
const
143 WindowBeingDragged *windowBeingDragged = DragController::instance()->windowBeingDragged();
144 if (!windowBeingDragged)
156 }
else if (isOutter) {
159 const bool isTheOnlyFrame = m_hoveredFrame && m_hoveredFrame->isTheOnlyFrame();
160 if (isTheOnlyFrame && !DockRegistry::self()->isProbablyObscured(m_hoveredFrame->window()->windowHandle(), windowBeingDragged))
163 if (!m_hoveredFrame || !m_hoveredFrame->isDockable())
166 if (
auto tabbingAllowedFunc =
Config::self().tabbingAllowedFunc()) {
167 if (!tabbingAllowedFunc(source, target))
172 if (!DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), windowBeingDragged->affinities()))
175 qWarning() << Q_FUNC_INFO <<
"Unknown drop indicator location" << dropLoc;
179 if (
auto dropIndicatorAllowedFunc =
Config::self().dropIndicatorAllowedFunc()) {
180 DropArea *dropArea = DragController::instance()->dropAreaUnderCursor();
181 if (!dropIndicatorAllowedFunc(dropLoc, source, target, dropArea))
188void DropIndicatorOverlayInterface::onFrameDestroyed()
190 setHoveredFrame(
nullptr);
193void DropIndicatorOverlayInterface::onHoveredFrameChanged(Frame *)
197void DropIndicatorOverlayInterface::setCurrentDropLocation(
DropLocation location)
199 if (m_currentDropLocation != location) {
200 m_currentDropLocation = location;
201 Q_EMIT currentDropLocationChanged();
207 return hover_impl(globalPos);
210void DropIndicatorOverlayInterface::setHoveredFrameRect(
QRect rect)
212 if (m_hoveredFrameRect != rect) {
213 m_hoveredFrameRect = rect;
214 Q_EMIT hoveredFrameRectChanged();
218void DropIndicatorOverlayInterface::removeHover()
220 setWindowBeingDragged(
false);
Application-wide config to tune certain behaviours of the framework.
void destroyed(QObject *obj)