(Window) Set class-name before Map 64/43364/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 8 Jul 2015 10:47:14 +0000 (11:47 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 8 Jul 2015 11:02:34 +0000 (12:02 +0100)
Change-Id: I37f6d6014ac73f84a4abc96efa6090114290817e

adaptors/common/application-impl.cpp
adaptors/common/window-impl.h
adaptors/public-api/adaptor-framework/window.cpp
adaptors/public-api/adaptor-framework/window.h
adaptors/wayland/window-impl-wl.cpp
adaptors/x11/window-impl-x.cpp
automated-tests/src/dali-adaptor/utc-Dali-Window.cpp

index fe3a17e..0407b78 100644 (file)
@@ -121,14 +121,8 @@ void Application::CreateWindow()
     windowPosition = PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() );
   }
 
-  mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT );
-
-  // Set the window class name if available
   const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
-  if( ! windowClassName.empty() )
-  {
-    mWindow.SetClass( mName, windowClassName );
-  }
+  mWindow = Dali::Window::New( windowPosition, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT );
 }
 
 void Application::CreateAdaptor()
index 22f046e..c4d4cf2 100644 (file)
@@ -64,10 +64,11 @@ public:
    * Create a new Window. This should only be called once by the Application class
    * @param[in] windowPosition The position and size of the window
    * @param[in] name The window title
+   * @param[in] className The window class name
    * @param[in] isTransparent Whether window is transparent
    * @return A newly allocated Window
    */
-  static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
+  static Window* New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent = false);
 
   /**
    * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
@@ -176,7 +177,7 @@ private:
   /**
    * Second stage initialization
    */
-  void Initialize(const PositionSize& posSize, const std::string& name);
+  void Initialize(const PositionSize& posSize, const std::string& name, const std::string& className);
 
   /**
    * Shows / hides the indicator bar.
index f6e11e3..bb1b4cc 100644 (file)
 namespace Dali
 {
 
-Window Window::New(PositionSize posSize, const std::string name, bool isTransparent)
+Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
 {
-  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, isTransparent);
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, "", isTransparent);
+  return Window(window);
+}
+
+Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
+{
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
   return Window(window);
 }
 
index b181bdf..5af67fa 100644 (file)
@@ -96,7 +96,17 @@ public:
    * @param[in] isTransparent Whether window is transparent
    * @return a new window
    */
-  static Window New(PositionSize windowPosition, std::string name, bool isTransparent = false);
+  static Window New(PositionSize windowPosition, const std::string& name, bool isTransparent = false);
+
+  /**
+   * @brief Create an initialized handle to a new Window.
+   * @param[in] windowPosition The position and size of the window
+   * @param[in] name The window title
+   * @param[in] className The window class name
+   * @param[in] isTransparent Whether window is transparent
+   * @return a new window
+   */
+  static Window New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
 
   /**
    * @brief Create an uninitalized handle.
index 9f2ef45..fc325ed 100644 (file)
@@ -104,11 +104,11 @@ struct Window::EventHandler
 };
 
 
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
 {
   Window* window = new Window();
   window->mIsTransparent = isTransparent;
-  window->Initialize(posSize, name);
+  window->Initialize(posSize, name, className);
   return window;
 }
 
@@ -214,11 +214,12 @@ Window::~Window()
   delete mSurface;
 }
 
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
 {
   // create an Wayland window by default
   Any surface;
   ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
+  SetClass( name, className );
   windowSurface->Map();
 
   mSurface = windowSurface;
index b189872..05722cc 100644 (file)
@@ -204,11 +204,11 @@ struct Window::EventHandler
 };
 
 
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
 {
   Window* window = new Window();
   window->mIsTransparent = isTransparent;
-  window->Initialize(posSize, name);
+  window->Initialize(posSize, name, className);
   return window;
 }
 
@@ -371,11 +371,12 @@ Window::~Window()
   delete mSurface;
 }
 
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
 {
   // create an X11 window by default
   Any surface;
   ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
+  SetClass( name, className );
   windowSurface->Map();
 
   mSurface = windowSurface;
index 051126e..c917d7b 100644 (file)
@@ -121,6 +121,19 @@ int UtcDaliWindowNewN(void)
     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
   }
 
+  // Attempt to create a new window
+  try
+  {
+    PositionSize windowPosition(0, 0, 0, 0);
+    Dali::Window window = Dali::Window::New( windowPosition, "test-window", "test-window-class", true );
+
+    tet_result( TET_FAIL );
+  }
+  catch ( DaliException& e )
+  {
+    DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
+  }
+
   END_TEST;
 }