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 mOrientation = Orientation::New(this);
148 // Get OrientationMode
149 int screenWidth, screenHeight;
150 WindowSystem::GetScreenSize(screenWidth, screenHeight);
151 if(screenWidth > screenHeight)
153 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
157 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
160 mNativeWindowId = mWindowBase->GetNativeWindowId();
163 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
165 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
166 mEventHandler->AddObserver(*this);
168 auto bridge = Accessibility::Bridge::GetCurrentBridge();
169 auto v = mScene.GetRootLayer();
170 auto accessible = Accessibility::Accessible::Get(v, true);
171 bridge->AddTopLevelWindow(accessible);
173 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
174 // The show must be called after the adaptor is initialized.
178 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
180 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
183 void Window::SetClass(std::string name, std::string className)
186 mClassName = className;
187 mWindowBase->SetClass(name, className);
190 std::string Window::GetClassName() const
197 mWindowBase->Raise();
199 mSurface->SetFullSwapNextFrame();
201 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
206 mWindowBase->Lower();
208 mSurface->SetFullSwapNextFrame();
210 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
213 void Window::Activate()
215 mWindowBase->Activate();
217 mSurface->SetFullSwapNextFrame();
219 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
222 uint32_t Window::GetLayerCount() const
224 return mScene.GetLayerCount();
227 Dali::Layer Window::GetLayer(uint32_t depth) const
229 return mScene.GetLayer(depth);
232 Dali::RenderTaskList Window::GetRenderTaskList() const
234 return mScene.GetRenderTaskList();
237 void Window::AddAvailableOrientation(WindowOrientation orientation)
239 if(IsOrientationAvailable(orientation) == false)
245 int convertedAngle = ConvertToAngle(orientation);
246 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
247 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
249 if(mAvailableAngles[i] == convertedAngle)
258 mAvailableAngles.push_back(convertedAngle);
259 SetAvailableAnlges(mAvailableAngles);
263 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
265 if(IsOrientationAvailable(orientation) == false)
270 int convertedAngle = ConvertToAngle(orientation);
271 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
272 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
273 iter != mAvailableAngles.end();
276 if(*iter == convertedAngle)
278 mAvailableAngles.erase(iter);
283 SetAvailableAnlges(mAvailableAngles);
286 void Window::SetPreferredOrientation(WindowOrientation orientation)
288 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
290 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
293 mPreferredAngle = ConvertToAngle(orientation);
294 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
295 mWindowBase->SetPreferredAngle(mPreferredAngle);
298 WindowOrientation Window::GetPreferredOrientation()
300 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
301 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
302 return preferredOrientation;
305 void Window::SetAvailableAnlges(const std::vector<int>& angles)
307 if(angles.size() > 4)
309 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
313 mWindowBase->SetAvailableAnlges(angles);
316 int Window::ConvertToAngle(WindowOrientation orientation)
318 int convertAngle = static_cast<int>(orientation);
319 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
323 case WindowOrientation::LANDSCAPE:
328 case WindowOrientation::PORTRAIT:
333 case WindowOrientation::LANDSCAPE_INVERSE:
338 case WindowOrientation::PORTRAIT_INVERSE:
343 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
353 WindowOrientation Window::ConvertToOrientation(int angle) const
355 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
356 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
362 orientation = WindowOrientation::LANDSCAPE;
367 orientation = WindowOrientation::PORTRAIT;
372 orientation = WindowOrientation::LANDSCAPE_INVERSE;
377 orientation = WindowOrientation::PORTRAIT_INVERSE;
382 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
390 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
392 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
394 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
400 Dali::Any Window::GetNativeHandle() const
402 return mWindowSurface->GetNativeWindow();
405 void Window::SetAcceptFocus(bool accept)
407 mIsFocusAcceptable = accept;
409 mWindowBase->SetAcceptFocus(accept);
412 bool Window::IsFocusAcceptable() const
414 return mIsFocusAcceptable;
425 WindowVisibilityObserver* observer(mAdaptor);
426 observer->OnWindowShown();
428 Dali::Window handle(this);
429 mVisibilityChangedSignal.Emit(handle, true);
432 mSurface->SetFullSwapNextFrame();
434 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
445 WindowVisibilityObserver* observer(mAdaptor);
446 observer->OnWindowHidden();
448 Dali::Window handle(this);
449 mVisibilityChangedSignal.Emit(handle, false);
452 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
455 bool Window::IsVisible() const
457 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
458 return mVisible && !mIconified;
461 unsigned int Window::GetSupportedAuxiliaryHintCount() const
463 return mWindowBase->GetSupportedAuxiliaryHintCount();
466 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
468 return mWindowBase->GetSupportedAuxiliaryHint(index);
471 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
473 return mWindowBase->AddAuxiliaryHint(hint, value);
476 bool Window::RemoveAuxiliaryHint(unsigned int id)
478 return mWindowBase->RemoveAuxiliaryHint(id);
481 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
483 return mWindowBase->SetAuxiliaryHintValue(id, value);
486 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
488 return mWindowBase->GetAuxiliaryHintValue(id);
491 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
493 return mWindowBase->GetAuxiliaryHintId(hint);
496 void Window::SetInputRegion(const Rect<int>& inputRegion)
498 mWindowBase->SetInputRegion(inputRegion);
500 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);
503 void Window::SetType(WindowType type)
507 mWindowBase->SetType(type);
513 WindowType Window::GetType() const
518 bool Window::SetNotificationLevel(WindowNotificationLevel level)
520 if(mType != WindowType::NOTIFICATION)
522 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType);
526 return mWindowBase->SetNotificationLevel(level);
529 WindowNotificationLevel Window::GetNotificationLevel() const
531 if(mType != WindowType::NOTIFICATION)
533 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType);
534 return WindowNotificationLevel::NONE;
537 return mWindowBase->GetNotificationLevel();
540 void Window::SetOpaqueState(bool opaque)
542 mOpaqueState = opaque;
544 mWindowBase->SetOpaqueState(opaque);
546 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
549 bool Window::IsOpaqueState() const
554 bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
556 return mWindowBase->SetScreenOffMode(screenOffMode);
559 WindowScreenOffMode Window::GetScreenOffMode() const
561 return mWindowBase->GetScreenOffMode();
564 bool Window::SetBrightness(int brightness)
566 if(brightness < 0 || brightness > 100)
568 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
572 return mWindowBase->SetBrightness(brightness);
575 int Window::GetBrightness() const
577 return mWindowBase->GetBrightness();
580 void Window::SetSize(Dali::Window::WindowSize size)
584 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
585 mResizeEnabled = true;
588 PositionSize oldRect = mSurface->GetPositionSize();
590 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
592 PositionSize newRect = mSurface->GetPositionSize();
594 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
595 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
597 Uint16Pair newSize(newRect.width, newRect.height);
601 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
603 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
605 Dali::Window handle(this);
606 mResizeSignal.Emit(handle, newSize);
608 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
611 mSurface->SetFullSwapNextFrame();
614 Dali::Window::WindowSize Window::GetSize() const
616 PositionSize positionSize = mSurface->GetPositionSize();
618 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
621 void Window::SetPosition(Dali::Window::WindowPosition position)
625 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
626 mResizeEnabled = true;
629 PositionSize oldRect = mSurface->GetPositionSize();
631 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
633 mSurface->SetFullSwapNextFrame();
636 Dali::Window::WindowPosition Window::GetPosition() const
638 PositionSize positionSize = mSurface->GetPositionSize();
640 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
643 void Window::SetPositionSize(PositionSize positionSize)
647 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
648 mResizeEnabled = true;
651 PositionSize oldRect = mSurface->GetPositionSize();
653 mWindowSurface->MoveResize(positionSize);
655 PositionSize newRect = mSurface->GetPositionSize();
657 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
658 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
660 Uint16Pair newSize(newRect.width, newRect.height);
664 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
666 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
667 Dali::Window handle(this);
668 mResizeSignal.Emit(handle, newSize);
669 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
672 mSurface->SetFullSwapNextFrame();
675 Dali::Layer Window::GetRootLayer() const
677 return mScene.GetRootLayer();
680 void Window::SetTransparency(bool transparent)
682 mWindowSurface->SetTransparency(transparent);
685 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
687 return mWindowBase->GrabKey(key, grabMode);
690 bool Window::UngrabKey(Dali::KEY key)
692 return mWindowBase->UngrabKey(key);
695 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
697 return mWindowBase->GrabKeyList(key, grabMode, result);
700 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
702 return mWindowBase->UngrabKeyList(key, result);
705 void Window::OnIconifyChanged(bool iconified)
713 WindowVisibilityObserver* observer(mAdaptor);
714 observer->OnWindowHidden();
716 Dali::Window handle(this);
717 mVisibilityChangedSignal.Emit(handle, false);
720 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
728 WindowVisibilityObserver* observer(mAdaptor);
729 observer->OnWindowShown();
731 Dali::Window handle(this);
732 mVisibilityChangedSignal.Emit(handle, true);
735 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
738 mSurface->SetFullSwapNextFrame();
741 void Window::OnFocusChanged(bool focusIn)
743 Dali::Window handle(this);
744 mFocusChangeSignal.Emit(handle, focusIn);
746 mSurface->SetFullSwapNextFrame();
748 if(auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
752 b->ApplicationShown();
756 b->ApplicationHidden();
761 void Window::OnOutputTransformed()
763 PositionSize positionSize = mSurface->GetPositionSize();
765 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
766 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
768 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
769 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
772 void Window::OnDeleteRequest()
774 mDeleteRequestSignal.Emit();
777 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
779 Dali::Window handle(this);
780 mTransitionEffectEventSignal.Emit(handle, state, type);
783 void Window::OnKeyboardRepeatSettingsChanged()
785 Dali::Window handle(this);
786 mKeyboardRepeatSettingsChangedSignal.Emit();
789 void Window::OnWindowRedrawRequest()
791 mAdaptor->RenderOnce();
794 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
796 FeedTouchPoint(point, timeStamp);
799 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
801 FeedWheelEvent(wheelEvent);
804 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
806 FeedKeyEvent(keyEvent);
809 void Window::OnRotation(const RotationEvent& rotation)
811 mRotationAngle = rotation.angle;
812 mWindowWidth = rotation.width;
813 mWindowHeight = rotation.height;
815 // Notify that the orientation is changed
816 mOrientation->OnOrientationChange(rotation);
818 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
820 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
821 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
823 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
825 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
827 Dali::Window handle(this);
828 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
830 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
833 void Window::OnPause()
837 mEventHandler->Pause();
841 void Window::OnResume()
845 mEventHandler->Resume();
848 mSurface->SetFullSwapNextFrame();
851 void Window::RecalculateTouchPosition(Integration::Point& point)
853 Vector2 position = point.GetScreenPosition();
854 Vector2 convertedPosition;
856 switch(mRotationAngle)
860 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
861 convertedPosition.y = position.x;
866 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
867 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
872 convertedPosition.x = position.y;
873 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
878 convertedPosition = position;
883 point.SetScreenPosition(convertedPosition);
886 Dali::Window Window::Get(Dali::Actor actor)
888 Internal::Adaptor::Window* windowImpl = nullptr;
890 if(Internal::Adaptor::Adaptor::IsAvailable())
892 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
893 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
896 return Dali::Window(windowImpl);
900 return Dali::Window();
903 void Window::SetParent(Dali::Window& parent)
905 if(DALI_UNLIKELY(parent))
907 mParentWindow = parent;
908 Dali::Window self = Dali::Window(this);
909 // check circular parent window setting
910 if(Dali::DevelWindow::GetParent(parent) == self)
912 Dali::DevelWindow::Unparent(parent);
914 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
918 void Window::Unparent()
920 mWindowBase->SetParent(nullptr);
921 mParentWindow.Reset();
924 Dali::Window Window::GetParent()
926 return mParentWindow;
929 WindowOrientation Window::GetCurrentOrientation() const
931 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
932 return ConvertToOrientation(mRotationAngle);
935 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
937 Dali::Vector<float>::SizeType count = orientations.Count();
938 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
940 if(IsOrientationAvailable(orientations[index]) == false)
942 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
947 int convertedAngle = ConvertToAngle(orientations[index]);
949 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
951 if(mAvailableAngles[i] == convertedAngle)
960 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
961 mAvailableAngles.push_back(convertedAngle);
964 SetAvailableAnlges(mAvailableAngles);
967 int32_t Window::GetNativeId() const
969 return mWindowBase->GetNativeWindowId();
972 } // namespace Adaptor
974 } // namespace Internal