Skip to content

Commit

Permalink
Merge pull request #14058 from Memphiz/fix_ios_tvout
Browse files Browse the repository at this point in the history
[ios] Fix external/tvout monitor support
  • Loading branch information
Rechi committed Jun 20, 2018
2 parents 29a455e + a642318 commit 77cbe2d
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 112 deletions.
1 change: 1 addition & 0 deletions system/settings/settings.xml
Expand Up @@ -2008,6 +2008,7 @@
<condition>HAVE_WAYLAND</condition>
<condition>HAVE_OSX</condition>
<condition>HAS_DX</condition>
<condition>HAVE_IOS</condition>
</or>
</requirement>
<level>0</level>
Expand Down
33 changes: 16 additions & 17 deletions xbmc/platform/darwin/ios/IOSExternalTouchController.mm
Expand Up @@ -52,6 +52,22 @@ - (id)init
[_touchView setMultipleTouchEnabled:YES];
[_touchView setContentMode:UIViewContentModeCenter];

//load the splash image
std::string strUserSplash = CUtil::GetSplashPath();
xbmcLogo = [UIImage imageWithContentsOfFile:[NSString stringWithUTF8String:strUserSplash.c_str()]];

//make a view with the image
xbmcLogoView = [[UIImageView alloc] initWithImage:xbmcLogo];
//center the image and add it to the view
[xbmcLogoView setFrame:frame];
[xbmcLogoView setContentMode:UIViewContentModeScaleAspectFill];
//autoresize the image frame
[xbmcLogoView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[xbmcLogoView setAutoresizesSubviews:YES];
[_touchView addSubview:xbmcLogoView];
//send the image to the background
[_touchView sendSubviewToBack:xbmcLogoView];
[xbmcLogoView release];

CGRect labelRect = frame;
labelRect.size.height/=2;
Expand Down Expand Up @@ -84,23 +100,6 @@ - (id)init
[_touchView addSubview:descriptionLabel];
[descriptionLabel release];

//load the splash image
std::string strUserSplash = CUtil::GetSplashPath();
xbmcLogo = [UIImage imageWithContentsOfFile:[NSString stringWithUTF8String:strUserSplash.c_str()]];

//make a view with the image
xbmcLogoView = [[UIImageView alloc] initWithImage:xbmcLogo];
//center the image and add it to the view
[xbmcLogoView setFrame:frame];
[xbmcLogoView setContentMode:UIViewContentModeCenter];
//autoresize the image frame
[xbmcLogoView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[xbmcLogoView setAutoresizesSubviews:YES];
[_touchView addSubview:xbmcLogoView];
//send the image to the background
[_touchView sendSubviewToBack:xbmcLogoView];
[xbmcLogoView release];

[[self view] addSubview: _touchView];

[self createGestureRecognizers];
Expand Down
16 changes: 12 additions & 4 deletions xbmc/platform/darwin/ios/IOSScreenManager.mm
Expand Up @@ -26,6 +26,7 @@
#include "threads/Event.h"
#include "Application.h"
#include "windowing/WinSystem.h"
#include "windowing/osx/WinSystemIOS.h"
#include "settings/DisplaySettings.h"
#include "ServiceBroker.h"
#include "cores/AudioEngine/Interfaces/AE.h"
Expand Down Expand Up @@ -271,16 +272,23 @@ - (void) screenDisconnect
{
//if we are on external screen and he was disconnected
//change back to internal screen
if([[UIScreen screens] count] == 1 && _screenIdx != 0)
if (_screenIdx != 0)
{
RESOLUTION_INFO res = CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP);//internal screen default res
CServiceBroker::GetWinSystem()->SetFullScreen(true, res, false);
CWinSystemIOS *winSystem = (CWinSystemIOS *)CServiceBroker::GetWinSystem();
if (winSystem != nullptr)
{
winSystem->MoveToTouchscreen();
}
}
}
//--------------------------------------------------------------
+ (void) updateResolutions
{
CServiceBroker::GetWinSystem()->UpdateResolutions();
CWinSystemBase *winSystem = CServiceBroker::GetWinSystem();
if (winSystem != nullptr)
{
winSystem->UpdateResolutions();
}
}
//--------------------------------------------------------------
- (void) dealloc
Expand Down
2 changes: 1 addition & 1 deletion xbmc/platform/darwin/ios/XBMCApplication.mm
Expand Up @@ -88,7 +88,7 @@ - (void)screenDidConnect:(NSNotification *)aNotification

- (void)screenDidDisconnect:(NSNotification *)aNotification
{
[IOSScreenManager updateResolutions];
[[IOSScreenManager sharedInstance] screenDisconnect];
}

- (void)registerScreenNotifications:(BOOL)bRegister
Expand Down
16 changes: 14 additions & 2 deletions xbmc/platform/darwin/ios/XBMCController.mm
Expand Up @@ -760,8 +760,20 @@ - (bool) presentFramebuffer
//--------------------------------------------------------------
- (CGSize) getScreenSize
{
screensize.width = m_glView.bounds.size.width * screenScale;
screensize.height = m_glView.bounds.size.height * screenScale;
__block CGSize tmp;
if ([NSThread isMainThread])
{
tmp.width = m_glView.bounds.size.width * screenScale;
tmp.height = m_glView.bounds.size.height * screenScale;
}
else
{
dispatch_sync(dispatch_get_main_queue(), ^{
tmp.width = m_glView.bounds.size.width * screenScale;
tmp.height = m_glView.bounds.size.height * screenScale;
});
}
screensize = tmp;
return screensize;
}
//--------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions xbmc/settings/DisplaySettings.cpp
Expand Up @@ -52,6 +52,8 @@
#include "windowing/X11/WinSystemX11.h"
#elif defined(TARGET_DARWIN_OSX)
#include "windowing/osx/WinSystemOSX.h"
#elif defined(TARGET_DARWIN_IOS)
#include "windowing/osx/WinSystemIOS.h"
#elif defined(HAVE_WAYLAND)
#include "windowing/wayland/WinSystemWayland.h"
#elif defined(TARGET_WINDOWS_DESKTOP)
Expand Down Expand Up @@ -778,7 +780,7 @@ void CDisplaySettings::SettingOptionsScreensFiller(SettingConstPtr setting, std:
if (g_advancedSettings.m_canWindowed && CServiceBroker::GetWinSystem()->CanDoWindowed())
list.push_back(std::make_pair(g_localizeStrings.Get(242), DM_WINDOWED));

#if defined(HAVE_X11) || defined(HAVE_WAYLAND) || defined(TARGET_DARWIN_OSX) || defined(TARGET_WINDOWS)
#if defined(HAVE_X11) || defined(HAVE_WAYLAND) || defined(TARGET_DARWIN_OSX) || defined(TARGET_WINDOWS) || defined(TARGET_DARWIN_IOS)
list.push_back(std::make_pair(g_localizeStrings.Get(244), 0));
#else

Expand Down Expand Up @@ -832,13 +834,15 @@ void CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller(Settin

void CDisplaySettings::SettingOptionsMonitorsFiller(SettingConstPtr setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current, void *data)
{
#if defined(HAVE_X11) || defined(TARGET_DARWIN_OSX)
#if defined(HAVE_X11) || defined(TARGET_DARWIN_OSX) || defined(TARGET_DARWIN_IOS)
std::vector<std::string> monitors;

#if defined(HAVE_X11)
CWinSystemX11 *winSystem = dynamic_cast<CWinSystemX11*>(CServiceBroker::GetWinSystem());
#elif defined(TARGET_DARWIN_OSX)
CWinSystemOSX *winSystem = dynamic_cast<CWinSystemOSX*>(CServiceBroker::GetWinSystem());
#elif defined(TARGET_DARWIN_IOS)
CWinSystemIOS *winSystem = dynamic_cast<CWinSystemIOS*>(CServiceBroker::GetWinSystem());
#endif
winSystem->GetConnectedOutputs(&monitors);
std::string currentMonitor = CServiceBroker::GetSettings().GetString(CSettings::SETTING_VIDEOSCREEN_MONITOR);
Expand Down
3 changes: 3 additions & 0 deletions xbmc/settings/SettingConditions.cpp
Expand Up @@ -333,6 +333,9 @@ void CSettingConditions::Initialize(const CProfilesManager &profileManager)
#ifdef TARGET_DARWIN_OSX
m_simpleConditions.insert("have_osx");
#endif
#ifdef TARGET_DARWIN_IOS
m_simpleConditions.insert("have_ios");
#endif
#ifdef HAS_LIBAMCODEC
if (aml_present())
m_simpleConditions.insert("have_amcodec");
Expand Down
10 changes: 5 additions & 5 deletions xbmc/windowing/osx/WinSystemIOS.h
Expand Up @@ -37,6 +37,7 @@ class CWinSystemIOS : public CWinSystemBase, public CRenderSystemGLES
CWinSystemIOS();
virtual ~CWinSystemIOS();

int GetDisplayIndexFromSettings();
// Implementation of CWinSystemBase
CRenderSystemBase *GetRenderSystem() override { return this; }
bool InitWindowSystem() override;
Expand Down Expand Up @@ -66,16 +67,15 @@ class CWinSystemIOS : public CWinSystemBase, public CRenderSystemGLES
void Register(IDispResource *resource) override;
void Unregister(IDispResource *resource) override;

int GetNumScreens() override;
int GetCurrentScreen() override;

virtual std::unique_ptr<CVideoSync> GetVideoSync(void *clock) override;

bool InitDisplayLink(CVideoSyncIos *syncImpl);
void DeinitDisplayLink(void);
void OnAppFocusChange(bool focus);
bool IsBackgrounded() const { return m_bIsBackgrounded; }
void* GetEAGLContextObj();
void GetConnectedOutputs(std::vector<std::string> *outputs);
void MoveToTouchscreen();

// winevents override
bool MessagePump() override;
Expand All @@ -95,8 +95,8 @@ class CWinSystemIOS : public CWinSystemBase, public CRenderSystemGLES

private:
bool GetScreenResolution(int* w, int* h, double* fps, int screenIdx);
void FillInVideoModes();
bool SwitchToVideoMode(int width, int height, double refreshrate, int screenIdx);
void FillInVideoModes(int screenIdx);
bool SwitchToVideoMode(int width, int height, double refreshrate);
CADisplayLinkWrapper *m_pDisplayLink;
};

0 comments on commit 77cbe2d

Please sign in to comment.