[Tizen] Modify window configure notification event callback 10/258310/1
authorWonsik Jung <sidein@samsung.com>
Thu, 13 May 2021 08:35:53 +0000 (17:35 +0900)
committerWonsik Jung <sidein@samsung.com>
Thu, 13 May 2021 08:37:19 +0000 (17:37 +0900)
Modify configure notification event callback for window is resized or moved.
This evnet is sent from the display server.
If the event has 0'size, the window is resized by client application.
In this case, dali should ignore that.
If the event has real size size, the window is resized by display server.
In this case, dali should resize own's window buffer and re-render his contents.

Change-Id: Ide3d7c0fb2ad133b444a9bc66f8281c6c2906c45

dali/internal/window-system/common/window-base.cpp
dali/internal/window-system/common/window-base.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp

index 867b72a..659ad2c 100644 (file)
@@ -39,7 +39,8 @@ WindowBase::WindowBase()
   mStyleChangedSignal(),
   mAccessibilitySignal(),
   mTransitionEffectEventSignal(),
-  mKeyboardRepeatSettingsChangedSignal()
+  mKeyboardRepeatSettingsChangedSignal(),
+  mUpdatePositionSizeSignal()
 {
 }
 
@@ -127,6 +128,12 @@ WindowBase::WindowRedrawRequestSignalType& WindowBase::WindowRedrawRequestSignal
   return mWindowRedrawRequestSignal;
 }
 
+WindowBase::UpdatePositionSizeType& WindowBase::UpdatePositionSizeSignal()
+{
+  return mUpdatePositionSizeSignal;
+}
+
+
 } // namespace Adaptor
 
 } // namespace Internal
index 62a70ed..0c0d896 100644 (file)
@@ -72,6 +72,7 @@ public:
   typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
   typedef Signal<void()>                                    KeyboardRepeatSettingsChangedSignalType;
   typedef Signal<void()>                                    WindowRedrawRequestSignalType;
+  typedef Signal<void(Dali::PositionSize&)>                 UpdatePositionSizeType;
 
   // Input events
   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
@@ -435,6 +436,11 @@ public:
    */
   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
 
+  /**
+   * @brief This signal is emitted when the window is resized or moved by display server.
+   */
+  UpdatePositionSizeType& UpdatePositionSizeSignal();
+
 protected:
   // Undefined
   WindowBase(const WindowBase&) = delete;
@@ -459,6 +465,8 @@ protected:
   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
+  UpdatePositionSizeType                  mUpdatePositionSizeSignal;
+
 };
 
 } // namespace Adaptor
index fe37203..69e75de 100644 (file)
@@ -79,7 +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)),
@@ -132,14 +131,11 @@ 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);
 
@@ -579,12 +575,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()));
@@ -620,12 +610,6 @@ 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));
@@ -642,12 +626,6 @@ Dali::Window::WindowPosition Window::GetPosition() const
 
 void Window::SetPositionSize(PositionSize positionSize)
 {
-  if(!mResizeEnabled)
-  {
-    AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
-    mResizeEnabled = true;
-  }
-
   PositionSize oldRect = mSurface->GetPositionSize();
 
   mWindowSurface->MoveResize(positionSize);
@@ -796,6 +774,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);
index cb27eb1..7b20b58 100644 (file)
@@ -434,6 +434,13 @@ private:
   void OnWindowRedrawRequest();
 
   /**
+   * @brief Called when the window is resized or moved by display server.
+   *
+   * @param positionSize the updated window's position and size.
+   */
+  void OnUpdatePositionSize(Dali::PositionSize& positionSize);
+
+  /**
    * @brief Set available orientation to window base.
    */
   void SetAvailableAnlges(const std::vector<int>& angles);
@@ -566,7 +573,6 @@ private:
   bool                 mIsFocusAcceptable : 1;
   bool                 mIconified : 1;
   bool                 mOpaqueState : 1;
-  bool                 mResizeEnabled : 1;
   WindowType           mType;
   Dali::Window         mParentWindow;
 
index b5fffa8..98afcfc 100644 (file)
@@ -344,15 +344,15 @@ void WindowRenderSurface::MoveResize(Dali::PositionSize positionSize)
   bool needToResize = false;
 
   // Check moving
-  if((fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) ||
-     (fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE))
+  if((fabs(positionSize.x - mPositionSize.x) >= MINIMUM_DIMENSION_CHANGE) ||
+     (fabs(positionSize.y - mPositionSize.y) >= MINIMUM_DIMENSION_CHANGE))
   {
     needToMove = true;
   }
 
   // Check resizing
-  if((fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) ||
-     (fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE))
+  if((fabs(positionSize.width - mPositionSize.width) >= MINIMUM_DIMENSION_CHANGE) ||
+     (fabs(positionSize.height - mPositionSize.height) >= MINIMUM_DIMENSION_CHANGE))
   {
     needToResize = true;
   }
index 4c91c35..f54c22b 100644 (file)
@@ -1004,10 +1004,40 @@ void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
 {
   Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
 
-  if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
+  if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
   {
     // Note: To comply with the wayland protocol, Dali should make an ack_configure
     // by calling ecore_wl2_window_commit
+
+    int tempWidth  = static_cast<int>(ev->w);
+    int tempHeight = static_cast<int>(ev->h);
+
+    // Initialize with previous size for skip resize when new size is 0.
+    // When window is just moved or window is resized by client application,
+    // The configure notification event's size will be 0.
+    // If new size is 0, the resized work should be skip.
+    int newWidth = mWindowPositionSize.width;
+    int newHeight = mWindowPositionSize.height;
+    bool windowMoved = false, windowResized = false;
+
+    if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
+    {
+      windowMoved = true;
+    }
+
+    if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
+    {
+      windowResized = true;
+      newWidth = tempWidth;
+      newHeight = tempHeight;
+    }
+
+    if(windowMoved || windowResized)
+    {
+      Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
+      mUpdatePositionSizeSignal.Emit(newPositionSize);
+    }
+
     ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
   }
 }