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:
parent
c0b11c5656
commit
a856c64104
3 changed files with 9 additions and 5 deletions
|
|
@ -37,7 +37,7 @@
|
|||
IMPERATIVE_CLOSE_REQUESTED, NO_CLOSE_REQUESTED, ChildMonitor, Color,
|
||||
EllipticCurveKey, KeyEvent, SingleKey, add_timer, apply_options_update,
|
||||
background_opacity_of, change_background_opacity, change_os_window_state,
|
||||
cocoa_set_menubar_title, create_os_window,
|
||||
cocoa_set_menubar_title, create_os_window, last_focused_os_window_id,
|
||||
current_application_quit_request, current_os_window, destroy_global_data,
|
||||
focus_os_window, get_boss, get_options, get_os_window_size,
|
||||
global_font_size, mark_os_window_for_close, os_window_font_size,
|
||||
|
|
@ -351,7 +351,7 @@ def list_os_windows(self, self_window: Optional[Window] = None) -> Iterator[OSWi
|
|||
yield {
|
||||
'id': os_window_id,
|
||||
'platform_window_id': platform_window_id(os_window_id),
|
||||
'is_focused': tm is active_tab_manager,
|
||||
'is_focused': tm is active_tab_manager and os_window_id == last_focused_os_window_id(),
|
||||
'tabs': list(tm.list_tabs(active_tab, active_window, self_window)),
|
||||
'wm_class': tm.wm_class,
|
||||
'wm_name': tm.wm_name
|
||||
|
|
|
|||
|
|
@ -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 @@ def move_window_backward(self) -> None:
|
|||
|
||||
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 @@ def list_tabs(self, active_tab: Optional[Tab], active_window: Optional[Window],
|
|||
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(),
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ def compile_match_query(exp: str, is_simple: bool = True) -> MatchPatternType:
|
|||
class WindowDict(TypedDict):
|
||||
id: int
|
||||
is_focused: bool
|
||||
is_active_window: bool
|
||||
title: str
|
||||
pid: Optional[int]
|
||||
cwd: str
|
||||
|
|
@ -614,10 +615,11 @@ def title(self) -> str:
|
|||
def __repr__(self) -> str:
|
||||
return f'Window(title={self.title}, id={self.id})'
|
||||
|
||||
def as_dict(self, is_focused: bool = False, is_self: bool = False) -> WindowDict:
|
||||
def as_dict(self, is_focused: bool = False, is_self: bool = False, is_active_window: bool = False) -> WindowDict:
|
||||
return dict(
|
||||
id=self.id,
|
||||
is_focused=is_focused,
|
||||
is_active_window=is_active_window,
|
||||
title=self.title,
|
||||
pid=self.child.pid,
|
||||
cwd=self.child.current_cwd or self.child.cwd,
|
||||
|
|
|
|||
Loading…
Reference in a new issue