Skip to content

Commit

Permalink
monitors: kde add banner on vrr, don't remove clicked monitor when cl…
Browse files Browse the repository at this point in the history
…icked on nothing
  • Loading branch information
DashieTM committed Jun 13, 2024
1 parent 5680332 commit 8d3af2f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
6 changes: 3 additions & 3 deletions monitors/src/frontend/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use gtk::{
DrawingArea,
};

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

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

Expand Down Expand Up @@ -141,10 +141,10 @@ pub fn add_vrr_monitor_option(
Some(&glib::Variant::from(true)),
)
.expect("Could not activate reset action");
if is_hyprland() {
if is_hyprland() || is_kde() {
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." ))
Some(&glib::Variant::from("Note, VRR is a non reported feature and is therefore shown by default despite possible incompatibility. Additionally, VRR might require a reload or persistent saving instead of temporary application." ))
).expect("Could not show banner");
}
});
Expand Down
48 changes: 30 additions & 18 deletions monitors/src/frontend/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub fn get_monitor_settings_group(
for refresh_rate in refresh_rates.into_iter() {
let rate = refresh_rate.0.to_string() + "Hz";
if monitor.uses_mode_id && converted_rates.contains(&rate) {
// id users might see duplicate entries otherwise
// id users might see duplicate entries otherwise
continue;
}
converted_rates.push(rate);
Expand Down Expand Up @@ -798,25 +798,37 @@ pub fn monitor_drag_start(
drawing_area: &DrawingArea,
) {
let mut iter = -1;
for (index, monitor) in start_ref.borrow_mut().iter_mut().enumerate() {
let x = x as i32;
let y = y as i32;
if monitor.is_coordinate_within(x, y) {
if monitor.enabled {
monitor.drag_information.drag_active = true;
}
monitor.drag_information.clicked = true;
monitor.drag_information.origin_x = monitor.offset.0;
monitor.drag_information.origin_y = monitor.offset.1;
if let Some(child) = settings_box_ref.first_child() {
settings_box_ref.remove(&child);
let mut previous = -1;
{
let mut monitors = start_ref.borrow_mut();
for (index, monitor) in monitors.iter_mut().enumerate() {
let x = x as i32;
let y = y as i32;
if monitor.is_coordinate_within(x, y) {
if monitor.enabled {
monitor.drag_information.drag_active = true;
}
monitor.drag_information.clicked = true;
monitor.drag_information.origin_x = monitor.offset.0;
monitor.drag_information.origin_y = monitor.offset.1;
if let Some(child) = settings_box_ref.first_child() {
settings_box_ref.remove(&child);
}
iter = index as i32;
} else if monitor.drag_information.clicked {
previous = index as i32;
}
iter = index as i32;
break;
}
}
if iter == -1 {
return;
if iter == -1 {
return;
}
if previous != -1 {
monitors
.get_mut(previous as usize)
.unwrap()
.drag_information
.clicked = false;
}
}
settings_box_ref.append(&get_monitor_settings_group(
start_ref.clone(),
Expand Down
2 changes: 0 additions & 2 deletions monitors/src/frontend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ pub extern "C" fn frontend_data() -> (SidebarInfo, Vec<gtk::Box>) {
let y = y as i32;
if monitor.is_coordinate_within(x, y) {
monitor.drag_information.clicked = true;
} else if monitor.drag_information.clicked {
monitor.drag_information.clicked = false;
}
}
});
Expand Down
4 changes: 4 additions & 0 deletions monitors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ pub fn is_hyprland() -> bool {
ENV.contains(HYPRLAND)
}

pub fn is_kde() -> bool {
ENV.contains(KDE)
}

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

0 comments on commit 8d3af2f

Please sign in to comment.