fix: use concrete launcher resolution default

This commit is contained in:
objz committed 2026-09-04 22:16:35 +02:00
1 parent 033a8b144a
commit 78ea2f0f54
5 files changed
+28 -6

No files matched your search

+1 -1
View File
@@ -147,7 +147,7 @@ memory_max = "2G"
jvm_args = []
environment = {}
window_mode = "windowed"
# resolution = [1920, 1080]
resolution = [854, 480]
[ui]
image_protocol = "auto"
+1 -1
View File
@@ -19,7 +19,7 @@ jvm_args = []
environment = {}
# inherited by instances that use launcher window defaults
window_mode = "windowed"
# resolution = [1920, 1080] # omitted = Minecraft default
resolution = [854, 480]
[ui]
# image protocol: auto, halfblocks, quadrants, kitty, or iterm2
+11 -2
View File
@@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize};
use crate::instance::models::{WindowMode, memory_kib, normalize_memory_value};
pub const DEFAULT_RESOLUTION: (u32, u32) = (854, 480);
#[derive(Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ImageProtocol {
@@ -271,7 +273,7 @@ pub struct Defaults {
pub environment: BTreeMap<String, String>,
#[serde(default)]
pub window_mode: WindowMode,
#[serde(default)]
#[serde(default = "default_resolution")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resolution: Option<(u32, u32)>,
}
@@ -283,6 +285,10 @@ fn default_memory_max() -> String {
"2G".to_owned()
}
fn default_resolution() -> Option<(u32, u32)> {
Some(DEFAULT_RESOLUTION)
}
impl Default for Defaults {
fn default() -> Self {
Self {
@@ -291,7 +297,7 @@ impl Default for Defaults {
jvm_args: Vec::new(),
environment: BTreeMap::new(),
window_mode: WindowMode::default(),
resolution: None,
resolution: default_resolution(),
}
}
}
@@ -373,6 +379,9 @@ impl Config {
.memory_max
.clone_from(&self.defaults.memory_min);
}
if self.defaults.resolution.is_none() {
self.defaults.resolution = default_resolution();
}
self.ui.error_auto_dismiss_ms = self.ui.error_auto_dismiss_ms.max(1);
self.ui.error_slide_start_ms = self
.ui
+9
View File
@@ -68,6 +68,10 @@ fn bundled_config_uses_platform_paths_and_automatic_java() {
assert_eq!(config.paths.meta_dir, settings::Paths::default().meta_dir);
assert!(config.paths.java_path.is_none());
assert_eq!(config.ui.image_protocol, settings::ImageProtocol::Auto);
assert_eq!(
config.defaults.resolution,
Some(settings::DEFAULT_RESOLUTION)
);
}
#[test]
@@ -81,6 +85,7 @@ fn config_normalizes_memory_java_and_notification_bounds() {
defaults: settings::Defaults {
memory_min: "invalid".to_owned(),
memory_max: "1G".to_owned(),
resolution: None,
..Default::default()
},
ui: settings::Ui {
@@ -101,6 +106,10 @@ fn config_normalizes_memory_java_and_notification_bounds() {
assert!(config.paths.java_path.is_none());
assert_eq!(config.defaults.memory_min, "512M");
assert_eq!(config.defaults.memory_max, "1G");
assert_eq!(
config.defaults.resolution,
Some(settings::DEFAULT_RESOLUTION)
);
assert_eq!(config.ui.error_slide_start_ms, 100);
assert_eq!(config.ui.error_fly_out_ms, 100);
assert_eq!(config.ui.max_error_events, 1);
+6 -2
View File
@@ -16,7 +16,7 @@ use ratatui_textarea::TextArea;
use crate::{
config::{
Config,
settings::{ContentProvider, ImageProtocol},
settings::{ContentProvider, DEFAULT_RESOLUTION, ImageProtocol},
theme::{BORDER_STYLE, BorderStyle, THEME, ThemeConfig},
},
instance::models::{WindowMode, normalize_memory_value, parse_resolution},
@@ -166,7 +166,9 @@ impl State {
.unwrap_or_else(|| self.java_picker.detected_path()),
),
6 => window_mode_title(self.config.defaults.window_mode).to_owned(),
7 if self.config.defaults.resolution.is_none() => "game default".to_owned(),
7 if self.config.defaults.resolution.is_none() => {
format!("{}x{}", DEFAULT_RESOLUTION.0, DEFAULT_RESOLUTION.1)
}
16 if self.config.content.max_fingerprint_size_mib == 0 => "unlimited".to_owned(),
23 => "provider and Java metadata".to_owned(),
_ => self.value(field),
@@ -1346,6 +1348,8 @@ mod tests {
#[test]
fn launcher_resolution_reuses_display_and_preset_choices() {
let mut state = State::new();
state.config.defaults.resolution = None;
assert_eq!(state.display_value(7), "854x480");
state.display_resolutions = vec![DisplayResolution {
width: 2560,
height: 1440,