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();
603 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
606 Dali::Window::WindowSize Window::GetSize() const
608 PositionSize positionSize = mSurface->GetPositionSize();
610 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
613 void Window::SetPosition(Dali::Window::WindowPosition position)
615 PositionSize oldRect = mSurface->GetPositionSize();
617 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
619 mSurface->SetFullSwapNextFrame();
621 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
624 Dali::Window::WindowPosition Window::GetPosition() const
626 PositionSize positionSize = mSurface->GetPositionSize();
628 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
631 void Window::SetPositionSize(PositionSize positionSize)
633 PositionSize oldRect = mSurface->GetPositionSize();
635 mWindowSurface->MoveResize(positionSize);
637 PositionSize newRect = mSurface->GetPositionSize();
639 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
640 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
642 Uint16Pair newSize(newRect.width, newRect.height);
646 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
648 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
649 Dali::Window handle(this);
650 mResizeSignal.Emit(handle, newSize);
651 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
654 mSurface->SetFullSwapNextFrame();
656 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
659 PositionSize Window::GetPositionSize() const
661 return mSurface->GetPositionSize();
664 Dali::Layer Window::GetRootLayer() const
666 return mScene.GetRootLayer();
669 void Window::SetTransparency(bool transparent)
671 mWindowSurface->SetTransparency(transparent);
674 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
676 return mWindowBase->GrabKey(key, grabMode);
679 bool Window::UngrabKey(Dali::KEY key)
681 return mWindowBase->UngrabKey(key);
684 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
686 return mWindowBase->GrabKeyList(key, grabMode, result);
689 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
691 return mWindowBase->UngrabKeyList(key, result);
694 void Window::OnIconifyChanged(bool iconified)
702 WindowVisibilityObserver* observer(mAdaptor);
703 observer->OnWindowHidden();
705 Dali::Window handle(this);
706 mVisibilityChangedSignal.Emit(handle, false);
709 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
717 WindowVisibilityObserver* observer(mAdaptor);
718 observer->OnWindowShown();
720 Dali::Window handle(this);
721 mVisibilityChangedSignal.Emit(handle, true);
724 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
727 mSurface->SetFullSwapNextFrame();
730 void Window::OnFocusChanged(bool focusIn)
732 Dali::Window handle(this);
733 mFocusChangeSignal.Emit(handle, focusIn);
735 mSurface->SetFullSwapNextFrame();
737 if(auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
741 b->ApplicationShown();
745 b->ApplicationHidden();
750 void Window::OnOutputTransformed()
752 PositionSize positionSize = mSurface->GetPositionSize();
754 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
755 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
757 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
758 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
761 void Window::OnDeleteRequest()
763 mDeleteRequestSignal.Emit();
766 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
768 Dali::Window handle(this);
769 mTransitionEffectEventSignal.Emit(handle, state, type);
772 void Window::OnKeyboardRepeatSettingsChanged()
774 Dali::Window handle(this);
775 mKeyboardRepeatSettingsChangedSignal.Emit();
778 void Window::OnWindowRedrawRequest()
780 mAdaptor->RenderOnce();
783 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
785 SetPositionSize(positionSize);
788 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
790 FeedTouchPoint(point, timeStamp);
793 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
795 FeedWheelEvent(wheelEvent);
798 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
800 FeedKeyEvent(keyEvent);
803 void Window::OnRotation(const RotationEvent& rotation)
805 mRotationAngle = rotation.angle;
806 mWindowWidth = rotation.width;
807 mWindowHeight = rotation.height;
809 // Notify that the orientation is changed
810 mOrientation->OnOrientationChange(rotation);
812 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
814 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
815 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
817 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
819 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
821 Dali::Window handle(this);
822 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
824 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
827 void Window::OnPause()
831 mEventHandler->Pause();
835 void Window::OnResume()
839 mEventHandler->Resume();
842 mSurface->SetFullSwapNextFrame();
845 void Window::RecalculateTouchPosition(Integration::Point& point)
847 Vector2 position = point.GetScreenPosition();
848 Vector2 convertedPosition;
850 switch(mRotationAngle)
854 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
855 convertedPosition.y = position.x;
860 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
861 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
866 convertedPosition.x = position.y;
867 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
872 convertedPosition = position;
877 point.SetScreenPosition(convertedPosition);
880 Dali::Window Window::Get(Dali::Actor actor)
882 Internal::Adaptor::Window* windowImpl = nullptr;
884 if(Internal::Adaptor::Adaptor::IsAvailable())
886 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
887 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
890 return Dali::Window(windowImpl);
894 return Dali::Window();
897 void Window::SetParent(Dali::Window& parent)
899 if(DALI_UNLIKELY(parent))
901 mParentWindow = parent;
902 Dali::Window self = Dali::Window(this);
903 // check circular parent window setting
904 if(Dali::DevelWindow::GetParent(parent) == self)
906 Dali::DevelWindow::Unparent(parent);
908 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
912 void Window::Unparent()
914 mWindowBase->SetParent(nullptr);
915 mParentWindow.Reset();
918 Dali::Window Window::GetParent()
920 return mParentWindow;
923 WindowOrientation Window::GetCurrentOrientation() const
925 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
926 return ConvertToOrientation(mRotationAngle);
929 int Window::GetPhysicalOrientation() const
931 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
934 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
936 Dali::Vector<float>::SizeType count = orientations.Count();
937 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
939 if(IsOrientationAvailable(orientations[index]) == false)
941 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
946 int convertedAngle = ConvertToAngle(orientations[index]);
948 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
950 if(mAvailableAngles[i] == convertedAngle)
959 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
960 mAvailableAngles.push_back(convertedAngle);
963 SetAvailableAnlges(mAvailableAngles);
966 int32_t Window::GetNativeId() const
968 return mWindowBase->GetNativeWindowId();
971 } // namespace Adaptor
973 } // namespace Internal