Fix pre-initialized window issue 29/255329/14
authorhuiyu.eun <huiyu.eun@samsung.com>
Wed, 17 Mar 2021 05:08:21 +0000 (14:08 +0900)
committerhuiyu eun <huiyu.eun@samsung.com>
Fri, 16 Apr 2021 02:42:05 +0000 (02:42 +0000)
1) Showing window after adaptor is initialized
 The Preinitialization creates a window in advance.
 If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
 The show must be called after the adaptor is initialized.

2) Resize pre-initialized window
 The pre-created window must be resized as needed after launching the app.
 (Environment variables, app arguments..)
 Some apps can receive screen size differently after launching by specifying size in manifest.
 So screen size checking is needed once more.

3) Store only the value before adaptor is created
 Occurs crash if resize the window before the adapter is created.

Change-Id: I0c928f4ebba752fed951df24d88a1a7c396acb7a
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/common/application-impl.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/public-api/adaptor-framework/application.cpp

index d039770..d15756d 100644 (file)
@@ -34,6 +34,7 @@
 #include <dali/internal/window-system/common/render-surface-factory.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
 
 // To disable a macro with the same name from one of OpenGL headers
 #undef Status
@@ -132,6 +133,43 @@ Application::~Application()
   delete mFramework;
 }
 
+void Application::StoreWindowPositionSize(PositionSize positionSize)
+{
+  mWindowPositionSize = positionSize;
+}
+
+void Application::ChangePreInitializedWindowSize()
+{
+  int screenWidth, screenHeight;
+  Dali::Internal::Adaptor::WindowSystem::GetScreenSize(screenWidth, screenHeight);
+
+  if(mWindowPositionSize != PositionSize(0, 0, 0, 0))
+  {
+    Dali::DevelWindow::SetPositionSize(mMainWindow, mWindowPositionSize);
+  }
+  else if(mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
+  {
+    // Command line options override environment options and full screen
+    mWindowPositionSize.width  = mCommandLineOptions->stageWidth;
+    mWindowPositionSize.height = mCommandLineOptions->stageHeight;
+    mMainWindow.SetSize(Dali::Window::WindowSize(mWindowPositionSize.width, mWindowPositionSize.height));
+  }
+  else if(mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight())
+  {
+    // Environment options override full screen functionality if command line arguments not provided
+    mWindowPositionSize.width  = mEnvironmentOptions.GetWindowWidth();
+    mWindowPositionSize.height = mEnvironmentOptions.GetWindowHeight();
+    mMainWindow.SetSize(Dali::Window::WindowSize(mWindowPositionSize.width, mWindowPositionSize.height));
+  }
+  else if(screenWidth != mWindowPositionSize.width || screenHeight != mWindowPositionSize.height)
+  {
+    //Some apps can receive screen size differently after launching by specifying size in manifest.
+    mWindowPositionSize.width = screenWidth;
+    mWindowPositionSize.height = screenHeight;
+    mMainWindow.SetSize(Dali::Window::WindowSize(mWindowPositionSize.width, mWindowPositionSize.height));
+  }
+}
+
 void Application::CreateWindow()
 {
   if(mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0)
@@ -219,6 +257,11 @@ void Application::OnInit()
 
   CreateAdaptor();
 
+  if(mLaunchpadState == Launchpad::PRE_INITIALIZED)
+  {
+    ChangePreInitializedWindowSize();
+  }
+
   // Run the adaptor
   mAdaptor->Start();
   Accessibility::Accessible::SetObjectRegistry(mAdaptor->GetObjectRegistry());
index 2598df7..5244025 100644 (file)
@@ -152,6 +152,11 @@ public:
    */
   static ApplicationPtr GetPreInitializedApplication();
 
+  /**
+   * Stores PositionSize of window
+   */
+  void StoreWindowPositionSize(PositionSize positionSize);
+
 public: // From Framework::Observer
   /**
    * Called when the framework is initialised.
@@ -355,6 +360,11 @@ protected:
    */
   void QuitFromMainLoop();
 
+  /**
+   * Changes size of preInitialized window
+   */
+  void ChangePreInitializedWindowSize();
+
 private:
   AppSignalType        mInitSignal;
   AppSignalType        mTerminateSignal;
index d35cf40..fe37203 100644 (file)
@@ -143,8 +143,6 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
 
   SetClass(name, className);
 
-  mWindowSurface->Map();
-
   mOrientation = Orientation::New(this);
 
   // Get OrientationMode
@@ -172,7 +170,8 @@ void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
   auto accessible = Accessibility::Accessible::Get(v, true);
   bridge->AddTopLevelWindow(accessible);
 
-  //FIXME: line below is temporary solution for missing "activate" signal and should be removed
+  // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
+  // The show must be called after the adaptor is initialized.
   Show();
 }
 
@@ -673,6 +672,11 @@ void Window::SetPositionSize(PositionSize positionSize)
   mSurface->SetFullSwapNextFrame();
 }
 
+PositionSize Window::GetPositionSize() const
+{
+  return mSurface->GetPositionSize();
+}
+
 Dali::Layer Window::GetRootLayer() const
 {
   return mScene.GetRootLayer();
index befb5f4..cb27eb1 100644 (file)
@@ -284,6 +284,11 @@ public:
   void SetPositionSize(PositionSize positionSize);
 
   /**
+   * @copydoc Dali::DevelWindow::GetPositionSize()
+   */
+  PositionSize GetPositionSize() const;
+
+  /**
    * @copydoc Dali::Window::GetRootLayer()
    */
   Dali::Layer GetRootLayer() const;
index 5cfeeab..872bd1a 100644 (file)
@@ -113,8 +113,9 @@ Application Application::New(int* argc, char** argv[], const std::string& styles
     internal->SetStyleSheet(stylesheet);
 
     internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
-    internal->GetWindow().SetSize(Window::WindowSize(positionSize.width, positionSize.height));
-    internal->GetWindow().SetPosition(Window::WindowPosition(positionSize.x, positionSize.y));
+
+    //Store only the value before adaptor is created
+    internal->StoreWindowPositionSize(positionSize);
 
     return Application(internal.Get());
   }