diff --git a/docs/changelog.rst b/docs/changelog.rst index 5f7c04aa7..643102ce4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -39,6 +39,9 @@ Detailed list of changes - Remote control: Allow using :ref:`Boolean operators ` when constructing queries to match windows or tabs +- Sessions: Fix :code:`os_window_size` and :code:`os_window_class` not applying to the first OS Window (:iss:`4957`) + + 0.25.0 [2022-04-11] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/overview.rst b/docs/overview.rst index 7d620ce97..70ecdbd84 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -149,7 +149,7 @@ For example: # Create a new OS window new_os_window - # set new window size to 80x25 cells + # set new window size to 80x25 cells (if specifed before new_os_window will apply to first OS window) os_window_size 80c 25c # set the --class for the new OS window os_window_class mywindow diff --git a/kitty/boss.py b/kitty/boss.py index 79b3f390e..025e7f86d 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -11,8 +11,8 @@ from functools import partial from gettext import gettext as _ from time import monotonic from typing import ( - Any, Callable, Container, Dict, Iterable, Iterator, List, Optional, - Sequence, Set, Tuple, Union + Any, Callable, Container, Dict, Iterable, Iterator, List, Optional, Set, + Tuple, Union ) from weakref import WeakValueDictionary @@ -274,7 +274,7 @@ class Boss: for sc in self.global_shortcuts.values(): self.keymap.pop(sc, None) - def startup_first_child(self, os_window_id: Optional[int], startup_sessions: Sequence[Optional[Session]] = ()) -> None: + def startup_first_child(self, os_window_id: Optional[int], startup_sessions: Iterable[Session] = ()) -> None: si = startup_sessions or create_sessions(get_options(), self.args, default_session=get_options().startup_session) for startup_session in si: self.add_os_window(startup_session, os_window_id=os_window_id) @@ -723,7 +723,7 @@ class Boss: def toggle_macos_secure_keyboard_entry(self) -> None: toggle_secure_input() - def start(self, first_os_window_id: int) -> None: + def start(self, first_os_window_id: int, startup_sessions: Iterable[Session]) -> None: if not getattr(self, 'io_thread_started', False): self.child_monitor.start() self.io_thread_started = True @@ -734,7 +734,7 @@ class Boss: self.startup_first_child(first_os_window_id, startup_sessions=tuple(sess)) self.launch_urls(*urls) else: - self.startup_first_child(first_os_window_id) + self.startup_first_child(first_os_window_id, startup_sessions=startup_sessions) if get_options().update_check_interval > 0 and not self.update_check_started and getattr(sys, 'frozen', False): from .update_check import run_update_check diff --git a/kitty/main.py b/kitty/main.py index df553db7c..ac7bde156 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -29,7 +29,7 @@ from .fonts.render import set_font_family from .options.types import Options from .options.utils import DELETE_ENV_VAR from .os_window_size import initial_window_size_func -from .session import get_os_window_sizing_data +from .session import create_sessions, get_os_window_sizing_data from .types import SingleKey from .utils import ( cleanup_ssh_control_masters, detach, expandvars, log_error, @@ -168,14 +168,16 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) if not is_wayland() and not is_macos: # no window icons on wayland set_x11_window_icon() with cached_values_for(run_app.cached_values_name) as cached_values: + startup_sessions = tuple(create_sessions(opts, args, default_session=opts.startup_session)) + wincls = (startup_sessions[0].os_window_class if startup_sessions else '') or args.cls or appname with startup_notification_handler(extra_callback=run_app.first_window_callback) as pre_show_callback: window_id = create_os_window( - run_app.initial_window_size_func(get_os_window_sizing_data(opts), cached_values), + run_app.initial_window_size_func(get_os_window_sizing_data(opts, startup_sessions[0] if startup_sessions else None), cached_values), pre_show_callback, args.title or appname, args.name or args.cls or appname, - args.cls or appname, load_all_shaders, disallow_override_title=bool(args.title)) + wincls, load_all_shaders, disallow_override_title=bool(args.title)) boss = Boss(opts, args, cached_values, global_shortcuts) - boss.start(window_id) + boss.start(window_id, startup_sessions) if bad_lines: boss.show_bad_config_lines(bad_lines) try: diff --git a/kitty/session.py b/kitty/session.py index c46b9c59a..2a1dc776a 100644 --- a/kitty/session.py +++ b/kitty/session.py @@ -3,18 +3,17 @@ import shlex import sys -from typing import Generator, List, Optional, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Generator, Iterator, List, Optional, Union from .cli_stub import CLIOptions -from .options.utils import to_layout_names, window_size from .constants import kitty_exe from .layout.interface import all_layouts from .options.types import Options +from .options.utils import to_layout_names, window_size from .os_window_size import WindowSize, WindowSizeData, WindowSizes from .typing import SpecialWindowInstance from .utils import log_error, resolved_shell - if TYPE_CHECKING: from .window import CwdRequest @@ -153,7 +152,7 @@ def create_sessions( cwd_from: Optional['CwdRequest'] = None, respect_cwd: bool = False, default_session: Optional[str] = None -) -> Generator[Session, None, None]: +) -> Iterator[Session]: if args and args.session: if isinstance(args.session, PreReadSession): session_data = '' + str(args.session)