From df14bd2feeee4445e4432dc960dcf62520f26640 Mon Sep 17 00:00:00 2001 From: daemyung jang Date: Mon, 23 Feb 2015 11:09:44 +0900 Subject: [PATCH] Add SetWindowEffect in WindowExtension namespace. Change-Id: Ib91b536b4c3484797490490bfde29cebaffacf10 --- adaptors/common/window-impl.h | 1 - adaptors/public-api/adaptor-framework/window.h | 1 - adaptors/tizen/file.list | 1 - adaptors/x11/file.list | 6 +- adaptors/x11/window-extensions.cpp | 123 +++++++++++++++++++++++++ adaptors/x11/window-extensions.h | 57 ++++++++++++ build/tizen/adaptor/Makefile.am | 8 ++ 7 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 adaptors/x11/window-extensions.cpp create mode 100644 adaptors/x11/window-extensions.h diff --git a/adaptors/common/window-impl.h b/adaptors/common/window-impl.h index 757e33b..3a56b27 100644 --- a/adaptors/common/window-impl.h +++ b/adaptors/common/window-impl.h @@ -171,7 +171,6 @@ public: */ void RotationDone( int orientation, int width, int height ); - private: /** * Private constructor. diff --git a/adaptors/public-api/adaptor-framework/window.h b/adaptors/public-api/adaptor-framework/window.h index c7f2511..aecf25c 100644 --- a/adaptors/public-api/adaptor-framework/window.h +++ b/adaptors/public-api/adaptor-framework/window.h @@ -241,7 +241,6 @@ public: * @brief Get the native handle of the window. * @return The native handle of the window or an empty handle. */ - Any GetNativeHandle() const; public: // Signals diff --git a/adaptors/tizen/file.list b/adaptors/tizen/file.list index 7ab1a0e..0525f6d 100644 --- a/adaptors/tizen/file.list +++ b/adaptors/tizen/file.list @@ -7,4 +7,3 @@ adaptor_tizen_internal_src_files = \ $(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \ $(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \ $(adaptor_tizen_dir)/tts-player-impl-tizen.cpp - diff --git a/adaptors/x11/file.list b/adaptors/x11/file.list index 5356395..8237698 100644 --- a/adaptors/x11/file.list +++ b/adaptors/x11/file.list @@ -22,7 +22,8 @@ adaptor_x11_tizen_internal_src_files = \ $(_adaptor_x11_internal_src_files) \ $(adaptor_x11_dir)/accessibility-manager-impl-x.cpp \ $(adaptor_x11_dir)/framework-x.cpp \ - $(adaptor_x11_dir)/key-impl-x.cpp + $(adaptor_x11_dir)/key-impl-x.cpp \ + $(adaptor_x11_dir)/window-extensions.cpp adaptor_x11_tv_internal_src_files = \ $(_adaptor_x11_internal_src_files) \ @@ -32,3 +33,6 @@ adaptor_x11_tv_internal_src_files = \ adaptor_x11_internal_default_profile_src_files = \ $(adaptor_x11_dir)/ecore-x-render-surface-factory.cpp \ $(adaptor_x11_dir)/system-settings-x.cpp + +public_api_adaptor_tizen_x11_header_files = \ + $(adaptor_x11_dir)/window-extensions.h diff --git a/adaptors/x11/window-extensions.cpp b/adaptors/x11/window-extensions.cpp new file mode 100644 index 0000000..81566b1 --- /dev/null +++ b/adaptors/x11/window-extensions.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace +{ +typedef std::vector< std::string > HintContainer; + +const char* HINT_EFFECT_NAME = "wm.comp.win.effect.enable"; +const char* HINT_ENABLE_POSTFIX = ":1"; +const char* HINT_DISABLE_POSTFIX = ":0"; + +void Tokenize(const std::string& str, HintContainer& hints, const std::string& delimiters = ",") +{ + std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); + std::string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (std::string::npos != pos || std::string::npos != lastPos) + { + hints.push_back(str.substr(lastPos, pos - lastPos)); + lastPos = str.find_first_not_of(delimiters, pos); + pos = str.find_first_of(delimiters, lastPos); + } +} + +void GetAppliedHints( Dali::Window window, HintContainer& hints ) +{ + Dali::Any nativeWindow = window.GetNativeHandle(); + if ( !nativeWindow.Empty() ) + { + Ecore_X_Window ecoreWindow; + nativeWindow.Get( ecoreWindow ); + + unsigned char* data = NULL; + int n = 0; + int res = ecore_x_window_prop_property_get( ecoreWindow, ECORE_X_ATOM_E_WINDOW_AUX_HINT_SUPPORTED_LIST, + ECORE_X_ATOM_STRING, 0, &data, &n ); + + if ((res == 8) && (n > 0)) + { + std::stringstream ss; + ss << data; + Tokenize(ss.str(), hints); + } + + free(data); + } +} + +} + +namespace Dali +{ + +namespace WindowExtensions +{ + +void EnableEffect( Window window, bool enable ) +{ + Any nativeWindow = window.GetNativeHandle(); + + DALI_ASSERT_ALWAYS( !nativeWindow.Empty() && "Empty window!!!" ); + + HintContainer hints; + GetAppliedHints( window, hints ); + + std::stringstream ss; + ss << hints.size() << ":" << HINT_EFFECT_NAME << (enable ? HINT_ENABLE_POSTFIX : HINT_DISABLE_POSTFIX); + + // Applied the window effect to the current window. + Ecore_X_Window ecoreWindow; + nativeWindow.Get(ecoreWindow); + ecore_x_window_prop_property_set( ecoreWindow, ECORE_X_ATOM_E_WINDOW_AUX_HINT, + ECORE_X_ATOM_STRING, 8, + (void*)ss.str().c_str(), ss.str().size() + 1 ); +} + +bool IsEffectEnabled( Window window ) +{ + Any nativeWindow = window.GetNativeHandle(); + + DALI_ASSERT_ALWAYS( !nativeWindow.Empty() && "Empty window!!!" ); + + HintContainer hints; + GetAppliedHints( window, hints ); + + HintContainer::iterator iter = std::find( hints.begin(), hints.end(), HINT_EFFECT_NAME ); + + return iter != hints.end(); +} + +} // namespace WindowExtensions + +} // namespace Dali + + diff --git a/adaptors/x11/window-extensions.h b/adaptors/x11/window-extensions.h new file mode 100644 index 0000000..243d006 --- /dev/null +++ b/adaptors/x11/window-extensions.h @@ -0,0 +1,57 @@ +#ifndef __DALI_WINDOW_EXTENSIONS_H__ +#define __DALI_WINDOW_EXTENSIONS_H__ + +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class Window; + +namespace WindowExtensions +{ + +/** + * @brief Set whether the effect will enable or not. + * + * The effect will be shown when the application is launched, quit, shown and hiden. + * + * @note This function is only specified by tizen. + * + * @param[in] window The window to set. + * @param[in] enable True if the effect is enabled. + */ +DALI_IMPORT_API void EnableEffect( Window window, bool enable ); + +/** + * @brief Retrieve whether the effect is enabled or not. + * + * @note This function is only specified by tizen. + * + * @param[in] window The window to set. + * @return True if the effect is enabled. + */ +DALI_IMPORT_API bool IsEffectEnabled( Window window ); + +} // namespace WindowExtensions + +} // namespace Dali + +#endif // __DALI_WINDOW_EXTENSIONS_H__ diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index 3a4d79e..6407407 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -335,6 +335,14 @@ tizenadaptorpublicapi_HEADERS = $(public_api_header_files) tizenadaptorframeworkpublicapidir = $(tizenadaptorpublicapidir)/adaptor-framework tizenadaptorframeworkpublicapi_HEADERS = $(public_api_adaptor_framework_header_files) +if !UBUNTU_PROFILE + +if !WAYLAND +tizenadaptorframeworkpublicapi_HEADERS += $(public_api_adaptor_tizen_x11_header_files) +endif # NOT WAYLAND + +endif # NOT UBUNTU_PROFILE + tizenadaptordaliheaderdir = $(devincludepath)/dali tizenadaptordaliheader_HEADERS = $(adaptor_dali_header_file) -- 2.7.4