From a646602dbd9a972bbd52fc86b4e7b10ac0d21838 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 8 Jul 2015 11:47:14 +0100 Subject: [PATCH] (Window) Set class-name before Map Change-Id: I37f6d6014ac73f84a4abc96efa6090114290817e --- adaptors/common/application-impl.cpp | 8 +------- adaptors/common/window-impl.h | 5 +++-- adaptors/public-api/adaptor-framework/window.cpp | 10 ++++++++-- adaptors/public-api/adaptor-framework/window.h | 12 +++++++++++- adaptors/wayland/window-impl-wl.cpp | 7 ++++--- adaptors/x11/window-impl-x.cpp | 7 ++++--- automated-tests/src/dali-adaptor/utc-Dali-Window.cpp | 13 +++++++++++++ 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index fe3a17e..0407b78 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -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() diff --git a/adaptors/common/window-impl.h b/adaptors/common/window-impl.h index 22f046e..c4d4cf2 100644 --- a/adaptors/common/window-impl.h +++ b/adaptors/common/window-impl.h @@ -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. diff --git a/adaptors/public-api/adaptor-framework/window.cpp b/adaptors/public-api/adaptor-framework/window.cpp index f6e11e3..bb1b4cc 100644 --- a/adaptors/public-api/adaptor-framework/window.cpp +++ b/adaptors/public-api/adaptor-framework/window.cpp @@ -25,9 +25,15 @@ 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); } diff --git a/adaptors/public-api/adaptor-framework/window.h b/adaptors/public-api/adaptor-framework/window.h index b181bdf..5af67fa 100644 --- a/adaptors/public-api/adaptor-framework/window.h +++ b/adaptors/public-api/adaptor-framework/window.h @@ -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. diff --git a/adaptors/wayland/window-impl-wl.cpp b/adaptors/wayland/window-impl-wl.cpp index 9f2ef45..fc325ed 100644 --- a/adaptors/wayland/window-impl-wl.cpp +++ b/adaptors/wayland/window-impl-wl.cpp @@ -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; diff --git a/adaptors/x11/window-impl-x.cpp b/adaptors/x11/window-impl-x.cpp index b189872..05722cc 100644 --- a/adaptors/x11/window-impl-x.cpp +++ b/adaptors/x11/window-impl-x.cpp @@ -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; diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index 051126e..c917d7b 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -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; } -- 2.7.4