Add SetWindowEffect in WindowExtension namespace. 48/35648/28
authordaemyung jang <dm86.jang@samsung.com>
Mon, 23 Feb 2015 02:09:44 +0000 (11:09 +0900)
committerdaemyung jang <dm86.jang@samsung.com>
Fri, 13 Mar 2015 01:42:39 +0000 (10:42 +0900)
Change-Id: Ib91b536b4c3484797490490bfde29cebaffacf10

adaptors/common/window-impl.h
adaptors/public-api/adaptor-framework/window.h
adaptors/tizen/file.list
adaptors/x11/file.list
adaptors/x11/window-extensions.cpp [new file with mode: 0644]
adaptors/x11/window-extensions.h [new file with mode: 0644]
build/tizen/adaptor/Makefile.am

index 757e33b..3a56b27 100644 (file)
@@ -171,7 +171,6 @@ public:
    */
   void RotationDone( int orientation, int width, int height );
 
-
 private:
   /**
    * Private constructor.
index c7f2511..aecf25c 100644 (file)
@@ -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
index 7ab1a0e..0525f6d 100644 (file)
@@ -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
-
index 5356395..8237698 100644 (file)
@@ -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 (file)
index 0000000..81566b1
--- /dev/null
@@ -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 <window-extensions.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <string>
+#include <sstream>
+#include <Ecore.h>
+#include <Ecore_X.h>
+
+// INTERNAL INCLUDES
+#include <window.h>
+
+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 (file)
index 0000000..243d006
--- /dev/null
@@ -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 <dali/public-api/common/dali-common.h>
+
+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__
index 3a4d79e..6407407 100644 (file)
@@ -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)