Skip to content

Commit

Permalink
monitors: Re-enable VRR for hyprland with warning banner
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 11, 2024
1 parent 96d132e commit cbdc33d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
10 changes: 4 additions & 6 deletions monitors/src/backend/hyprland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use std::{
use super::wlr::{wlr_apply_monitor_configuration, wlr_get_monitor_information};

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

for monitor in monitors {
// re-enabled when switching is supported on the fly
// let vrr = if monitor.vrr { 1 } else { 0 };
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,{}\n",
"monitor={},{}x{}@{},{}x{},{:.6},transform,{},vrr,{}\n",
monitor.name,
monitor.size.0,
monitor.size.1,
Expand All @@ -137,7 +135,7 @@ pub fn hy_save_monitor_configuration(monitors: &Vec<Monitor>) {
monitor.offset.1,
monitor.scale,
monitor.transform,
// vrr
vrr
);
}
}
Expand Down
13 changes: 11 additions & 2 deletions monitors/src/frontend/general.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::{cell::RefCell, rc::Rc};

use adw::{prelude::{PreferencesGroupExt, PreferencesRowExt}, PreferencesGroup, SpinRow};
use adw::{
prelude::{PreferencesGroupExt, PreferencesRowExt},
PreferencesGroup, SpinRow,
};
use gtk::{
prelude::BoxExt,
prelude::{ButtonExt, WidgetExt},
DrawingArea,
};

use crate::utils::{get_environment, is_gnome, Monitor, GNOME, HYPRLAND};
use crate::utils::{get_environment, is_gnome, is_hyprland, Monitor, GNOME, HYPRLAND};

use super::handlers::{apply_monitor_clicked, rearrange_monitors, scaling_update};

Expand Down Expand Up @@ -138,6 +141,12 @@ pub fn add_vrr_monitor_option(
Some(&glib::Variant::from(true)),
)
.expect("Could not activate reset action");
if is_hyprland() {
state.activate_action(
"win.banner",
Some(&glib::Variant::from("Note, VRR only works with hyprland when saving and reloading the configuration. Temporary application of VRR will not work on Hyprland as of now." ))
).expect("Could not show banner");
}
});
settings.add(&vrr);
}
Expand Down
4 changes: 4 additions & 0 deletions monitors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ pub fn is_gnome() -> bool {
ENV.contains(GNOME)
}

pub fn is_hyprland() -> bool {
ENV.contains(HYPRLAND)
}

pub fn is_flatpak() -> bool {
ENV.contains("container")
}
Expand Down

0 comments on commit cbdc33d

Please sign in to comment.