domferr / tilingshell

Extend Gnome Shell with advanced tiling window management. Supports multiple monitors, Windows 11 Snap Assistant, Fancy Zones, customised tiling layouts and more.
https://extensions.gnome.org/extension/7065/tiling-shell/
GNU General Public License v2.0
645 stars 20 forks source link

feat: add focus next/prev window #195

Open jessedhillon opened 1 day ago

jessedhillon commented 1 day ago

This adds two new focus-switching actions: focus next window, and focus previous window, where previous and next windows are determined by the window manager and limited to the current workspace. It also adds an option to wrap around to the beginning of the window list when the extent is reached, e.g. when you're at the last window, focus next will wrap around and focus the first window.

This also fixes a bug where the focus keybindings are not unbound when the extension is disabled, e.g. when the screen is locked, so the attempt to rebind them fails with a message from GNOME Shell that duplicate bindings are being set.

jessedhillon commented 1 day ago

I created this feature because my preferred keybinding scheme is:

I find this more natural, as I usually have 2-5 windows on screen so flipping between them doesn't require multidirectional navigation. I am open to a better scheme for figuring out the "next" and "previous" windows, perhaps one that is more aware of the currently used layout.

domferr commented 20 hours ago

Hey thank you for all of this, I love it! I agree with you that this could be more natural for some people. I appreciate a lot you also added a setting to Enable next/previous window focus to wrap around! Since this is already in a very good stage, I'm changing the branch target from main to the next release's branch (v15.1).

This also fixes a bug where the focus keybindings are not unbound when the extension is disabled

I noticed it yesterday and I was starting to work on a fix for this issue, but I'm happy to see you also fixed this, thank you so much!

I am open to a better scheme for figuring out the "next" and "previous" windows

I gave a look at your code and I'm looking into testing it. From what I already saw it's very well made! Meanwhile, as a suggestion, we could consider to follow the same ordering you have on ALT + TAB. I'm curious to know your opinion about it! Currently, you do something like const windowList = focus_window.get_workspace().list_windows(); (which is correct) and that could be replaced with Tiling Shell's getWindows() method who follows ALT + TAB ordering! It does some filtering as well.

jessedhillon commented 16 hours ago

Thanks @domferr I'll try out getWindows this evening and see how it feels.

I have not spent a lot of time looking at the Tiling Shell code, but I imagine that there might be a way where we can

  1. get the current layout, I assume the layout object has some member like tiles which describes all of the tiles
  2. figure out which tile the focused window occupies
  3. switch focus to tiles[currentIndex + 1]

One problem would be that some windows may not be tiled, so they would have to be handled in some way. I think this can wait for the future, but it could be a good improvement.