From 9a3da098999fee9f40f8b3a233011c27cd414ef7 Mon Sep 17 00:00:00 2001 From: Natalie Clarius Date: Tue, 16 May 2023 07:54:06 +0000 Subject: [PATCH] Refine order of previous/next screens in Workspace::findOutput A screen should be considered further top, and therefore more previous, only it is strictly above the other with no vertical overlap, and not if only the vertical center is higher while they are horizontally on a line. Otherwise, on a left to right setup with screens of different resolutions aligned at the edges (and thus different vertical centesr), the order will be unintuitive. BUG: 467996 FIXED-IN: 5.27 --- src/workspace.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workspace.cpp b/src/workspace.cpp index 022112fb6d..70193c4c1c 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -1247,7 +1247,9 @@ Output *Workspace::findOutput(Output *reference, Direction direction, bool wrapA return o1->geometry().center().y() < o2->geometry().center().y(); default: // order outputs from top to bottom, then left to right - return (o1->geometry().center().y() < o2->geometry().center().y() || (o1->geometry().center().y() == o2->geometry().center().y() && o1->geometry().center().x() < o2->geometry().center().x())); + // case 1: o1 is above o2 + // case 2: o1 is not below o2, and o1 is left of o2 + return o1->geometry().y() + o1->geometry().height() <= o2->geometry().top() || (o1->geometry().top() < o2->geometry().y() + o2->geometry().height() && o1->geometry().left() < o2->geometry().left()); } });