[plasma/kwin] src: Fix Window::checkOffscreenPosition() moving window too much

Vlad Zahorodnii <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 3aaf43d82732c8a32c2727f77bcea2a19d96f1e4 by Vlad Zahorodnii.
Committed on 10/08/2026 at 12:47.
Pushed by vladz into branch 'master'.

Fix Window::checkOffscreenPosition() moving window too much

The window size can be smaller than screenArea.size() / 4.

M  +4    -4    src/window.cpp

https://invent.kde.org/plasma/kwin/-/commit/3aaf43d82732c8a32c2727f77bcea2a19d96f1e4

diff --git a/src/window.cpp b/src/window.cpp
index fd09bb9b0fe..a934b783e2a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -4203,14 +4203,14 @@ void Window::checkWorkspacePosition(RectF oldGeometry, LogicalOutput *oldOutput)
 void Window::checkOffscreenPosition(RectF *geom, const RectF &screenArea)
 {
     if (geom->left() > screenArea.right()) {
-        geom->moveLeft(screenArea.right() - screenArea.width() / 4);
+        geom->moveLeft(screenArea.right() - std::min(geom->width(), screenArea.width() / 4));
     } else if (geom->right() < screenArea.left()) {
-        geom->moveRight(screenArea.left() + screenArea.width() / 4);
+        geom->moveRight(screenArea.left() + std::min(geom->width(), screenArea.width() / 4));
     }
     if (geom->top() > screenArea.bottom()) {
-        geom->moveTop(screenArea.bottom() - screenArea.height() / 4);
+        geom->moveTop(screenArea.bottom() - std::min(geom->height(), screenArea.height() / 4));
     } else if (geom->bottom() < screenArea.top()) {
-        geom->moveBottom(screenArea.top() + screenArea.height() / 4);
+        geom->moveBottom(screenArea.top() + std::min(geom->height(), screenArea.height() / 4));
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.