macOS: Display the newly created OS window in specified state

Fix the maximized window can't occupy full screen space when window
decoration or title bar is hidden.
Fix resize_in_steps being applied even when window is maximized.
Allows to specify `os_window_state` in startup session file.
This commit is contained in:
pagedown
2023-02-18 14:02:19 +08:00
parent 1b76cee9b4
commit ba83ce7b10
12 changed files with 109 additions and 33 deletions

View File

@@ -25,7 +25,7 @@ from .constants import (
shell_path,
ssh_control_master_template,
)
from .fast_data_types import Color, open_tty
from .fast_data_types import WINDOW_FULLSCREEN, WINDOW_MAXIMIZED, WINDOW_MINIMIZED, WINDOW_NORMAL, Color, open_tty
from .rgb import to_color
from .types import run_once
from .typing import AddressFamily, PopenType, Socket, StartupCtx
@@ -509,6 +509,18 @@ def parse_address_spec(spec: str) -> Tuple[AddressFamily, Union[Tuple[str, int],
return family, address, socket_path
def parse_os_window_state(state: str) -> int:
if state == 'normal':
return WINDOW_NORMAL
elif state in ('fullscreen', 'fullscreened'):
return WINDOW_FULLSCREEN
elif state == 'maximized':
return WINDOW_MAXIMIZED
elif state == 'minimized':
return WINDOW_MINIMIZED
raise ValueError(f'Unknown OS window state: {state}')
def write_all(fd: int, data: Union[str, bytes], block_until_written: bool = True) -> None:
if isinstance(data, str):
data = data.encode('utf-8')