Move startup of first child out of the constructor of Boss

This commit is contained in:
Kovid Goyal 2020-03-19 16:48:16 +05:30
parent 83e8018787
commit cfe9b408ce
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 13 deletions

View File

@ -135,7 +135,6 @@ class Boss:
def __init__(
self,
os_window_id: Optional[int],
opts: Options,
args: CLIOptions,
cached_values: Dict[str, Any],
@ -165,22 +164,24 @@ class Boss:
)
set_boss(self)
self.opts, self.args = opts, args
startup_sessions = create_sessions(opts, args, default_session=opts.startup_session)
self.keymap = self.opts.keymap.copy()
if new_os_window_trigger is not None:
self.keymap.pop(new_os_window_trigger, None)
for startup_session in startup_sessions:
self.add_os_window(startup_session, os_window_id=os_window_id)
os_window_id = None
if args.start_as != 'normal':
if args.start_as == 'fullscreen':
self.toggle_fullscreen()
else:
change_os_window_state(args.start_as)
if is_macos:
from .fast_data_types import cocoa_set_notification_activated_callback
cocoa_set_notification_activated_callback(notification_activated)
def startup_first_child(self, os_window_id: Optional[int]) -> None:
startup_sessions = create_sessions(self.opts, self.args, default_session=self.opts.startup_session)
for startup_session in startup_sessions:
self.add_os_window(startup_session, os_window_id=os_window_id)
os_window_id = None
if self.args.start_as != 'normal':
if self.args.start_as == 'fullscreen':
self.toggle_fullscreen()
else:
change_os_window_state(self.args.start_as)
def add_os_window(
self,
startup_session: Optional[Session] = None,
@ -427,10 +428,12 @@ class Boss:
def toggle_maximized(self) -> None:
toggle_maximized()
def start(self) -> None:
def start(self, first_os_window_id: int) -> None:
if not getattr(self, 'io_thread_started', False):
self.child_monitor.start()
self.io_thread_started = True
self.startup_first_child(first_os_window_id)
if self.opts.update_check_interval > 0 and not hasattr(self, 'update_check_started'):
from .update_check import run_update_check
run_update_check(self.opts.update_check_interval * 60 * 60)

View File

@ -133,8 +133,8 @@ def _run_app(opts: OptionsStub, args: CLIOptions, bad_lines: Sequence[BadLine] =
pre_show_callback,
appname, args.name or args.cls or appname,
args.cls or appname, load_all_shaders)
boss = Boss(window_id, opts, args, cached_values, new_os_window_trigger)
boss.start()
boss = Boss(opts, args, cached_values, new_os_window_trigger)
boss.start(window_id)
if bad_lines:
boss.show_bad_config_lines(bad_lines)
try: