Skip to content

Commit

Permalink
[ios] disable GUI insets for external screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kambala-decapitator committed Mar 9, 2020
1 parent 337c3f8 commit 7c04acf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xbmc/platform/darwin/ios/IOSEAGLView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ + (Class) layerClass
//--------------------------------------------------------------
- (void) resizeFrameBuffer
{
auto frame = currentScreen == UIScreen.mainScreen ? self.bounds : currentScreen.bounds;
auto frame = currentScreen.bounds;
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)[self layer];
//allow a maximum framebuffer size of 1080p
//needed for tvout on iPad3/4 and iphone4/5 and maybe AppleTV3
Expand Down
1 change: 1 addition & 0 deletions xbmc/platform/darwin/ios/IOSScreenManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ - (void) setScreen:(unsigned int) screenIdx withMode:(UIScreenMode *)mode
{
[[IOSScreenManager sharedInstance] fadeFromBlack:timeSwitchingToInternalSecs];
}
[g_xbmcController setGUIInsetsFromMainThread:YES];

int w = [[newScreen currentMode] size].width;
int h = [[newScreen currentMode] size].height;
Expand Down
1 change: 1 addition & 0 deletions xbmc/platform/darwin/ios/XBMCController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- (void) observeDefaultCenterStuff: (NSNotification *) notification;
- (CGRect)fullscreenSubviewFrame;
- (void)onXbmcAlive;
- (void)setGUIInsetsFromMainThread:(BOOL)isMainThread;
- (void) setFramebuffer;
- (bool) presentFramebuffer;
- (CGSize) getScreenSize;
Expand Down
37 changes: 29 additions & 8 deletions xbmc/platform/darwin/ios/XBMCController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,39 @@ - (CGRect)fullscreenSubviewFrame
- (void)onXbmcAlive
{
m_debugLogSharingPresenter = std::make_unique<DebugLogSharingPresenter>();
[self setGUIInsetsFromMainThread:NO];
}
//--------------------------------------------------------------
- (void)setGUIInsetsFromMainThread:(BOOL)isMainThread
{
auto& guiInsets = CDisplaySettings::GetInstance().GetCurrentResolutionInfo().guiInsets;

// disable insets for external screen
if ([[IOSScreenManager sharedInstance] isExternalScreen])
{
guiInsets = EdgeInsets{};
return;
}

// apply safe area to Kodi GUI
UIEdgeInsets __block insets;
dispatch_sync(dispatch_get_main_queue(), ^{
auto getInsets = ^{
insets = m_window.safeAreaInsets;
});
if (!UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsetsZero))
{
auto scale = [m_glView getScreenScale:UIScreen.mainScreen];
CDisplaySettings::GetInstance().GetCurrentResolutionInfo().guiInsets = EdgeInsets(
insets.left * scale, insets.top * scale, insets.right * scale, insets.bottom * scale);
}
};
if (isMainThread)
getInsets();
else
dispatch_sync(dispatch_get_main_queue(), getInsets);

CLog::Log(LOGDEBUG, "insets: {}\nwindow: {}\nscreen: {}",
NSStringFromUIEdgeInsets(insets).UTF8String, m_window.description.UTF8String,
m_glView.currentScreen.description.UTF8String);
if (UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsetsZero))
return;

auto scale = [m_glView getScreenScale:m_glView.currentScreen];
guiInsets = EdgeInsets(insets.left * scale, insets.top * scale, insets.right * scale,
insets.bottom * scale);
}
//--------------------------------------------------------------
- (void) setFramebuffer
Expand Down

0 comments on commit 7c04acf

Please sign in to comment.