Supports some tizen window features.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index d35cf40..0aa1cb1 100644 (file)
@@ -58,17 +58,17 @@ Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "L
 
 } // unnamed namespace
 
-Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
+Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
 {
   Any surface;
-  return Window::New(surface, positionSize, name, className, isTransparent);
+  return Window::New(surface, positionSize, name, className, type, isTransparent);
 }
 
-Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
+Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
 {
   Window* window         = new Window();
   window->mIsTransparent = isTransparent;
-  window->Initialize(surface, positionSize, name, className);
+  window->Initialize(surface, positionSize, name, className, type);
   return window;
 }
 
@@ -79,8 +79,6 @@ Window::Window()
   mIsFocusAcceptable(true),
   mIconified(false),
   mOpaqueState(false),
-  mResizeEnabled(false),
-  mType(WindowType::NORMAL),
   mParentWindow(NULL),
   mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
   mRotationAngle(0),
@@ -115,7 +113,7 @@ Window::~Window()
   }
 }
 
-void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
+void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
 {
   // Create a window render surface
   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
@@ -125,6 +123,16 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   // Get a window base
   mWindowBase = mWindowSurface->GetWindowBase();
 
+  // Set Window Type
+  mWindowBase->SetType(type);
+
+  // Initialize for Ime window type
+  if(type == WindowType::IME)
+  {
+    mWindowBase->InitializeIme();
+    mWindowSurface->InitializeImeSurface();
+  }
+
   // Connect signals
   mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
   mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
@@ -132,19 +140,14 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
   mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
   mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
+  mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
 
-  if(!positionSize.IsEmpty())
-  {
-    AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
-    mResizeEnabled = true;
-  }
+  AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
 
   SetClass(name, className);
 
-  mWindowSurface->Map();
-
   mOrientation = Orientation::New(this);
 
   // Get OrientationMode
@@ -172,7 +175,8 @@ void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
   auto accessible = Accessibility::Accessible::Get(v, true);
   bridge->AddTopLevelWindow(accessible);
 
-  //FIXME: line below is temporary solution for missing "activate" signal and should be removed
+  // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
+  // The show must be called after the adaptor is initialized.
   Show();
 }
 
@@ -303,6 +307,12 @@ WindowOrientation Window::GetPreferredOrientation()
   return preferredOrientation;
 }
 
+void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
+{
+  int angle = ConvertToAngle(orientation);
+  mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
+}
+
 void Window::SetAvailableAnlges(const std::vector<int>& angles)
 {
   if(angles.size() > 4)
@@ -503,25 +513,21 @@ void Window::SetInputRegion(const Rect<int>& inputRegion)
 
 void Window::SetType(WindowType type)
 {
-  if(type != mType)
-  {
-    mWindowBase->SetType(type);
-
-    mType = type;
-  }
+  mWindowBase->SetType(type);
 }
 
 WindowType Window::GetType() const
 {
-  return mType;
+  return mWindowBase->GetType();
 }
 
-bool Window::SetNotificationLevel(WindowNotificationLevel level)
+WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
 {
-  if(mType != WindowType::NOTIFICATION)
+  WindowType type = mWindowBase->GetType();
+  if(type != WindowType::NOTIFICATION)
   {
-    DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType);
-    return false;
+    DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
+    return WindowOperationResult::INVALID_OPERATION;
   }
 
   return mWindowBase->SetNotificationLevel(level);
@@ -529,9 +535,10 @@ bool Window::SetNotificationLevel(WindowNotificationLevel level)
 
 WindowNotificationLevel Window::GetNotificationLevel() const
 {
-  if(mType != WindowType::NOTIFICATION)
+  WindowType type = mWindowBase->GetType();
+  if(type != WindowType::NOTIFICATION)
   {
-    DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType);
+    DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
     return WindowNotificationLevel::NONE;
   }
 
@@ -552,7 +559,7 @@ bool Window::IsOpaqueState() const
   return mOpaqueState;
 }
 
-bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
+WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
 {
   return mWindowBase->SetScreenOffMode(screenOffMode);
 }
@@ -562,12 +569,12 @@ WindowScreenOffMode Window::GetScreenOffMode() const
   return mWindowBase->GetScreenOffMode();
 }
 
-bool Window::SetBrightness(int brightness)
+WindowOperationResult Window::SetBrightness(int brightness)
 {
   if(brightness < 0 || brightness > 100)
   {
     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
-    return false;
+    return WindowOperationResult::INVALID_OPERATION;
   }
 
   return mWindowBase->SetBrightness(brightness);
@@ -580,12 +587,6 @@ int Window::GetBrightness() const
 
 void Window::SetSize(Dali::Window::WindowSize size)
 {
-  if(!mResizeEnabled)
-  {
-    AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
-    mResizeEnabled = true;
-  }
-
   PositionSize oldRect = mSurface->GetPositionSize();
 
   mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
@@ -610,6 +611,8 @@ void Window::SetSize(Dali::Window::WindowSize size)
   }
 
   mSurface->SetFullSwapNextFrame();
+
+  Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
 }
 
 Dali::Window::WindowSize Window::GetSize() const
@@ -621,17 +624,13 @@ Dali::Window::WindowSize Window::GetSize() const
 
 void Window::SetPosition(Dali::Window::WindowPosition position)
 {
-  if(!mResizeEnabled)
-  {
-    AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
-    mResizeEnabled = true;
-  }
-
   PositionSize oldRect = mSurface->GetPositionSize();
 
   mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
 
   mSurface->SetFullSwapNextFrame();
+
+  Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
 }
 
 Dali::Window::WindowPosition Window::GetPosition() const
@@ -641,14 +640,13 @@ Dali::Window::WindowPosition Window::GetPosition() const
   return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
 }
 
-void Window::SetPositionSize(PositionSize positionSize)
+PositionSize Window::GetPositionSize() const
 {
-  if(!mResizeEnabled)
-  {
-    AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
-    mResizeEnabled = true;
-  }
+  return mSurface->GetPositionSize();
+}
 
+void Window::SetPositionSize(PositionSize positionSize)
+{
   PositionSize oldRect = mSurface->GetPositionSize();
 
   mWindowSurface->MoveResize(positionSize);
@@ -671,6 +669,8 @@ void Window::SetPositionSize(PositionSize positionSize)
   }
 
   mSurface->SetFullSwapNextFrame();
+
+  Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
 }
 
 Dali::Layer Window::GetRootLayer() const
@@ -792,6 +792,11 @@ void Window::OnWindowRedrawRequest()
   mAdaptor->RenderOnce();
 }
 
+void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
+{
+  SetPositionSize(positionSize);
+}
+
 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
 {
   FeedTouchPoint(point, timeStamp);
@@ -975,6 +980,21 @@ int32_t Window::GetNativeId() const
   return mWindowBase->GetNativeWindowId();
 }
 
+void Window::RequestMoveToServer()
+{
+  mWindowBase->RequestMoveToServer();
+}
+
+void Window::RequestResizeToServer(WindowResizeDirection direction)
+{
+  mWindowBase->RequestResizeToServer(direction);
+}
+
+void Window::EnableFloatingMode(bool enable)
+{
+  mWindowBase->EnableFloatingMode(enable);
+}
+
 } // namespace Adaptor
 
 } // namespace Internal