Skip to content

Commit

Permalink
Refine method order
Browse files Browse the repository at this point in the history
  • Loading branch information
xordog committed Apr 6, 2024
1 parent a282a54 commit 29d6494
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
38 changes: 19 additions & 19 deletions src/ios/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down
18 changes: 9 additions & 9 deletions src/osx/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit 29d6494

Please sign in to comment.