Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frame/layershell/x11dlayershellemulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ void LayerShellEmulation::onPositionChanged()
rect.setHeight(screen->geometry().height() - m_dlayerShellWindow->topMargin() - m_dlayerShellWindow->bottomMargin());
}

// Qt moves a window to the screen holding its center, re-entering here with that screen's origin forever;
// keep the center on this screen but preserve intentional partial overlap (e.g. notifications avoiding the dock).
const auto keepOnScreen = [](int pos, int size, int screenStart, int screenSize) {
if (size > screenSize) {
return screenStart + (screenSize - size) / 2;
}
return qBound(screenStart, pos, screenStart + screenSize - size);
};
const QPoint center = rect.center();
if (center.x() < screenRect.left() || center.x() > screenRect.right()) {
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
rect.moveLeft(keepOnScreen(rect.left(), rect.width(), screenRect.left(), screenRect.width()));
}
if (center.y() < screenRect.top() || center.y() > screenRect.bottom()) {
rect.moveTop(keepOnScreen(rect.top(), rect.height(), screenRect.top(), screenRect.height()));
}

if (m_window->geometry() != rect) {
m_window->setGeometry(rect);
}
Expand Down
Loading