2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/integration-api/core.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/public-api/actors/actor.h>
26 #include <dali/public-api/actors/camera-actor.h>
27 #include <dali/public-api/actors/layer.h>
28 #include <dali/public-api/adaptor-framework/window-enumerations.h>
29 #include <dali/public-api/render-tasks/render-task-list.h>
30 #include <dali/public-api/render-tasks/render-task.h>
31 #include <dali/public-api/rendering/frame-buffer.h>
35 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
36 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
37 #include <dali/internal/graphics/gles/egl-graphics.h>
38 #include <dali/internal/window-system/common/event-handler.h>
39 #include <dali/internal/window-system/common/orientation-impl.h>
40 #include <dali/internal/window-system/common/render-surface-factory.h>
41 #include <dali/internal/window-system/common/window-base.h>
42 #include <dali/internal/window-system/common/window-factory.h>
43 #include <dali/internal/window-system/common/window-render-surface.h>
44 #include <dali/internal/window-system/common/window-system.h>
45 #include <dali/internal/window-system/common/window-visibility-observer.h>
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
59 } // unnamed namespace
61 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
64 return Window::New(surface, positionSize, name, className, isTransparent);
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
69 Window* window = new Window();
70 window->mIsTransparent = isTransparent;
71 window->Initialize(surface, positionSize, name, className);
76 : mWindowSurface(nullptr),
78 mIsTransparent(false),
79 mIsFocusAcceptable(true),
82 mResizeEnabled(false),
83 mType(WindowType::NORMAL),
85 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
89 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
91 mDeleteRequestSignal(),
94 mVisibilityChangedSignal(),
95 mTransitionEffectEventSignal(),
96 mKeyboardRepeatSettingsChangedSignal()
104 auto bridge = Accessibility::Bridge::GetCurrentBridge();
105 auto accessible2 = mScene.GetRootLayer();
106 auto accessible = Accessibility::Accessible::Get(accessible2);
107 bridge->RemoveTopLevelWindow(accessible);
109 mAdaptor->RemoveWindow(this);
114 mEventHandler->RemoveObserver(*this);
118 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
120 // Create a window render surface
121 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
122 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
123 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
126 mWindowBase = mWindowSurface->GetWindowBase();
129 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
130 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
131 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
132 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
133 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
134 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
136 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
138 if(!positionSize.IsEmpty())
140 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
141 mResizeEnabled = true;
144 SetClass(name, className);
146 mWindowSurface->Map();
148 mOrientation = Orientation::New(this);
150 // Get OrientationMode
151 int screenWidth, screenHeight;
152 WindowSystem::GetScreenSize(screenWidth, screenHeight);
153 if(screenWidth > screenHeight)
155 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
159 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
162 mNativeWindowId = mWindowBase->GetNativeWindowId();
165 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
167 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
168 mEventHandler->AddObserver(*this);
170 auto bridge = Accessibility::Bridge::GetCurrentBridge();
171 auto v = mScene.GetRootLayer();
172 auto accessible = Accessibility::Accessible::Get(v, true);
173 bridge->AddTopLevelWindow(accessible);
175 //FIXME: line below is temporary solution for missing "activate" signal and should be removed
179 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
181 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
184 void Window::SetClass(std::string name, std::string className)
187 mClassName = className;
188 mWindowBase->SetClass(name, className);
191 std::string Window::GetClassName() const
198 mWindowBase->Raise();
200 mSurface->SetFullSwapNextFrame();
202 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
207 mWindowBase->Lower();
209 mSurface->SetFullSwapNextFrame();
211 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
214 void Window::Activate()
216 mWindowBase->Activate();
218 mSurface->SetFullSwapNextFrame();
220 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
223 uint32_t Window::GetLayerCount() const
225 return mScene.GetLayerCount();
228 Dali::Layer Window::GetLayer(uint32_t depth) const
230 return mScene.GetLayer(depth);
233 Dali::RenderTaskList Window::GetRenderTaskList() const
235 return mScene.GetRenderTaskList();
238 void Window::AddAvailableOrientation(WindowOrientation orientation)
240 if(IsOrientationAvailable(orientation) == false)
246 int convertedAngle = ConvertToAngle(orientation);
247 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
248 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
250 if(mAvailableAngles[i] == convertedAngle)
259 mAvailableAngles.push_back(convertedAngle);
260 SetAvailableAnlges(mAvailableAngles);
264 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
266 if(IsOrientationAvailable(orientation) == false)
271 int convertedAngle = ConvertToAngle(orientation);
272 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
273 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
274 iter != mAvailableAngles.end();
277 if(*iter == convertedAngle)
279 mAvailableAngles.erase(iter);
284 SetAvailableAnlges(mAvailableAngles);
287 void Window::SetPreferredOrientation(WindowOrientation orientation)
289 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
291 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
294 mPreferredAngle = ConvertToAngle(orientation);
295 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
296 mWindowBase->SetPreferredAngle(mPreferredAngle);
299 WindowOrientation Window::GetPreferredOrientation()
301 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
302 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
303 return preferredOrientation;
306 void Window::SetAvailableAnlges(const std::vector<int>& angles)
308 if(angles.size() > 4)
310 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
314 mWindowBase->SetAvailableAnlges(angles);
317 int Window::ConvertToAngle(WindowOrientation orientation)
319 int convertAngle = static_cast<int>(orientation);
320 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
324 case WindowOrientation::LANDSCAPE:
329 case WindowOrientation::PORTRAIT:
334 case WindowOrientation::LANDSCAPE_INVERSE:
339 case WindowOrientation::PORTRAIT_INVERSE:
344 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
354 WindowOrientation Window::ConvertToOrientation(int angle) const
356 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
357 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
363 orientation = WindowOrientation::LANDSCAPE;
368 orientation = WindowOrientation::PORTRAIT;
373 orientation = WindowOrientation::LANDSCAPE_INVERSE;
378 orientation = WindowOrientation::PORTRAIT_INVERSE;
383 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
391 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
393 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
395 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
401 Dali::Any Window::GetNativeHandle() const
403 return mWindowSurface->GetNativeWindow();
406 void Window::SetAcceptFocus(bool accept)
408 mIsFocusAcceptable = accept;
410 mWindowBase->SetAcceptFocus(accept);
413 bool Window::IsFocusAcceptable() const
415 return mIsFocusAcceptable;
426 WindowVisibilityObserver* observer(mAdaptor);
427 observer->OnWindowShown();
429 Dali::Window handle(this);
430 mVisibilityChangedSignal.Emit(handle, true);
433 mSurface->SetFullSwapNextFrame();
435 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
446 WindowVisibilityObserver* observer(mAdaptor);
447 observer->OnWindowHidden();
449 Dali::Window handle(this);
450 mVisibilityChangedSignal.Emit(handle, false);
453 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
456 bool Window::IsVisible() const
458 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
459 return mVisible && !mIconified;
462 unsigned int Window::GetSupportedAuxiliaryHintCount() const
464 return mWindowBase->GetSupportedAuxiliaryHintCount();
467 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
469 return mWindowBase->GetSupportedAuxiliaryHint(index);
472 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
474 return mWindowBase->AddAuxiliaryHint(hint, value);
477 bool Window::RemoveAuxiliaryHint(unsigned int id)
479 return mWindowBase->RemoveAuxiliaryHint(id);
482 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
484 return mWindowBase->SetAuxiliaryHintValue(id, value);
487 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
489 return mWindowBase->GetAuxiliaryHintValue(id);
492 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
494 return mWindowBase->GetAuxiliaryHintId(hint);
497 void Window::SetInputRegion(const Rect<int>& inputRegion)
499 mWindowBase->SetInputRegion(inputRegion);
501 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
504 void Window::SetType(WindowType type)
508 mWindowBase->SetType(type);
514 WindowType Window::GetType() const
519 bool Window::SetNotificationLevel(WindowNotificationLevel level)
521 if(mType != WindowType::NOTIFICATION)
523 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType);
527 return mWindowBase->SetNotificationLevel(level);
530 WindowNotificationLevel Window::GetNotificationLevel() const
532 if(mType != WindowType::NOTIFICATION)
534 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType);
535 return WindowNotificationLevel::NONE;
538 return mWindowBase->GetNotificationLevel();
541 void Window::SetOpaqueState(bool opaque)
543 mOpaqueState = opaque;
545 mWindowBase->SetOpaqueState(opaque);
547 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
550 bool Window::IsOpaqueState() const
555 bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
557 return mWindowBase->SetScreenOffMode(screenOffMode);
560 WindowScreenOffMode Window::GetScreenOffMode() const
562 return mWindowBase->GetScreenOffMode();
565 bool Window::SetBrightness(int brightness)
567 if(brightness < 0 || brightness > 100)
569 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
573 return mWindowBase->SetBrightness(brightness);
576 int Window::GetBrightness() const
578 return mWindowBase->GetBrightness();
581 void Window::SetSize(Dali::Window::WindowSize size)
585 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
586 mResizeEnabled = true;
589 PositionSize oldRect = mSurface->GetPositionSize();
591 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
593 PositionSize newRect = mSurface->GetPositionSize();
595 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
596 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
598 Uint16Pair newSize(newRect.width, newRect.height);
602 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
604 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
606 Dali::Window handle(this);
607 mResizeSignal.Emit(handle, newSize);
609 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
612 mSurface->SetFullSwapNextFrame();
615 Dali::Window::WindowSize Window::GetSize() const
617 PositionSize positionSize = mSurface->GetPositionSize();
619 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
622 void Window::SetPosition(Dali::Window::WindowPosition position)
626 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
627 mResizeEnabled = true;
630 PositionSize oldRect = mSurface->GetPositionSize();
632 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
634 mSurface->SetFullSwapNextFrame();
637 Dali::Window::WindowPosition Window::GetPosition() const
639 PositionSize positionSize = mSurface->GetPositionSize();
641 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
644 void Window::SetPositionSize(PositionSize positionSize)
648 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
649 mResizeEnabled = true;
652 PositionSize oldRect = mSurface->GetPositionSize();
654 mWindowSurface->MoveResize(positionSize);
656 PositionSize newRect = mSurface->GetPositionSize();
658 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
659 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
661 Uint16Pair newSize(newRect.width, newRect.height);
665 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
667 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
668 Dali::Window handle(this);
669 mResizeSignal.Emit(handle, newSize);
670 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
673 mSurface->SetFullSwapNextFrame();
676 Dali::Layer Window::GetRootLayer() const
678 return mScene.GetRootLayer();
681 void Window::SetTransparency(bool transparent)
683 mWindowSurface->SetTransparency(transparent);
686 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
688 return mWindowBase->GrabKey(key, grabMode);
691 bool Window::UngrabKey(Dali::KEY key)
693 return mWindowBase->UngrabKey(key);
696 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
698 return mWindowBase->GrabKeyList(key, grabMode, result);
701 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
703 return mWindowBase->UngrabKeyList(key, result);
706 void Window::OnIconifyChanged(bool iconified)
714 WindowVisibilityObserver* observer(mAdaptor);
715 observer->OnWindowHidden();
717 Dali::Window handle(this);
718 mVisibilityChangedSignal.Emit(handle, false);
721 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
729 WindowVisibilityObserver* observer(mAdaptor);
730 observer->OnWindowShown();
732 Dali::Window handle(this);
733 mVisibilityChangedSignal.Emit(handle, true);
736 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
739 mSurface->SetFullSwapNextFrame();
742 void Window::OnFocusChanged(bool focusIn)
744 Dali::Window handle(this);
745 mFocusChangeSignal.Emit(handle, focusIn);
747 mSurface->SetFullSwapNextFrame();
749 if(auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
753 b->ApplicationShown();
757 b->ApplicationHidden();
762 void Window::OnOutputTransformed()
764 PositionSize positionSize = mSurface->GetPositionSize();
766 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
767 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
769 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
770 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
773 void Window::OnDeleteRequest()
775 mDeleteRequestSignal.Emit();
778 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
780 Dali::Window handle(this);
781 mTransitionEffectEventSignal.Emit(handle, state, type);
784 void Window::OnKeyboardRepeatSettingsChanged()
786 Dali::Window handle(this);
787 mKeyboardRepeatSettingsChangedSignal.Emit();
790 void Window::OnWindowRedrawRequest()
792 mAdaptor->RenderOnce();
795 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
797 FeedTouchPoint(point, timeStamp);
800 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
802 FeedWheelEvent(wheelEvent);
805 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
807 FeedKeyEvent(keyEvent);
810 void Window::OnRotation(const RotationEvent& rotation)
812 mRotationAngle = rotation.angle;
813 mWindowWidth = rotation.width;
814 mWindowHeight = rotation.height;
816 // Notify that the orientation is changed
817 mOrientation->OnOrientationChange(rotation);
819 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
821 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
822 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
824 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
826 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
828 Dali::Window handle(this);
829 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
831 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
834 void Window::OnPause()
838 mEventHandler->Pause();
842 void Window::OnResume()
846 mEventHandler->Resume();
849 mSurface->SetFullSwapNextFrame();
852 void Window::RecalculateTouchPosition(Integration::Point& point)
854 Vector2 position = point.GetScreenPosition();
855 Vector2 convertedPosition;
857 switch(mRotationAngle)
861 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
862 convertedPosition.y = position.x;
867 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
868 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
873 convertedPosition.x = position.y;
874 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
879 convertedPosition = position;
884 point.SetScreenPosition(convertedPosition);
887 Dali::Window Window::Get(Dali::Actor actor)
889 Internal::Adaptor::Window* windowImpl = nullptr;
891 if(Internal::Adaptor::Adaptor::IsAvailable())
893 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
894 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
897 return Dali::Window(windowImpl);
901 return Dali::Window();
904 void Window::SetParent(Dali::Window& parent)
906 if(DALI_UNLIKELY(parent))
908 mParentWindow = parent;
909 Dali::Window self = Dali::Window(this);
910 // check circular parent window setting
911 if(Dali::DevelWindow::GetParent(parent) == self)
913 Dali::DevelWindow::Unparent(parent);
915 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
919 void Window::Unparent()
921 mWindowBase->SetParent(nullptr);
922 mParentWindow.Reset();
925 Dali::Window Window::GetParent()
927 return mParentWindow;
930 WindowOrientation Window::GetCurrentOrientation() const
932 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
933 return ConvertToOrientation(mRotationAngle);
936 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
938 Dali::Vector<float>::SizeType count = orientations.Count();
939 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
941 if(IsOrientationAvailable(orientations[index]) == false)
943 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
948 int convertedAngle = ConvertToAngle(orientations[index]);
950 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
952 if(mAvailableAngles[i] == convertedAngle)
961 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
962 mAvailableAngles.push_back(convertedAngle);
965 SetAvailableAnlges(mAvailableAngles);
968 int32_t Window::GetNativeId() const
970 return mWindowBase->GetNativeWindowId();
973 } // namespace Adaptor
975 } // namespace Internal