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 mType(WindowType::NORMAL),
84 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
88 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
90 mDeleteRequestSignal(),
93 mVisibilityChangedSignal(),
94 mTransitionEffectEventSignal(),
95 mKeyboardRepeatSettingsChangedSignal()
103 auto bridge = Accessibility::Bridge::GetCurrentBridge();
104 auto accessible2 = mScene.GetRootLayer();
105 auto accessible = Accessibility::Accessible::Get(accessible2);
106 bridge->RemoveTopLevelWindow(accessible);
108 mAdaptor->RemoveWindow(this);
113 mEventHandler->RemoveObserver(*this);
117 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
119 // Create a window render surface
120 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
121 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
122 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
125 mWindowBase = mWindowSurface->GetWindowBase();
128 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
129 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
130 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
131 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
132 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
133 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
134 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
136 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
138 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
140 SetClass(name, className);
142 mOrientation = Orientation::New(this);
144 // Get OrientationMode
145 int screenWidth, screenHeight;
146 WindowSystem::GetScreenSize(screenWidth, screenHeight);
147 if(screenWidth > screenHeight)
149 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
153 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
156 mNativeWindowId = mWindowBase->GetNativeWindowId();
159 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
161 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
162 mEventHandler->AddObserver(*this);
164 auto bridge = Accessibility::Bridge::GetCurrentBridge();
165 auto v = mScene.GetRootLayer();
166 auto accessible = Accessibility::Accessible::Get(v, true);
167 bridge->AddTopLevelWindow(accessible);
169 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
170 // The show must be called after the adaptor is initialized.
174 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
176 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
179 void Window::SetClass(std::string name, std::string className)
182 mClassName = className;
183 mWindowBase->SetClass(name, className);
186 std::string Window::GetClassName() const
193 mWindowBase->Raise();
195 mSurface->SetFullSwapNextFrame();
197 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
202 mWindowBase->Lower();
204 mSurface->SetFullSwapNextFrame();
206 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
209 void Window::Activate()
211 mWindowBase->Activate();
213 mSurface->SetFullSwapNextFrame();
215 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
218 uint32_t Window::GetLayerCount() const
220 return mScene.GetLayerCount();
223 Dali::Layer Window::GetLayer(uint32_t depth) const
225 return mScene.GetLayer(depth);
228 Dali::RenderTaskList Window::GetRenderTaskList() const
230 return mScene.GetRenderTaskList();
233 void Window::AddAvailableOrientation(WindowOrientation orientation)
235 if(IsOrientationAvailable(orientation) == false)
241 int convertedAngle = ConvertToAngle(orientation);
242 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
243 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
245 if(mAvailableAngles[i] == convertedAngle)
254 mAvailableAngles.push_back(convertedAngle);
255 SetAvailableAnlges(mAvailableAngles);
259 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
261 if(IsOrientationAvailable(orientation) == false)
266 int convertedAngle = ConvertToAngle(orientation);
267 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
268 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
269 iter != mAvailableAngles.end();
272 if(*iter == convertedAngle)
274 mAvailableAngles.erase(iter);
279 SetAvailableAnlges(mAvailableAngles);
282 void Window::SetPreferredOrientation(WindowOrientation orientation)
284 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
286 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
289 mPreferredAngle = ConvertToAngle(orientation);
290 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
291 mWindowBase->SetPreferredAngle(mPreferredAngle);
294 WindowOrientation Window::GetPreferredOrientation()
296 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
297 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
298 return preferredOrientation;
301 void Window::SetAvailableAnlges(const std::vector<int>& angles)
303 if(angles.size() > 4)
305 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
309 mWindowBase->SetAvailableAnlges(angles);
312 int Window::ConvertToAngle(WindowOrientation orientation)
314 int convertAngle = static_cast<int>(orientation);
315 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
319 case WindowOrientation::LANDSCAPE:
324 case WindowOrientation::PORTRAIT:
329 case WindowOrientation::LANDSCAPE_INVERSE:
334 case WindowOrientation::PORTRAIT_INVERSE:
339 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
349 WindowOrientation Window::ConvertToOrientation(int angle) const
351 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
352 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
358 orientation = WindowOrientation::LANDSCAPE;
363 orientation = WindowOrientation::PORTRAIT;
368 orientation = WindowOrientation::LANDSCAPE_INVERSE;
373 orientation = WindowOrientation::PORTRAIT_INVERSE;
378 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
386 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
388 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
390 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
396 Dali::Any Window::GetNativeHandle() const
398 return mWindowSurface->GetNativeWindow();
401 void Window::SetAcceptFocus(bool accept)
403 mIsFocusAcceptable = accept;
405 mWindowBase->SetAcceptFocus(accept);
408 bool Window::IsFocusAcceptable() const
410 return mIsFocusAcceptable;
421 WindowVisibilityObserver* observer(mAdaptor);
422 observer->OnWindowShown();
424 Dali::Window handle(this);
425 mVisibilityChangedSignal.Emit(handle, true);
428 mSurface->SetFullSwapNextFrame();
430 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
441 WindowVisibilityObserver* observer(mAdaptor);
442 observer->OnWindowHidden();
444 Dali::Window handle(this);
445 mVisibilityChangedSignal.Emit(handle, false);
448 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
451 bool Window::IsVisible() const
453 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
454 return mVisible && !mIconified;
457 unsigned int Window::GetSupportedAuxiliaryHintCount() const
459 return mWindowBase->GetSupportedAuxiliaryHintCount();
462 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
464 return mWindowBase->GetSupportedAuxiliaryHint(index);
467 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
469 return mWindowBase->AddAuxiliaryHint(hint, value);
472 bool Window::RemoveAuxiliaryHint(unsigned int id)
474 return mWindowBase->RemoveAuxiliaryHint(id);
477 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
479 return mWindowBase->SetAuxiliaryHintValue(id, value);
482 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
484 return mWindowBase->GetAuxiliaryHintValue(id);
487 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
489 return mWindowBase->GetAuxiliaryHintId(hint);
492 void Window::SetInputRegion(const Rect<int>& inputRegion)
494 mWindowBase->SetInputRegion(inputRegion);
496 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);
499 void Window::SetType(WindowType type)
503 mWindowBase->SetType(type);
509 WindowType Window::GetType() const
514 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
516 if(mType != WindowType::NOTIFICATION)
518 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType);
519 return WindowOperationResult::INVALID_OPERATION;
522 return mWindowBase->SetNotificationLevel(level);
525 WindowNotificationLevel Window::GetNotificationLevel() const
527 if(mType != WindowType::NOTIFICATION)
529 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType);
530 return WindowNotificationLevel::NONE;
533 return mWindowBase->GetNotificationLevel();
536 void Window::SetOpaqueState(bool opaque)
538 mOpaqueState = opaque;
540 mWindowBase->SetOpaqueState(opaque);
542 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
545 bool Window::IsOpaqueState() const
550 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
552 return mWindowBase->SetScreenOffMode(screenOffMode);
555 WindowScreenOffMode Window::GetScreenOffMode() const
557 return mWindowBase->GetScreenOffMode();
560 WindowOperationResult Window::SetBrightness(int brightness)
562 if(brightness < 0 || brightness > 100)
564 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
565 return WindowOperationResult::INVALID_OPERATION;
568 return mWindowBase->SetBrightness(brightness);
571 int Window::GetBrightness() const
573 return mWindowBase->GetBrightness();
576 void Window::SetSize(Dali::Window::WindowSize size)
578 PositionSize oldRect = mSurface->GetPositionSize();
580 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
582 PositionSize newRect = mSurface->GetPositionSize();
584 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
585 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
587 Uint16Pair newSize(newRect.width, newRect.height);
591 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
593 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
595 Dali::Window handle(this);
596 mResizeSignal.Emit(handle, newSize);
598 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
601 mSurface->SetFullSwapNextFrame();
604 Dali::Window::WindowSize Window::GetSize() const
606 PositionSize positionSize = mSurface->GetPositionSize();
608 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
611 void Window::SetPosition(Dali::Window::WindowPosition position)
613 PositionSize oldRect = mSurface->GetPositionSize();
615 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
617 mSurface->SetFullSwapNextFrame();
620 Dali::Window::WindowPosition Window::GetPosition() const
622 PositionSize positionSize = mSurface->GetPositionSize();
624 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
627 void Window::SetPositionSize(PositionSize positionSize)
629 PositionSize oldRect = mSurface->GetPositionSize();
631 mWindowSurface->MoveResize(positionSize);
633 PositionSize newRect = mSurface->GetPositionSize();
635 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
636 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
638 Uint16Pair newSize(newRect.width, newRect.height);
642 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
644 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
645 Dali::Window handle(this);
646 mResizeSignal.Emit(handle, newSize);
647 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
650 mSurface->SetFullSwapNextFrame();
653 PositionSize Window::GetPositionSize() const
655 return mSurface->GetPositionSize();
658 Dali::Layer Window::GetRootLayer() const
660 return mScene.GetRootLayer();
663 void Window::SetTransparency(bool transparent)
665 mWindowSurface->SetTransparency(transparent);
668 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
670 return mWindowBase->GrabKey(key, grabMode);
673 bool Window::UngrabKey(Dali::KEY key)
675 return mWindowBase->UngrabKey(key);
678 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
680 return mWindowBase->GrabKeyList(key, grabMode, result);
683 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
685 return mWindowBase->UngrabKeyList(key, result);
688 void Window::OnIconifyChanged(bool iconified)
696 WindowVisibilityObserver* observer(mAdaptor);
697 observer->OnWindowHidden();
699 Dali::Window handle(this);
700 mVisibilityChangedSignal.Emit(handle, false);
703 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
711 WindowVisibilityObserver* observer(mAdaptor);
712 observer->OnWindowShown();
714 Dali::Window handle(this);
715 mVisibilityChangedSignal.Emit(handle, true);
718 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
721 mSurface->SetFullSwapNextFrame();
724 void Window::OnFocusChanged(bool focusIn)
726 Dali::Window handle(this);
727 mFocusChangeSignal.Emit(handle, focusIn);
729 mSurface->SetFullSwapNextFrame();
731 if(auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
735 b->ApplicationShown();
739 b->ApplicationHidden();
744 void Window::OnOutputTransformed()
746 PositionSize positionSize = mSurface->GetPositionSize();
748 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
749 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
751 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
752 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
755 void Window::OnDeleteRequest()
757 mDeleteRequestSignal.Emit();
760 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
762 Dali::Window handle(this);
763 mTransitionEffectEventSignal.Emit(handle, state, type);
766 void Window::OnKeyboardRepeatSettingsChanged()
768 Dali::Window handle(this);
769 mKeyboardRepeatSettingsChangedSignal.Emit();
772 void Window::OnWindowRedrawRequest()
774 mAdaptor->RenderOnce();
777 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
779 SetPositionSize(positionSize);
782 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
784 FeedTouchPoint(point, timeStamp);
787 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
789 FeedWheelEvent(wheelEvent);
792 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
794 FeedKeyEvent(keyEvent);
797 void Window::OnRotation(const RotationEvent& rotation)
799 mRotationAngle = rotation.angle;
800 mWindowWidth = rotation.width;
801 mWindowHeight = rotation.height;
803 // Notify that the orientation is changed
804 mOrientation->OnOrientationChange(rotation);
806 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
808 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
809 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
811 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
813 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
815 Dali::Window handle(this);
816 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
818 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
821 void Window::OnPause()
825 mEventHandler->Pause();
829 void Window::OnResume()
833 mEventHandler->Resume();
836 mSurface->SetFullSwapNextFrame();
839 void Window::RecalculateTouchPosition(Integration::Point& point)
841 Vector2 position = point.GetScreenPosition();
842 Vector2 convertedPosition;
844 switch(mRotationAngle)
848 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
849 convertedPosition.y = position.x;
854 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
855 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
860 convertedPosition.x = position.y;
861 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
866 convertedPosition = position;
871 point.SetScreenPosition(convertedPosition);
874 Dali::Window Window::Get(Dali::Actor actor)
876 Internal::Adaptor::Window* windowImpl = nullptr;
878 if(Internal::Adaptor::Adaptor::IsAvailable())
880 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
881 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
884 return Dali::Window(windowImpl);
888 return Dali::Window();
891 void Window::SetParent(Dali::Window& parent)
893 if(DALI_UNLIKELY(parent))
895 mParentWindow = parent;
896 Dali::Window self = Dali::Window(this);
897 // check circular parent window setting
898 if(Dali::DevelWindow::GetParent(parent) == self)
900 Dali::DevelWindow::Unparent(parent);
902 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
906 void Window::Unparent()
908 mWindowBase->SetParent(nullptr);
909 mParentWindow.Reset();
912 Dali::Window Window::GetParent()
914 return mParentWindow;
917 WindowOrientation Window::GetCurrentOrientation() const
919 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
920 return ConvertToOrientation(mRotationAngle);
923 int Window::GetPhysicalOrientation() const
925 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
928 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
930 Dali::Vector<float>::SizeType count = orientations.Count();
931 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
933 if(IsOrientationAvailable(orientations[index]) == false)
935 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
940 int convertedAngle = ConvertToAngle(orientations[index]);
942 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
944 if(mAvailableAngles[i] == convertedAngle)
953 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
954 mAvailableAngles.push_back(convertedAngle);
957 SetAvailableAnlges(mAvailableAngles);
960 int32_t Window::GetNativeId() const
962 return mWindowBase->GetNativeWindowId();
965 } // namespace Adaptor
967 } // namespace Internal