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:
@@ -37,7 +37,7 @@ from .fast_data_types import (
|
|||||||
IMPERATIVE_CLOSE_REQUESTED, NO_CLOSE_REQUESTED, ChildMonitor, Color,
|
IMPERATIVE_CLOSE_REQUESTED, NO_CLOSE_REQUESTED, ChildMonitor, Color,
|
||||||
EllipticCurveKey, KeyEvent, SingleKey, add_timer, apply_options_update,
|
EllipticCurveKey, KeyEvent, SingleKey, add_timer, apply_options_update,
|
||||||
background_opacity_of, change_background_opacity, change_os_window_state,
|
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,
|
current_application_quit_request, current_os_window, destroy_global_data,
|
||||||
focus_os_window, get_boss, get_options, get_os_window_size,
|
focus_os_window, get_boss, get_options, get_os_window_size,
|
||||||
global_font_size, mark_os_window_for_close, os_window_font_size,
|
global_font_size, mark_os_window_for_close, os_window_font_size,
|
||||||
@@ -351,7 +351,7 @@ class Boss:
|
|||||||
yield {
|
yield {
|
||||||
'id': os_window_id,
|
'id': os_window_id,
|
||||||
'platform_window_id': platform_window_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)),
|
'tabs': list(tm.list_tabs(active_tab, active_window, self_window)),
|
||||||
'wm_class': tm.wm_class,
|
'wm_class': tm.wm_class,
|
||||||
'wm_name': tm.wm_name
|
'wm_name': tm.wm_name
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class TabMouseEvent(NamedTuple):
|
|||||||
class TabDict(TypedDict):
|
class TabDict(TypedDict):
|
||||||
id: int
|
id: int
|
||||||
is_focused: bool
|
is_focused: bool
|
||||||
|
is_active_tab: bool
|
||||||
title: str
|
title: str
|
||||||
layout: str
|
layout: str
|
||||||
layout_state: Dict[str, Any]
|
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]:
|
def list_windows(self, active_window: Optional[Window], self_window: Optional[Window] = None) -> Generator[WindowDict, None, None]:
|
||||||
for w in self:
|
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:
|
def matches_query(self, field: str, query: str, active_tab_manager: Optional['TabManager'] = None) -> bool:
|
||||||
if field == 'title':
|
if field == 'title':
|
||||||
@@ -938,7 +939,8 @@ class TabManager: # {{{
|
|||||||
for tab in self:
|
for tab in self:
|
||||||
yield {
|
yield {
|
||||||
'id': tab.id,
|
'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,
|
'title': tab.name or tab.title,
|
||||||
'layout': str(tab.current_layout.name),
|
'layout': str(tab.current_layout.name),
|
||||||
'layout_state': tab.current_layout.layout_state(),
|
'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):
|
class WindowDict(TypedDict):
|
||||||
id: int
|
id: int
|
||||||
is_focused: bool
|
is_focused: bool
|
||||||
|
is_active_window: bool
|
||||||
title: str
|
title: str
|
||||||
pid: Optional[int]
|
pid: Optional[int]
|
||||||
cwd: str
|
cwd: str
|
||||||
@@ -614,10 +615,11 @@ class Window:
|
|||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'Window(title={self.title}, id={self.id})'
|
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(
|
return dict(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
is_focused=is_focused,
|
is_focused=is_focused,
|
||||||
|
is_active_window=is_active_window,
|
||||||
title=self.title,
|
title=self.title,
|
||||||
pid=self.child.pid,
|
pid=self.child.pid,
|
||||||
cwd=self.child.current_cwd or self.child.cwd,
|
cwd=self.child.current_cwd or self.child.cwd,
|
||||||
|
|||||||
Reference in New Issue
Block a user