mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
Fix macOS 32bit (#2327)
This commit is contained in:
parent
40abb526cc
commit
6474891f1e
3 changed files with 11 additions and 9 deletions
|
@ -7,7 +7,7 @@ use std::ops::{BitAnd, Deref};
|
||||||
use std::os::raw::c_uchar;
|
use std::os::raw::c_uchar;
|
||||||
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::{NSApp, NSWindowStyleMask},
|
appkit::{CGFloat, NSApp, NSWindowStyleMask},
|
||||||
base::{id, nil},
|
base::{id, nil},
|
||||||
foundation::{NSPoint, NSRect, NSString, NSUInteger},
|
foundation::{NSPoint, NSRect, NSString, NSUInteger},
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,7 @@ impl Drop for TraceGuard {
|
||||||
// 1. translate the bottom-left window corner into the top-left window corner
|
// 1. translate the bottom-left window corner into the top-left window corner
|
||||||
// 2. translate the coordinate from a bottom-left origin coordinate system to a top-left one
|
// 2. translate the coordinate from a bottom-left origin coordinate system to a top-left one
|
||||||
pub fn bottom_left_to_top_left(rect: NSRect) -> f64 {
|
pub fn bottom_left_to_top_left(rect: NSRect) -> f64 {
|
||||||
CGDisplay::main().pixels_high() as f64 - (rect.origin.y + rect.size.height)
|
CGDisplay::main().pixels_high() as f64 - (rect.origin.y + rect.size.height) as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts from winit screen-coordinates to macOS screen-coordinates.
|
/// Converts from winit screen-coordinates to macOS screen-coordinates.
|
||||||
|
@ -121,8 +121,8 @@ pub fn bottom_left_to_top_left(rect: NSRect) -> f64 {
|
||||||
/// macOS: bottom-left is (0, 0) and y increasing upwards
|
/// macOS: bottom-left is (0, 0) and y increasing upwards
|
||||||
pub fn window_position(position: LogicalPosition<f64>) -> NSPoint {
|
pub fn window_position(position: LogicalPosition<f64>) -> NSPoint {
|
||||||
NSPoint::new(
|
NSPoint::new(
|
||||||
position.x,
|
position.x as CGFloat,
|
||||||
CGDisplay::main().pixels_high() as f64 - position.y,
|
CGDisplay::main().pixels_high() as CGFloat - position.y as CGFloat,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ extern "C" fn pressure_change_with_event(this: &Object, _sel: Sel, event: id) {
|
||||||
event: WindowEvent::TouchpadPressure {
|
event: WindowEvent::TouchpadPressure {
|
||||||
device_id: DEVICE_ID,
|
device_id: DEVICE_ID,
|
||||||
pressure,
|
pressure,
|
||||||
stage,
|
stage: stage as i64,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1255,10 +1255,11 @@ unsafe fn set_min_inner_size<V: NSWindow + Copy>(window: V, mut min_size: Logica
|
||||||
// Convert from client area size to window size
|
// Convert from client area size to window size
|
||||||
min_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0
|
min_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0
|
||||||
min_size.height += (current_rect.size.height - content_rect.size.height) as f64;
|
min_size.height += (current_rect.size.height - content_rect.size.height) as f64;
|
||||||
window.setMinSize_(NSSize {
|
let min_size = NSSize {
|
||||||
width: min_size.width as CGFloat,
|
width: min_size.width as CGFloat,
|
||||||
height: min_size.height as CGFloat,
|
height: min_size.height as CGFloat,
|
||||||
});
|
};
|
||||||
|
window.setMinSize_(min_size);
|
||||||
// If necessary, resize the window to match constraint
|
// If necessary, resize the window to match constraint
|
||||||
if current_rect.size.width < min_size.width {
|
if current_rect.size.width < min_size.width {
|
||||||
current_rect.size.width = min_size.width;
|
current_rect.size.width = min_size.width;
|
||||||
|
@ -1279,10 +1280,11 @@ unsafe fn set_max_inner_size<V: NSWindow + Copy>(window: V, mut max_size: Logica
|
||||||
// Convert from client area size to window size
|
// Convert from client area size to window size
|
||||||
max_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0
|
max_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0
|
||||||
max_size.height += (current_rect.size.height - content_rect.size.height) as f64;
|
max_size.height += (current_rect.size.height - content_rect.size.height) as f64;
|
||||||
window.setMaxSize_(NSSize {
|
let max_size = NSSize {
|
||||||
width: max_size.width as CGFloat,
|
width: max_size.width as CGFloat,
|
||||||
height: max_size.height as CGFloat,
|
height: max_size.height as CGFloat,
|
||||||
});
|
};
|
||||||
|
window.setMaxSize_(max_size);
|
||||||
// If necessary, resize the window to match constraint
|
// If necessary, resize the window to match constraint
|
||||||
if current_rect.size.width > max_size.width {
|
if current_rect.size.width > max_size.width {
|
||||||
current_rect.size.width = max_size.width;
|
current_rect.size.width = max_size.width;
|
||||||
|
|
Loading…
Add table
Reference in a new issue