From 29d6494969e4d1ce7b4c29d5e866da0a4561c525 Mon Sep 17 00:00:00 2001 From: xordog Date: Sun, 7 Apr 2024 03:56:38 +0900 Subject: [PATCH] Refine method order --- src/ios/window.mm | 38 +++++++++++++++++++------------------- src/osx/window.mm | 18 +++++++++--------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/ios/window.mm b/src/ios/window.mm index 3987000..a896a19 100644 --- a/src/ios/window.mm +++ b/src/ios/window.mm @@ -142,6 +142,25 @@ - (void) bind: (Reflex::Window*) window; return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height); } + static UIScreen* + get_screen (const Window& window) + { + UIWindow* w = get_vc(&window).view.window; + if (@available(iOS 13.0, *)) + return w.windowScene.screen; + else + return w.screen; + } + + Screen + Window_get_screen (const Window& window) + { + Screen s; + UIScreen* screen = get_screen(window); + Screen_initialize(&s, screen ? screen : UIScreen.mainScreen); + return s; + } + static UIInterfaceOrientationMask g_orientation_mask = UIInterfaceOrientationMaskAll; @@ -246,25 +265,6 @@ - (void) bind: (Reflex::Window*) window; flags_to_orientation_mask(flags & (Window::FLAG_PORTRAIT | Window::FLAG_LANDSCAPE))); } - static UIScreen* - get_screen (const Window& window) - { - UIWindow* w = get_vc(&window).view.window; - if (@available(iOS 13.0, *)) - return w.windowScene.screen; - else - return w.screen; - } - - Screen - Window_get_screen (const Window& window) - { - Screen s; - UIScreen* screen = get_screen(window); - Screen_initialize(&s, screen ? screen : UIScreen.mainScreen); - return s; - } - float Window_get_pixel_density (const Window& window) { diff --git a/src/osx/window.mm b/src/osx/window.mm index f648ab6..5aa65ab 100644 --- a/src/osx/window.mm +++ b/src/osx/window.mm @@ -143,6 +143,15 @@ - (void) bind: (Reflex::Window*) window; return Bounds(f.origin.x, f.origin.y, f.size.width, f.size.height); } + Screen + Window_get_screen (const Window& window) + { + Screen s; + NSScreen* screen = get_native(&window).screen; + if (screen) Screen_initialize(&s, screen); + return s; + } + void Window_set_flags (Window* window, uint flags) { @@ -163,15 +172,6 @@ - (void) bind: (Reflex::Window*) window; [native toggleFullScreen: native]; } - Screen - Window_get_screen (const Window& window) - { - Screen s; - NSScreen* screen = get_native(&window).screen; - if (screen) Screen_initialize(&s, screen); - return s; - } - float Window_get_pixel_density (const Window& window) {