mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
Ensure all windows in OS Window are destroyed when OS Window is closed
This commit is contained in:
@@ -1817,13 +1817,15 @@ class Boss:
|
|||||||
|
|
||||||
def on_os_window_closed(self, os_window_id: int, viewport_width: int, viewport_height: int) -> None:
|
def on_os_window_closed(self, os_window_id: int, viewport_width: int, viewport_height: int) -> None:
|
||||||
self.cached_values['window-size'] = viewport_width, viewport_height
|
self.cached_values['window-size'] = viewport_width, viewport_height
|
||||||
|
windows_in_os_window = {w.id: w for w in self.window_id_map.values() if w.os_window_id == os_window_id}
|
||||||
tm = self.os_window_map.pop(os_window_id, None)
|
tm = self.os_window_map.pop(os_window_id, None)
|
||||||
if tm is not None:
|
if tm is not None:
|
||||||
tm.destroy()
|
tm.destroy() # this will call destroy on all windows
|
||||||
for window_id in tuple(w.id for w in self.window_id_map.values() if w.os_window_id == os_window_id):
|
for window_id, w in windows_in_os_window.items():
|
||||||
self.child_monitor.mark_for_close(window_id)
|
self.child_monitor.mark_for_close(window_id)
|
||||||
self.window_id_map.pop(window_id, None)
|
self.window_id_map.pop(window_id, None)
|
||||||
self.window_floats_map.pop(window_id, None)
|
self.window_floats_map.pop(window_id, None)
|
||||||
|
w.destroy() # in case tm was None
|
||||||
if not self.os_window_map and is_macos:
|
if not self.os_window_map and is_macos:
|
||||||
cocoa_set_menubar_title('')
|
cocoa_set_menubar_title('')
|
||||||
action = self.os_window_death_actions.pop(os_window_id, None)
|
action = self.os_window_death_actions.pop(os_window_id, None)
|
||||||
|
|||||||
@@ -1743,10 +1743,12 @@ class Window:
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def destroy(self) -> None:
|
def destroy(self) -> None:
|
||||||
|
if self.destroyed:
|
||||||
|
return
|
||||||
|
self.destroyed = True
|
||||||
for cw in self.floats:
|
for cw in self.floats:
|
||||||
cw.destroy()
|
cw.destroy()
|
||||||
self.call_watchers(self.watchers.on_close, {})
|
self.call_watchers(self.watchers.on_close, {})
|
||||||
self.destroyed = True
|
|
||||||
self.clipboard_request_manager.close()
|
self.clipboard_request_manager.close()
|
||||||
del self.kitten_result_processors
|
del self.kitten_result_processors
|
||||||
if hasattr(self, 'screen'):
|
if hasattr(self, 'screen'):
|
||||||
|
|||||||
Reference in New Issue
Block a user