diff --git a/applets/pager/package/contents/ui/main.qml b/applets/pager/package/contents/ui/main.qml --- a/applets/pager/package/contents/ui/main.qml +++ b/applets/pager/package/contents/ui/main.qml @@ -430,8 +430,8 @@ /* since we move clipRect with 1, move it back */ x: (geometry.x * pagerItemGrid.widthScaleFactor) - Math.round(units.devicePixelRatio) y: (geometry.y * pagerItemGrid.heightScaleFactor) - Math.round(units.devicePixelRatio) - width: Math.min(parent.width - x, geometry.width * pagerItemGrid.widthScaleFactor) - height: Math.min(parent.height - y, geometry.height * pagerItemGrid.heightScaleFactor) + width: geometry.width * pagerItemGrid.widthScaleFactor + height: geometry.height * pagerItemGrid.heightScaleFactor visible: model.IsMinimized !== true color: { if (desktop.active) { diff --git a/applets/pager/plugin/windowmodel.cpp b/applets/pager/plugin/windowmodel.cpp --- a/applets/pager/plugin/windowmodel.cpp +++ b/applets/pager/plugin/windowmodel.cpp @@ -28,6 +28,8 @@ #include +#include + using namespace TaskManager; class WindowModel::Private @@ -75,11 +77,10 @@ QVariant WindowModel::data(const QModelIndex &index, int role) const { if (role == AbstractTasksModel::Geometry) { - const QRect &windowGeo = TaskFilterProxyModel::data(index, role).toRect(); + QRect windowGeo = TaskFilterProxyModel::data(index, role).toRect(); + const QRect &desktopGeo = d->desktopWidget->geometry(); if (KWindowSystem::mapViewport()) { - const QRect &desktopGeo = d->desktopWidget->geometry(); - int x = windowGeo.center().x() % desktopGeo.width(); int y = windowGeo.center().y() % desktopGeo.height(); @@ -97,14 +98,25 @@ if (filterByScreen() && screenGeometry().isValid()) { const QPoint &screenOffset = screenGeometry().topLeft(); - return mappedGeo.translated(0 - screenOffset.x(), 0 - screenOffset.y()); + windowGeo = mappedGeo.translated(0 - screenOffset.x(), 0 - screenOffset.y()); } + } else if (filterByScreen() && screenGeometry().isValid()) { + const QPoint &screenOffset = screenGeometry().topLeft(); + + windowGeo.translate(0 - screenOffset.x(), 0 - screenOffset.y()); } - if (filterByScreen() && screenGeometry().isValid()) { - const QPoint &screenOffset = screenGeometry().topLeft(); + // Clamp to desktop rect. + // TODO: Switch from qBound to std::clamp once we use C++17. + windowGeo.setX(qBound(0, windowGeo.x(), desktopGeo.width())); + windowGeo.setY(qBound(0, windowGeo.y(), desktopGeo.height())); + + if ((windowGeo.x() + windowGeo.width()) > desktopGeo.width()) { + windowGeo.setWidth(desktopGeo.width() - windowGeo.x()); + } - return windowGeo.translated(0 - screenOffset.x(), 0 - screenOffset.y()); + if ((windowGeo.y() + windowGeo.height()) > desktopGeo.height()) { + windowGeo.setHeight(desktopGeo.height() - windowGeo.y()); } return windowGeo;