From d1d634ab7a35115409223b72974bdba7667d1add Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 16 Jun 2015 14:38:09 +0100 Subject: [PATCH] Window initial size is set as per environment variables Problem: EnvironmentOptions class was created by adaptor. The window class gets created before environment options are parsed by the adaptor and some window managers ignore resize requests. Solution: Create EnvironmentOptions in Application class and pass them to Adaptor. Adaptor still has the ability to create the class if it is not passed the options. Change-Id: I634ebc999049fcc5e09116cbfa3a6e03f4a52563 --- adaptors/common/adaptor-impl.cpp | 77 +++++++++++++++++++++--------------- adaptors/common/adaptor-impl.h | 29 ++++++++++---- adaptors/common/adaptor.cpp | 10 +---- adaptors/common/application-impl.cpp | 13 ++++-- adaptors/common/application-impl.h | 2 + adaptors/common/framework.h | 3 +- adaptors/tizen/framework-tizen.cpp | 3 +- adaptors/ubuntu/framework-ubuntu.cpp | 3 +- 8 files changed, 83 insertions(+), 57 deletions(-) diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index 1038e11..7dcb897 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -72,10 +73,10 @@ namespace __thread Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get } // unnamed namespace -Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration ) +Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; - Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface ); + Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); adaptor->mImpl = impl; impl->Initialize(configuration); @@ -83,13 +84,22 @@ Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Con return adaptor; } +Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +{ + Any winId = window.GetNativeHandle(); + + Window& windowImpl = Dali::GetImplementation(window); + Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions ); + windowImpl.SetAdaptor(*adaptor); + return adaptor; +} void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) { // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler. Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage ); - mEnvironmentOptions.SetLogFunction( logFunction ); - mEnvironmentOptions.InstallLogFunction(); // install logging for main thread + mEnvironmentOptions->SetLogFunction( logFunction ); + mEnvironmentOptions->InstallLogFunction(); // install logging for main thread mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction; @@ -105,20 +115,20 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from // files automatically. - if( mEnvironmentOptions.PerformanceServerRequired() ) + if( mEnvironmentOptions->PerformanceServerRequired() ) { - mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions ); + mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions ); } mCallbackManager = CallbackManager::New(); PositionSize size = mSurface->GetPositionSize(); - mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions); + mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions); - if( mEnvironmentOptions.GetGlesCallTime() > 0 ) + if( mEnvironmentOptions->GetGlesCallTime() > 0 ) { - mGLES = new GlProxyImplementation( mEnvironmentOptions ); + mGLES = new GlProxyImplementation( *mEnvironmentOptions ); } else { @@ -137,46 +147,42 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mVSyncMonitor = new VSyncMonitor; - mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions ); + mUpdateRenderController = new UpdateRenderController( *this, *mEnvironmentOptions ); mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME ); // Should be called after Core creation - if( mEnvironmentOptions.GetPanGestureLoggingLevel() ) + if( mEnvironmentOptions->GetPanGestureLoggingLevel() ) { Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE ); } - if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 ) + if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 ) { - Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode()); + Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode()); } - if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 ) + if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 ) { - Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount()); + Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount()); } - if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 ) + if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 ) { - Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount()); + Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount()); } - if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 ) + if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 ) { - Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount()); + Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount()); } - if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 ) + if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 ) { - Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment()); + Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment()); } - if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 ) + if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 ) { - Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode()); + Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode()); } - if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f ) + if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f ) { - Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount()); - } - if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) - { - SurfaceResized( PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() )); + Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount()); } } @@ -211,6 +217,12 @@ Adaptor::~Adaptor() // uninstall it on this thread (main actor thread) Dali::Integration::Log::UninstallLogFunction(); + + // Delete environment options if we own it + if( mEnvironmentOptionsOwned ) + { + delete mEnvironmentOptions; + } } void Adaptor::Start() @@ -754,7 +766,7 @@ void Adaptor::ProcessCoreEventsFromIdle() mNotificationOnIdleInstalled = false; } -Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface) +Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions) : mResizedSignal(), mLanguageChangedSignal(), mAdaptor(adaptor), @@ -777,9 +789,10 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mObservers(), mDragAndDropDetector(), mDeferredRotationObserver(NULL), - mEnvironmentOptions(), + mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */), mPerformanceInterface(NULL), - mObjectProfiler(NULL) + mObjectProfiler(NULL), + mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); gThreadLocalAdaptor = this; diff --git a/adaptors/common/adaptor-impl.h b/adaptors/common/adaptor-impl.h index 5e4e25e..6d9d299 100644 --- a/adaptors/common/adaptor-impl.h +++ b/adaptors/common/adaptor-impl.h @@ -48,6 +48,7 @@ namespace Dali { class RenderSurface; +class Window; namespace Integration { @@ -91,15 +92,25 @@ public: /** * Creates a New Adaptor - * @param[in] nativeWindow native window handle - * @param[in] surface A render surface can be one of the following - * - Pixmap, adaptor will use existing Pixmap to draw on to - * - Window, adaptor will use existing Window to draw on to - * @param[in] configuration The context loss configuration ( to choose resource discard policy ) + * @param[in] nativeWindow Native window handle + * @param[in] surface A render surface can be one of the following + * - Pixmap, adaptor will use existing Pixmap to draw on to + * - Window, adaptor will use existing Window to draw on to + * @param[in] configuration The context loss configuration ( to choose resource discard policy ) + * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ static Dali::Adaptor* New( Any nativeWindow, RenderSurface* surface, - Dali::Configuration::ContextLoss configuration ); + Dali::Configuration::ContextLoss configuration, + EnvironmentOptions* environmentOptions ); + + /** + * Creates a New Adaptor + * @param[in] nativeWindow native window handle + * @param[in] configuration The context loss configuration ( to choose resource discard policy ) + * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. + */ + static Dali::Adaptor* New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); /** * 2-step initialisation, this should be called after creating an adaptor instance. @@ -478,8 +489,9 @@ private: * @param[in] surface A render surface can be one of the following * - Pixmap, adaptor will use existing Pixmap to draw on to * - Window, adaptor will use existing Window to draw on to + * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface ); + Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions ); private: // Types @@ -523,13 +535,14 @@ private: // Data ObserverContainer mObservers; ///< A list of adaptor observer pointers DragAndDropDetectorPtr mDragAndDropDetector; ///< The Drag & Drop detector RotationObserver* mDeferredRotationObserver; ///< deferred Rotation observer needs event handler - EnvironmentOptions mEnvironmentOptions; ///< environment options + EnvironmentOptions* mEnvironmentOptions; ///< environment options PerformanceInterface* mPerformanceInterface; ///< Performance interface KernelTrace mKernelTracer; ///< Kernel tracer SystemTrace mSystemTracer; ///< System tracer TriggerEventFactory mTriggerEventFactory; ///< Trigger event factory ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling SocketFactory mSocketFactory; ///< Socket factory + const bool mEnvironmentOptionsOwned:1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it) public: inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;} }; diff --git a/adaptors/common/adaptor.cpp b/adaptors/common/adaptor.cpp index 944650c..c1c6556 100644 --- a/adaptors/common/adaptor.cpp +++ b/adaptors/common/adaptor.cpp @@ -25,10 +25,8 @@ #include #include #include -#include #include #include -#include namespace Dali { @@ -40,11 +38,7 @@ Adaptor& Adaptor::New( Window window ) Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration ) { - Any winId = window.GetNativeHandle(); - - Internal::Adaptor::Window& windowImpl = GetImplementation(window); - Adaptor* adaptor = Internal::Adaptor::Adaptor::New( winId, windowImpl.GetSurface(), configuration ); - windowImpl.SetAdaptor(*adaptor); + Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, configuration, NULL ); return *adaptor; } @@ -56,7 +50,7 @@ Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface ) Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, Configuration::ContextLoss configuration ) { Dali::RenderSurface* pSurface = const_cast(&surface); - Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, configuration ); + Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, configuration, NULL ); return *adaptor; } diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index 6a98391..b7ef064 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -71,6 +71,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mMemoryLowSignal(), mEventLoop( NULL ), mFramework( NULL ), + mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ), mCommandLineOptions( NULL ), mSingletonService( SingletonService::New() ), mAdaptor( NULL ), @@ -78,6 +79,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mWindowMode( windowMode ), mName(), mStylesheet( stylesheet ), + mEnvironmentOptions(), mInitialized( false ), mSlotDelegate( this ) { @@ -89,7 +91,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mCommandLineOptions = new CommandLineOptions(argc, argv); - mFramework = new Framework(*this, argc, argv, mName); + mFramework = new Framework( *this, argc, argv ); } Application::~Application() @@ -108,9 +110,14 @@ 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 ); } @@ -119,7 +126,7 @@ void Application::CreateAdaptor() { DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" ); - mAdaptor = &Dali::Adaptor::New( mWindow, mContextLossConfiguration ); + mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions ); mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize ); } diff --git a/adaptors/common/application-impl.h b/adaptors/common/application-impl.h index 761cc42..1a8e612 100644 --- a/adaptors/common/application-impl.h +++ b/adaptors/common/application-impl.h @@ -28,6 +28,7 @@ #include #include +#include namespace Dali { @@ -306,6 +307,7 @@ private: Dali::Application::WINDOW_MODE mWindowMode; std::string mName; std::string mStylesheet; + EnvironmentOptions mEnvironmentOptions; bool mInitialized; diff --git a/adaptors/common/framework.h b/adaptors/common/framework.h index ee39a3a..3704431 100644 --- a/adaptors/common/framework.h +++ b/adaptors/common/framework.h @@ -110,7 +110,7 @@ public: * @param[in] argc A pointer to the number of arguments. * @param[in] argv A pointer the the argument list. */ - Framework(Observer& observer, int* argc, char ***argv, const std::string& name); + Framework( Observer& observer, int* argc, char ***argv ); /** * Destructor @@ -193,7 +193,6 @@ private: bool mRunning; int* mArgc; char*** mArgv; - std::string mName; std::string mBundleName; std::string mBundleId; AbortHandler mAbortHandler; diff --git a/adaptors/tizen/framework-tizen.cpp b/adaptors/tizen/framework-tizen.cpp index e22a8c1..1eef794 100644 --- a/adaptors/tizen/framework-tizen.cpp +++ b/adaptors/tizen/framework-tizen.cpp @@ -259,13 +259,12 @@ struct Framework::Impl }; -Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name) +Framework::Framework( Framework::Observer& observer, int *argc, char ***argv ) : mObserver(observer), mInitialised(false), mRunning(false), mArgc(argc), mArgv(argv), - mName(name), mBundleName(""), mBundleId(""), mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ), diff --git a/adaptors/ubuntu/framework-ubuntu.cpp b/adaptors/ubuntu/framework-ubuntu.cpp index e3832df..1edd301 100644 --- a/adaptors/ubuntu/framework-ubuntu.cpp +++ b/adaptors/ubuntu/framework-ubuntu.cpp @@ -124,13 +124,12 @@ struct Framework::Impl }; -Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name) +Framework::Framework( Framework::Observer& observer, int *argc, char ***argv ) : mObserver(observer), mInitialised(false), mRunning(false), mArgc(argc), mArgv(argv), - mName(name), mBundleName(""), mBundleId(""), mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ), -- 2.7.4