Move close_window from Tab to Boss

We might eventually implement OS Window level floating windows
and the close_window action actually used the Boss method anyway
This commit is contained in:
Kovid Goyal 2021-11-06 10:45:07 +05:30
parent 8630c7a700
commit 49a0e8e242
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 9 additions and 11 deletions

View File

@ -182,7 +182,7 @@ class VisualSelect:
if self.window_used_for_selection_id:
w = boss.window_id_map.get(self.window_used_for_selection_id)
if w is not None:
boss.close_window(w)
boss.mark_window_for_close(w)
return boss
@ -585,11 +585,15 @@ class Boss:
if window is not None:
window.focus_changed(True)
def close_window(self, window: Optional[Window] = None) -> None:
def mark_window_for_close(self, window: Optional[Window] = None) -> None:
window = window or self.active_window
if window:
self.child_monitor.mark_for_close(window.id)
@ac('win', 'Close the currently active window')
def close_window(self) -> None:
self.mark_window_for_close()
@ac('tab', 'Close the current tab')
def close_tab(self, tab: Optional[Tab] = None) -> None:
tab = tab or self.active_tab
@ -626,7 +630,7 @@ class Boss:
def close_tab_no_confirm(self, tab: Tab) -> None:
for window in tab:
self.close_window(window)
self.mark_window_for_close(window)
@ac('win', 'Toggle the fullscreen status of the active OS Window')
def toggle_fullscreen(self, os_window_id: int = 0) -> None:

View File

@ -33,7 +33,7 @@ If specified close the window this command is run in, rather than the active win
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
for window in self.windows_for_match_payload(boss, window, payload_get):
if window:
boss.close_window(window)
boss.mark_window_for_close(window)
return None

View File

@ -456,12 +456,6 @@ class Tab: # {{{
allow_remote_control=allow_remote_control, watchers=special_window.watchers
)
@ac('win', 'Close the currently active window')
def close_window(self) -> None:
w = self.active_window
if w is not None:
self.remove_window(w)
@ac('win', 'Close all windows in the tab other than the currently active window')
def close_other_windows_in_tab(self) -> None:
if len(self.windows) > 1:

View File

@ -577,7 +577,7 @@ class Window:
return g.left <= x <= g.right and g.top <= y <= g.bottom
def close(self) -> None:
get_boss().close_window(self)
get_boss().mark_window_for_close(self)
@ac('misc', '''
Send the specified text to the active window