mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Make size/position types generic over pixel type (#1277)
* Begin implementing DPI generics * Fix multithreaded example * Format * Fix serde test * hopefully fix most of the errors * Fix dpi module errors * More error fixings * Format * fix macos errors * Another error pass * Replace bad type signatures * more fixins
This commit is contained in:
parent
b16042a047
commit
3a1e694c2f
|
@ -12,7 +12,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const WINDOW_COUNT: usize = 3;
|
const WINDOW_COUNT: usize = 3;
|
||||||
const WINDOW_SIZE: PhysicalSize = PhysicalSize::new(600, 400);
|
const WINDOW_SIZE: PhysicalSize<u32> = PhysicalSize::new(600, 400);
|
||||||
|
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
|
@ -108,9 +108,9 @@ fn main() {
|
||||||
M => window.set_maximized(state),
|
M => window.set_maximized(state),
|
||||||
P => window.set_outer_position({
|
P => window.set_outer_position({
|
||||||
let mut position = window.outer_position().unwrap();
|
let mut position = window.outer_position().unwrap();
|
||||||
let sign = if state { 1.0 } else { -1.0 };
|
let sign = if state { 1 } else { -1 };
|
||||||
position.x += 10.0 * sign;
|
position.x += 10 * sign;
|
||||||
position.y += 10.0 * sign;
|
position.y += 10 * sign;
|
||||||
position
|
position
|
||||||
}),
|
}),
|
||||||
Q => window.request_redraw(),
|
Q => window.request_redraw(),
|
||||||
|
@ -126,10 +126,7 @@ fn main() {
|
||||||
if let Size::Physical(size) = WINDOW_SIZE.into() {
|
if let Size::Physical(size) = WINDOW_SIZE.into() {
|
||||||
window
|
window
|
||||||
.set_cursor_position(Position::Physical(
|
.set_cursor_position(Position::Physical(
|
||||||
PhysicalPosition::new(
|
PhysicalPosition::new(size.width / 2, size.height / 2),
|
||||||
size.width as f64 / 2.0,
|
|
||||||
size.height as f64 / 2.0,
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
324
src/dpi.rs
324
src/dpi.rs
|
@ -76,6 +76,54 @@
|
||||||
//! If you never received any [`HiDpiFactorChanged`](crate::event::WindowEvent::HiDpiFactorChanged) events,
|
//! If you never received any [`HiDpiFactorChanged`](crate::event::WindowEvent::HiDpiFactorChanged) events,
|
||||||
//! then your window's DPI factor is 1.
|
//! then your window's DPI factor is 1.
|
||||||
|
|
||||||
|
pub trait Pixel: Copy + Into<f64> {
|
||||||
|
fn from_f64(f: f64) -> Self;
|
||||||
|
fn cast<P: Pixel>(self) -> P {
|
||||||
|
P::from_f64(self.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pixel for u8 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for u16 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as u16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for u32 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as u32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for i8 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as i8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for i16 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as i16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for i32 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f.round() as i32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for f32 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f as f32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pixel for f64 {
|
||||||
|
fn from_f64(f: f64) -> Self {
|
||||||
|
f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks that the DPI factor is a normal positive `f64`.
|
/// Checks that the DPI factor is a normal positive `f64`.
|
||||||
///
|
///
|
||||||
/// All functions that take a DPI factor assert that this will return `true`. If you're sourcing DPI factors from
|
/// All functions that take a DPI factor assert that this will return `true`. If you're sourcing DPI factors from
|
||||||
|
@ -93,57 +141,53 @@ pub fn validate_hidpi_factor(dpi_factor: f64) -> bool {
|
||||||
/// does the rounding for you.
|
/// does the rounding for you.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LogicalPosition {
|
pub struct LogicalPosition<P> {
|
||||||
pub x: f64,
|
pub x: P,
|
||||||
pub y: f64,
|
pub y: P,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogicalPosition {
|
impl<P> LogicalPosition<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(x: f64, y: f64) -> Self {
|
pub const fn new(x: P, y: P) -> Self {
|
||||||
LogicalPosition { x, y }
|
LogicalPosition { x, y }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Pixel> LogicalPosition<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_physical<T: Into<PhysicalPosition>>(physical: T, dpi_factor: f64) -> Self {
|
pub fn from_physical<T: Into<PhysicalPosition<X>>, X: Pixel>(
|
||||||
|
physical: T,
|
||||||
|
dpi_factor: f64,
|
||||||
|
) -> Self {
|
||||||
physical.into().to_logical(dpi_factor)
|
physical.into().to_logical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_physical(&self, dpi_factor: f64) -> PhysicalPosition {
|
pub fn to_physical<X: Pixel>(&self, dpi_factor: f64) -> PhysicalPosition<X> {
|
||||||
assert!(validate_hidpi_factor(dpi_factor));
|
assert!(validate_hidpi_factor(dpi_factor));
|
||||||
let x = self.x * dpi_factor;
|
let x = self.x.into() * dpi_factor;
|
||||||
let y = self.y * dpi_factor;
|
let y = self.y.into() * dpi_factor;
|
||||||
PhysicalPosition::new(x, y)
|
PhysicalPosition::new(x, y).cast()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn cast<X: Pixel>(&self) -> LogicalPosition<X> {
|
||||||
|
LogicalPosition {
|
||||||
|
x: self.x.cast(),
|
||||||
|
y: self.y.cast(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(f64, f64)> for LogicalPosition {
|
impl<P: Pixel, X: Pixel> From<(X, X)> for LogicalPosition<P> {
|
||||||
#[inline]
|
fn from((x, y): (X, X)) -> LogicalPosition<P> {
|
||||||
fn from((x, y): (f64, f64)) -> Self {
|
LogicalPosition::new(x.cast(), y.cast())
|
||||||
Self::new(x, y)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(i32, i32)> for LogicalPosition {
|
impl<P: Pixel, X: Pixel> Into<(X, X)> for LogicalPosition<P> {
|
||||||
#[inline]
|
fn into(self: Self) -> (X, X) {
|
||||||
fn from((x, y): (i32, i32)) -> Self {
|
(self.x.cast(), self.y.cast())
|
||||||
Self::new(x as f64, y as f64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(f64, f64)> for LogicalPosition {
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (f64, f64) {
|
|
||||||
(self.x, self.y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(i32, i32)> for LogicalPosition {
|
|
||||||
/// Note that this rounds instead of truncating.
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (i32, i32) {
|
|
||||||
(self.x.round() as _, self.y.round() as _)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,57 +198,53 @@ impl Into<(i32, i32)> for LogicalPosition {
|
||||||
/// does the rounding for you.
|
/// does the rounding for you.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PhysicalPosition {
|
pub struct PhysicalPosition<P> {
|
||||||
pub x: f64,
|
pub x: P,
|
||||||
pub y: f64,
|
pub y: P,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PhysicalPosition {
|
impl<P> PhysicalPosition<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(x: f64, y: f64) -> Self {
|
pub const fn new(x: P, y: P) -> Self {
|
||||||
PhysicalPosition { x, y }
|
PhysicalPosition { x, y }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Pixel> PhysicalPosition<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_logical<T: Into<LogicalPosition>>(logical: T, dpi_factor: f64) -> Self {
|
pub fn from_logical<T: Into<LogicalPosition<X>>, X: Pixel>(
|
||||||
|
logical: T,
|
||||||
|
dpi_factor: f64,
|
||||||
|
) -> Self {
|
||||||
logical.into().to_physical(dpi_factor)
|
logical.into().to_physical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_logical(&self, dpi_factor: f64) -> LogicalPosition {
|
pub fn to_logical<X: Pixel>(&self, dpi_factor: f64) -> LogicalPosition<X> {
|
||||||
assert!(validate_hidpi_factor(dpi_factor));
|
assert!(validate_hidpi_factor(dpi_factor));
|
||||||
let x = self.x / dpi_factor;
|
let x = self.x.into() / dpi_factor;
|
||||||
let y = self.y / dpi_factor;
|
let y = self.y.into() / dpi_factor;
|
||||||
LogicalPosition::new(x, y)
|
LogicalPosition::new(x, y).cast()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn cast<X: Pixel>(&self) -> PhysicalPosition<X> {
|
||||||
|
PhysicalPosition {
|
||||||
|
x: self.x.cast(),
|
||||||
|
y: self.y.cast(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(f64, f64)> for PhysicalPosition {
|
impl<P: Pixel, X: Pixel> From<(X, X)> for PhysicalPosition<P> {
|
||||||
#[inline]
|
fn from((x, y): (X, X)) -> PhysicalPosition<P> {
|
||||||
fn from((x, y): (f64, f64)) -> Self {
|
PhysicalPosition::new(x.cast(), y.cast())
|
||||||
Self::new(x, y)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(i32, i32)> for PhysicalPosition {
|
impl<P: Pixel, X: Pixel> Into<(X, X)> for PhysicalPosition<P> {
|
||||||
#[inline]
|
fn into(self: Self) -> (X, X) {
|
||||||
fn from((x, y): (i32, i32)) -> Self {
|
(self.x.cast(), self.y.cast())
|
||||||
Self::new(x as f64, y as f64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(f64, f64)> for PhysicalPosition {
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (f64, f64) {
|
|
||||||
(self.x, self.y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(i32, i32)> for PhysicalPosition {
|
|
||||||
/// Note that this rounds instead of truncating.
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (i32, i32) {
|
|
||||||
(self.x.round() as _, self.y.round() as _)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,108 +255,108 @@ impl Into<(i32, i32)> for PhysicalPosition {
|
||||||
/// does the rounding for you.
|
/// does the rounding for you.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LogicalSize {
|
pub struct LogicalSize<P> {
|
||||||
pub width: f64,
|
pub width: P,
|
||||||
pub height: f64,
|
pub height: P,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogicalSize {
|
impl<P> LogicalSize<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(width: f64, height: f64) -> Self {
|
pub const fn new(width: P, height: P) -> Self {
|
||||||
LogicalSize { width, height }
|
LogicalSize { width, height }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Pixel> LogicalSize<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_physical<T: Into<PhysicalSize>>(physical: T, dpi_factor: f64) -> Self {
|
pub fn from_physical<T: Into<PhysicalSize<X>>, X: Pixel>(physical: T, dpi_factor: f64) -> Self {
|
||||||
physical.into().to_logical(dpi_factor)
|
physical.into().to_logical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_physical(&self, dpi_factor: f64) -> PhysicalSize {
|
pub fn to_physical<X: Pixel>(&self, dpi_factor: f64) -> PhysicalSize<X> {
|
||||||
assert!(validate_hidpi_factor(dpi_factor));
|
assert!(validate_hidpi_factor(dpi_factor));
|
||||||
let width = self.width * dpi_factor;
|
let width = self.width.into() * dpi_factor;
|
||||||
let height = self.height * dpi_factor;
|
let height = self.height.into() * dpi_factor;
|
||||||
PhysicalSize::new(width.round() as _, height.round() as _)
|
PhysicalSize::new(width, height).cast()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn cast<X: Pixel>(&self) -> LogicalSize<X> {
|
||||||
|
LogicalSize {
|
||||||
|
width: self.width.cast(),
|
||||||
|
height: self.height.cast(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(f64, f64)> for LogicalSize {
|
impl<P: Pixel, X: Pixel> From<(X, X)> for LogicalSize<P> {
|
||||||
#[inline]
|
fn from((x, y): (X, X)) -> LogicalSize<P> {
|
||||||
fn from((width, height): (f64, f64)) -> Self {
|
LogicalSize::new(x.cast(), y.cast())
|
||||||
Self::new(width, height)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(u32, u32)> for LogicalSize {
|
impl<P: Pixel, X: Pixel> Into<(X, X)> for LogicalSize<P> {
|
||||||
#[inline]
|
fn into(self: LogicalSize<P>) -> (X, X) {
|
||||||
fn from((width, height): (u32, u32)) -> Self {
|
(self.width.cast(), self.height.cast())
|
||||||
Self::new(width as f64, height as f64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(f64, f64)> for LogicalSize {
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (f64, f64) {
|
|
||||||
(self.width, self.height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Into<(u32, u32)> for LogicalSize {
|
|
||||||
/// Note that this rounds instead of truncating.
|
|
||||||
#[inline]
|
|
||||||
fn into(self) -> (u32, u32) {
|
|
||||||
(self.width.round() as _, self.height.round() as _)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A size represented in physical pixels.
|
/// A size represented in physical pixels.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PhysicalSize {
|
pub struct PhysicalSize<P> {
|
||||||
pub width: u32,
|
pub width: P,
|
||||||
pub height: u32,
|
pub height: P,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PhysicalSize {
|
impl<P> PhysicalSize<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(width: u32, height: u32) -> Self {
|
pub const fn new(width: P, height: P) -> Self {
|
||||||
PhysicalSize { width, height }
|
PhysicalSize { width, height }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Pixel> PhysicalSize<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_logical<T: Into<LogicalSize>>(logical: T, dpi_factor: f64) -> Self {
|
pub fn from_logical<T: Into<LogicalSize<X>>, X: Pixel>(logical: T, dpi_factor: f64) -> Self {
|
||||||
logical.into().to_physical(dpi_factor)
|
logical.into().to_physical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_logical(&self, dpi_factor: f64) -> LogicalSize {
|
pub fn to_logical<X: Pixel>(&self, dpi_factor: f64) -> LogicalSize<X> {
|
||||||
assert!(validate_hidpi_factor(dpi_factor));
|
assert!(validate_hidpi_factor(dpi_factor));
|
||||||
let width = self.width as f64 / dpi_factor;
|
let width = self.width.into() / dpi_factor;
|
||||||
let height = self.height as f64 / dpi_factor;
|
let height = self.height.into() / dpi_factor;
|
||||||
LogicalSize::new(width, height)
|
LogicalSize::new(width, height).cast()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn cast<X: Pixel>(&self) -> PhysicalSize<X> {
|
||||||
|
PhysicalSize {
|
||||||
|
width: self.width.cast(),
|
||||||
|
height: self.height.cast(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(u32, u32)> for PhysicalSize {
|
impl<P: Pixel, X: Pixel> From<(X, X)> for PhysicalSize<P> {
|
||||||
#[inline]
|
fn from((x, y): (X, X)) -> PhysicalSize<P> {
|
||||||
fn from((width, height): (u32, u32)) -> Self {
|
PhysicalSize::new(x.cast(), y.cast())
|
||||||
Self::new(width, height)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<(u32, u32)> for PhysicalSize {
|
impl<P: Pixel, X: Pixel> Into<(X, X)> for PhysicalSize<P> {
|
||||||
/// Note that this rounds instead of truncating.
|
fn into(self: Self) -> (X, X) {
|
||||||
#[inline]
|
(self.width.cast(), self.height.cast())
|
||||||
fn into(self) -> (u32, u32) {
|
|
||||||
(self.width, self.height)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub enum Size {
|
pub enum Size {
|
||||||
Physical(PhysicalSize),
|
Physical(PhysicalSize<u32>),
|
||||||
Logical(LogicalSize),
|
Logical(LogicalSize<f64>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Size {
|
impl Size {
|
||||||
|
@ -324,40 +364,40 @@ impl Size {
|
||||||
size.into()
|
size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_logical(&self, dpi_factor: f64) -> LogicalSize {
|
pub fn to_logical<P: Pixel>(&self, dpi_factor: f64) -> LogicalSize<P> {
|
||||||
match *self {
|
match *self {
|
||||||
Size::Physical(size) => size.to_logical(dpi_factor),
|
Size::Physical(size) => size.to_logical(dpi_factor),
|
||||||
Size::Logical(size) => size,
|
Size::Logical(size) => size.cast(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_physical(&self, dpi_factor: f64) -> PhysicalSize {
|
pub fn to_physical<P: Pixel>(&self, dpi_factor: f64) -> PhysicalSize<P> {
|
||||||
match *self {
|
match *self {
|
||||||
Size::Physical(size) => size,
|
Size::Physical(size) => size.cast(),
|
||||||
Size::Logical(size) => size.to_physical(dpi_factor),
|
Size::Logical(size) => size.to_physical(dpi_factor),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PhysicalSize> for Size {
|
impl<P: Pixel> From<PhysicalSize<P>> for Size {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(size: PhysicalSize) -> Size {
|
fn from(size: PhysicalSize<P>) -> Size {
|
||||||
Size::Physical(size)
|
Size::Physical(size.cast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<LogicalSize> for Size {
|
impl<P: Pixel> From<LogicalSize<P>> for Size {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(size: LogicalSize) -> Size {
|
fn from(size: LogicalSize<P>) -> Size {
|
||||||
Size::Logical(size)
|
Size::Logical(size.cast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub enum Position {
|
pub enum Position {
|
||||||
Physical(PhysicalPosition),
|
Physical(PhysicalPosition<u32>),
|
||||||
Logical(LogicalPosition),
|
Logical(LogicalPosition<f64>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Position {
|
impl Position {
|
||||||
|
@ -365,31 +405,31 @@ impl Position {
|
||||||
position.into()
|
position.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_logical(&self, dpi_factor: f64) -> LogicalPosition {
|
pub fn to_logical<P: Pixel>(&self, dpi_factor: f64) -> LogicalPosition<P> {
|
||||||
match *self {
|
match *self {
|
||||||
Position::Physical(position) => position.to_logical(dpi_factor),
|
Position::Physical(position) => position.to_logical(dpi_factor),
|
||||||
Position::Logical(position) => position,
|
Position::Logical(position) => position.cast(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_physical(&self, dpi_factor: f64) -> PhysicalPosition {
|
pub fn to_physical<P: Pixel>(&self, dpi_factor: f64) -> PhysicalPosition<P> {
|
||||||
match *self {
|
match *self {
|
||||||
Position::Physical(position) => position,
|
Position::Physical(position) => position.cast(),
|
||||||
Position::Logical(position) => position.to_physical(dpi_factor),
|
Position::Logical(position) => position.to_physical(dpi_factor),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PhysicalPosition> for Position {
|
impl<P: Pixel> From<PhysicalPosition<P>> for Position {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(position: PhysicalPosition) -> Position {
|
fn from(position: PhysicalPosition<P>) -> Position {
|
||||||
Position::Physical(position)
|
Position::Physical(position.cast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<LogicalPosition> for Position {
|
impl<P: Pixel> From<LogicalPosition<P>> for Position {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(position: LogicalPosition) -> Position {
|
fn from(position: LogicalPosition<P>) -> Position {
|
||||||
Position::Logical(position)
|
Position::Logical(position.cast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/event.rs
12
src/event.rs
|
@ -182,10 +182,10 @@ pub enum StartCause {
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum WindowEvent<'a> {
|
pub enum WindowEvent<'a> {
|
||||||
/// The size of the window has changed. Contains the client area's new dimensions.
|
/// The size of the window has changed. Contains the client area's new dimensions.
|
||||||
Resized(PhysicalSize),
|
Resized(PhysicalSize<u32>),
|
||||||
|
|
||||||
/// The position of the window has changed. Contains the window's new position.
|
/// The position of the window has changed. Contains the window's new position.
|
||||||
Moved(PhysicalPosition),
|
Moved(PhysicalPosition<u32>),
|
||||||
|
|
||||||
/// The window has been requested to close.
|
/// The window has been requested to close.
|
||||||
CloseRequested,
|
CloseRequested,
|
||||||
|
@ -242,7 +242,7 @@ pub enum WindowEvent<'a> {
|
||||||
/// (x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is
|
/// (x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is
|
||||||
/// limited by the display area and it may have been transformed by the OS to implement effects such as cursor
|
/// limited by the display area and it may have been transformed by the OS to implement effects such as cursor
|
||||||
/// acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control.
|
/// acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control.
|
||||||
position: PhysicalPosition,
|
position: PhysicalPosition<i32>,
|
||||||
#[deprecated = "Deprecated in favor of DeviceEvent::ModifiersChanged"]
|
#[deprecated = "Deprecated in favor of DeviceEvent::ModifiersChanged"]
|
||||||
modifiers: ModifiersState,
|
modifiers: ModifiersState,
|
||||||
},
|
},
|
||||||
|
@ -308,7 +308,7 @@ pub enum WindowEvent<'a> {
|
||||||
/// For more information about DPI in general, see the [`dpi`](dpi/index.html) module.
|
/// For more information about DPI in general, see the [`dpi`](dpi/index.html) module.
|
||||||
HiDpiFactorChanged {
|
HiDpiFactorChanged {
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
new_inner_size: &'a mut Option<PhysicalSize>,
|
new_inner_size: &'a mut Option<PhysicalSize<u32>>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// The system window theme has changed.
|
/// The system window theme has changed.
|
||||||
|
@ -534,7 +534,7 @@ pub enum TouchPhase {
|
||||||
pub struct Touch {
|
pub struct Touch {
|
||||||
pub device_id: DeviceId,
|
pub device_id: DeviceId,
|
||||||
pub phase: TouchPhase,
|
pub phase: TouchPhase,
|
||||||
pub location: PhysicalPosition,
|
pub location: PhysicalPosition<f64>,
|
||||||
/// Describes how hard the screen was pressed. May be `None` if the platform
|
/// Describes how hard the screen was pressed. May be `None` if the platform
|
||||||
/// does not support pressure sensitivity.
|
/// does not support pressure sensitivity.
|
||||||
///
|
///
|
||||||
|
@ -645,7 +645,7 @@ pub enum MouseScrollDelta {
|
||||||
/// Scroll events are expressed as a PixelDelta if
|
/// Scroll events are expressed as a PixelDelta if
|
||||||
/// supported by the device (eg. a touchpad) and
|
/// supported by the device (eg. a touchpad) and
|
||||||
/// platform.
|
/// platform.
|
||||||
PixelDelta(LogicalPosition),
|
PixelDelta(LogicalPosition<f64>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Symbolic name for a keyboard key.
|
/// Symbolic name for a keyboard key.
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl Ord for VideoMode {
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
/// Returns the resolution of this video mode.
|
/// Returns the resolution of this video mode.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.video_mode.size()
|
self.video_mode.size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ impl MonitorHandle {
|
||||||
///
|
///
|
||||||
/// - **Web:** Always returns (0,0)
|
/// - **Web:** Always returns (0,0)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.inner.size()
|
self.inner.size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ impl MonitorHandle {
|
||||||
///
|
///
|
||||||
/// - **Web:** Always returns (0,0)
|
/// - **Web:** Always returns (0,0)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
self.inner.position()
|
self.inner.position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ pub trait WindowBuilderExtMacOS {
|
||||||
/// Makes the window content appear behind the titlebar.
|
/// Makes the window content appear behind the titlebar.
|
||||||
fn with_fullsize_content_view(self, fullsize_content_view: bool) -> WindowBuilder;
|
fn with_fullsize_content_view(self, fullsize_content_view: bool) -> WindowBuilder;
|
||||||
/// Build window with `resizeIncrements` property. Values must not be 0.
|
/// Build window with `resizeIncrements` property. Values must not be 0.
|
||||||
fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder;
|
fn with_resize_increments(self, increments: LogicalSize<f64>) -> WindowBuilder;
|
||||||
fn with_disallow_hidpi(self, disallow_hidpi: bool) -> WindowBuilder;
|
fn with_disallow_hidpi(self, disallow_hidpi: bool) -> WindowBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ impl WindowBuilderExtMacOS for WindowBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn with_resize_increments(mut self, increments: LogicalSize) -> WindowBuilder {
|
fn with_resize_increments(mut self, increments: LogicalSize<f64>) -> WindowBuilder {
|
||||||
self.platform_specific.resize_increments = Some(increments.into());
|
self.platform_specific.resize_increments = Some(increments.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,9 +380,9 @@ pub trait WindowBuilderExtUnix {
|
||||||
/// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11.
|
/// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11.
|
||||||
fn with_gtk_theme_variant(self, variant: String) -> Self;
|
fn with_gtk_theme_variant(self, variant: String) -> Self;
|
||||||
/// Build window with resize increment hint. Only implemented on X11.
|
/// Build window with resize increment hint. Only implemented on X11.
|
||||||
fn with_resize_increments(self, increments: LogicalSize) -> Self;
|
fn with_resize_increments(self, increments: LogicalSize<f64>) -> Self;
|
||||||
/// Build window with base size hint. Only implemented on X11.
|
/// Build window with base size hint. Only implemented on X11.
|
||||||
fn with_base_size(self, base_size: LogicalSize) -> Self;
|
fn with_base_size(self, base_size: LogicalSize<f64>) -> Self;
|
||||||
|
|
||||||
/// Build window with a given application ID. It should match the `.desktop` file distributed with
|
/// Build window with a given application ID. It should match the `.desktop` file distributed with
|
||||||
/// your program. Only relevant on Wayland.
|
/// your program. Only relevant on Wayland.
|
||||||
|
@ -431,13 +431,13 @@ impl WindowBuilderExtUnix for WindowBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn with_resize_increments(mut self, increments: LogicalSize) -> Self {
|
fn with_resize_increments(mut self, increments: LogicalSize<f64>) -> Self {
|
||||||
self.platform_specific.resize_increments = Some(increments.into());
|
self.platform_specific.resize_increments = Some(increments.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn with_base_size(mut self, base_size: LogicalSize) -> Self {
|
fn with_base_size(mut self, base_size: LogicalSize<f64>) -> Self {
|
||||||
self.platform_specific.base_size = Some(base_size.into());
|
self.platform_specific.base_size = Some(base_size.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,8 @@ impl fmt::Debug for MonitorHandle {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
dimensions: PhysicalSize,
|
dimensions: PhysicalSize<u32>,
|
||||||
position: PhysicalPosition,
|
position: PhysicalPosition<i32>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let window = android_glue::native_window();
|
let window = android_glue::native_window();
|
||||||
(
|
(
|
||||||
|
@ -228,7 +228,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> PhysicalPosition {
|
pub fn outer_position(&self) -> PhysicalPosition<i32> {
|
||||||
// Android assumes single screen
|
// Android assumes single screen
|
||||||
(0, 0).into()
|
(0, 0).into()
|
||||||
}
|
}
|
||||||
|
@ -283,29 +283,29 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Option<LogicalPosition> {
|
pub fn outer_position(&self) -> Option<LogicalPosition<f64>> {
|
||||||
// N/A
|
// N/A
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Option<LogicalPosition> {
|
pub fn inner_position(&self) -> Option<LogicalPosition<f64>> {
|
||||||
// N/A
|
// N/A
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_outer_position(&self, _position: LogicalPosition) {
|
pub fn set_outer_position(&self, _position: LogicalPosition<f64>) {
|
||||||
// N/A
|
// N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_min_inner_size(&self, _dimensions: Option<LogicalSize>) {
|
pub fn set_min_inner_size(&self, _dimensions: Option<LogicalSize<f64>>) {
|
||||||
// N/A
|
// N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_max_inner_size(&self, _dimensions: Option<LogicalSize>) {
|
pub fn set_max_inner_size(&self, _dimensions: Option<LogicalSize<f64>>) {
|
||||||
// N/A
|
// N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> Option<LogicalSize> {
|
pub fn inner_size(&self) -> Option<LogicalSize<f64>> {
|
||||||
if self.native_window.is_null() {
|
if self.native_window.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -326,12 +326,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> Option<LogicalSize> {
|
pub fn outer_size(&self) -> Option<LogicalSize<f64>> {
|
||||||
self.inner_size()
|
self.inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_inner_size(&self, _size: LogicalSize) {
|
pub fn set_inner_size(&self, _size: LogicalSize<f64>) {
|
||||||
// N/A
|
// N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,10 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(
|
||||||
|
&self,
|
||||||
|
_position: LogicalPosition<f64>,
|
||||||
|
) -> Result<(), ExternalError> {
|
||||||
Err(ExternalError::NotSupported(NotSupportedError::new()))
|
Err(ExternalError::NotSupported(NotSupportedError::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +403,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_ime_position(&self, _spot: LogicalPosition) {
|
pub fn set_ime_position(&self, _spot: LogicalPosition<f64>) {
|
||||||
// N/A
|
// N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -806,7 +806,9 @@ pub unsafe fn handle_main_events_cleared() {
|
||||||
let mut redraw_events: Vec<Event<Never>> = this
|
let mut redraw_events: Vec<Event<Never>> = this
|
||||||
.main_events_cleared_transition()
|
.main_events_cleared_transition()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|window| EventWrapper::StaticEvent(Event::RedrawRequested(RootWindowId(window.into()))))
|
.map(|window| {
|
||||||
|
EventWrapper::StaticEvent(Event::RedrawRequested(RootWindowId(window.into())))
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !redraw_events.is_empty() {
|
if !redraw_events.is_empty() {
|
||||||
|
@ -855,7 +857,7 @@ fn handle_event_proxy(
|
||||||
fn handle_hidpi_proxy(
|
fn handle_hidpi_proxy(
|
||||||
event_handler: &mut Box<dyn EventHandler>,
|
event_handler: &mut Box<dyn EventHandler>,
|
||||||
mut control_flow: ControlFlow,
|
mut control_flow: ControlFlow,
|
||||||
suggested_size: LogicalSize,
|
suggested_size: LogicalSize<f64>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
window_id: id,
|
window_id: id,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub enum EventWrapper {
|
||||||
pub enum EventProxy {
|
pub enum EventProxy {
|
||||||
HiDpiFactorChangedProxy {
|
HiDpiFactorChangedProxy {
|
||||||
window_id: id,
|
window_id: id,
|
||||||
suggested_size: LogicalSize,
|
suggested_size: LogicalSize<f64>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub struct CGSize {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CGSize {
|
impl CGSize {
|
||||||
pub fn new(size: LogicalSize) -> CGSize {
|
pub fn new(size: LogicalSize<f64>) -> CGSize {
|
||||||
CGSize {
|
CGSize {
|
||||||
width: size.width as _,
|
width: size.width as _,
|
||||||
height: size.height as _,
|
height: size.height as _,
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl VideoMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.size.into()
|
self.size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +171,8 @@ impl fmt::Debug for MonitorHandle {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
size: PhysicalSize,
|
size: PhysicalSize<u32>,
|
||||||
position: PhysicalPosition,
|
position: PhysicalPosition<i32>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,14 +216,14 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds];
|
let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds];
|
||||||
PhysicalSize::new(bounds.size.width as u32, bounds.size.height as u32)
|
PhysicalSize::new(bounds.size.width as u32, bounds.size.height as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds];
|
let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds];
|
||||||
(bounds.origin.x as f64, bounds.origin.y as f64).into()
|
(bounds.origin.x as f64, bounds.origin.y as f64).into()
|
||||||
|
|
|
@ -103,8 +103,12 @@ unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
let window: id = msg_send![object, window];
|
let window: id = msg_send![object, window];
|
||||||
assert!(!window.is_null());
|
assert!(!window.is_null());
|
||||||
app_state::handle_nonuser_events(
|
app_state::handle_nonuser_events(
|
||||||
std::iter::once(EventWrapper::StaticEvent(Event::RedrawRequested(RootWindowId(window.into()))))
|
std::iter::once(EventWrapper::StaticEvent(Event::RedrawRequested(
|
||||||
.chain(std::iter::once(EventWrapper::StaticEvent(Event::RedrawEventsCleared))),
|
RootWindowId(window.into()),
|
||||||
|
)))
|
||||||
|
.chain(std::iter::once(EventWrapper::StaticEvent(
|
||||||
|
Event::RedrawEventsCleared,
|
||||||
|
))),
|
||||||
);
|
);
|
||||||
let superclass: &'static Class = msg_send![object, superclass];
|
let superclass: &'static Class = msg_send![object, superclass];
|
||||||
let () = msg_send![super(object, superclass), drawRect: rect];
|
let () = msg_send![super(object, superclass), drawRect: rect];
|
||||||
|
@ -125,8 +129,8 @@ unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
msg_send![object, convertRect:bounds toCoordinateSpace:screen_space];
|
msg_send![object, convertRect:bounds toCoordinateSpace:screen_space];
|
||||||
let dpi_factor: CGFloat = msg_send![screen, scale];
|
let dpi_factor: CGFloat = msg_send![screen, scale];
|
||||||
let size = crate::dpi::LogicalSize {
|
let size = crate::dpi::LogicalSize {
|
||||||
width: screen_frame.size.width as _,
|
width: screen_frame.size.width as f64,
|
||||||
height: screen_frame.size.height as _,
|
height: screen_frame.size.height as f64,
|
||||||
}
|
}
|
||||||
.to_physical(dpi_factor.into());
|
.to_physical(dpi_factor.into());
|
||||||
app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::WindowEvent {
|
app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::WindowEvent {
|
||||||
|
@ -508,7 +512,9 @@ pub unsafe fn create_window(
|
||||||
let () = msg_send![uiscreen, setCurrentMode: video_mode.video_mode.screen_mode.0];
|
let () = msg_send![uiscreen, setCurrentMode: video_mode.video_mode.screen_mode.0];
|
||||||
msg_send![window, setScreen:video_mode.monitor().ui_screen()]
|
msg_send![window, setScreen:video_mode.monitor().ui_screen()]
|
||||||
}
|
}
|
||||||
Some(Fullscreen::Borderless(ref monitor)) => msg_send![window, setScreen:monitor.ui_screen()],
|
Some(Fullscreen::Borderless(ref monitor)) => {
|
||||||
|
msg_send![window, setScreen:monitor.ui_screen()]
|
||||||
|
}
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,24 +76,24 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let safe_area = self.safe_area_screen_space();
|
let safe_area = self.safe_area_screen_space();
|
||||||
let position = LogicalPosition {
|
let position = LogicalPosition {
|
||||||
x: safe_area.origin.x as _,
|
x: safe_area.origin.x as f64,
|
||||||
y: safe_area.origin.y as _,
|
y: safe_area.origin.y as f64,
|
||||||
};
|
};
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
Ok(position.to_physical(dpi_factor))
|
Ok(position.to_physical(dpi_factor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let screen_frame = self.screen_frame();
|
let screen_frame = self.screen_frame();
|
||||||
let position = LogicalPosition {
|
let position = LogicalPosition {
|
||||||
x: screen_frame.origin.x as _,
|
x: screen_frame.origin.x as f64,
|
||||||
y: screen_frame.origin.y as _,
|
y: screen_frame.origin.y as f64,
|
||||||
};
|
};
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
Ok(position.to_physical(dpi_factor))
|
Ok(position.to_physical(dpi_factor))
|
||||||
|
@ -103,7 +103,7 @@ impl Inner {
|
||||||
pub fn set_outer_position(&self, physical_position: Position) {
|
pub fn set_outer_position(&self, physical_position: Position) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let position = physical_position.to_logical(dpi_factor);
|
let position = physical_position.to_logical::<f64>(dpi_factor);
|
||||||
let screen_frame = self.screen_frame();
|
let screen_frame = self.screen_frame();
|
||||||
let new_screen_frame = CGRect {
|
let new_screen_frame = CGRect {
|
||||||
origin: CGPoint {
|
origin: CGPoint {
|
||||||
|
@ -117,25 +117,25 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let safe_area = self.safe_area_screen_space();
|
let safe_area = self.safe_area_screen_space();
|
||||||
let size = LogicalSize {
|
let size = LogicalSize {
|
||||||
width: safe_area.size.width as _,
|
width: safe_area.size.width as f64,
|
||||||
height: safe_area.size.height as _,
|
height: safe_area.size.height as f64,
|
||||||
};
|
};
|
||||||
size.to_physical(dpi_factor)
|
size.to_physical(dpi_factor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let screen_frame = self.screen_frame();
|
let screen_frame = self.screen_frame();
|
||||||
let size = LogicalSize {
|
let size = LogicalSize {
|
||||||
width: screen_frame.size.width as _,
|
width: screen_frame.size.width as f64,
|
||||||
height: screen_frame.size.height as _,
|
height: screen_frame.size.height as f64,
|
||||||
};
|
};
|
||||||
size.to_physical(dpi_factor)
|
size.to_physical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ impl Window {
|
||||||
let frame = match window_attributes.inner_size {
|
let frame = match window_attributes.inner_size {
|
||||||
Some(dim) => {
|
Some(dim) => {
|
||||||
let dpi_factor = msg_send![screen, scale];
|
let dpi_factor = msg_send![screen, scale];
|
||||||
let size = dim.to_logical(dpi_factor);
|
let size = dim.to_logical::<f64>(dpi_factor);
|
||||||
CGRect {
|
CGRect {
|
||||||
origin: screen_bounds.origin,
|
origin: screen_bounds.origin,
|
||||||
size: CGSize {
|
size: CGSize {
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
match self {
|
match self {
|
||||||
&MonitorHandle::X(ref m) => m.size(),
|
&MonitorHandle::X(ref m) => m.size(),
|
||||||
&MonitorHandle::Wayland(ref m) => m.size(),
|
&MonitorHandle::Wayland(ref m) => m.size(),
|
||||||
|
@ -140,7 +140,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
match self {
|
match self {
|
||||||
&MonitorHandle::X(ref m) => m.position(),
|
&MonitorHandle::X(ref m) => m.position(),
|
||||||
&MonitorHandle::Wayland(ref m) => m.position(),
|
&MonitorHandle::Wayland(ref m) => m.position(),
|
||||||
|
@ -172,7 +172,7 @@ pub enum VideoMode {
|
||||||
|
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
match self {
|
match self {
|
||||||
&VideoMode::X(ref m) => m.size(),
|
&VideoMode::X(ref m) => m.size(),
|
||||||
&VideoMode::Wayland(ref m) => m.size(),
|
&VideoMode::Wayland(ref m) => m.size(),
|
||||||
|
@ -246,7 +246,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.outer_position(),
|
&Window::X(ref w) => w.outer_position(),
|
||||||
&Window::Wayland(ref w) => w.outer_position(),
|
&Window::Wayland(ref w) => w.outer_position(),
|
||||||
|
@ -254,7 +254,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref m) => m.inner_position(),
|
&Window::X(ref m) => m.inner_position(),
|
||||||
&Window::Wayland(ref m) => m.inner_position(),
|
&Window::Wayland(ref m) => m.inner_position(),
|
||||||
|
@ -270,7 +270,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.inner_size(),
|
&Window::X(ref w) => w.inner_size(),
|
||||||
&Window::Wayland(ref w) => w.inner_size(),
|
&Window::Wayland(ref w) => w.inner_size(),
|
||||||
|
@ -278,7 +278,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.outer_size(),
|
&Window::X(ref w) => w.outer_size(),
|
||||||
&Window::Wayland(ref w) => w.outer_size(),
|
&Window::Wayland(ref w) => w.outer_size(),
|
||||||
|
|
|
@ -729,7 +729,7 @@ impl<T> EventLoop<T> {
|
||||||
|
|
||||||
if let Some(dpi) = window.new_dpi {
|
if let Some(dpi) = window.new_dpi {
|
||||||
let dpi = dpi as f64;
|
let dpi = dpi as f64;
|
||||||
let logical_size = LogicalSize::from(*window.size);
|
let logical_size = LogicalSize::<f64>::from(*window.size);
|
||||||
let mut new_inner_size = Some(logical_size.to_physical(dpi));
|
let mut new_inner_size = Some(logical_size.to_physical(dpi));
|
||||||
|
|
||||||
callback(Event::WindowEvent {
|
callback(Event::WindowEvent {
|
||||||
|
@ -741,7 +741,7 @@ impl<T> EventLoop<T> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(new_size) = new_inner_size {
|
if let Some(new_size) = new_inner_size {
|
||||||
let (w, h) = new_size.to_logical(dpi).into();
|
let (w, h) = new_size.to_logical::<u32>(dpi).into();
|
||||||
frame.resize(w, h);
|
frame.resize(w, h);
|
||||||
*window.size = (w, h);
|
*window.size = (w, h);
|
||||||
}
|
}
|
||||||
|
@ -947,7 +947,7 @@ pub struct VideoMode {
|
||||||
|
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.size.into()
|
self.size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,8 +1007,8 @@ impl fmt::Debug for MonitorHandle {
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
native_identifier: u32,
|
native_identifier: u32,
|
||||||
size: PhysicalSize,
|
size: PhysicalSize<u32>,
|
||||||
position: PhysicalPosition,
|
position: PhysicalPosition<i32>,
|
||||||
hidpi_factor: i32,
|
hidpi_factor: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@ impl MonitorHandle {
|
||||||
self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0)
|
self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
match self.mgr.with_info(&self.proxy, |_, info| {
|
match self.mgr.with_info(&self.proxy, |_, info| {
|
||||||
info.modes
|
info.modes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1049,7 +1049,7 @@ impl MonitorHandle {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
self.mgr
|
self.mgr
|
||||||
.with_info(&self.proxy, |_, info| info.location)
|
.with_info(&self.proxy, |_, info| info.location)
|
||||||
.unwrap_or((0, 0))
|
.unwrap_or((0, 0))
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl Window {
|
||||||
let dpi = get_dpi_factor(&surface) as f64;
|
let dpi = get_dpi_factor(&surface) as f64;
|
||||||
let (width, height) = attributes
|
let (width, height) = attributes
|
||||||
.inner_size
|
.inner_size
|
||||||
.map(|size| size.to_logical(dpi).into())
|
.map(|size| size.to_logical::<f64>(dpi).into())
|
||||||
.unwrap_or((800, 600));
|
.unwrap_or((800, 600));
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
|
@ -147,12 +147,12 @@ impl Window {
|
||||||
frame.set_min_size(
|
frame.set_min_size(
|
||||||
attributes
|
attributes
|
||||||
.min_inner_size
|
.min_inner_size
|
||||||
.map(|size| size.to_logical(dpi).into()),
|
.map(|size| size.to_logical::<f64>(dpi).into()),
|
||||||
);
|
);
|
||||||
frame.set_max_size(
|
frame.set_max_size(
|
||||||
attributes
|
attributes
|
||||||
.max_inner_size
|
.max_inner_size
|
||||||
.map(|size| size.to_logical(dpi).into()),
|
.map(|size| size.to_logical::<f64>(dpi).into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let kill_switch = Arc::new(Mutex::new(false));
|
let kill_switch = Arc::new(Mutex::new(false));
|
||||||
|
@ -206,12 +206,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
Err(NotSupportedError::new())
|
Err(NotSupportedError::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
Err(NotSupportedError::new())
|
Err(NotSupportedError::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,9 +220,9 @@ impl Window {
|
||||||
// Not possible with wayland
|
// Not possible with wayland
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
let dpi = self.hidpi_factor() as f64;
|
let dpi = self.hidpi_factor() as f64;
|
||||||
let size = LogicalSize::from(*self.size.lock().unwrap());
|
let size = LogicalSize::<f64>::from(*self.size.lock().unwrap());
|
||||||
size.to_physical(dpi)
|
size.to_physical(dpi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,11 +231,11 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
let dpi = self.hidpi_factor() as f64;
|
let dpi = self.hidpi_factor() as f64;
|
||||||
let (w, h) = self.size.lock().unwrap().clone();
|
let (w, h) = self.size.lock().unwrap().clone();
|
||||||
// let (w, h) = super::wayland_window::add_borders(w as i32, h as i32);
|
// let (w, h) = super::wayland_window::add_borders(w as i32, h as i32);
|
||||||
let size = LogicalSize::from((w, h));
|
let size = LogicalSize::<f64>::from((w, h));
|
||||||
size.to_physical(dpi)
|
size.to_physical(dpi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ impl Window {
|
||||||
// NOTE: This will only resize the borders, the contents must be updated by the user
|
// NOTE: This will only resize the borders, the contents must be updated by the user
|
||||||
pub fn set_inner_size(&self, size: Size) {
|
pub fn set_inner_size(&self, size: Size) {
|
||||||
let dpi = self.hidpi_factor() as f64;
|
let dpi = self.hidpi_factor() as f64;
|
||||||
let (w, h) = size.to_logical(dpi).into();
|
let (w, h) = size.to_logical::<u32>(dpi).into();
|
||||||
self.frame.lock().unwrap().resize(w, h);
|
self.frame.lock().unwrap().resize(w, h);
|
||||||
*(self.size.lock().unwrap()) = (w, h);
|
*(self.size.lock().unwrap()) = (w, h);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ impl Window {
|
||||||
self.frame
|
self.frame
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_min_size(dimensions.map(|dim| dim.to_logical(dpi).into()));
|
.set_min_size(dimensions.map(|dim| dim.to_logical::<f64>(dpi).into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -263,7 +263,7 @@ impl Window {
|
||||||
self.frame
|
self.frame
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_max_size(dimensions.map(|dim| dim.to_logical(dpi).into()));
|
.set_max_size(dimensions.map(|dim| dim.to_logical::<f64>(dpi).into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -707,7 +707,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
});
|
});
|
||||||
if cursor_moved == Some(true) {
|
if cursor_moved == Some(true) {
|
||||||
let position =
|
let position =
|
||||||
PhysicalPosition::new(xev.event_x as f64, xev.event_y as f64);
|
PhysicalPosition::new(xev.event_x as i32, xev.event_y as i32);
|
||||||
|
|
||||||
callback(Event::WindowEvent {
|
callback(Event::WindowEvent {
|
||||||
window_id,
|
window_id,
|
||||||
|
@ -814,7 +814,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
});
|
});
|
||||||
|
|
||||||
let position =
|
let position =
|
||||||
PhysicalPosition::new(xev.event_x as f64, xev.event_y as f64);
|
PhysicalPosition::new(xev.event_x as i32, xev.event_y as i32);
|
||||||
|
|
||||||
// The mods field on this event isn't actually populated, so query the
|
// The mods field on this event isn't actually populated, so query the
|
||||||
// pointer device. In the future, we can likely remove this round-trip by
|
// pointer device. In the future, we can likely remove this round-trip by
|
||||||
|
@ -883,7 +883,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
.unwrap_or(2);
|
.unwrap_or(2);
|
||||||
|
|
||||||
let position =
|
let position =
|
||||||
PhysicalPosition::new(xev.event_x as f64, xev.event_y as f64);
|
PhysicalPosition::new(xev.event_x as i32, xev.event_y as i32);
|
||||||
|
|
||||||
callback(Event::WindowEvent {
|
callback(Event::WindowEvent {
|
||||||
window_id,
|
window_id,
|
||||||
|
@ -941,7 +941,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
window_id,
|
window_id,
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
device_id: mkdid(util::VIRTUAL_CORE_POINTER),
|
device_id: mkdid(util::VIRTUAL_CORE_POINTER),
|
||||||
position: location,
|
position: location.cast(),
|
||||||
modifiers,
|
modifiers,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct VideoMode {
|
||||||
|
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.size.into()
|
self.size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,11 +157,11 @@ impl MonitorHandle {
|
||||||
self.id as u32
|
self.id as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.dimensions.into()
|
self.dimensions.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
self.position.into()
|
self.position.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,9 +137,9 @@ impl FrameExtentsHeuristic {
|
||||||
|
|
||||||
pub fn inner_pos_to_outer_logical(
|
pub fn inner_pos_to_outer_logical(
|
||||||
&self,
|
&self,
|
||||||
mut logical: LogicalPosition,
|
mut logical: LogicalPosition<f64>,
|
||||||
factor: f64,
|
factor: f64,
|
||||||
) -> LogicalPosition {
|
) -> LogicalPosition<f64> {
|
||||||
use self::FrameExtentsHeuristicPath::*;
|
use self::FrameExtentsHeuristicPath::*;
|
||||||
if self.heuristic_path != UnsupportedBordered {
|
if self.heuristic_path != UnsupportedBordered {
|
||||||
let frame_extents = self.frame_extents.as_logical(factor);
|
let frame_extents = self.frame_extents.as_logical(factor);
|
||||||
|
@ -166,9 +166,9 @@ impl FrameExtentsHeuristic {
|
||||||
|
|
||||||
pub fn inner_size_to_outer_logical(
|
pub fn inner_size_to_outer_logical(
|
||||||
&self,
|
&self,
|
||||||
mut logical: LogicalSize,
|
mut logical: LogicalSize<f64>,
|
||||||
factor: f64,
|
factor: f64,
|
||||||
) -> LogicalSize {
|
) -> LogicalSize<f64> {
|
||||||
let frame_extents = self.frame_extents.as_logical(factor);
|
let frame_extents = self.frame_extents.as_logical(factor);
|
||||||
logical.width += frame_extents.left + frame_extents.right;
|
logical.width += frame_extents.left + frame_extents.right;
|
||||||
logical.height += frame_extents.top + frame_extents.bottom;
|
logical.height += frame_extents.top + frame_extents.bottom;
|
||||||
|
|
|
@ -138,17 +138,17 @@ impl UnownedWindow {
|
||||||
|
|
||||||
let max_inner_size: Option<(u32, u32)> = window_attrs
|
let max_inner_size: Option<(u32, u32)> = window_attrs
|
||||||
.max_inner_size
|
.max_inner_size
|
||||||
.map(|size| size.to_physical(dpi_factor).into());
|
.map(|size| size.to_physical::<u32>(dpi_factor).into());
|
||||||
let min_inner_size: Option<(u32, u32)> = window_attrs
|
let min_inner_size: Option<(u32, u32)> = window_attrs
|
||||||
.min_inner_size
|
.min_inner_size
|
||||||
.map(|size| size.to_physical(dpi_factor).into());
|
.map(|size| size.to_physical::<u32>(dpi_factor).into());
|
||||||
|
|
||||||
let dimensions = {
|
let dimensions = {
|
||||||
// x11 only applies constraints when the window is actively resized
|
// x11 only applies constraints when the window is actively resized
|
||||||
// by the user, so we have to manually apply the initial constraints
|
// by the user, so we have to manually apply the initial constraints
|
||||||
let mut dimensions: (u32, u32) = window_attrs
|
let mut dimensions: (u32, u32) = window_attrs
|
||||||
.inner_size
|
.inner_size
|
||||||
.map(|size| size.to_physical(dpi_factor))
|
.map(|size| size.to_physical::<u32>(dpi_factor))
|
||||||
.or_else(|| Some((800, 600).into()))
|
.or_else(|| Some((800, 600).into()))
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -320,10 +320,10 @@ impl UnownedWindow {
|
||||||
{
|
{
|
||||||
let mut min_inner_size = window_attrs
|
let mut min_inner_size = window_attrs
|
||||||
.min_inner_size
|
.min_inner_size
|
||||||
.map(|size| size.to_physical(dpi_factor));
|
.map(|size| size.to_physical::<u32>(dpi_factor));
|
||||||
let mut max_inner_size = window_attrs
|
let mut max_inner_size = window_attrs
|
||||||
.max_inner_size
|
.max_inner_size
|
||||||
.map(|size| size.to_physical(dpi_factor));
|
.map(|size| size.to_physical::<u32>(dpi_factor));
|
||||||
if !window_attrs.resizable {
|
if !window_attrs.resizable {
|
||||||
if util::wm_name_is_one_of(&["Xfwm4"]) {
|
if util::wm_name_is_one_of(&["Xfwm4"]) {
|
||||||
warn!("To avoid a WM bug, disabling resizing has no effect on Xfwm4");
|
warn!("To avoid a WM bug, disabling resizing has no effect on Xfwm4");
|
||||||
|
@ -941,7 +941,7 @@ impl UnownedWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
let extents = (*self.shared_state.lock()).frame_extents.clone();
|
let extents = (*self.shared_state.lock()).frame_extents.clone();
|
||||||
if let Some(extents) = extents {
|
if let Some(extents) = extents {
|
||||||
let (x, y) = self.inner_position_physical();
|
let (x, y) = self.inner_position_physical();
|
||||||
|
@ -962,7 +962,7 @@ impl UnownedWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
Ok(self.inner_position_physical().into())
|
Ok(self.inner_position_physical().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,7 +993,7 @@ impl UnownedWindow {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_outer_position(&self, position: Position) {
|
pub fn set_outer_position(&self, position: Position) {
|
||||||
let (x, y) = position.to_physical(self.hidpi_factor()).into();
|
let (x, y) = position.to_physical::<i32>(self.hidpi_factor()).into();
|
||||||
self.set_position_physical(x, y);
|
self.set_position_physical(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,12 +1007,12 @@ impl UnownedWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
self.inner_size_physical().into()
|
self.inner_size_physical().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
let extents = self.shared_state.lock().frame_extents.clone();
|
let extents = self.shared_state.lock().frame_extents.clone();
|
||||||
if let Some(extents) = extents {
|
if let Some(extents) = extents {
|
||||||
let (width, height) = self.inner_size_physical();
|
let (width, height) = self.inner_size_physical();
|
||||||
|
@ -1039,7 +1039,7 @@ impl UnownedWindow {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_inner_size(&self, size: Size) {
|
pub fn set_inner_size(&self, size: Size) {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let (width, height) = size.to_physical(dpi_factor).into();
|
let (width, height) = size.to_physical::<u32>(dpi_factor).into();
|
||||||
self.set_inner_size_physical(width, height);
|
self.set_inner_size_physical(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1063,7 @@ impl UnownedWindow {
|
||||||
pub fn set_min_inner_size(&self, dimensions: Option<Size>) {
|
pub fn set_min_inner_size(&self, dimensions: Option<Size>) {
|
||||||
self.shared_state.lock().min_inner_size = dimensions;
|
self.shared_state.lock().min_inner_size = dimensions;
|
||||||
let physical_dimensions =
|
let physical_dimensions =
|
||||||
dimensions.map(|dimensions| dimensions.to_physical(self.hidpi_factor()).into());
|
dimensions.map(|dimensions| dimensions.to_physical::<u32>(self.hidpi_factor()).into());
|
||||||
self.set_min_inner_size_physical(physical_dimensions);
|
self.set_min_inner_size_physical(physical_dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,7 +1076,7 @@ impl UnownedWindow {
|
||||||
pub fn set_max_inner_size(&self, dimensions: Option<Size>) {
|
pub fn set_max_inner_size(&self, dimensions: Option<Size>) {
|
||||||
self.shared_state.lock().max_inner_size = dimensions;
|
self.shared_state.lock().max_inner_size = dimensions;
|
||||||
let physical_dimensions =
|
let physical_dimensions =
|
||||||
dimensions.map(|dimensions| dimensions.to_physical(self.hidpi_factor()).into());
|
dimensions.map(|dimensions| dimensions.to_physical::<u32>(self.hidpi_factor()).into());
|
||||||
self.set_max_inner_size_physical(physical_dimensions);
|
self.set_max_inner_size_physical(physical_dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,10 +1135,10 @@ impl UnownedWindow {
|
||||||
|
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let min_inner_size = min_size
|
let min_inner_size = min_size
|
||||||
.map(|size| size.to_physical(dpi_factor))
|
.map(|size| size.to_physical::<u32>(dpi_factor))
|
||||||
.map(Into::into);
|
.map(Into::into);
|
||||||
let max_inner_size = max_size
|
let max_inner_size = max_size
|
||||||
.map(|size| size.to_physical(dpi_factor))
|
.map(|size| size.to_physical::<u32>(dpi_factor))
|
||||||
.map(Into::into);
|
.map(Into::into);
|
||||||
self.update_normal_hints(|normal_hints| {
|
self.update_normal_hints(|normal_hints| {
|
||||||
normal_hints.set_min_size(min_inner_size);
|
normal_hints.set_min_size(min_inner_size);
|
||||||
|
@ -1274,7 +1274,7 @@ impl UnownedWindow {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, position: Position) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(&self, position: Position) -> Result<(), ExternalError> {
|
||||||
let (x, y) = position.to_physical(self.hidpi_factor()).into();
|
let (x, y) = position.to_physical::<i32>(self.hidpi_factor()).into();
|
||||||
self.set_cursor_position_physical(x, y)
|
self.set_cursor_position_physical(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,7 +1287,7 @@ impl UnownedWindow {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_ime_position(&self, spot: Position) {
|
pub fn set_ime_position(&self, spot: Position) {
|
||||||
let (x, y) = spot.to_physical(self.hidpi_factor()).into();
|
let (x, y) = spot.to_physical::<i32>(self.hidpi_factor()).into();
|
||||||
self.set_ime_position_physical(x, y);
|
self.set_ime_position_physical(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ impl Handler {
|
||||||
&self,
|
&self,
|
||||||
callback: &mut Box<dyn EventHandler + 'static>,
|
callback: &mut Box<dyn EventHandler + 'static>,
|
||||||
ns_window: IdRef,
|
ns_window: IdRef,
|
||||||
suggested_size: LogicalSize,
|
suggested_size: LogicalSize<f64>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
) {
|
) {
|
||||||
let size = suggested_size.to_physical(hidpi_factor);
|
let size = suggested_size.to_physical(hidpi_factor);
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub enum EventWrapper {
|
||||||
pub enum EventProxy {
|
pub enum EventProxy {
|
||||||
HiDpiFactorChangedProxy {
|
HiDpiFactorChangedProxy {
|
||||||
ns_window: IdRef,
|
ns_window: IdRef,
|
||||||
suggested_size: LogicalSize,
|
suggested_size: LogicalSize<f64>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl Clone for NativeDisplayMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.size.into()
|
self.size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ impl fmt::Debug for MonitorHandle {
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
native_identifier: u32,
|
native_identifier: u32,
|
||||||
size: PhysicalSize,
|
size: PhysicalSize<u32>,
|
||||||
position: PhysicalPosition,
|
position: PhysicalPosition<i32>,
|
||||||
hidpi_factor: f64,
|
hidpi_factor: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,18 +199,18 @@ impl MonitorHandle {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
let MonitorHandle(display_id) = *self;
|
let MonitorHandle(display_id) = *self;
|
||||||
let display = CGDisplay::new(display_id);
|
let display = CGDisplay::new(display_id);
|
||||||
let height = display.pixels_high();
|
let height = display.pixels_high();
|
||||||
let width = display.pixels_wide();
|
let width = display.pixels_wide();
|
||||||
PhysicalSize::from_logical((width as f64, height as f64), self.hidpi_factor())
|
PhysicalSize::from_logical::<_, f64>((width as f64, height as f64), self.hidpi_factor())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
let bounds = unsafe { CGDisplayBounds(self.native_identifier()) };
|
let bounds = unsafe { CGDisplayBounds(self.native_identifier()) };
|
||||||
PhysicalPosition::from_logical(
|
PhysicalPosition::from_logical::<_, f64>(
|
||||||
(bounds.origin.x as f64, bounds.origin.y as f64),
|
(bounds.origin.x as f64, bounds.origin.y as f64),
|
||||||
self.hidpi_factor(),
|
self.hidpi_factor(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -73,10 +73,10 @@ pub unsafe fn set_style_mask_sync(ns_window: id, ns_view: id, mask: NSWindowStyl
|
||||||
|
|
||||||
struct SetContentSizeData {
|
struct SetContentSizeData {
|
||||||
ns_window: id,
|
ns_window: id,
|
||||||
size: LogicalSize,
|
size: LogicalSize<f64>,
|
||||||
}
|
}
|
||||||
impl SetContentSizeData {
|
impl SetContentSizeData {
|
||||||
fn new_ptr(ns_window: id, size: LogicalSize) -> *mut Self {
|
fn new_ptr(ns_window: id, size: LogicalSize<f64>) -> *mut Self {
|
||||||
Box::into_raw(Box::new(SetContentSizeData { ns_window, size }))
|
Box::into_raw(Box::new(SetContentSizeData { ns_window, size }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ extern "C" fn set_content_size_callback(context: *mut c_void) {
|
||||||
}
|
}
|
||||||
// `setContentSize:` isn't thread-safe either, though it doesn't log any errors
|
// `setContentSize:` isn't thread-safe either, though it doesn't log any errors
|
||||||
// and just fails silently. Anyway, GCD to the rescue!
|
// and just fails silently. Anyway, GCD to the rescue!
|
||||||
pub unsafe fn set_content_size_async(ns_window: id, size: LogicalSize) {
|
pub unsafe fn set_content_size_async(ns_window: id, size: LogicalSize<f64>) {
|
||||||
let context = SetContentSizeData::new_ptr(ns_window, size);
|
let context = SetContentSizeData::new_ptr(ns_window, size);
|
||||||
dispatch_async_f(
|
dispatch_async_f(
|
||||||
dispatch_get_main_queue(),
|
dispatch_get_main_queue(),
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
||||||
pub titlebar_hidden: bool,
|
pub titlebar_hidden: bool,
|
||||||
pub titlebar_buttons_hidden: bool,
|
pub titlebar_buttons_hidden: bool,
|
||||||
pub fullsize_content_view: bool,
|
pub fullsize_content_view: bool,
|
||||||
pub resize_increments: Option<LogicalSize>,
|
pub resize_increments: Option<LogicalSize<f64>>,
|
||||||
pub disallow_hidpi: bool,
|
pub disallow_hidpi: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ pub struct UnownedWindow {
|
||||||
pub shared_state: Arc<Mutex<SharedState>>,
|
pub shared_state: Arc<Mutex<SharedState>>,
|
||||||
decorations: AtomicBool,
|
decorations: AtomicBool,
|
||||||
cursor_state: Weak<Mutex<CursorState>>,
|
cursor_state: Weak<Mutex<CursorState>>,
|
||||||
pub inner_rect: Option<PhysicalSize>,
|
pub inner_rect: Option<PhysicalSize<u32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for UnownedWindow {}
|
unsafe impl Send for UnownedWindow {}
|
||||||
|
@ -440,7 +440,7 @@ impl UnownedWindow {
|
||||||
AppState::queue_redraw(RootWindowId(self.id()));
|
AppState::queue_redraw(RootWindowId(self.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
let frame_rect = unsafe { NSWindow::frame(*self.ns_window) };
|
let frame_rect = unsafe { NSWindow::frame(*self.ns_window) };
|
||||||
let position = LogicalPosition::new(
|
let position = LogicalPosition::new(
|
||||||
frame_rect.origin.x as f64,
|
frame_rect.origin.x as f64,
|
||||||
|
@ -450,7 +450,7 @@ impl UnownedWindow {
|
||||||
Ok(position.to_physical(dpi_factor))
|
Ok(position.to_physical(dpi_factor))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
let content_rect = unsafe {
|
let content_rect = unsafe {
|
||||||
NSWindow::contentRectForFrameRect_(*self.ns_window, NSWindow::frame(*self.ns_window))
|
NSWindow::contentRectForFrameRect_(*self.ns_window, NSWindow::frame(*self.ns_window))
|
||||||
};
|
};
|
||||||
|
@ -480,18 +480,18 @@ impl UnownedWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
let view_frame = unsafe { NSView::frame(*self.ns_view) };
|
let view_frame = unsafe { NSView::frame(*self.ns_view) };
|
||||||
let logical: LogicalSize =
|
let logical: LogicalSize<f64> =
|
||||||
(view_frame.size.width as f64, view_frame.size.height as f64).into();
|
(view_frame.size.width as f64, view_frame.size.height as f64).into();
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
logical.to_physical(dpi_factor)
|
logical.to_physical(dpi_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
let view_frame = unsafe { NSWindow::frame(*self.ns_window) };
|
let view_frame = unsafe { NSWindow::frame(*self.ns_window) };
|
||||||
let logical: LogicalSize =
|
let logical: LogicalSize<f64> =
|
||||||
(view_frame.size.width as f64, view_frame.size.height as f64).into();
|
(view_frame.size.width as f64, view_frame.size.height as f64).into();
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
logical.to_physical(dpi_factor)
|
logical.to_physical(dpi_factor)
|
||||||
|
@ -591,11 +591,11 @@ impl UnownedWindow {
|
||||||
pub fn set_cursor_position(&self, cursor_position: Position) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(&self, cursor_position: Position) -> Result<(), ExternalError> {
|
||||||
let physical_window_position = self.inner_position().unwrap();
|
let physical_window_position = self.inner_position().unwrap();
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let window_position = physical_window_position.to_logical(dpi_factor);
|
let window_position = physical_window_position.to_logical::<CGFloat>(dpi_factor);
|
||||||
let logical_cursor_position = cursor_position.to_logical(dpi_factor);
|
let logical_cursor_position = cursor_position.to_logical::<CGFloat>(dpi_factor);
|
||||||
let point = appkit::CGPoint {
|
let point = appkit::CGPoint {
|
||||||
x: (logical_cursor_position.x + window_position.x) as CGFloat,
|
x: logical_cursor_position.x + window_position.x,
|
||||||
y: (logical_cursor_position.y + window_position.y) as CGFloat,
|
y: logical_cursor_position.y + window_position.y,
|
||||||
};
|
};
|
||||||
CGDisplay::warp_mouse_cursor_position(point)
|
CGDisplay::warp_mouse_cursor_position(point)
|
||||||
.map_err(|e| ExternalError::Os(os_error!(OsError::CGError(e))))?;
|
.map_err(|e| ExternalError::Os(os_error!(OsError::CGError(e))))?;
|
||||||
|
@ -1095,7 +1095,7 @@ impl Drop for UnownedWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn set_min_inner_size<V: NSWindow + Copy>(window: V, mut min_size: LogicalSize) {
|
unsafe fn set_min_inner_size<V: NSWindow + Copy>(window: V, mut min_size: LogicalSize<f64>) {
|
||||||
let mut current_rect = NSWindow::frame(window);
|
let mut current_rect = NSWindow::frame(window);
|
||||||
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
|
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
|
||||||
// Convert from client area size to window size
|
// Convert from client area size to window size
|
||||||
|
@ -1119,7 +1119,7 @@ unsafe fn set_min_inner_size<V: NSWindow + Copy>(window: V, mut min_size: Logica
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn set_max_inner_size<V: NSWindow + Copy>(window: V, mut max_size: LogicalSize) {
|
unsafe fn set_max_inner_size<V: NSWindow + Copy>(window: V, mut max_size: LogicalSize<f64>) {
|
||||||
let mut current_rect = NSWindow::frame(window);
|
let mut current_rect = NSWindow::frame(window);
|
||||||
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
|
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
|
||||||
// Convert from client area size to window size
|
// Convert from client area size to window size
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl WindowDelegateState {
|
||||||
(unsafe { NSWindow::backingScaleFactor(*self.ns_window) }) as f64
|
(unsafe { NSWindow::backingScaleFactor(*self.ns_window) }) as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_size(&self) -> LogicalSize {
|
fn view_size(&self) -> LogicalSize<f64> {
|
||||||
let ns_size = unsafe { NSView::frame(*self.ns_view).size };
|
let ns_size = unsafe { NSView::frame(*self.ns_view).size };
|
||||||
LogicalSize::new(ns_size.width as f64, ns_size.height as f64)
|
LogicalSize::new(ns_size.width as f64, ns_size.height as f64)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ impl Handle {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
PhysicalPosition { x: 0.0, y: 0.0 }
|
PhysicalPosition { x: 0.0, y: 0.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ impl Handle {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
PhysicalSize {
|
PhysicalSize {
|
||||||
width: 0.0,
|
width: 0.0,
|
||||||
height: 0.0,
|
height: 0.0,
|
||||||
|
@ -33,7 +33,7 @@ impl Handle {
|
||||||
pub struct Mode;
|
pub struct Mode;
|
||||||
|
|
||||||
impl Mode {
|
impl Mode {
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl Canvas {
|
||||||
self.raw.height() as f64
|
self.raw.height() as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_size(&self, size: LogicalSize) {
|
pub fn set_size(&self, size: LogicalSize<f64>) {
|
||||||
self.raw.set_width(size.width as u32);
|
self.raw.set_width(size.width as u32);
|
||||||
self.raw.set_height(size.height as u32);
|
self.raw.set_height(size.height as u32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn mouse_modifiers(event: &impl IMouseEvent) -> ModifiersState {
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mouse_position(event: &impl IMouseEvent) -> LogicalPosition {
|
pub fn mouse_position(event: &impl IMouseEvent) -> LogicalPosition<f64> {
|
||||||
LogicalPosition {
|
LogicalPosition {
|
||||||
x: event.offset_x() as f64,
|
x: event.offset_x() as f64,
|
||||||
y: event.offset_y() as f64,
|
y: event.offset_y() as f64,
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl WindowExtStdweb for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_size() -> LogicalSize {
|
pub fn window_size() -> LogicalSize<f64> {
|
||||||
let window = window();
|
let window = window();
|
||||||
let width = window.inner_width() as f64;
|
let width = window.inner_width() as f64;
|
||||||
let height = window.inner_height() as f64;
|
let height = window.inner_height() as f64;
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl Canvas {
|
||||||
self.raw.height() as f64
|
self.raw.height() as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_size(&self, size: LogicalSize) {
|
pub fn set_size(&self, size: LogicalSize<f64>) {
|
||||||
self.raw.set_width(size.width as u32);
|
self.raw.set_width(size.width as u32);
|
||||||
self.raw.set_height(size.height as u32);
|
self.raw.set_height(size.height as u32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn mouse_modifiers(event: &MouseEvent) -> ModifiersState {
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mouse_position(event: &MouseEvent) -> LogicalPosition {
|
pub fn mouse_position(event: &MouseEvent) -> LogicalPosition<f64> {
|
||||||
LogicalPosition {
|
LogicalPosition {
|
||||||
x: event.offset_x() as f64,
|
x: event.offset_x() as f64,
|
||||||
y: event.offset_y() as f64,
|
y: event.offset_y() as f64,
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl WindowExtWebSys for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_size() -> LogicalSize {
|
pub fn window_size() -> LogicalSize<f64> {
|
||||||
let window = web_sys::window().expect("Failed to obtain window");
|
let window = web_sys::window().expect("Failed to obtain window");
|
||||||
let width = window
|
let width = window
|
||||||
.inner_width()
|
.inner_width()
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::collections::VecDeque;
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
canvas: backend::Canvas,
|
canvas: backend::Canvas,
|
||||||
previous_pointer: RefCell<&'static str>,
|
previous_pointer: RefCell<&'static str>,
|
||||||
position: RefCell<LogicalPosition>,
|
position: RefCell<LogicalPosition<f64>>,
|
||||||
id: Id,
|
id: Id,
|
||||||
register_redraw_request: Box<dyn Fn()>,
|
register_redraw_request: Box<dyn Fn()>,
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,17 @@ impl Window {
|
||||||
(self.register_redraw_request)();
|
(self.register_redraw_request)();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_position(&self) -> Result<LogicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<LogicalPosition<f64>, NotSupportedError> {
|
||||||
let (x, y) = self.canvas.position();
|
let (x, y) = self.canvas.position();
|
||||||
|
|
||||||
Ok(LogicalPosition { x, y })
|
Ok(LogicalPosition { x, y })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_position(&self) -> Result<LogicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<LogicalPosition<f64>, NotSupportedError> {
|
||||||
Ok(*self.position.borrow())
|
Ok(*self.position.borrow())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_outer_position(&self, position: LogicalPosition) {
|
pub fn set_outer_position(&self, position: LogicalPosition<f64>) {
|
||||||
*self.position.borrow_mut() = position;
|
*self.position.borrow_mut() = position;
|
||||||
|
|
||||||
self.canvas.set_attribute("position", "fixed");
|
self.canvas.set_attribute("position", "fixed");
|
||||||
|
@ -91,7 +91,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> LogicalSize {
|
pub fn inner_size(&self) -> LogicalSize<f64> {
|
||||||
LogicalSize {
|
LogicalSize {
|
||||||
width: self.canvas.width() as f64,
|
width: self.canvas.width() as f64,
|
||||||
height: self.canvas.height() as f64,
|
height: self.canvas.height() as f64,
|
||||||
|
@ -99,7 +99,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> LogicalSize {
|
pub fn outer_size(&self) -> LogicalSize<f64> {
|
||||||
LogicalSize {
|
LogicalSize {
|
||||||
width: self.canvas.width() as f64,
|
width: self.canvas.width() as f64,
|
||||||
height: self.canvas.height() as f64,
|
height: self.canvas.height() as f64,
|
||||||
|
@ -107,17 +107,17 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_inner_size(&self, size: LogicalSize) {
|
pub fn set_inner_size(&self, size: LogicalSize<f64>) {
|
||||||
self.canvas.set_size(size);
|
self.canvas.set_size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_min_inner_size(&self, _dimensions: Option<LogicalSize>) {
|
pub fn set_min_inner_size(&self, _dimensions: Option<LogicalSize<f64>>) {
|
||||||
// Intentionally a no-op: users can't resize canvas elements
|
// Intentionally a no-op: users can't resize canvas elements
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_max_inner_size(&self, _dimensions: Option<LogicalSize>) {
|
pub fn set_max_inner_size(&self, _dimensions: Option<LogicalSize<f64>>) {
|
||||||
// Intentionally a no-op: users can't resize canvas elements
|
// Intentionally a no-op: users can't resize canvas elements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,10 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(
|
||||||
|
&self,
|
||||||
|
_position: LogicalPosition<f64>,
|
||||||
|
) -> Result<(), ExternalError> {
|
||||||
// Intentionally a no-op, as the web does not support setting cursor positions
|
// Intentionally a no-op, as the web does not support setting cursor positions
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -243,7 +246,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_ime_position(&self, _position: LogicalPosition) {
|
pub fn set_ime_position(&self, _position: LogicalPosition<f64>) {
|
||||||
// Currently a no-op as it does not seem there is good support for this on web
|
// Currently a no-op as it does not seem there is good support for this on web
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,7 +707,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
||||||
let windowpos = lparam as *const winuser::WINDOWPOS;
|
let windowpos = lparam as *const winuser::WINDOWPOS;
|
||||||
if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE {
|
if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE {
|
||||||
let physical_position =
|
let physical_position =
|
||||||
PhysicalPosition::new((*windowpos).x as f64, (*windowpos).y as f64);
|
PhysicalPosition::new((*windowpos).x as u32, (*windowpos).y as u32);
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
event: Moved(physical_position),
|
event: Moved(physical_position),
|
||||||
|
@ -829,8 +829,8 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = windowsx::GET_X_LPARAM(lparam) as f64;
|
let x = windowsx::GET_X_LPARAM(lparam) as i32;
|
||||||
let y = windowsx::GET_Y_LPARAM(lparam) as f64;
|
let y = windowsx::GET_Y_LPARAM(lparam) as i32;
|
||||||
let position = PhysicalPosition::new(x, y);
|
let position = PhysicalPosition::new(x, y);
|
||||||
|
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
|
@ -1489,8 +1489,8 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
||||||
// We calculate our own size because the default suggested rect doesn't do a great job
|
// We calculate our own size because the default suggested rect doesn't do a great job
|
||||||
// of preserving the window's logical size.
|
// of preserving the window's logical size.
|
||||||
let suggested_physical_inner_size = old_physical_inner_size
|
let suggested_physical_inner_size = old_physical_inner_size
|
||||||
.to_logical(old_dpi_factor)
|
.to_logical::<f64>(old_dpi_factor)
|
||||||
.to_physical(new_dpi_factor);
|
.to_physical::<u32>(new_dpi_factor);
|
||||||
|
|
||||||
// `allow_resize` prevents us from re-applying DPI adjustment to the restored size after
|
// `allow_resize` prevents us from re-applying DPI adjustment to the restored size after
|
||||||
// exiting fullscreen (the restored size is already DPI adjusted).
|
// exiting fullscreen (the restored size is already DPI adjusted).
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl std::fmt::Debug for VideoMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VideoMode {
|
impl VideoMode {
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
self.size.into()
|
self.size.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
let monitor_info = get_monitor_info(self.0).unwrap();
|
let monitor_info = get_monitor_info(self.0).unwrap();
|
||||||
PhysicalSize {
|
PhysicalSize {
|
||||||
width: (monitor_info.rcMonitor.right - monitor_info.rcMonitor.left) as u32,
|
width: (monitor_info.rcMonitor.right - monitor_info.rcMonitor.left) as u32,
|
||||||
|
@ -194,11 +194,11 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||||
let monitor_info = get_monitor_info(self.0).unwrap();
|
let monitor_info = get_monitor_info(self.0).unwrap();
|
||||||
PhysicalPosition {
|
PhysicalPosition {
|
||||||
x: monitor_info.rcMonitor.left as f64,
|
x: monitor_info.rcMonitor.left,
|
||||||
y: monitor_info.rcMonitor.top as f64,
|
y: monitor_info.rcMonitor.top,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub fn get_client_rect(hwnd: HWND) -> Result<RECT, io::Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adjust_size(hwnd: HWND, size: PhysicalSize) -> PhysicalSize {
|
pub fn adjust_size(hwnd: HWND, size: PhysicalSize<u32>) -> PhysicalSize<u32> {
|
||||||
let (width, height): (u32, u32) = size.into();
|
let (width, height): (u32, u32) = size.into();
|
||||||
let rect = RECT {
|
let rect = RECT {
|
||||||
left: 0,
|
left: 0,
|
||||||
|
|
|
@ -147,24 +147,24 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
util::get_window_rect(self.window.0)
|
util::get_window_rect(self.window.0)
|
||||||
.map(|rect| Ok(PhysicalPosition::new(rect.left as f64, rect.top as f64)))
|
.map(|rect| Ok(PhysicalPosition::new(rect.left as i32, rect.top as i32)))
|
||||||
.expect("Unexpected GetWindowRect failure; please report this error to https://github.com/rust-windowing/winit")
|
.expect("Unexpected GetWindowRect failure; please report this error to https://github.com/rust-windowing/winit")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
let mut position: POINT = unsafe { mem::zeroed() };
|
let mut position: POINT = unsafe { mem::zeroed() };
|
||||||
if unsafe { winuser::ClientToScreen(self.window.0, &mut position) } == 0 {
|
if unsafe { winuser::ClientToScreen(self.window.0, &mut position) } == 0 {
|
||||||
panic!("Unexpected ClientToScreen failure: please report this error to https://github.com/rust-windowing/winit")
|
panic!("Unexpected ClientToScreen failure: please report this error to https://github.com/rust-windowing/winit")
|
||||||
}
|
}
|
||||||
Ok(PhysicalPosition::new(position.x as f64, position.y as f64))
|
Ok(PhysicalPosition::new(position.x as i32, position.y as i32))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_outer_position(&self, position: Position) {
|
pub fn set_outer_position(&self, position: Position) {
|
||||||
let (x, y): (i32, i32) = position.to_physical(self.hidpi_factor()).into();
|
let (x, y): (i32, i32) = position.to_physical::<i32>(self.hidpi_factor()).into();
|
||||||
|
|
||||||
let window_state = Arc::clone(&self.window_state);
|
let window_state = Arc::clone(&self.window_state);
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
|
@ -192,7 +192,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
let mut rect: RECT = unsafe { mem::zeroed() };
|
let mut rect: RECT = unsafe { mem::zeroed() };
|
||||||
if unsafe { winuser::GetClientRect(self.window.0, &mut rect) } == 0 {
|
if unsafe { winuser::GetClientRect(self.window.0, &mut rect) } == 0 {
|
||||||
panic!("Unexpected GetClientRect failure: please report this error to https://github.com/rust-windowing/winit")
|
panic!("Unexpected GetClientRect failure: please report this error to https://github.com/rust-windowing/winit")
|
||||||
|
@ -204,7 +204,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
util::get_window_rect(self.window.0)
|
util::get_window_rect(self.window.0)
|
||||||
.map(|rect| {
|
.map(|rect| {
|
||||||
PhysicalSize::new(
|
PhysicalSize::new(
|
||||||
|
@ -250,7 +250,7 @@ impl Window {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_inner_size(&self, size: Size) {
|
pub fn set_inner_size(&self, size: Size) {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let (width, height) = size.to_physical(dpi_factor).into();
|
let (width, height) = size.to_physical::<u32>(dpi_factor).into();
|
||||||
|
|
||||||
let window_state = Arc::clone(&self.window_state);
|
let window_state = Arc::clone(&self.window_state);
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
|
@ -363,7 +363,7 @@ impl Window {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, position: Position) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(&self, position: Position) -> Result<(), ExternalError> {
|
||||||
let dpi_factor = self.hidpi_factor();
|
let dpi_factor = self.hidpi_factor();
|
||||||
let (x, y) = position.to_physical(dpi_factor).into();
|
let (x, y) = position.to_physical::<i32>(dpi_factor).into();
|
||||||
|
|
||||||
let mut point = POINT { x, y };
|
let mut point = POINT { x, y };
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -422,7 +422,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// [safe area]: https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets?language=objc
|
/// [safe area]: https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets?language=objc
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
self.window.inner_position()
|
self.window.inner_position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ impl Window {
|
||||||
/// - **iOS:** Can only be called on the main thread. Returns the top left coordinates of the
|
/// - **iOS:** Can only be called on the main thread. Returns the top left coordinates of the
|
||||||
/// window in the screen space coordinate system.
|
/// window in the screen space coordinate system.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition, NotSupportedError> {
|
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||||
self.window.outer_position()
|
self.window.outer_position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// [safe area]: https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets?language=objc
|
/// [safe area]: https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets?language=objc
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_size(&self) -> PhysicalSize {
|
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||||
self.window.inner_size()
|
self.window.inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ impl Window {
|
||||||
/// - **iOS:** Can only be called on the main thread. Returns the `PhysicalSize` of the window in
|
/// - **iOS:** Can only be called on the main thread. Returns the `PhysicalSize` of the window in
|
||||||
/// screen space coordinates.
|
/// screen space coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_size(&self) -> PhysicalSize {
|
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||||
self.window.outer_size()
|
self.window.outer_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ fn events_serde() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dpi_serde() {
|
fn dpi_serde() {
|
||||||
needs_serde::<LogicalPosition>();
|
needs_serde::<LogicalPosition<f64>>();
|
||||||
needs_serde::<PhysicalPosition>();
|
needs_serde::<PhysicalPosition<i32>>();
|
||||||
needs_serde::<LogicalSize>();
|
needs_serde::<PhysicalPosition<f64>>();
|
||||||
needs_serde::<PhysicalSize>();
|
needs_serde::<LogicalSize<f64>>();
|
||||||
|
needs_serde::<PhysicalSize<u32>>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue