Make MonitorId::get_position() return (i32, i32) instead of (u32, u32) because it can be negative on Windows (#324)

This commit is contained in:
kryptan 2017-10-19 20:08:05 +03:00 committed by tomaka
parent 229029f2da
commit 4e4db1749d
12 changed files with 27 additions and 19 deletions

View file

@ -12,7 +12,7 @@ pub struct MonitorId {
/// The size of the monitor
dimensions: (u32, u32),
/// The position of the monitor in the X screen
position: (u32, u32),
position: (i32, i32),
/// If the monitor is the primary one
primary: bool,
}
@ -40,7 +40,7 @@ pub fn get_available_monitors(x: &Arc<XConnection>) -> Vec<MonitorId> {
id: i as u32,
name,
dimensions: (monitor.width as u32, monitor.height as u32),
position: (monitor.x as u32, monitor.y as u32),
position: (monitor.x as i32, monitor.y as i32),
primary: (monitor.primary != 0),
});
}
@ -61,7 +61,7 @@ pub fn get_available_monitors(x: &Arc<XConnection>) -> Vec<MonitorId> {
id: crtcid as u32,
name,
dimensions: ((*crtc).width as u32, (*crtc).height as u32),
position: ((*crtc).x as u32, (*crtc).y as u32),
position: ((*crtc).x as i32, (*crtc).y as i32),
primary: true,
});
}
@ -98,7 +98,7 @@ impl MonitorId {
self.dimensions
}
pub fn get_position(&self) -> (u32, u32) {
pub fn get_position(&self) -> (i32, i32) {
self.position
}

View file

@ -332,6 +332,8 @@ impl Window2 {
let mut find = default;
for monitor in monitors {
let (mx, my) = monitor.get_position();
let mx = mx as u32;
let my = my as u32;
let (mw, mh) = monitor.get_dimensions();
let (mxo, myo) = (mx+mw-1, my+mh-1);
let (ox, oy) = (cmp::max(wx, mx), cmp::max(wy, my));