X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fapplication-impl.cpp;h=dece482954f1cd40b6f944660f4704314cbcfaee;hb=b35c370293df4576f87c2c00e381a7997615bb6f;hp=05f668e09fbd11652ba7dbc58990a91eb2b03fba;hpb=f5a4def878ef606629ff52b8cbf8f4e05a5f08ac;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index 05f668e..dece482 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,17 @@ #include #include +// CONDITIONAL INCLUDES +#ifdef DALI_ELDBUS_AVAILABLE +#include +#endif // DALI_ELDBUS_AVAILABLE + namespace Dali { -namespace SlpPlatform +namespace TizenPlatform { -class SlpPlatformAbstraction; +class TizenPlatformAbstraction; } namespace Integration @@ -47,18 +52,26 @@ namespace Internal namespace Adaptor { +#if defined(DEBUG_ENABLED) +namespace +{ +Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS" ); +} // anonymous namespace +#endif + ApplicationPtr Application::New( int* argc, char **argv[], - const std::string& name, - const DeviceLayout& baseLayout, - Dali::Application::WINDOW_MODE windowMode) + const std::string& stylesheet, + Dali::Application::WINDOW_MODE windowMode, + Framework::Type applicationType) { - ApplicationPtr application ( new Application (argc, argv, name, baseLayout, windowMode ) ); + ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, applicationType ) ); return application; } -Application::Application( int* argc, char** argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode) +Application::Application( int* argc, char** argv[], const std::string& stylesheet, + Dali::Application::WINDOW_MODE windowMode, Framework::Type applicationType ) : mInitSignal(), mTerminateSignal(), mPauseSignal(), @@ -72,19 +85,28 @@ Application::Application( int* argc, char** argv[], const std::string& name, con mMemoryLowSignal(), mEventLoop( NULL ), mFramework( NULL ), + mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ), mCommandLineOptions( NULL ), mSingletonService( SingletonService::New() ), mAdaptor( NULL ), mWindow(), mWindowMode( windowMode ), - mName( name ), - mInitialized( false ), - mBaseLayout( baseLayout ), + mName(), + mStylesheet( stylesheet ), + mEnvironmentOptions(), mSlotDelegate( this ) { - mCommandLineOptions = new CommandLineOptions(argc, argv); + // Get mName from environment options + mName = mEnvironmentOptions.GetWindowName(); + if( mName.empty() && argc && ( *argc > 0 ) ) + { + // Set mName from command-line args if environment option not set + mName = (*argv)[0]; + } - mFramework = new Framework(*this, argc, argv, name); + mCommandLineOptions = new CommandLineOptions(argc, argv); + mFramework = new Framework( *this, argc, argv, applicationType ); + mUseRemoteSurface = (applicationType == Framework::WATCH); } Application::~Application() @@ -94,6 +116,13 @@ Application::~Application() delete mFramework; delete mCommandLineOptions; delete mAdaptor; + +#ifdef DALI_ELDBUS_AVAILABLE + // Shutdown ELDBus. + DALI_LOG_INFO( gDBusLogging, Debug::General, "Shutting down DBus\n" ); + eldbus_shutdown(); +#endif + mWindow.Reset(); } @@ -103,32 +132,31 @@ void Application::CreateWindow() if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 ) { - // let the command line options over ride + // Command line options override environment options and full screen windowPosition = PositionSize( 0, 0, mCommandLineOptions->stageWidth, mCommandLineOptions->stageHeight ); } + else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) + { + // Environment options override full screen functionality if command line arguments not provided + windowPosition = PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ); + } - mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT ); + const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName(); + mWindow = Dali::Window::New( windowPosition, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT ); + + // Quit the application when the window is closed + GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit ); } void Application::CreateAdaptor() { DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" ); - mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout, mContextLossConfiguration ); - - std::string dpiStr = mCommandLineOptions->stageDPI; - if(!dpiStr.empty()) - { - // Use DPI from command line. - unsigned int hDPI = 0; - unsigned int vDPI = 0; - - sscanf(dpiStr.c_str(), "%ux%u", &hDPI, &vDPI); - - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetDpi(hDPI, vDPI); - } + mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions ); mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize ); + + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface ); } void Application::MainLoop(Dali::Configuration::ContextLoss configuration) @@ -155,12 +183,8 @@ void Application::QuitFromMainLoop() { mAdaptor->Stop(); - Dali::Application application(this); - mTerminateSignal.Emit( application ); - mFramework->Quit(); // This will trigger OnTerminate(), below, after the main loop has completed. - mInitialized = false; } void Application::OnInit() @@ -168,9 +192,15 @@ void Application::OnInit() mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); CreateWindow(); - CreateAdaptor(); - // Run the adaptor +#ifdef DALI_ELDBUS_AVAILABLE + // Initialize ElDBus. + DALI_LOG_INFO( gDBusLogging, Debug::General, "Starting DBus Initialization\n" ); + eldbus_init(); +#endif + + // Start the adaptor + CreateAdaptor(); mAdaptor->Start(); // Check if user requires no vsyncing and set on X11 Adaptor @@ -190,7 +220,10 @@ void Application::OnInit() Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode ); } - mInitialized = true; + if( ! mStylesheet.empty() ) + { + Dali::StyleMonitor::Get().SetTheme( mStylesheet ); + } // Wire up the LifecycleController Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get(); @@ -206,7 +239,7 @@ void Application::OnInit() Dali::Application application(this); mInitSignal.Emit( application ); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetCore().SceneCreated(); + mAdaptor->NotifySceneCreated(); } void Application::OnTerminate() @@ -214,8 +247,16 @@ void Application::OnTerminate() // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously // delete the window as ecore_x has been destroyed by AppCore + Dali::Application application(this); + mTerminateSignal.Emit( application ); + + if( mAdaptor ) + { + // Ensure that the render-thread is not using the surface(window) after we delete it + mAdaptor->Stop(); + } + mWindow.Reset(); - mInitialized = false; } void Application::OnPause() @@ -227,9 +268,11 @@ void Application::OnPause() void Application::OnResume() { - mAdaptor->Resume(); + // Emit the signal first so the application can queue any messages before we do an update/render + // This ensures we do not just redraw the last frame before pausing if that's not required Dali::Application application(this); mResumeSignal.Emit( application ); + mAdaptor->Resume(); } void Application::OnReset() @@ -240,8 +283,6 @@ void Application::OnReset() */ Dali::Application application(this); mResetSignal.Emit( application ); - - mWindow.Raise(); } void Application::OnAppControl(void *data) @@ -253,6 +294,8 @@ void Application::OnAppControl(void *data) void Application::OnLanguageChanged() { mAdaptor->NotifyLanguageChanged(); + Dali::Application application(this); + mLanguageChangedSignal.Emit( application ); } void Application::OnRegionChanged() @@ -294,16 +337,6 @@ Dali::Window Application::GetWindow() return mWindow; } -const std::string& Application::GetTheme() -{ - return Dali::StyleMonitor::Get().GetTheme(); -} - -void Application::SetTheme(const std::string& themeFilePath) -{ - return Dali::StyleMonitor::Get().SetTheme(themeFilePath); -} - // Stereoscopy void Application::SetViewMode( ViewMode viewMode ) @@ -334,7 +367,9 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string& windowImpl.SetAdaptor(*mAdaptor); newWindow.ShowIndicator(Dali::Window::INVISIBLE); Dali::RenderSurface* renderSurface = windowImpl.GetSurface(); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(*renderSurface); + + Any nativeWindow = newWindow.GetNativeHandle(); + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface); mWindow = newWindow; }