12 #include "DropIndicatorOverlayInterface_p.h"
15 #include "DropArea_p.h"
16 #include "DockRegistry_p.h"
17 #include "DragController_p.h"
22 DropIndicatorOverlayInterface::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) {
41 void DropIndicatorOverlayInterface::setWindowBeingDragged(
bool is)
43 if (is == m_draggedWindowIsHovering)
46 m_draggedWindowIsHovering = is;
48 setGeometry(m_dropArea->QWidgetAdapter::rect());
51 setHoveredFrame(
nullptr);
58 QRect DropIndicatorOverlayInterface::hoveredFrameRect()
const
60 return m_hoveredFrameRect;
63 void DropIndicatorOverlayInterface::setHoveredFrame(Frame *frame)
65 if (frame == m_hoveredFrame)
69 disconnect(m_hoveredFrame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
71 m_hoveredFrame = frame;
73 connect(frame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
74 setHoveredFrameRect(m_hoveredFrame->QWidgetAdapter::geometry());
76 setHoveredFrameRect(
QRect());
80 Q_EMIT hoveredFrameChanged(m_hoveredFrame);
81 onHoveredFrameChanged(m_hoveredFrame);
84 bool DropIndicatorOverlayInterface::isHovered()
const
86 return m_draggedWindowIsHovering;
89 DropLocation DropIndicatorOverlayInterface::currentDropLocation()
const
91 return m_currentDropLocation;
117 qWarning() << Q_FUNC_INFO <<
"Unexpected drop location" << dropLoc;
124 bool DropIndicatorOverlayInterface::dropIndicatorVisible(
DropLocation dropLoc)
const
129 WindowBeingDragged *windowBeingDragged = DragController::instance()->windowBeingDragged();
130 if (!windowBeingDragged)
142 }
else if (isOutter) {
145 const bool isTheOnlyFrame = m_hoveredFrame && m_hoveredFrame->isTheOnlyFrame();
146 if (isTheOnlyFrame && !DockRegistry::self()->isProbablyObscured(m_hoveredFrame->window()->windowHandle(), windowBeingDragged))
149 if (!m_hoveredFrame || !m_hoveredFrame->isDockable())
152 if (
auto tabbingAllowedFunc = Config::self().tabbingAllowedFunc()) {
153 if (!tabbingAllowedFunc(source, target))
158 if (!DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), windowBeingDragged->affinities()))
161 qWarning() << Q_FUNC_INFO <<
"Unknown drop indicator location" << dropLoc;
165 if (
auto dropIndicatorAllowedFunc = Config::self().dropIndicatorAllowedFunc()) {
166 DropArea *dropArea = DragController::instance()->dropAreaUnderCursor();
167 if (!dropIndicatorAllowedFunc(dropLoc, source, target, dropArea))
174 void DropIndicatorOverlayInterface::onFrameDestroyed()
176 setHoveredFrame(
nullptr);
179 void DropIndicatorOverlayInterface::onHoveredFrameChanged(Frame *)
183 void DropIndicatorOverlayInterface::setCurrentDropLocation(
DropLocation location)
185 if (m_currentDropLocation != location) {
186 m_currentDropLocation = location;
187 Q_EMIT currentDropLocationChanged();
193 return hover_impl(globalPos);
196 void DropIndicatorOverlayInterface::setHoveredFrameRect(
QRect rect)
198 if (m_hoveredFrameRect != rect) {
199 m_hoveredFrameRect = rect;
200 Q_EMIT hoveredFrameRectChanged();
204 void DropIndicatorOverlayInterface::removeHover()
206 setWindowBeingDragged(
false);