fix #126, improve behavior for auto positioning

--support also an edge case where a top and left dock
overlap each other but there is also a free space in them.
This case hasnt been taken into account into the previous
implementation
pull/1/head
Michail Vourlakos 8 years ago
parent 0c404b57a2
commit 329ba8b6ff

@ -592,9 +592,35 @@ inline void DockView::syncGeometry()
if (formFactor() == Plasma::Types::Vertical) {
freeRegion = corona()->availableScreenRegion(this->containment()->screen());
maximumRect = maximumNormalGeometry();
QRegion availableRegion = freeRegion.intersected(maximumRect);
availableScreenRect = freeRegion.intersected(maximumRect).boundingRect();
float area = 0;
//! it is used to choose which or the availableRegion rectangles will
//! be the one representing dock geometry
for (int i = 0; i < availableRegion.rectCount(); ++i) {
QRect rect = availableRegion.rects().at(i);
//! the area of each rectangle in calculated in squares of 50x50
//! this is a way to avoid enourmous numbers for area value
float tempArea = (float)(rect.width() * rect.height()) / 2500;
if (tempArea > area) {
availableScreenRect = rect;
area = tempArea;
}
}
if (availableRegion.rectCount() > 1 && m_drawShadows)
m_forceDrawCenteredBorders = true;
else
m_forceDrawCenteredBorders = false;
} else {
m_forceDrawCenteredBorders = false;
}
updateEnabledBorders();
resizeWindow(availableScreenRect);
updatePosition(availableScreenRect);
@ -699,6 +725,7 @@ void DockView::setDrawShadows(bool draw)
} else {
PanelShadows::self()->removeWindow(this);
m_enabledBorders = Plasma::FrameSvg::AllBorders;
emit enabledBordersChanged();
}
@ -1298,16 +1325,16 @@ void DockView::updateEnabledBorders()
}
if ((location() == Plasma::Types::LeftEdge || location() == Plasma::Types::RightEdge)) {
if (maxLength() == 1 && m_alignment == Dock::Justify) {
if (maxLength() == 1 && m_alignment == Dock::Justify && !m_forceDrawCenteredBorders) {
borders &= ~Plasma::FrameSvg::TopBorder;
borders &= ~Plasma::FrameSvg::BottomBorder;
}
if (m_alignment == Dock::Top) {
if (m_alignment == Dock::Top && !m_forceDrawCenteredBorders) {
borders &= ~Plasma::FrameSvg::TopBorder;
}
if (m_alignment == Dock::Bottom) {
if (m_alignment == Dock::Bottom && !m_forceDrawCenteredBorders) {
borders &= ~Plasma::FrameSvg::BottomBorder;
}

@ -193,6 +193,7 @@ private:
private:
Plasma::Containment *containmentById(uint id);
bool m_forceDrawCenteredBorders{false};
bool m_drawShadows{false};
bool m_onPrimary{true};
int m_maxThickness{24};

Loading…
Cancel
Save