Remote control: Allow matching the parent of an overlay window

This commit is contained in:
Kovid Goyal
2022-12-30 11:29:05 +05:30
parent 080d1bf935
commit c18bff7821
4 changed files with 34 additions and 8 deletions

View File

@@ -652,6 +652,13 @@ class Window:
ans['overlay_type'] = self.overlay_type.value
return ans
@property
def overlay_parent(self) -> Optional['Window']:
tab = self.tabref()
if tab is None:
return None
return tab.overlay_parent(self)
@property
def current_colors(self) -> Dict[str, Optional[int]]:
return self.screen.color_profile.as_dict()
@@ -692,7 +699,7 @@ class Window:
return False
return False
def matches_query(self, field: str, query: str, active_tab: Optional[TabType] = None) -> bool:
def matches_query(self, field: str, query: str, active_tab: Optional[TabType] = None, self_window: Optional['Window'] = None) -> bool:
if field in ('num', 'recent'):
if active_tab is not None:
try:
@@ -720,6 +727,10 @@ class Window:
return False
if query == 'parent_focused':
return active_tab is not None and self.tabref() is active_tab and last_focused_os_window_id() == self.os_window_id
if query == 'self':
return self is self_window
if query == 'overlay_parent':
return self_window is not None and self is self_window.overlay_parent
return False
pat = compile_match_query(query, field != 'env')
return self.matches(field, pat)