launch: Allow specifying the state (fullscreen/maximized/minimized) for newly created OS Windows

Fixes #6026
This commit is contained in:
Kovid Goyal 2023-02-16 16:24:46 +05:30
parent c73c165be1
commit 72b2ba51df
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 14 additions and 2 deletions

View File

@ -54,6 +54,8 @@ Detailed list of changes
- When reloading configuration, also reload custom MIME types from :file:`mime.types` config file (:pull:`6012`) - When reloading configuration, also reload custom MIME types from :file:`mime.types` config file (:pull:`6012`)
- launch: Allow specifying the state (fullscreen/maximized/minimized) for newly created OS Windows (:iss:`6026`)
0.27.1 [2023-02-07] 0.27.1 [2023-02-07]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -13,7 +13,7 @@ from .cli import parse_args
from .cli_stub import LaunchCLIOptions from .cli_stub import LaunchCLIOptions
from .clipboard import set_clipboard_string, set_primary_selection from .clipboard import set_clipboard_string, set_primary_selection
from .constants import kitten_exe, shell_path from .constants import kitten_exe, shell_path
from .fast_data_types import add_timer, get_boss, get_options, get_os_window_title, patch_color_profiles from .fast_data_types import add_timer, change_os_window_state, get_boss, get_options, get_os_window_title, patch_color_profiles
from .options.utils import env as parse_env from .options.utils import env as parse_env
from .tabs import Tab, TabManager from .tabs import Tab, TabManager
from .types import OverlayType, run_once from .types import OverlayType, run_once
@ -252,6 +252,13 @@ titles set by programs running in kitty. The special value :code:`current` will
use the title of the current OS window, if any. use the title of the current OS window, if any.
--os-window-state
type=choices
default=normal
choices=normal,fullscreen,maximized,minimized
The initial state for the newly created OS Window.
--logo --logo
completion=type:file ext:png group:"PNG images" relative:conf completion=type:file ext:png group:"PNG images" relative:conf
Path to a PNG image to use as the logo for the newly created window. See Path to a PNG image to use as the logo for the newly created window. See
@ -324,6 +331,8 @@ def tab_for_window(boss: Boss, opts: LaunchCLIOptions, target_tab: Optional[Tab]
def create_tab(tm: Optional[TabManager] = None) -> Tab: def create_tab(tm: Optional[TabManager] = None) -> Tab:
if tm is None: if tm is None:
oswid = boss.add_os_window(wclass=opts.os_window_class, wname=opts.os_window_name, override_title=opts.os_window_title or None) oswid = boss.add_os_window(wclass=opts.os_window_class, wname=opts.os_window_name, override_title=opts.os_window_title or None)
if opts.os_window_state != 'normal':
change_os_window_state(opts.os_window_state, oswid)
tm = boss.os_window_map[oswid] tm = boss.os_window_map[oswid]
tab = tm.new_tab(empty_tab=True, location=opts.location) tab = tm.new_tab(empty_tab=True, location=opts.location)
if opts.tab_title: if opts.tab_title:
@ -595,7 +604,7 @@ def launch(
def clone_safe_opts() -> FrozenSet[str]: def clone_safe_opts() -> FrozenSet[str]:
return frozenset(( return frozenset((
'window_title', 'tab_title', 'type', 'keep_focus', 'cwd', 'env', 'hold', 'window_title', 'tab_title', 'type', 'keep_focus', 'cwd', 'env', 'hold',
'location', 'os_window_class', 'os_window_name', 'os_window_title', 'location', 'os_window_class', 'os_window_name', 'os_window_title', 'os_window_state',
'logo', 'logo_position', 'logo_alpha', 'color', 'spacing', 'logo', 'logo_position', 'logo_alpha', 'color', 'spacing',
)) ))

View File

@ -46,6 +46,7 @@ class Launch(RemoteCommand):
os_window_title/str: Title for OS Window os_window_title/str: Title for OS Window
os_window_name/str: WM_NAME for OS Window os_window_name/str: WM_NAME for OS Window
os_window_class/str: WM_CLASS for OS Window os_window_class/str: WM_CLASS for OS Window
os_window_state/choices.normal.fullscreen.maximized.minimized: The initial state for OS Window
color/list.str: list of color specifications such as foreground=red color/list.str: list of color specifications such as foreground=red
watcher/list.str: list of paths to watcher files watcher/list.str: list of paths to watcher files
''' '''