feat: prefer highest refresh rate at native resolution
populate_modes() now selects the mode with the highest refresh rate at the preferred (native) resolution instead of blindly using the EDID PREFERRED flag. This ensures high-refresh panels (120 Hz, 144 Hz, …) are used out-of-the-box, including in the greeter session. Also fix libcosmic → libcosmic-yoda package reference.
This commit is contained in:
parent
d1849f639b
commit
7187efd58f
3 changed files with 18 additions and 7 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
|
@ -1009,7 +1009,7 @@ dependencies = [
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.0",
|
||||||
"jiff",
|
"jiff",
|
||||||
"keyframe",
|
"keyframe",
|
||||||
"libcosmic",
|
"libcosmic-yoda",
|
||||||
"libdisplay-info",
|
"libdisplay-info",
|
||||||
"libsystemd",
|
"libsystemd",
|
||||||
"log-panics",
|
"log-panics",
|
||||||
|
|
@ -1115,7 +1115,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-randr-shell"
|
name = "cosmic-randr-shell"
|
||||||
version = "0.1.0"
|
version = "1.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kdl",
|
"kdl",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
|
|
@ -3139,7 +3139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic-yoda"
|
||||||
version = "0.1.0-yoda.2"
|
version = "0.1.0-yoda.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ iced_tiny_skia = { path = "../libcosmic/iced/tiny_skia" }
|
||||||
iced_graphics = { path = "../libcosmic/iced/graphics", features = ["geometry"] }
|
iced_graphics = { path = "../libcosmic/iced/graphics", features = ["geometry"] }
|
||||||
indexmap = "2.13"
|
indexmap = "2.13"
|
||||||
keyframe = "1.1.1"
|
keyframe = "1.1.1"
|
||||||
cosmic = { package = "libcosmic", path = "../libcosmic", default-features = false, features = [
|
cosmic = { package = "libcosmic-yoda", path = "../libcosmic", default-features = false, features = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"wayland",
|
"wayland",
|
||||||
"multi-window",
|
"multi-window",
|
||||||
|
|
|
||||||
|
|
@ -1269,15 +1269,26 @@ fn populate_modes(
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let conn_info = drm.get_connector(conn, false)?;
|
let conn_info = drm.get_connector(conn, false)?;
|
||||||
let max_bpc = drm_helpers::get_max_bpc(drm, conn)?.map(|(_val, range)| range.end.min(16));
|
let max_bpc = drm_helpers::get_max_bpc(drm, conn)?.map(|(_val, range)| range.end.min(16));
|
||||||
let Some(mode) = conn_info
|
let preferred = conn_info
|
||||||
.modes()
|
.modes()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|mode| mode.mode_type().contains(ModeTypeFlags::PREFERRED))
|
.find(|mode| mode.mode_type().contains(ModeTypeFlags::PREFERRED))
|
||||||
.copied()
|
.copied()
|
||||||
.or(conn_info.modes().first().copied())
|
.or(conn_info.modes().first().copied());
|
||||||
else {
|
let Some(preferred) = preferred else {
|
||||||
anyhow::bail!("No mode found");
|
anyhow::bail!("No mode found");
|
||||||
};
|
};
|
||||||
|
// Prefer the highest refresh rate at the native resolution so that
|
||||||
|
// high-refresh panels (120 Hz, 144 Hz, …) are used out-of-the-box
|
||||||
|
// without a pre-existing outputs.ron config.
|
||||||
|
let preferred_size = preferred.size();
|
||||||
|
let mode = conn_info
|
||||||
|
.modes()
|
||||||
|
.iter()
|
||||||
|
.filter(|m| m.size() == preferred_size)
|
||||||
|
.max_by_key(|m| drm_helpers::calculate_refresh_rate(**m))
|
||||||
|
.copied()
|
||||||
|
.unwrap_or(preferred);
|
||||||
|
|
||||||
let refresh_rate = drm_helpers::calculate_refresh_rate(mode);
|
let refresh_rate = drm_helpers::calculate_refresh_rate(mode);
|
||||||
let output_mode = OutputMode {
|
let output_mode = OutputMode {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue