From e7069e6600d290fb68810872d2077e0a90cf8657 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Mon, 6 Sep 2021 19:05:39 +0900 Subject: [PATCH] Add SetParent in Window Add SetParent in Window. This function has additional flag whether child is the above or below of parent. Change-Id: Ibcc1a3fd69b9f81cc0b856d634f4b39c908e9d1d --- automated-tests/src/dali-adaptor/utc-Dali-Window.cpp | 16 ++++++++++++++++ dali/devel-api/adaptor-framework/window-devel.cpp | 5 +++++ dali/devel-api/adaptor-framework/window-devel.h | 12 ++++++++++++ .../window-system/android/window-base-android.cpp | 2 +- .../window-system/android/window-base-android.h | 2 +- dali/internal/window-system/common/gl-window-impl.cpp | 2 +- dali/internal/window-system/common/window-base.h | 2 +- dali/internal/window-system/common/window-impl.cpp | 19 +++++++++++++++++-- dali/internal/window-system/common/window-impl.h | 7 ++++++- dali/internal/window-system/macos/window-base-mac.h | 2 +- dali/internal/window-system/macos/window-base-mac.mm | 2 +- .../tizen-wayland/ecore-wl/window-base-ecore-wl.cpp | 2 +- .../tizen-wayland/ecore-wl/window-base-ecore-wl.h | 2 +- .../tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp | 4 ++-- .../tizen-wayland/ecore-wl2/window-base-ecore-wl2.h | 2 +- .../window-system/ubuntu-x11/window-base-ecore-x.cpp | 2 +- .../window-system/ubuntu-x11/window-base-ecore-x.h | 2 +- .../window-system/windows/window-base-win.cpp | 2 +- dali/internal/window-system/windows/window-base-win.h | 2 +- 19 files changed, 71 insertions(+), 18 deletions(-) diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index cab5d0a..b44030d 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -1351,6 +1351,22 @@ int UtcDaliWindowSetParentNegative(void) END_TEST; } +int UtcDaliWindowSetParentWithBelowParentNegative(void) +{ + try + { + Dali::Window arg1; + Dali::Window arg2; + DevelWindow::SetParent(arg1, arg2, true); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + int UtcDaliWindowAddInputRegion(void) { Dali::Window instance; diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp index 908a8ae..9f87ce7 100644 --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -106,6 +106,11 @@ void SetParent(Window window, Window parent) GetImplementation(window).SetParent(parent); } +void SetParent(Window window, Window parent, bool belowParent) +{ + GetImplementation(window).SetParent(parent, belowParent); +} + void Unparent(Window window) { GetImplementation(window).Unparent(); diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h index 108b4f4..8bc287e 100644 --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -158,6 +158,18 @@ DALI_ADAPTOR_API KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettings DALI_ADAPTOR_API void SetParent(Window window, Window parent); /** + * @brief Sets parent window of the window. + * + * After setting that, these windows do together when raise-up, lower and iconified/deiconified. + * This function has the additional flag whether the child is located above or below of the parent. + * + * @param[in] window The window instance + * @param[in] parent The parent window instance + * @param[in] belowParent The flag is whether the child is located above or below of the parent. + */ +DALI_ADAPTOR_API void SetParent(Window window, Window parent, bool belowParent); + +/** * @brief Unsets parent window of the window. * * After unsetting, the window is disconnected his parent window. diff --git a/dali/internal/window-system/android/window-base-android.cpp b/dali/internal/window-system/android/window-base-android.cpp index 99e1dee..9fc4ab7 100644 --- a/dali/internal/window-system/android/window-base-android.cpp +++ b/dali/internal/window-system/android/window-base-android.cpp @@ -341,7 +341,7 @@ void WindowBaseAndroid::SetTransparency(bool transparent) { } -void WindowBaseAndroid::SetParent(WindowBase* parentWinBase) +void WindowBaseAndroid::SetParent(WindowBase* parentWinBase, bool belowParent) { } diff --git a/dali/internal/window-system/android/window-base-android.h b/dali/internal/window-system/android/window-base-android.h index 8ba0a14..286ea5c 100644 --- a/dali/internal/window-system/android/window-base-android.h +++ b/dali/internal/window-system/android/window-base-android.h @@ -351,7 +351,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/common/gl-window-impl.cpp b/dali/internal/window-system/common/gl-window-impl.cpp index d94dbe8..4edb1a0 100644 --- a/dali/internal/window-system/common/gl-window-impl.cpp +++ b/dali/internal/window-system/common/gl-window-impl.cpp @@ -740,7 +740,7 @@ void GlWindow::SetChild(Dali::Window& child) WindowBase* childWindowBase = renderSurface->GetWindowBase(); if(childWindowBase) { - childWindowBase->SetParent(mWindowBase.get()); + childWindowBase->SetParent(mWindowBase.get(), false); } } } diff --git a/dali/internal/window-system/common/window-base.h b/dali/internal/window-system/common/window-base.h index 7983f45..926a365 100644 --- a/dali/internal/window-system/common/window-base.h +++ b/dali/internal/window-system/common/window-base.h @@ -375,7 +375,7 @@ public: /** * @copydoc Dali::Window::SetParent() */ - virtual void SetParent(WindowBase* parentWinBase) = 0; + virtual void SetParent(WindowBase* parentWinBase, bool belowParent) = 0; /** * @brief Create a sync fence that can tell the frame is rendered by the graphics driver. diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 1bc3188..2d88bb3 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -917,13 +917,28 @@ void Window::SetParent(Dali::Window& parent) { Dali::DevelWindow::Unparent(parent); } - mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase); + mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false); + } +} + +void Window::SetParent(Dali::Window& parent, bool belowParent) +{ + if(DALI_UNLIKELY(parent)) + { + mParentWindow = parent; + Dali::Window self = Dali::Window(this); + // check circular parent window setting + if(Dali::DevelWindow::GetParent(parent) == self) + { + Dali::DevelWindow::Unparent(parent); + } + mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent); } } void Window::Unparent() { - mWindowBase->SetParent(nullptr); + mWindowBase->SetParent(nullptr, false); mParentWindow.Reset(); } diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 761bb0e..843870b 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -326,11 +326,16 @@ public: static Dali::Window Get(Dali::Actor actor); /** - * @copydoc Dali::DevelWindow::SetParent() + * @copydoc Dali::DevelWindow::SetParent(Window window, Window parent) */ void SetParent(Dali::Window& parent); /** + * @copydoc Dali::DevelWindow::SetParent(Window window, Window parent, bool belowParent) + */ + void SetParent(Dali::Window& parent, bool belowParent); + + /** * @copydoc Dali::DevelWindow::Unparent() */ void Unparent(); diff --git a/dali/internal/window-system/macos/window-base-mac.h b/dali/internal/window-system/macos/window-base-mac.h index b967686..7831e5f 100644 --- a/dali/internal/window-system/macos/window-base-mac.h +++ b/dali/internal/window-system/macos/window-base-mac.h @@ -290,7 +290,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/macos/window-base-mac.mm b/dali/internal/window-system/macos/window-base-mac.mm index 594a186..0053e79 100644 --- a/dali/internal/window-system/macos/window-base-mac.mm +++ b/dali/internal/window-system/macos/window-base-mac.mm @@ -635,7 +635,7 @@ void WindowBaseCocoa::SetTransparency( bool transparent ) mImpl->mWindow.alphaValue = static_cast(!transparent); } -void WindowBaseCocoa::SetParent( WindowBase* parentWinBase ) +void WindowBaseCocoa::SetParent(WindowBase* parentWinBase, bool belowParent) { auto &parent = dynamic_cast(*parentWinBase); [mImpl->mWindow setParentWindow:parent.mImpl->mWindow]; diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp index 55c6a7e..b5edc0a 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp @@ -2159,7 +2159,7 @@ void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize) } } -void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase) +void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase, bool belowParent) { Ecore_Wl_Window* ecoreParent = NULL; if(parentWinBase) diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h index 8cca415..c1b4dbd 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h @@ -423,7 +423,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index 403337a..737f1a9 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -2513,7 +2513,7 @@ void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize) ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); } -void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase) +void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent) { Ecore_Wl2_Window* ecoreParent = NULL; if(parentWinBase) @@ -2521,7 +2521,7 @@ void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase) WindowBaseEcoreWl2* winBaseEcore2 = static_cast(parentWinBase); ecoreParent = winBaseEcore2->mEcoreWindow; } - ecore_wl2_window_parent_set(mEcoreWindow, ecoreParent); + ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent); } int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index d05c99a..6c180c8 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -455,7 +455,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp index 67cb784..f7058dc 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp @@ -900,7 +900,7 @@ void WindowBaseEcoreX::CreateWindow(PositionSize positionSize, bool isTransparen } } -void WindowBaseEcoreX::SetParent(WindowBase* parentWinBase) +void WindowBaseEcoreX::SetParent(WindowBase* parentWinBase, bool belowParent) { Ecore_X_Window ecoreParent = 0; if(parentWinBase) diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h index 2a34f8f..62d9b58 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h @@ -357,7 +357,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() diff --git a/dali/internal/window-system/windows/window-base-win.cpp b/dali/internal/window-system/windows/window-base-win.cpp index cb903ef..07c584e 100644 --- a/dali/internal/window-system/windows/window-base-win.cpp +++ b/dali/internal/window-system/windows/window-base-win.cpp @@ -568,7 +568,7 @@ void WindowBaseWin::EventEntry(TWinEventInfo* event) } } -void WindowBaseWin::SetParent(WindowBase* parentWinBase) +void WindowBaseWin::SetParent(WindowBase* parentWinBase, bool belowParent) { } diff --git a/dali/internal/window-system/windows/window-base-win.h b/dali/internal/window-system/windows/window-base-win.h index 6e0f7db..a98e8b8 100644 --- a/dali/internal/window-system/windows/window-base-win.h +++ b/dali/internal/window-system/windows/window-base-win.h @@ -344,7 +344,7 @@ public: /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent() */ - void SetParent(WindowBase* parentWinBase) override; + void SetParent(WindowBase* parentWinBase, bool belowParent) override; /** * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence() -- 2.7.4