Window initial size is set as per environment variables
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 16 Jun 2015 13:38:09 +0000 (14:38 +0100)
committerYoonsang Lee <ysang114.lee@samsung.com>
Tue, 23 Jun 2015 02:30:58 +0000 (11:30 +0900)
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
adaptors/common/adaptor-impl.h
adaptors/common/adaptor.cpp
adaptors/common/application-impl.cpp
adaptors/common/application-impl.h
adaptors/common/framework.h
adaptors/tizen/framework-tizen.cpp
adaptors/ubuntu/framework-ubuntu.cpp

index 5fd0e15..b6af617 100644 (file)
@@ -53,6 +53,7 @@
 #include <vsync-monitor.h>
 #include <object-profiler.h>
 #include <base/display-connection.h>
+#include <window-impl.h>
 
 #include <tizen-logging.h>
 
@@ -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()
@@ -759,7 +771,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),
@@ -782,9 +794,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;
index 9f4ba11..8bf062b 100644 (file)
@@ -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.
@@ -483,8 +494,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
 
@@ -528,13 +540,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;}
 };
index f041a68..55bea40 100644 (file)
 #include <accessibility-manager.h>
 #include <imf-manager.h>
 #include <style-monitor.h>
-#include <window.h>
 #include <render-surface.h>
 #include <adaptor-impl.h>
-#include <window-impl.h>
 
 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<Dali::RenderSurface *>(&surface);
-  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, configuration );
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, configuration, NULL );
   return *adaptor;
 }
 
index 6a98391..b7ef064 100644 (file)
@@ -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 );
 }
index 761cc42..1a8e612 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <framework.h>
 #include <window-impl.h>
+#include <base/environment-options.h>
 
 namespace Dali
 {
@@ -306,6 +307,7 @@ private:
   Dali::Application::WINDOW_MODE        mWindowMode;
   std::string                           mName;
   std::string                           mStylesheet;
+  EnvironmentOptions                    mEnvironmentOptions;
 
   bool                                  mInitialized;
 
index ee39a3a..3704431 100644 (file)
@@ -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;
index e22a8c1..1eef794 100644 (file)
@@ -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 ) ),
index e3832df..1edd301 100644 (file)
@@ -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 ) ),