Add Window auxiliary hint APIs 51/126951/12
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 25 Apr 2017 10:37:48 +0000 (19:37 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 15 May 2017 13:07:42 +0000 (22:07 +0900)
Change-Id: Ida8a038053ad360624de6f6b05d163f839ad21fa

adaptors/common/window-impl.h
adaptors/devel-api/adaptor-framework/window-devel.cpp
adaptors/devel-api/adaptor-framework/window-devel.h
adaptors/ecore/wayland/window-impl-ecore-wl.cpp
adaptors/wayland/window-impl-wl.cpp
adaptors/x11/window-impl-x.cpp

index 0cf251b..ceed80a 100644 (file)
@@ -195,6 +195,69 @@ public:
    */
   void RotationDone( int orientation, int width, int height );
 
+  /**
+   * @brief Gets the count of supported auxiliary hints of the window.
+   * @return The number of supported auxiliary hints.
+   *
+   * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
+   * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
+   */
+   unsigned int GetSupportedAuxiliaryHintCount();
+
+  /**
+   * @brief Gets the supported auxiliary hint string of the window.
+   * @param[in] index The index of the supported auxiliary hint lists
+   * @return The auxiliary hint string of the index.
+   *
+   * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
+   * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
+   */
+  std::string GetSupportedAuxiliaryHint( unsigned int index );
+
+  /**
+   * @brief Creates an auxiliary hint of the window.
+   * @param[in] hint The auxiliary hint string.
+   * @param[in] value The value string.
+   * @return The ID of created auxiliary hint, or @c 0 on failure.
+   */
+  unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
+
+  /**
+   * @brief Removes an auxiliary hint of the window.
+   * @param[in] id The ID of the auxiliary hint.
+   * @return True if no error occurred, false otherwise.
+   */
+  bool RemoveAuxiliaryHint( unsigned int id );
+
+  /**
+   * @brief Changes a value of the auxiliary hint.
+   * @param[in] id The auxiliary hint ID.
+   * @param[in] value The value string to be set.
+   * @return True if no error occurred, false otherwise.
+   */
+  bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
+
+  /**
+   * @brief Gets a value of the auxiliary hint.
+   * @param[in] id The auxiliary hint ID.
+   * @return The string value of the auxiliary hint ID, or an empty string if none exists.
+   */
+  std::string GetAuxiliaryHintValue( unsigned int id ) const;
+
+  /**
+   * @brief Gets a ID of the auxiliary hint string.
+   * @param[in] hint The auxiliary hint string.
+   * @return The ID of the auxiliary hint string, or @c 0 if none exists.
+   */
+  unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
+
+  /**
+   * @brief Sets a region to get input events.
+   * @param[in] inputRegion The rectangle region to get input events.
+   * @note To set an empty region, pass width and height as 0. An empty input region means the entire window will accept input events.
+   */
+  void SetInputRegion( const Rect< int >& inputRegion );
+
 private:
   /**
    * Private constructor.
@@ -297,7 +360,7 @@ public: // Signals
 
 private:
 
-  typedef std::vector< IndicatorInterface * > DiscardedIndicators;
+  typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
 
   RenderSurface*                   mSurface;
   Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
@@ -324,6 +387,9 @@ private:
   std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
   Dali::Window::WindowOrientation              mPreferredOrientation;
 
+  std::vector< std::string >        mSupportedAuxiliaryHints;
+  AuxiliaryHints                    mAuxiliaryHints;
+
   // Signals
   IndicatorSignalType mIndicatorVisibilityChangedSignal;
   FocusSignalType     mFocusChangedSignal;
index 70ad18e..40a3ee0 100644 (file)
@@ -55,6 +55,46 @@ bool IsVisible( Window window )
   return GetImplementation( window ).IsVisible();
 }
 
+unsigned int GetSupportedAuxiliaryHintCount( Window window )
+{
+  return GetImplementation( window ).GetSupportedAuxiliaryHintCount();
+}
+
+std::string GetSupportedAuxiliaryHint( Window window, unsigned int index )
+{
+  return GetImplementation( window ).GetSupportedAuxiliaryHint( index );
+}
+
+unsigned int AddAuxiliaryHint( Window window, const std::string& hint, const std::string& value )
+{
+  return GetImplementation( window ).AddAuxiliaryHint( hint, value );
+}
+
+bool RemoveAuxiliaryHint( Window window, unsigned int id )
+{
+  return GetImplementation( window ).RemoveAuxiliaryHint( id );
+}
+
+bool SetAuxiliaryHintValue( Window window, unsigned int id, const std::string& value )
+{
+  return GetImplementation( window ).SetAuxiliaryHintValue( id, value );
+}
+
+std::string GetAuxiliaryHintValue( Window window, unsigned int id )
+{
+  return GetImplementation( window ).GetAuxiliaryHintValue( id );
+}
+
+unsigned int GetAuxiliaryHintId( Window window, const std::string& hint )
+{
+  return GetImplementation( window ).GetAuxiliaryHintId( hint );
+}
+
+void SetInputRegion( Window window, const Rect< int >& inputRegion )
+{
+  return GetImplementation( window ).SetInputRegion( inputRegion );
+}
+
 } // namespace DevelWindow
 
 } // namespace Dali
index db6c6ac..10325ed 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/math/rect.h>
+
 // INTERNAL INCLUDES
 #ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
 #include <window.h>
@@ -82,6 +86,76 @@ DALI_IMPORT_API void Hide( Window window );
  */
 DALI_IMPORT_API bool IsVisible( Window window );
 
+/**
+ * @brief Gets the count of supported auxiliary hints of the window.
+ * @param[in] window The window to get the hint count
+ * @return The number of supported auxiliary hints.
+ *
+ * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
+ * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
+ */
+DALI_IMPORT_API unsigned int GetSupportedAuxiliaryHintCount( Window window );
+
+/**
+ * @brief Gets the supported auxiliary hint string of the window.
+ * @param[in] window The window to get the hint
+ * @param[in] index The index of the supported auxiliary hint lists
+ * @return The auxiliary hint string of the index.
+ *
+ * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
+ * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
+ */
+DALI_IMPORT_API std::string GetSupportedAuxiliaryHint( Window window, unsigned int index );
+
+/**
+ * @brief Creates an auxiliary hint of the window.
+ * @param[in] window The window to create a hint
+ * @param[in] hint The auxiliary hint string.
+ * @param[in] value The value string.
+ * @return The ID of created auxiliary hint, or @c 0 on failure.
+ */
+DALI_IMPORT_API unsigned int AddAuxiliaryHint( Window window, const std::string& hint, const std::string& value );
+
+/**
+ * @brief Removes an auxiliary hint of the window.
+ * @param[in] window The window to remove a hint
+ * @param[in] id The ID of the auxiliary hint.
+ * @return True if no error occurred, false otherwise.
+ */
+DALI_IMPORT_API bool RemoveAuxiliaryHint( Window window, unsigned int id );
+
+/**
+ * @brief Changes a value of the auxiliary hint.
+ * @param[in] window The window to set a value
+ * @param[in] id The auxiliary hint ID.
+ * @param[in] value The value string to be set.
+ * @return True if no error occurred, false otherwise.
+ */
+DALI_IMPORT_API bool SetAuxiliaryHintValue( Window window, unsigned int id, const std::string& value );
+
+/**
+ * @brief Gets a value of the auxiliary hint.
+ * @param[in] window The window to get a value
+ * @param[in] id The auxiliary hint ID.
+ * @return The string value of the auxiliary hint ID, or an empty string if none exists.
+ */
+DALI_IMPORT_API std::string GetAuxiliaryHintValue( Window window, unsigned int id );
+
+/**
+ * @brief Gets a ID of the auxiliary hint string.
+ * @param[in] window The window to get an ID
+ * @param[in] hint The auxiliary hint string.
+ * @return The ID of the auxiliary hint string, or @c 0 if none exists.
+ */
+DALI_IMPORT_API unsigned int GetAuxiliaryHintId( Window window, const std::string& hint );
+
+/**
+ * @brief Sets a region to accept input events.
+ * @param[in] window The window to set a region
+ * @param[in] inputRegion The region to accept input events.
+ */
+DALI_IMPORT_API void SetInputRegion( Window window, const Rect< int >& inputRegion );
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 564999f..ad286f4 100644 (file)
@@ -49,7 +49,7 @@ namespace Internal
 namespace Adaptor
 {
 #if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
 #endif
 
 /**
@@ -321,7 +321,9 @@ Window::Window()
   mOverlay( NULL ),
   mAdaptor( NULL ),
   mEventHandler( NULL ),
-  mPreferredOrientation( Dali::Window::PORTRAIT )
+  mPreferredOrientation( Dali::Window::PORTRAIT ),
+  mSupportedAuxiliaryHints(),
+  mAuxiliaryHints()
 {
 }
 
@@ -343,6 +345,9 @@ Window::~Window()
   }
 
   delete mSurface;
+
+  mSupportedAuxiliaryHints.clear();
+  mAuxiliaryHints.clear();
 }
 
 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
@@ -359,6 +364,21 @@ void Window::Initialize(const PositionSize& windowPosition, const std::string& n
 
   // create event handler for Wayland window
   mEventHandler = new EventHandler( this );
+
+  // get auxiliary hint
+  Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEventHandler->mEcoreWindow );
+  if( hints )
+  {
+    Eina_List* l = NULL;
+    char* hint = NULL;
+
+    for( l = hints, ( hint =  static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
+    {
+      mSupportedAuxiliaryHints.push_back( hint );
+
+      DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
+    }
+  }
 }
 
 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
@@ -680,6 +700,137 @@ void Window::RotationDone( int orientation, int width, int height )
   ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
 }
 
+unsigned int Window::GetSupportedAuxiliaryHintCount()
+{
+  return mSupportedAuxiliaryHints.size();
+}
+
+std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
+{
+  if( index >= GetSupportedAuxiliaryHintCount() )
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
+  }
+
+  return mSupportedAuxiliaryHints[index];
+}
+
+unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+  bool supported = false;
+
+  // Check if the hint is suppported
+  for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
+  {
+    if( *iter == hint )
+    {
+      supported = true;
+      break;
+    }
+  }
+
+  if( !supported )
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
+    return 0;
+  }
+
+  // Check if the hint is already added
+  for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+  {
+    if( mAuxiliaryHints[i].first == hint )
+    {
+      // Just change the value
+      mAuxiliaryHints[i].second = value;
+
+      DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
+
+      return i + 1;   // id is index + 1
+    }
+  }
+
+  // Add the hint
+  mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
+
+  unsigned int id = mAuxiliaryHints.size();
+
+  ecore_wl_window_aux_hint_add( mEventHandler->mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
+
+  return id;
+}
+
+bool Window::RemoveAuxiliaryHint( unsigned int id )
+{
+  if( id == 0 || id > mAuxiliaryHints.size() )
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
+    return false;
+  }
+
+  mAuxiliaryHints[id - 1].second = std::string();
+
+  ecore_wl_window_aux_hint_del( mEventHandler->mEcoreWindow, static_cast< int >( id ) );
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
+
+  return true;
+}
+
+bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+  if( id == 0 || id > mAuxiliaryHints.size() )
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
+    return false;
+  }
+
+  mAuxiliaryHints[id - 1].second = value;
+
+  ecore_wl_window_aux_hint_change( mEventHandler->mEcoreWindow, static_cast< int >( id ), value.c_str() );
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+
+  return true;
+}
+
+std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
+{
+  if( id == 0 || id > mAuxiliaryHints.size() )
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
+    return std::string();
+  }
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+
+  return mAuxiliaryHints[id - 1].second;
+}
+
+unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
+{
+  for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+  {
+    if( mAuxiliaryHints[i].first == hint )
+    {
+      DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
+      return i + 1;
+    }
+  }
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
+
+  return 0;
+}
+
+void Window::SetInputRegion( const Rect< int >& inputRegion )
+{
+  ecore_wl_window_input_region_set( mEventHandler->mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+
+  DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+}
+
 } // Adaptor
 } // Internal
 } // Dali
index e9ec667..18e17b7 100644 (file)
@@ -117,7 +117,9 @@ Window::Window()
   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
   mOverlay( NULL ),
   mAdaptor( NULL ),
-  mPreferredOrientation( Dali::Window::PORTRAIT )
+  mPreferredOrientation( Dali::Window::PORTRAIT ),
+  mSupportedAuxiliaryHints(),
+  mAuxiliaryHints()
 {
   mEventHandler = NULL;
 }
@@ -310,6 +312,45 @@ void Window::RotationDone( int orientation, int width, int height )
 {
 }
 
+unsigned int Window::GetSupportedAuxiliaryHintCount()
+{
+  return 0;
+}
+
+std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
+{
+  return std::string();
+}
+
+unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+  return -1;
+}
+
+bool Window::RemoveAuxiliaryHint( unsigned int id )
+{
+  return false;
+}
+
+bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+  return false;
+}
+
+std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
+{
+  return std::string();
+}
+
+unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
+{
+  return -1;
+}
+
+void Window::SetInputRegion( const Rect< int >& inputRegion )
+{
+}
+
 } // Adaptor
 } // Internal
 } // Dali
index 63069b2..e3e3e2f 100644 (file)
@@ -352,7 +352,9 @@ Window::Window()
   mOverlay( NULL ),
   mAdaptor( NULL ),
   mEventHandler( NULL ),
-  mPreferredOrientation( Dali::Window::PORTRAIT )
+  mPreferredOrientation( Dali::Window::PORTRAIT ),
+  mSupportedAuxiliaryHints(),
+  mAuxiliaryHints()
 {
 
   // Detect if we're not running in a ecore main loop (e.g. libuv).
@@ -811,6 +813,44 @@ void Window::RotationDone( int orientation, int width, int height )
   }
 }
 
+unsigned int Window::GetSupportedAuxiliaryHintCount()
+{
+  return 0;
+}
+
+std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
+{
+  return std::string();
+}
+
+unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+  return -1;
+}
+
+bool Window::RemoveAuxiliaryHint( unsigned int id )
+{
+  return false;
+}
+
+bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+  return false;
+}
+
+std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
+{
+  return std::string();
+}
+
+unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
+{
+  return -1;
+}
+
+void Window::SetInputRegion( const Rect< int >& inputRegion )
+{
+}
 
 } // Adaptor
 } // Internal