Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/native/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@
let mut ios_pos: NSPoint = msg_send![ios_touch, locationInView: this];

if native_display().lock().unwrap().high_dpi {
ios_pos.x *= 2.;
ios_pos.y *= 2.;
let main_screen: ObjcId = msg_send![class!(UIScreen), mainScreen];
let scale: f64 = msg_send![main_screen, scale];

ios_pos.x *= scale;
ios_pos.y *= scale;
} else {
let content_scale_factor: f64 = msg_send![this, contentScaleFactor];
ios_pos.x *= content_scale_factor;
Expand Down Expand Up @@ -317,9 +320,11 @@
let high_dpi = native_display().lock().unwrap().high_dpi;

let (screen_width, screen_height) = if high_dpi {
let scale: f64 = unsafe { msg_send![main_screen, scale] };

(
screen_rect.size.width as i32 * 2,
screen_rect.size.height as i32 * 2,
(screen_rect.size.width * scale) as i32,
(screen_rect.size.height * scale) as i32,
)
} else {
let content_scale_factor: f64 = unsafe { msg_send![payload.view, contentScaleFactor] };
Expand Down Expand Up @@ -414,7 +419,10 @@
msg_send_![glk_view_obj, setUserInteractionEnabled: YES];
msg_send_![glk_view_obj, setMultipleTouchEnabled: YES];
if high_dpi {
msg_send_![glk_view_obj, setContentScaleFactor: 2.0];
let main_screen: ObjcId = msg_send![class!(UIScreen), mainScreen];
let scale: f64 = msg_send![main_screen, scale];

msg_send_![glk_view_obj, setContentScaleFactor: scale];
} else {
msg_send_![glk_view_obj, setContentScaleFactor: 1.0];
}
Expand Down Expand Up @@ -480,15 +488,17 @@
_: ObjcId,
) -> BOOL {
unsafe {
let (f, conf) = RUN_ARGS.take().unwrap();

Check warning on line 491 in src/native/ios.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-ios)

creating a mutable reference to mutable static

Check warning on line 491 in src/native/ios.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, aarch64-apple-ios)

creating a mutable reference to mutable static

let main_screen: ObjcId = msg_send![class!(UIScreen), mainScreen];
let screen_rect: NSRect = msg_send![main_screen, bounds];

let (_, _) = if conf.high_dpi {
let scale: f64 = msg_send![main_screen, scale];

(
screen_rect.size.width as i32 * 2,
screen_rect.size.height as i32 * 2,
(screen_rect.size.width * scale) as i32,
(screen_rect.size.height * scale) as i32,
)
} else {
(
Expand Down
Loading