Add Window::SetPositionSize() and remove redundant value check 62/192862/11
authorJiyun Yang <ji.yang@samsung.com>
Mon, 12 Nov 2018 06:07:26 +0000 (15:07 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Thu, 15 Nov 2018 08:12:02 +0000 (17:12 +0900)
For Window::SetPosition() and Window::SetSize(),
calling one after another does not guarantee to be displayed on the screen at once.
The new API SetPositionSize() can guarantee atomic "move + resize".

And this commit also removes duplicate and wrong surface rect check in
Window::SetPosition() and Window::SetSize().
Previously, WindowRenderSurface only allowed at least 2 pixel bigger/smaller size update,
but codes in Window did not fit this condition so that it could cause a bug.

Change-Id: I7479e5124906af8baafc5e2ec8d1a07d8845f007
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
build/tizen/adaptor/configure.ac
dali/devel-api/adaptor-framework/window-devel.cpp [new file with mode: 0644]
dali/devel-api/adaptor-framework/window-devel.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h
packaging/dali-adaptor.spec

index 6fc5844..11a6816 100644 (file)
@@ -306,7 +306,7 @@ fi
 if test "x$enable_wayland" = "xyes"; then
 
 if test "x$enable_ecore_wayland2" = "xyes"; then
-PKG_CHECK_MODULES(WAYLAND, [ecore-wl2 egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm])
+PKG_CHECK_MODULES(WAYLAND, [ecore-wl2 egl wayland-egl wayland-egl-tizen wayland-client >= 1.2.0 xkbcommon libtbm])
 else
 PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm])
 fi
diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp
new file mode 100644 (file)
index 0000000..f14bc8d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018 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/devel-api/adaptor-framework/window-devel.h>
+#include <dali/internal/window-system/common/window-impl.h>
+
+namespace Dali
+{
+
+namespace DevelWindow
+{
+
+void SetPositionSize( Window window, PositionSize positionSize )
+{
+  GetImplementation( window ).SetPositionSize( positionSize );
+}
+
+} // namespace DevelWindow
+
+} // namespace Dali
diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h
new file mode 100644 (file)
index 0000000..9ed8a18
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef DALI_WINDOW_DEVEL_H
+#define DALI_WINDOW_DEVEL_H
+
+/*
+ * Copyright (c) 2018 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/adaptor-framework/window.h>
+
+namespace Dali
+{
+
+namespace DevelWindow
+{
+
+/**
+ * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once.
+ *
+ * @param[in] window The window instance
+ * @param[in] positionSize The new window position and size
+ */
+DALI_ADAPTOR_API void SetPositionSize( Window window, PositionSize positionSize );
+
+} // namespace DevelWindow
+
+} // namespace Dali
+
+#endif // DALI_WINDOW_DEVEL_H
index 59a216f..735f7b9 100755 (executable)
@@ -29,7 +29,8 @@ devel_api_src_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.cpp \
-  $(adaptor_devel_api_dir)/adaptor-framework/web-engine.cpp
+  $(adaptor_devel_api_dir)/adaptor-framework/web-engine.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/window-devel.cpp
 
 
 
@@ -74,7 +75,8 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/key-devel.h \
-  $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.h
+  $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/window-devel.h
 
 devel_api_text_abstraction_src_files = \
    $(adaptor_devel_api_dir)/text-abstraction/bidirectional-support.cpp \
index 8412d53..2ea6269 100644 (file)
@@ -488,21 +488,22 @@ void Window::SetSize( Dali::Window::WindowSize size )
     mResizeEnabled = true;
   }
 
-  PositionSize positionSize = mSurface->GetPositionSize();
+  PositionSize oldRect = mSurface->GetPositionSize();
 
-  if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() )
-  {
-    positionSize.width = size.GetWidth();
-    positionSize.height = size.GetHeight();
+  mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
 
-    mSurface->MoveResize( positionSize );
+  PositionSize newRect = mSurface->GetPositionSize();
+
+  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+  if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+  {
+    Uint16Pair newSize( newRect.width, newRect.height );
 
-    mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+    mAdaptor->SurfaceResizePrepare( newSize );
 
-    // Emit signal
-    mResizedSignal.Emit( Dali::Window::WindowSize( positionSize.width, positionSize.height ) );
+    mResizedSignal.Emit( newSize );
 
-    mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+    mAdaptor->SurfaceResizeComplete( newSize );
   }
 }
 
@@ -521,15 +522,9 @@ void Window::SetPosition( Dali::Window::WindowPosition position )
     mResizeEnabled = true;
   }
 
-  PositionSize positionSize = mSurface->GetPositionSize();
-
-  if( positionSize.x != position.GetX() || positionSize.y != position.GetY() )
-  {
-    positionSize.x = position.GetX();
-    positionSize.y = position.GetY();
+  PositionSize oldRect = mSurface->GetPositionSize();
 
-    mSurface->MoveResize( positionSize );
-  }
+  mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
 }
 
 Dali::Window::WindowPosition Window::GetPosition() const
@@ -539,6 +534,33 @@ Dali::Window::WindowPosition Window::GetPosition() const
   return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
 }
 
+void Window::SetPositionSize( PositionSize positionSize )
+{
+  if( !mResizeEnabled )
+  {
+    AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+    mResizeEnabled = true;
+  }
+
+  PositionSize oldRect = mSurface->GetPositionSize();
+
+  mSurface->MoveResize( positionSize );
+
+  PositionSize newRect = mSurface->GetPositionSize();
+
+  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+  if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+  {
+    Uint16Pair newSize( newRect.width, newRect.height );
+
+    mAdaptor->SurfaceResizePrepare( newSize );
+
+    mResizedSignal.Emit( newSize );
+
+    mAdaptor->SurfaceResizeComplete( newSize );
+  }
+}
+
 void Window::SetTransparency( bool transparent )
 {
   mSurface->SetTransparency( transparent );
index c2a2b48..fff44b7 100644 (file)
@@ -300,6 +300,11 @@ public:
   Dali::Window::WindowPosition GetPosition() const;
 
   /**
+   * @copydoc Dali::DevelWindow::SetPositionSize()
+   */
+  void SetPositionSize( PositionSize positionSize );
+
+  /**
    * @copydoc Dali::Window::SetTransparency()
    */
   void SetTransparency( bool transparent );
index c1b4534..c95ba10 100755 (executable)
@@ -35,6 +35,7 @@
 #include <Ecore_Input.h>
 #include <vconf.h>
 #include <vconf-keys.h>
+#include <wayland-egl-tizen.h>
 
 namespace Dali
 {
@@ -606,7 +607,9 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any sur
   mBrightness( 0 ),
   mBrightnessChangeState( 0 ),
   mBrightnessChangeDone( true ),
-  mOwnSurface( false )
+  mOwnSurface( false ),
+  mMoveResizeSerial( 0 ),
+  mLastSubmittedMoveResizeSerial( 0 )
 #ifdef DALI_ELDBUS_AVAILABLE
   , mSystemConnection( NULL )
 #endif
@@ -1332,6 +1335,13 @@ void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
 {
   wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
+
+  // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
+  if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
+  {
+    wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
+    mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
+  }
 }
 
 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
@@ -1358,8 +1368,7 @@ void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
 
 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
 {
-  ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
-  ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+  ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
 }
 
 void WindowBaseEcoreWl2::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
index 246bd3a..ae00a8c 100644 (file)
@@ -495,6 +495,9 @@ private:
 
   bool                                 mOwnSurface;
 
+  volatile uint32_t                    mMoveResizeSerial;
+  uint32_t                             mLastSubmittedMoveResizeSerial;
+
 #ifdef DALI_ELDBUS_AVAILABLE
   Eldbus_Connection*                   mSystemConnection;
 #endif // DALI_ELDBUS_AVAILABLE
index 440b19c..6a9a927 100644 (file)
@@ -98,6 +98,7 @@ BuildRequires:  wayland-extension-client-devel
 # dali-adaptor uses ecore mainloop
 %if 0%{?tizen_version_major} >= 5
 BuildRequires:  pkgconfig(ecore-wl2)
+BuildRequires:  pkgconfig(wayland-egl-tizen)
 %else
 BuildRequires:  pkgconfig(ecore-wayland)
 %endif