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

swap_and_focus* commands #662

Open
6 tasks
dalyIsaac opened this issue Dec 4, 2023 · 1 comment
Open
6 tasks

swap_and_focus* commands #662

dalyIsaac opened this issue Dec 4, 2023 · 1 comment
Labels
bug Something isn't working core Whim

Comments

@dalyIsaac
Copy link
Owner

dalyIsaac commented Dec 4, 2023

Current behavior is to swap window position, but keep the current window focused.

  • swap_and_focus_window.left
  • swap_and_focus_window.right
  • swap_and_focus_window.up
  • swap_and_focus_window.down
  • move_and_focus_window.next_monitor
  • move_and_focus_window.previous_monitor
@dalyIsaac dalyIsaac added core Whim enhancement New feature or request labels Dec 4, 2023
@dalyIsaac dalyIsaac added this to Whim Dec 4, 2023
@urob
Copy link
Contributor

urob commented Dec 16, 2023

I had look into this and I can offer a bit more information.

Clarification

In most cases, the current default behavior of the various swap_window* commands is already doing what this feature request is asking: The focus follows then moved window.

Exception

The one case I could find where this is not true, is when focus-follows-mouse is enabled in the OS settings. Apologies that I didn't catch this earlier (I am so used to this setting, that I didn't think about that this may be the culprit). So instead of a feature request, this should have been a bug report.

Fix

In the simplest case, this can be fixed by actively focusing the moved window with window.Focus() after it has been moved. However, this fails when the move triggers any resizing among other windows (e.g., on the old monitor after move_window_to_monitor). In this case, the resizing may move another window underneath the mouse cursor, snatching the focus away again.

I played around a bit, and one somewhat hacky fix is to delay the window.Focus() by a few hundred milliseconds:

Task.Run(async delegate
{
    await Task.Delay(300);
    window.Focus();
});

This seems to do the trick based on my initial testing but it definitely feels hacky. A cleaner solution might be to also move the mouse pointer to the center of the moved window.

@dalyIsaac dalyIsaac added bug Something isn't working and removed enhancement New feature or request labels Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Whim
Projects
Status: No status
Development

No branches or pull requests

2 participants