A mappable action to visually select the window to focus with the keyboard

This commit is contained in:
Kovid Goyal
2021-10-11 20:18:35 +05:30
parent 563b7ad2d0
commit 440640bbbc
2 changed files with 47 additions and 8 deletions

View File

@@ -6,9 +6,7 @@ import weakref
from collections import deque
from contextlib import suppress
from itertools import count
from typing import (
Any, Deque, Dict, Generator, Iterator, List, Optional, Tuple, Union
)
from typing import Any, Deque, Dict, Iterator, List, Optional, Tuple, Union
from .types import WindowGeometry
from .typing import EdgeLiteral, TabType, WindowType
@@ -202,7 +200,7 @@ class WindowList:
def change_tab(self, tab: TabType) -> None:
self.tabref = weakref.ref(tab)
def iter_windows_with_visibility(self) -> Generator[Tuple[WindowType, bool], None, None]:
def iter_windows_with_visibility(self) -> Iterator[Tuple[WindowType, bool]]:
for g in self.groups:
aw = g.active_window_id
for window in g:
@@ -211,6 +209,16 @@ class WindowList:
def iter_all_layoutable_groups(self, only_visible: bool = False) -> Iterator[WindowGroup]:
return iter(g for g in self.groups if g.is_visible_in_layout) if only_visible else iter(self.groups)
def iter_visible_windows_with_number(self) -> Iterator[Tuple[int, WindowType]]:
for i, g in enumerate(self.groups):
if g.is_visible_in_layout:
aw = g.active_window_id
for window in g:
if window in g:
if window.id == aw:
yield i, window
break
def make_previous_group_active(self, which: int = 1, notify: bool = True) -> None:
which = max(1, which)
gid_map = {g.id: i for i, g in enumerate(self.groups)}