Properly specify semantics of active and focused

active means active in parent. focused means actually has keyboard
focus.
This commit is contained in:
Kovid Goyal
2022-11-04 10:32:55 +05:30
parent d1eb9340ac
commit 10ad56885e
7 changed files with 75 additions and 49 deletions

View File

@@ -707,15 +707,20 @@ class Window:
return False
if field == 'state':
if query == 'active':
return active_tab is not None and self is active_tab.active_window
tab = self.tabref()
return tab is not None and tab.active_window is self
if query == 'focused':
return active_tab is not None and self is active_tab.active_window and last_focused_os_window_id() == self.os_window_id
if query == 'needs_attention':
return self.needs_attention
if query == 'parent_active':
return active_tab is not None and self.tabref() is active_tab
tab = self.tabref()
if tab is not None:
tm = tab.tab_manager_ref()
return tm is not None and tm.active_tab is tab
return False
if query == 'parent_focused':
return active_tab is not None and self.tabref() is active_tab and current_os_window() == self.os_window_id
return active_tab is not None and self.tabref() is active_tab and last_focused_os_window_id() == self.os_window_id
return False
pat = compile_match_query(query, field != 'env')
return self.matches(field, pat)