Fix Front buffer rendering does not activate when window created.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index dd75c39..7c6ebfc 100644 (file)
@@ -23,7 +23,6 @@
 #include <dali/devel-api/events/key-event-devel.h>
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/touch-integ.h>
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/actors/layer.h>
@@ -58,17 +57,18 @@ Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "L
 #endif
 } // unnamed namespace
 
-Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
+Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
 {
   Any surface;
-  return Window::New(surface, positionSize, name, className, type, isTransparent);
+  return Window::New(surface, name, className, windowData);
 }
 
-Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
+Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
 {
   Window* window         = new Window();
-  window->mIsTransparent = isTransparent;
-  window->Initialize(surface, positionSize, name, className, type);
+  window->mIsTransparent = windowData.GetTransparency();
+  window->mIsFrontBufferRendering = windowData.GetFrontBufferRendering();
+  window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
   return window;
 }
 
@@ -92,10 +92,12 @@ Window::Window()
   mMovedSignal(),
   mOrientationChangedSignal(),
   mMouseInOutEventSignal(),
+  mMouseRelativeEventSignal(),
   mMoveCompletedSignal(),
   mResizeCompletedSignal(),
+  mInsetsChangedSignal(),
+  mPointerConstraintsSignal(),
   mLastKeyEvent(),
-  mLastTouchEvent(),
   mIsTransparent(false),
   mIsFocusAcceptable(true),
   mIconified(false),
@@ -104,7 +106,9 @@ Window::Window()
   mWindowRotationAcknowledgement(false),
   mFocused(false),
   mIsWindowRotating(false),
-  mIsEnabledUserGeometry(false)
+  mIsEnabledUserGeometry(false),
+  mIsEmittedWindowCreatedEvent(false),
+  mIsFrontBufferRendering(false)
 {
 }
 
@@ -162,12 +166,16 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
   mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
   mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
+  mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
   mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
   mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
+  mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
 
+  mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
+
   SetClass(name, className);
 
   mOrientation = Orientation::New(this);
@@ -190,8 +198,8 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   bool isSetWithScreenSize = false;
   if(mWindowWidth <= 0 || mWindowHeight <= 0)
   {
-    mWindowWidth         = screenWidth;
-    mWindowHeight        = screenHeight;
+    mWindowWidth        = screenWidth;
+    mWindowHeight       = screenHeight;
     isSetWithScreenSize = true;
     DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
   }
@@ -203,6 +211,11 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
 
   // For Debugging
   mNativeWindowId = mWindowBase->GetNativeWindowId();
+
+  if(mIsFrontBufferRendering)
+  {
+    SetFrontBufferRendering(mIsFrontBufferRendering);
+  }
 }
 
 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
@@ -220,22 +233,27 @@ void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
   mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
   mEventHandler->AddObserver(*this);
 
-  // Add Window to bridge for ATSPI
-  auto bridge = Accessibility::Bridge::GetCurrentBridge();
-  if(bridge->IsUp())
+  if(mWindowBase->GetType() == WindowType::IME)
   {
-    auto rootLayer  = mScene.GetRootLayer();
-    auto accessible = Accessibility::Accessible::Get(rootLayer);
-    bridge->AddTopLevelWindow(accessible);
-
-    // Emit Window create event
-    // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
-    bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
+    mWindowBase->InitializeIme();
+    mWindowSurface->InitializeImeSurface();
   }
 
+  // Add Window to bridge for ATSPI
+  auto bridge = Accessibility::Bridge::GetCurrentBridge();
+
   bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
   bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
 
+  if(bridge->IsUp())
+  {
+    OnAccessibilityEnabled();
+  }
+  else
+  {
+    OnAccessibilityDisabled();
+  }
+
   // 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();
@@ -334,6 +352,16 @@ void Window::KeepRendering(float durationSeconds)
   mScene.KeepRendering(durationSeconds);
 }
 
+void Window::SetPartialUpdateEnabled(bool enabled)
+{
+  mScene.SetPartialUpdateEnabled(enabled);
+}
+
+bool Window::IsPartialUpdateEnabled() const
+{
+  return mScene.IsPartialUpdateEnabled();
+}
+
 std::string Window::GetNativeResourceId() const
 {
   return mWindowBase->GetNativeWindowResourceId();
@@ -1044,7 +1072,6 @@ void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
 
 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
 {
-  mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
   FeedTouchPoint(point, timeStamp);
 }
 
@@ -1066,6 +1093,23 @@ void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseIn
   mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
 }
 
+void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
+{
+  Dali::Window handle(this);
+
+  mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
+}
+
+void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
+{
+  Dali::Window handle(this);
+
+  Vector2                                    newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
+  Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
+
+  mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
+}
+
 void Window::OnRotation(const RotationEvent& rotation)
 {
   PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
@@ -1122,6 +1166,11 @@ void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value
   mAuxiliaryMessageSignal.Emit(key, value, options);
 }
 
+void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
+{
+  mInsetsChangedSignal.Emit(partType, partState, insets);
+}
+
 void Window::OnAccessibilityEnabled()
 {
   auto bridge     = Accessibility::Bridge::GetCurrentBridge();
@@ -1129,16 +1178,26 @@ void Window::OnAccessibilityEnabled()
   auto accessible = Accessibility::Accessible::Get(rootLayer);
   bridge->AddTopLevelWindow(accessible);
 
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
+
+  Dali::Window handle(this);
+  if(!mIsEmittedWindowCreatedEvent)
+  {
+    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
+    bridge->WindowCreated(handle);
+    mIsEmittedWindowCreatedEvent = true;
+  }
+
   if(!mVisible || mIconified)
   {
     return;
   }
 
-  Dali::Window handle(this);
   bridge->WindowShown(handle);
 
   if(mFocused)
   {
+    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
     bridge->WindowFocused(handle);
   }
 }
@@ -1149,6 +1208,7 @@ void Window::OnAccessibilityDisabled()
   auto rootLayer  = mScene.GetRootLayer();
   auto accessible = Accessibility::Accessible::Get(rootLayer);
   bridge->RemoveTopLevelWindow(accessible);
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
 }
 
 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
@@ -1318,6 +1378,11 @@ void Window::EnableFloatingMode(bool enable)
   mWindowBase->EnableFloatingMode(enable);
 }
 
+bool Window::IsFloatingModeEnabled()
+{
+  return mWindowBase->IsFloatingModeEnabled();
+}
+
 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
 {
   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
@@ -1356,11 +1421,6 @@ const Dali::KeyEvent& Window::GetLastKeyEvent() const
   return mLastKeyEvent;
 }
 
-const Dali::TouchEvent& Window::GetLastTouchEvent() const
-{
-  return mLastTouchEvent;
-}
-
 void Window::SetUserGeometryPolicy()
 {
   if(mIsEnabledUserGeometry == true)
@@ -1373,6 +1433,67 @@ void Window::SetUserGeometryPolicy()
   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
 }
 
+bool Window::PointerConstraintsLock()
+{
+  return mWindowBase->PointerConstraintsLock();
+}
+
+bool Window::PointerConstraintsUnlock()
+{
+  return mWindowBase->PointerConstraintsUnlock();
+}
+
+void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
+{
+  mWindowBase->LockedPointerRegionSet(x, y, width, height);
+}
+
+void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
+{
+  mWindowBase->LockedPointerCursorPositionHintSet(x, y);
+}
+
+bool Window::PointerWarp(int32_t x, int32_t y)
+{
+  return mWindowBase->PointerWarp(x, y);
+}
+
+void Window::CursorVisibleSet(bool visible)
+{
+  mWindowBase->CursorVisibleSet(visible);
+}
+
+bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
+{
+  return mWindowBase->KeyboardGrab(deviceSubclass);
+}
+
+bool Window::KeyboardUnGrab()
+{
+  return mWindowBase->KeyboardUnGrab();
+}
+
+void Window::SetFullScreen(bool fullscreen)
+{
+  mWindowBase->SetFullScreen(fullscreen);
+}
+
+bool Window::GetFullScreen()
+{
+  return mWindowBase->GetFullScreen();
+}
+
+void Window::SetFrontBufferRendering(bool enable)
+{
+  mWindowBase->SetFrontBufferRendering(enable);
+  mWindowSurface->SetFrontBufferRendering(enable);
+}
+
+bool Window::GetFrontBufferRendering()
+{
+  return mWindowBase->GetFrontBufferRendering();
+}
+
 } // namespace Adaptor
 
 } // namespace Internal