Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Monitor dimensions functions to size functions #911

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ impl Iterator for AvailableMonitorsIter {
/// [monitor_get]: ../monitor/struct.MonitorHandle.html#method.video_modes
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct VideoMode {
pub(crate) dimensions: (u32, u32),
pub(crate) size: (u32, u32),
pub(crate) bit_depth: u16,
pub(crate) refresh_rate: u16,
}

impl VideoMode {
/// Returns the resolution of this video mode.
pub fn dimensions(&self) -> PhysicalSize {
self.dimensions.into()
pub fn size(&self) -> PhysicalSize {
self.size.into()
}

/// Returns the bit depth of this video mode, as in how many bits you have
Expand Down Expand Up @@ -104,8 +104,8 @@ impl MonitorHandle {

/// Returns the monitor's resolution.
#[inline]
pub fn dimensions(&self) -> PhysicalSize {
self.inner.dimensions()
pub fn size(&self) -> PhysicalSize {
self.inner.size()
}

/// Returns the top-left corner position of the monitor relative to the larger full
Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl EventLoop {
None
} else {
let dpi_factor = MonitorHandle.hidpi_factor();
let physical_size = MonitorHandle.dimensions();
let physical_size = MonitorHandle.size();
let size = LogicalSize::from_physical(physical_size, dpi_factor);
Some(Event::WindowEvent {
window_id: RootWindowId(WindowId),
Expand Down Expand Up @@ -207,7 +207,7 @@ impl fmt::Debug for MonitorHandle {

let monitor_id_proxy = MonitorHandle {
name: self.name(),
dimensions: self.dimensions(),
dimensions: self.size(),
position: self.outer_position(),
hidpi_factor: self.hidpi_factor(),
};
Expand All @@ -223,7 +223,7 @@ impl MonitorHandle {
}

#[inline]
pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
unsafe {
let window = android_glue::native_window();
(
Expand Down Expand Up @@ -325,7 +325,7 @@ impl Window {
None
} else {
let dpi_factor = self.hidpi_factor();
let physical_size = self.current_monitor().dimensions();
let physical_size = self.current_monitor().size();
Some(LogicalSize::from_physical(physical_size, dpi_factor))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl MonitorHandle {
}

#[inline]
pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
(0, 0).into()
}

Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/ios/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ impl fmt::Debug for MonitorHandle {
#[derive(Debug)]
struct MonitorHandle {
name: Option<String>,
dimensions: PhysicalSize,
size: PhysicalSize,
position: PhysicalPosition,
hidpi_factor: f64,
}

let monitor_id_proxy = MonitorHandle {
name: self.name(),
dimensions: self.dimensions(),
size: self.size(),
position: self.position(),
hidpi_factor: self.hidpi_factor(),
};
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Inner {
}
}

pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
unsafe {
let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds];
(bounds.size.width as f64, bounds.size.height as f64).into()
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Inner {
let mode: id = unsafe { msg_send![available_modes, objectAtIndex: i] };
let size: CGSize = unsafe { msg_send![mode, size] };
modes.insert(VideoMode {
dimensions: (size.width as u32, size.height as u32),
size: (size.width as u32, size.height as u32),
bit_depth: 32,
refresh_rate: refresh_rate as u16,
});
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ impl MonitorHandle {
}

#[inline]
pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
match self {
&MonitorHandle::X(ref m) => m.dimensions(),
&MonitorHandle::Wayland(ref m) => m.dimensions(),
&MonitorHandle::X(ref m) => m.size(),
&MonitorHandle::Wayland(ref m) => m.size(),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/linux/wayland/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ impl fmt::Debug for MonitorHandle {
struct MonitorHandle {
name: Option<String>,
native_identifier: u32,
dimensions: PhysicalSize,
size: PhysicalSize,
position: PhysicalPosition,
hidpi_factor: i32,
}

let monitor_id_proxy = MonitorHandle {
name: self.name(),
native_identifier: self.native_identifier(),
dimensions: self.dimensions(),
size: self.size(),
position: self.position(),
hidpi_factor: self.hidpi_factor(),
};
Expand All @@ -560,7 +560,7 @@ impl MonitorHandle {
self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0)
}

pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
match self.mgr.with_info(&self.proxy, |_, info| {
info.modes
.iter()
Expand Down Expand Up @@ -594,7 +594,7 @@ impl MonitorHandle {
.unwrap_or(vec![])
.into_iter()
.map(|x| VideoMode {
dimensions: (x.dimensions.0 as u32, x.dimensions.1 as u32),
size: (x.dimensions.0 as u32, x.dimensions.1 as u32),
refresh_rate: (x.refresh_rate as f32 / 1000.0).round() as u16,
bit_depth: 32
})
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/linux/x11/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl MonitorHandle {
primary: bool,
) -> Option<Self> {
let (name, hidpi_factor, video_modes) = unsafe { xconn.get_output_info(resources, &repr)? };
let (dimensions, position) = unsafe { (repr.dimensions(), repr.position()) };
let (dimensions, position) = unsafe { (repr.size(), repr.position()) };
let rect = util::AaRect::new(position, dimensions);
Some(MonitorHandle {
id,
Expand All @@ -93,7 +93,7 @@ impl MonitorHandle {
self.id as u32
}

pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
self.dimensions.into()
}

Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/linux/x11/util/randr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl MonitorRepr {
}
}

pub unsafe fn dimensions(&self) -> (u32, u32) {
pub unsafe fn size(&self) -> (u32, u32) {
match *self {
MonitorRepr::Monitor(monitor) => ((*monitor).width as u32, (*monitor).height as u32),
MonitorRepr::Crtc(crtc) => ((*crtc).width as u32, (*crtc).height as u32),
Expand Down Expand Up @@ -136,7 +136,7 @@ impl XConnection {
};

VideoMode {
dimensions: (x.width, x.height),
size: (x.width, x.height),
refresh_rate: (refresh_rate as f32 / 1000.0).round() as u16,
bit_depth: bit_depth as u16,
}
Expand All @@ -151,7 +151,7 @@ impl XConnection {
dpi / 96.
} else {
calc_dpi_factor(
repr.dimensions(),
repr.size(),
((*output_info).mm_width as u64, (*output_info).mm_height as u64),
)
};
Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/macos/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ impl fmt::Debug for MonitorHandle {
struct MonitorHandle {
name: Option<String>,
native_identifier: u32,
dimensions: PhysicalSize,
size: PhysicalSize,
position: PhysicalPosition,
hidpi_factor: f64,
}

let monitor_id_proxy = MonitorHandle {
name: self.name(),
native_identifier: self.native_identifier(),
dimensions: self.dimensions(),
size: self.size(),
position: self.position(),
hidpi_factor: self.hidpi_factor(),
};
Expand All @@ -74,7 +74,7 @@ impl MonitorHandle {
self.0
}

pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
let MonitorHandle(display_id) = *self;
let display = CGDisplay::new(display_id);
let height = display.pixels_high();
Expand Down Expand Up @@ -133,7 +133,7 @@ impl MonitorHandle {
};

VideoMode {
dimensions: (mode.width() as u32, mode.height() as u32),
size: (mode.width() as u32, mode.height() as u32),
refresh_rate: refresh_rate as u16,
bit_depth: mode.bit_depth() as u16,
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/windows/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl MonitorHandle {
}

#[inline]
pub fn dimensions(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize {
self.dimensions.into()
}

Expand Down Expand Up @@ -201,7 +201,7 @@ impl MonitorHandle {
assert!(mode.dmFields & REQUIRED_FIELDS == REQUIRED_FIELDS);

modes.insert(VideoMode {
dimensions: (mode.dmPelsWidth, mode.dmPelsHeight),
size: (mode.dmPelsWidth, mode.dmPelsHeight),
bit_depth: mode.dmBitsPerPel as u16,
refresh_rate: mode.dmDisplayFrequency as u16,
});
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ impl Window {
match &monitor {
&Some(RootMonitorHandle { ref inner }) => {
let (x, y): (i32, i32) = inner.position().into();
let (width, height): (u32, u32) = inner.dimensions().into();
let (width, height): (u32, u32) = inner.size().into();

let mut monitor = monitor.clone();
self.thread_executor.execute_in_thread(move || {
Expand Down
2 changes: 1 addition & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl WindowBuilder {
self.window.inner_size = Some(self.window.inner_size.unwrap_or_else(|| {
if let Some(ref monitor) = self.window.fullscreen {
// resizing the window to the dimensions of the monitor when fullscreen
LogicalSize::from_physical(monitor.dimensions(), 1.0)
LogicalSize::from_physical(monitor.size(), 1.0)
} else {
// default dimensions
(1024, 768).into()
Expand Down