mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 11:07:38 +03:00
When no OS Window is focused the active_* should return those belonging to the last focused OS Window
This commit is contained in:
parent
10ad56885e
commit
59ded41f7a
@ -343,7 +343,6 @@ def add_os_window(
|
||||
|
||||
def list_os_windows(self, self_window: Optional[Window] = None) -> Iterator[OSWindowDict]:
|
||||
with cached_process_data():
|
||||
active_tab, active_window = self.active_tab, self.active_window
|
||||
active_tab_manager = self.active_tab_manager
|
||||
for os_window_id, tm in self.os_window_map.items():
|
||||
yield {
|
||||
@ -352,7 +351,7 @@ def list_os_windows(self, self_window: Optional[Window] = None) -> Iterator[OSWi
|
||||
'is_active': tm is active_tab_manager,
|
||||
'is_focused': current_focused_os_window_id() == os_window_id,
|
||||
'last_focused': os_window_id == last_focused_os_window_id(),
|
||||
'tabs': list(tm.list_tabs(active_tab, active_window, self_window)),
|
||||
'tabs': list(tm.list_tabs(self_window)),
|
||||
'wm_class': tm.wm_class,
|
||||
'wm_name': tm.wm_name
|
||||
}
|
||||
@ -1090,8 +1089,14 @@ def set_background_opacity(self, opacity: str) -> None:
|
||||
|
||||
@property
|
||||
def active_tab_manager(self) -> Optional[TabManager]:
|
||||
os_window_id = current_os_window()
|
||||
return None if os_window_id is None else self.os_window_map.get(os_window_id)
|
||||
os_window_id = current_focused_os_window_id()
|
||||
if os_window_id <= 0:
|
||||
os_window_id = last_focused_os_window_id()
|
||||
if os_window_id <= 0:
|
||||
q = current_os_window()
|
||||
if q is not None:
|
||||
os_window_id = q
|
||||
return self.os_window_map.get(os_window_id)
|
||||
|
||||
@property
|
||||
def active_tab(self) -> Optional[Tab]:
|
||||
|
@ -699,7 +699,8 @@ def move_window_forward(self) -> None:
|
||||
def move_window_backward(self) -> None:
|
||||
self.move_window(-1)
|
||||
|
||||
def list_windows(self, active_window: Optional[Window], self_window: Optional[Window] = None) -> Generator[WindowDict, None, None]:
|
||||
def list_windows(self, self_window: Optional[Window] = None) -> Generator[WindowDict, None, None]:
|
||||
active_window = self.active_window
|
||||
for w in self:
|
||||
yield w.as_dict(
|
||||
is_active_window=w is active_window,
|
||||
@ -939,7 +940,8 @@ def __iter__(self) -> Iterator[Tab]:
|
||||
def __len__(self) -> int:
|
||||
return len(self.tabs)
|
||||
|
||||
def list_tabs(self, active_tab: Optional[Tab], active_window: Optional[Window], self_window: Optional[Window] = None) -> Generator[TabDict, None, None]:
|
||||
def list_tabs(self, self_window: Optional[Window] = None) -> Generator[TabDict, None, None]:
|
||||
active_tab = self.active_tab
|
||||
for tab in self:
|
||||
yield {
|
||||
'id': tab.id,
|
||||
@ -950,7 +952,7 @@ def list_tabs(self, active_tab: Optional[Tab], active_window: Optional[Window],
|
||||
'layout_state': tab.current_layout.layout_state(),
|
||||
'layout_opts': tab.current_layout.layout_opts.serialized(),
|
||||
'enabled_layouts': tab.enabled_layouts,
|
||||
'windows': list(tab.list_windows(active_window, self_window)),
|
||||
'windows': list(tab.list_windows(self_window)),
|
||||
'active_window_history': list(tab.windows.active_window_history),
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,12 @@
|
||||
NUM_UNDERLINE_STYLES, OSC, REVERSE, SCROLL_FULL, SCROLL_LINE, SCROLL_PAGE,
|
||||
STRIKETHROUGH, TINT_PROGRAM, Color, KeyEvent, Screen, add_timer, add_window,
|
||||
cell_size_for_window, click_mouse_cmd_output, click_mouse_url, compile_program,
|
||||
current_os_window, encode_key_for_tty, get_boss, get_click_interval, get_options,
|
||||
init_cell_program, mark_os_window_dirty, mouse_selection, last_focused_os_window_id,
|
||||
move_cursor_to_mouse_if_in_prompt, pt_to_px, set_titlebar_color, set_window_logo,
|
||||
set_window_padding, set_window_render_data, update_ime_position_for_window,
|
||||
update_window_title, update_window_visibility, wakeup_main_loop,
|
||||
current_focused_os_window_id, encode_key_for_tty, get_boss, get_click_interval,
|
||||
get_options, init_cell_program, last_focused_os_window_id, mark_os_window_dirty,
|
||||
mouse_selection, move_cursor_to_mouse_if_in_prompt, pt_to_px, set_titlebar_color,
|
||||
set_window_logo, set_window_padding, set_window_render_data,
|
||||
update_ime_position_for_window, update_window_title, update_window_visibility,
|
||||
wakeup_main_loop,
|
||||
)
|
||||
from .keys import keyboard_mode_name, mod_mask
|
||||
from .notify import (
|
||||
@ -926,7 +927,7 @@ def focus_changed(self, focused: bool) -> None:
|
||||
tab = self.tabref()
|
||||
if tab is not None:
|
||||
tab.relayout_borders()
|
||||
elif self.os_window_id == current_os_window():
|
||||
elif self.os_window_id == current_focused_os_window_id():
|
||||
# Cancel IME composition after loses focus
|
||||
update_ime_position_for_window(self.id, False, -1)
|
||||
|
||||
@ -1361,7 +1362,7 @@ def destroy(self) -> None:
|
||||
self.destroyed = True
|
||||
del self.kitten_result_processors
|
||||
if hasattr(self, 'screen'):
|
||||
if self.is_active and self.os_window_id == current_os_window():
|
||||
if self.is_active and self.os_window_id == current_focused_os_window_id():
|
||||
# Cancel IME composition when window is destroyed
|
||||
update_ime_position_for_window(self.id, False, -1)
|
||||
# Remove cycles so that screen is de-allocated immediately
|
||||
|
Loading…
Reference in New Issue
Block a user