Changed how borderless setting works.
This commit is contained in:
@@ -15,6 +15,7 @@ from .paths import AppPaths
|
||||
|
||||
|
||||
SETTINGS_SCHEMA = 1
|
||||
_TITLE_FRAME_DEFAULT_MIGRATION_KEY = "title_frame_default_migrated"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -26,7 +27,7 @@ class Settings:
|
||||
output_height: int = 900
|
||||
refresh_rate: int = 60
|
||||
fullscreen: bool = False
|
||||
borderless: bool = True
|
||||
borderless: bool = False
|
||||
suppress_unresponsive_warnings: bool = True
|
||||
scaler: str = "fit"
|
||||
filter: str = "linear"
|
||||
@@ -141,7 +142,7 @@ def _settings_from_object(value: dict[str, object]) -> Settings:
|
||||
output_height=_integer(value, "output_height", 900),
|
||||
refresh_rate=_integer(value, "refresh_rate", 60),
|
||||
fullscreen=_boolean(value, "fullscreen", False),
|
||||
borderless=_boolean(value, "borderless", True),
|
||||
borderless=_migrated_borderless(value),
|
||||
suppress_unresponsive_warnings=_boolean(
|
||||
value,
|
||||
"suppress_unresponsive_warnings",
|
||||
@@ -158,6 +159,22 @@ def _settings_from_object(value: dict[str, object]) -> Settings:
|
||||
return settings
|
||||
|
||||
|
||||
def _migrated_borderless(value: dict[str, object]) -> bool:
|
||||
"""Retire the old implicit borderless default exactly once.
|
||||
|
||||
Older releases wrote ``borderless=true`` for every default installation, so
|
||||
they cannot distinguish an inherited value from an explicit choice. The
|
||||
migration marker keeps schema 1 backward compatible while letting users opt
|
||||
back into Borderless after the decorated default has been applied.
|
||||
"""
|
||||
|
||||
borderless = _boolean(value, "borderless", False)
|
||||
migrated = _boolean(value, _TITLE_FRAME_DEFAULT_MIGRATION_KEY, False)
|
||||
if not migrated:
|
||||
return False
|
||||
return borderless
|
||||
|
||||
|
||||
def _decode_settings(content: bytes) -> str:
|
||||
"""Accept native UTF-8 plus settings saved by common Windows editors."""
|
||||
|
||||
@@ -174,6 +191,7 @@ def _settings_need_migration(value: dict[str, object]) -> bool:
|
||||
return (
|
||||
value.get("schema") != SETTINGS_SCHEMA
|
||||
or not _SETTINGS_FIELD_NAMES.issubset(value)
|
||||
or value.get(_TITLE_FRAME_DEFAULT_MIGRATION_KEY) is not True
|
||||
)
|
||||
|
||||
|
||||
@@ -185,6 +203,7 @@ def _write_settings(
|
||||
payload = dict(existing or {})
|
||||
payload.update(asdict(settings))
|
||||
payload["schema"] = SETTINGS_SCHEMA
|
||||
payload[_TITLE_FRAME_DEFAULT_MIGRATION_KEY] = True
|
||||
temporary = paths.settings_file.with_name(
|
||||
f".{paths.settings_file.name}.{os.getpid()}.{threading.get_ident()}."
|
||||
f"{secrets.token_hex(8)}.tmp"
|
||||
|
||||
Reference in New Issue
Block a user