Have the semantics of is_focused match that of state:focused otherwise things are liable to get confusing

The previous value is now available as is_active_window
This commit is contained in:
Kovid Goyal
2022-11-03 22:28:37 +05:30
parent c0b11c5656
commit a856c64104
3 changed files with 9 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ class TabMouseEvent(NamedTuple):
class TabDict(TypedDict):
id: int
is_focused: bool
is_active_tab: bool
title: str
layout: str
layout_state: Dict[str, Any]
@@ -700,7 +701,7 @@ class Tab: # {{{
def list_windows(self, active_window: Optional[Window], self_window: Optional[Window] = None) -> Generator[WindowDict, None, None]:
for w in self:
yield w.as_dict(is_focused=w is active_window, is_self=w is self_window)
yield w.as_dict(is_focused=w is active_window and w.os_window_id == last_focused_os_window_id(), is_self=w is self_window)
def matches_query(self, field: str, query: str, active_tab_manager: Optional['TabManager'] = None) -> bool:
if field == 'title':
@@ -938,7 +939,8 @@ class TabManager: # {{{
for tab in self:
yield {
'id': tab.id,
'is_focused': tab is active_tab,
'is_focused': tab is active_tab and tab.os_window_id == last_focused_os_window_id(),
'is_active_tab': tab is active_tab,
'title': tab.name or tab.title,
'layout': str(tab.current_layout.name),
'layout_state': tab.current_layout.layout_state(),