Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X.A.WindowNavigation: better handling of floating windows and Full layout #896

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

Rogach
Copy link
Contributor

@Rogach Rogach commented Jun 29, 2024

Description

Previous version of WindowNavigation just got "stuck" on floating windows, switching back and forth between floating window and tiled window underneath. This was because "magic point" was left in the same position and thus next navigation commands selected the same windows over and over again. Now the "magic point" is moved around such that it doesn't overlap with the previously selected window, and there are more complicated rules to make navigation between floating and tiled windows more natural.

The original behavior of navigating between tiled windows is preserved almost precisely (the tree-like layouts - which should be overwhelmingly the most popular ones - will have exactly the same behavior, the only differences might be in some convoluted custom layouts).

Previous version of WindowNavigation also prevented switching windows using focusUp/focusDown when in Full layout. Now there's a special case that handles such situations.

Checklist

  • I've read CONTRIBUTING.md
  • I've tested the changes with unit tests. Just look how pretty the tests are - there are diagrams that explain what each case is actually testing!
  • I updated the CHANGES.md file

-- (keeps the position as-is if it is already inside the target rectangle)
centerPosition :: Rectangle -> Point -> Point
centerPosition (Rectangle rx ry rw rh) pos@(Point x y) = do
if x >= rx && x < rx + fromIntegral rw && y >= ry && y < ry + fromIntegral rh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's useful, I'll update the code.

pos = pointTransform dir currentPos
wr = rectTransform dir currentRect

rectInside r = (rect_p1 r >= rect_p1 wr && rect_p1 r < rect_p2 wr && rect_p2 r > rect_p1 wr && rect_p2 r <= rect_p2 wr) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is less useful, because it doesn't handle the special case of a window that fully overlaps the current window in the orthogonal direction.

…yout

Previous version most of the time just got "stuck" on floating windows,
switching back and forth between floating window and tiled window underneath.
This was because "magic point" was left in the same position and thus next
navigation commands selected the same windows over and over again.
Now the "magic point" is moved around such that it doesn't overlap with the previously selected window,
and there are more complicated rules to make navigation between floating and tiled windows more natural.

The original behavior of navigating between tiled windows is preserved almost precisely.

Previous version also prevented switching windows using focusUp/focusDown
when in Full layout. Now there's a special case that handles such situations.
@Rogach Rogach force-pushed the pr/window-navigation branch from 3f6e585 to 66d334f Compare July 1, 2024 15:45
@geekosaur
Copy link
Contributor

I'm going to wait a few days for one of the other maintainers to look at it, but as they're often unavailable I won't wait too long.

@slotThe
Copy link
Member

slotThe commented Jul 2, 2024

I'm going to wait a few days for one of the other maintainers to look at it, but as they're often unavailable I won't wait too long.

FWIW I definitely plan to look at this in the coming days

@slotThe slotThe merged commit eb72684 into xmonad:master Jul 28, 2024
20 checks passed
@slotThe
Copy link
Member

slotThe commented Jul 28, 2024

Thanks!

@Rogach Rogach deleted the pr/window-navigation branch August 11, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants