Change Focus keyboard action to check borders closest to focus direction #1786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! I just want to say I love what you are doing with this desktop environment.
I often use keyboard shortcuts to navigate around the system both in floating and tiling so I couldn't help but notice the odd priorities when the compositor has to choose which window should be focused next.
Right now the compositor chooses the next window to focus based on which is the closest window along the relevant axis (X for right and left, Y for up and down)

But this is clunky, because that position is on the opposite end of the current window, so for example if we are trying to focus to the right window of the current one, we end up choosing the window that's closest to the left border of the current window instead of the window that's closest to the right border of the current window. This leads to behavior like two windows that are seemingly perfectly next to each other, you want to switch focus, and a small window from under pops up.
I changed this to prioritize windows that are closer to the relevant border on the relevant axis.
So if we take the example with the right window again it goes something like this:
Prioritize the window whose X position is closest to the right border on the right side of the right border.
i.e:
min(other.X - (current.X + current.width) ) // where this is > 0If there is no window that matches that, looks for the window whose X position is closest to the right border on the left side of the right border.
i.e:
max(other.X - (current.X + current.width)) // where this is < 0