Skip to content

Commit

Permalink
monitors: Remove vrr from Hyprland
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 11, 2024
1 parent 0ee3c4a commit 96d132e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
17 changes: 10 additions & 7 deletions monitors/src/backend/hyprland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use std::{
use super::wlr::{wlr_apply_monitor_configuration, wlr_get_monitor_information};

pub const HYPRFEATURES: MonitorFeatures = MonitorFeatures {
vrr: true,
// Hyprland supports vrr, but can't be changed on the fly -> reload required
vrr: false,
// Hyprland has no primary monitor concept
primary: false,
fractional_scaling: true,
Expand Down Expand Up @@ -121,12 +122,13 @@ pub fn hy_save_monitor_configuration(monitors: &Vec<Monitor>) {
let mut monitor_string = String::new();

for monitor in monitors {
let vrr = if monitor.vrr { 1 } else { 0 };
// re-enabled when switching is supported on the fly
// let vrr = if monitor.vrr { 1 } else { 0 };
if !monitor.enabled {
monitor_string += &format!("keyword monitor {},disabled;", monitor.name);
} else {
monitor_string += &format!(
"monitor={},{}x{}@{},{}x{},{:.6},transform,{},vrr,{}\n",
"monitor={},{}x{}@{},{}x{},{:.6},transform,{}\n",
monitor.name,
monitor.size.0,
monitor.size.1,
Expand All @@ -135,7 +137,7 @@ pub fn hy_save_monitor_configuration(monitors: &Vec<Monitor>) {
monitor.offset.1,
monitor.scale,
monitor.transform,
vrr
// vrr
);
}
}
Expand Down Expand Up @@ -207,12 +209,13 @@ fn monitor_to_configstring(monitors: &Vec<Monitor>) -> String {
let mut strings = Vec::new();

for monitor in monitors {
let vrr = if monitor.vrr { 1 } else { 0 };
// re-enabled when switching is supported on the fly
// let vrr = if monitor.vrr { 1 } else { 0 };
if !monitor.enabled {
strings.push(format!("keyword monitor {},disabled;", monitor.name));
} else {
strings.push(format!(
"keyword monitor {},{}x{}@{},{}x{},{:.6},transform,{},vrr,{};",
"keyword monitor {},{}x{}@{},{}x{},{:.6},transform,{};",
monitor.name,
&monitor.size.0,
&monitor.size.1,
Expand All @@ -221,7 +224,7 @@ fn monitor_to_configstring(monitors: &Vec<Monitor>) -> String {
&monitor.offset.1,
&monitor.scale,
&monitor.transform,
vrr
// vrr
));
}
}
Expand Down
37 changes: 19 additions & 18 deletions monitors/src/frontend/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ pub fn get_monitor_settings_group(
);

let model_list = StringList::new(&[
"0",
"90",
"180",
"270",
"0-flipped",
"90-flipped",
"180-flipped",
"270-flipped",
"0°",
"90°",
"180°",
"270°",
"0°-flipped",
"90°-flipped",
"180°-flipped",
"270°-flipped",
]);
let transform = adw::ComboRow::new();
transform.set_tooltip_markup(Some("Changes the orientation of the monitor"));
Expand All @@ -269,14 +269,14 @@ pub fn get_monitor_settings_group(
let monitor = monitors.get_mut(monitor_index).unwrap();
let original_monitor = monitor.clone();
match model_list.string(dropdown.selected()).unwrap().as_str() {
"0" => monitor.transform = 0,
"90" => monitor.transform = 1,
"180" => monitor.transform = 2,
"270" => monitor.transform = 3,
"0-flipped" => monitor.transform = 4,
"90-flipped" => monitor.transform = 5,
"180-flipped" => monitor.transform = 6,
"270-flipped" => monitor.transform = 7,
"0°" => monitor.transform = 0,
"90°" => monitor.transform = 1,
"180°" => monitor.transform = 2,
"270°" => monitor.transform = 3,
"0°-flipped" => monitor.transform = 4,
"90°-flipped" => monitor.transform = 5,
"180°-flipped" => monitor.transform = 6,
"270°-flipped" => monitor.transform = 7,
_ => ERROR!("Received unexpected transform", ErrorLevel::Recoverable),
};
rearrange_monitors(original_monitor, monitors);
Expand Down Expand Up @@ -338,7 +338,7 @@ pub fn get_monitor_settings_group(
rearrange_monitors(original_monitor, monitors);
}

let refresh_rates: Vec<String> = refresh_rates.iter().map(|x| x.0.to_string()).collect();
let refresh_rates: Vec<String> = refresh_rates.iter().map(|x| x.0.to_string() + "Hz").collect();
let refresh_rates: Vec<&str> = refresh_rates.iter().map(|x| x.as_str()).collect();
let refresh_rate_model = StringList::new(&refresh_rates);
refresh_rate_combo_ref.set_model(Some(&refresh_rate_model));
Expand Down Expand Up @@ -390,7 +390,7 @@ pub fn get_monitor_settings_group(
}
}

let refresh_rates: Vec<String> = refresh_rates.iter().map(|x| x.0.to_string()).collect();
let refresh_rates: Vec<String> = refresh_rates.iter().map(|x| x.0.to_string() + "Hz").collect();
let refresh_rates: Vec<&str> = refresh_rates.iter().map(|x| x.as_str()).collect();
let refresh_rate_model = StringList::new(&refresh_rates);
refresh_rate.set_model(Some(&refresh_rate_model));
Expand All @@ -407,6 +407,7 @@ pub fn get_monitor_settings_group(
.unwrap()
.string()
.to_string()
.trim_end_matches("Hz")
.parse()
.unwrap();
if monitor.uses_mode_id {
Expand Down

0 comments on commit 96d132e

Please sign in to comment.