1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

UIViewComponentPeer: Enable non-full-screen views

This commit is contained in:
reuk 2021-01-12 19:35:52 +00:00
parent 04f2ca61e2
commit 51170e6073
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -661,6 +661,20 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
return Orientations::convertToJuce (orientation);
}
static Rectangle<int> getRecommendedWindowBounds()
{
// The most straightforward way of retrieving the screen area available to an iOS app
// seems to be to create a new window (which will take up all available space) and to
// query its frame.
struct TemporaryWindow
{
UIWindow* window = [[UIWindow alloc] init];
~TemporaryWindow() noexcept { [window release]; }
};
return convertToRectInt (TemporaryWindow{}.window.frame);
}
void Displays::findDisplays (float masterScale)
{
JUCE_AUTORELEASEPOOL
@ -668,7 +682,8 @@ void Displays::findDisplays (float masterScale)
UIScreen* s = [UIScreen mainScreen];
Display d;
d.userArea = d.totalArea = convertToRectInt ([s bounds]) / masterScale;
d.totalArea = convertToRectInt ([s bounds]) / masterScale;
d.userArea = getRecommendedWindowBounds() / masterScale;
d.isMain = true;
d.scale = masterScale * s.scale;
d.dpi = 160 * d.scale;