Skip to content

Commit

Permalink
monitors: adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 6, 2024
1 parent 8166d9b commit 1a898cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
15 changes: 13 additions & 2 deletions monitors/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
backend::{
gnome::{gnome_features, GnomeLogicalMonitor, GnomeMonitor, GnomeMonitorConfig},
gnome::{gnome_features, GnomeLogicalMonitor, GnomeMode, GnomeMonitor, GnomeMonitorConfig},
hyprland::{HyprMonitor, HYPRFEATURES},
kde::{KDEMode, KDEMonitor, KDE_FEATURES},
},
Expand Down Expand Up @@ -56,7 +56,9 @@ fn convert_hyprmonitor() {

#[test]
fn convert_gnomemonitor() {
let gnome_mode = GnomeMode::default();
let gnome_monitor = GnomeMonitor {
modes: vec![gnome_mode],
..Default::default()
};
let logical_gnome_monitor = GnomeLogicalMonitor {
Expand All @@ -69,9 +71,18 @@ fn convert_gnomemonitor() {
};
let monitor = Monitor {
// hyprland has disabled instead -> invert
id: 600129007,
enabled: false,
mode: String::from("-1"),
size: Size(500, 500),
offset: Offset(-1050, 0),
scale: 1.0,
features: gnome_features(false),
available_modes: vec![AvailableMode {
id: "".into(),
size: Size(0, 0),
refresh_rates: vec![0],
supported_scales: vec![],
}],
..Default::default()
};
assert_eq!(
Expand Down
16 changes: 9 additions & 7 deletions monitors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ impl Monitor {

pub fn handle_scaled_transform(&self) -> (i32, i32) {
let (width, height) = self.handle_transform();
let (scaled_width, scaled_height) = (
(width as f64 / self.scale).round(),
(height as f64 / self.scale).round(),
);
let (scaled_width, scaled_height) = if self.scale <= 0.0 {
(width as f64, height as f64)
} else {
(
(width as f64 / self.scale).round(),
(height as f64 / self.scale).round(),
)
};
(scaled_width as i32, scaled_height as i32)
}
}
Expand Down Expand Up @@ -284,9 +288,7 @@ impl<'a> Get<'a> for Monitor {
impl Arg for Monitor {
const ARG_TYPE: arg::ArgType = ArgType::Struct;
fn signature() -> Signature<'static> {
unsafe {
Signature::from_slice_unchecked("(ub(ssss)(udu)bb(ii)(ii)sa(s(ii)auad)(bbbb))\0")
}
unsafe { Signature::from_slice_unchecked("(ub(ssss)(udu)bb(ii)(ii)sa(s(ii)auad)(bbbb))\0") }
}
}

Expand Down

0 comments on commit 1a898cc

Please sign in to comment.