fix position when external shadows is enable

v0.6
audoban committed by Michail Vourlakos
parent e9221f8719
commit ea2e6b6ff0

@ -203,6 +203,10 @@ QRect DockCorona::availableScreenRect(int id) const
if (view && view->containment() && view->screen() == screen) { if (view && view->containment() && view->screen() == screen) {
auto dockRect = view->absGeometry(); auto dockRect = view->absGeometry();
// Usually availableScreenRect is used by the desktop,
// but Latte dont have desktop, then here just
// need calculate available space for top and bottom location,
// because the left and right are those who dodge others docks
switch (view->location()) { switch (view->location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
available.setTopLeft({available.x(), dockRect.bottom()}); available.setTopLeft({available.x(), dockRect.bottom()});

@ -287,15 +287,17 @@ void DockView::updatePosition()
QPoint position; QPoint position;
position = {0, 0}; position = {0, 0};
int maxLengthWidth = maxLength() * screenGeometry.width(); const auto length = [&](int length) -> int {
int maxLengthHeight = maxLength() * screenGeometry.height(); return static_cast<int>(length * (1 - maxLength()) / 2);
};
int cleanThickness = normalThickness() - shadow(); int cleanThickness = normalThickness() - shadow();
switch (location()) { switch (location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
screenGeometry = screen()->geometry(); screenGeometry = screen()->geometry();
if (m_drawShadows) { if (m_drawShadows) {
position = {screenGeometry.x() + (screenGeometry.width() / 2 - maxLengthWidth / 2), screenGeometry.y()}; position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y()};
} else { } else {
position = {screenGeometry.x(), screenGeometry.y()}; position = {screenGeometry.x(), screenGeometry.y()};
} }
@ -305,7 +307,7 @@ void DockView::updatePosition()
case Plasma::Types::BottomEdge: case Plasma::Types::BottomEdge:
screenGeometry = screen()->geometry(); screenGeometry = screen()->geometry();
if (m_drawShadows) { if (m_drawShadows) {
position = {screenGeometry.x() + (screenGeometry.width() / 2 - maxLengthWidth / 2), position = {screenGeometry.x() + length(screenGeometry.width()),
screenGeometry.y() + screenGeometry.height() - cleanThickness screenGeometry.y() + screenGeometry.height() - cleanThickness
}; };
} else { } else {
@ -318,7 +320,7 @@ void DockView::updatePosition()
screenGeometry = corona()->availableScreenRect(containment()->screen()); screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) { if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x() + screenGeometry.width() - cleanThickness, position = {screenGeometry.x() + screenGeometry.width() - cleanThickness,
screenGeometry.y() + (screenGeometry.height() / 2 - maxLengthHeight / 2) screenGeometry.y() + length(screenGeometry.height())
}; };
} else { } else {
position = {screenGeometry.x() + screenGeometry.width() - width(), screenGeometry.y()}; position = {screenGeometry.x() + screenGeometry.width() - width(), screenGeometry.y()};
@ -329,7 +331,7 @@ void DockView::updatePosition()
case Plasma::Types::LeftEdge: case Plasma::Types::LeftEdge:
screenGeometry = corona()->availableScreenRect(containment()->screen()); screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) { if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x(), screenGeometry.y() + (screenGeometry.height() / 2 - maxLengthHeight / 2)}; position = {screenGeometry.x(), screenGeometry.y() + length(screenGeometry.height())};
} else { } else {
position = {screenGeometry.x(), screenGeometry.y()}; position = {screenGeometry.x(), screenGeometry.y()};
} }

Loading…
Cancel
Save