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, Dali::WindowType type, bool isTransparent)
64 return Window::New(surface, positionSize, name, className, type, isTransparent);
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
69 Window* window = new Window();
70 window->mIsTransparent = isTransparent;
71 window->Initialize(surface, positionSize, name, className, type);
76 : mWindowSurface(nullptr),
78 mIsTransparent(false),
79 mIsFocusAcceptable(true),
82 mWindowRotationAcknowledgement(false),
84 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
88 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
90 mDeleteRequestSignal(),
93 mVisibilityChangedSignal(),
94 mTransitionEffectEventSignal(),
95 mKeyboardRepeatSettingsChangedSignal(),
96 mAuxiliaryMessageSignal()
102 auto bridge = Accessibility::Bridge::GetCurrentBridge();
103 auto rootLayer = mScene.GetRootLayer();
104 auto accessible = Accessibility::Accessible::Get(rootLayer);
105 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, WindowType type)
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->SetType(type);
131 // Initialize for Ime window type
132 if(type == WindowType::IME)
134 mWindowBase->InitializeIme();
135 mWindowSurface->InitializeImeSurface();
139 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
140 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
141 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
142 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
143 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
144 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
145 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
146 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
148 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
150 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
152 SetClass(name, className);
154 mOrientation = Orientation::New(this);
156 // Get OrientationMode
157 int screenWidth, screenHeight;
158 WindowSystem::GetScreenSize(screenWidth, screenHeight);
159 if(screenWidth > screenHeight)
161 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
165 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
168 mNativeWindowId = mWindowBase->GetNativeWindowId();
171 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
173 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
174 mEventHandler->AddObserver(*this);
176 // Add Window to bridge for ATSPI
177 auto bridge = Accessibility::Bridge::GetCurrentBridge();
178 auto rootLayer = mScene.GetRootLayer();
179 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
180 bridge->AddTopLevelWindow(accessible);
182 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
183 // The show must be called after the adaptor is initialized.
187 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
189 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
192 void Window::SetClass(std::string name, std::string className)
195 mClassName = className;
196 mWindowBase->SetClass(name, className);
199 std::string Window::GetClassName() const
206 mWindowBase->Raise();
208 mSurface->SetFullSwapNextFrame();
210 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
215 mWindowBase->Lower();
217 mSurface->SetFullSwapNextFrame();
219 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
222 void Window::Activate()
224 mWindowBase->Activate();
226 mSurface->SetFullSwapNextFrame();
228 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
231 uint32_t Window::GetLayerCount() const
233 return mScene.GetLayerCount();
236 Dali::Layer Window::GetLayer(uint32_t depth) const
238 return mScene.GetLayer(depth);
241 Dali::RenderTaskList Window::GetRenderTaskList() const
243 return mScene.GetRenderTaskList();
246 void Window::AddAvailableOrientation(WindowOrientation orientation)
248 if(IsOrientationAvailable(orientation) == false)
254 int convertedAngle = ConvertToAngle(orientation);
255 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
256 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
258 if(mAvailableAngles[i] == convertedAngle)
267 mAvailableAngles.push_back(convertedAngle);
268 SetAvailableAnlges(mAvailableAngles);
272 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
274 if(IsOrientationAvailable(orientation) == false)
279 int convertedAngle = ConvertToAngle(orientation);
280 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
281 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
282 iter != mAvailableAngles.end();
285 if(*iter == convertedAngle)
287 mAvailableAngles.erase(iter);
292 SetAvailableAnlges(mAvailableAngles);
295 void Window::SetPreferredOrientation(WindowOrientation orientation)
297 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
299 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
302 mPreferredAngle = ConvertToAngle(orientation);
303 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
304 mWindowBase->SetPreferredAngle(mPreferredAngle);
307 WindowOrientation Window::GetPreferredOrientation()
309 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
310 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
311 return preferredOrientation;
314 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
316 int angle = ConvertToAngle(orientation);
317 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
320 void Window::SetAvailableAnlges(const std::vector<int>& angles)
322 if(angles.size() > 4)
324 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
328 mWindowBase->SetAvailableAnlges(angles);
331 int Window::ConvertToAngle(WindowOrientation orientation)
333 int convertAngle = static_cast<int>(orientation);
334 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
338 case WindowOrientation::LANDSCAPE:
343 case WindowOrientation::PORTRAIT:
348 case WindowOrientation::LANDSCAPE_INVERSE:
353 case WindowOrientation::PORTRAIT_INVERSE:
358 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
368 WindowOrientation Window::ConvertToOrientation(int angle) const
370 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
371 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
377 orientation = WindowOrientation::LANDSCAPE;
382 orientation = WindowOrientation::PORTRAIT;
387 orientation = WindowOrientation::LANDSCAPE_INVERSE;
392 orientation = WindowOrientation::PORTRAIT_INVERSE;
397 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
405 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
407 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
409 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
415 Dali::Any Window::GetNativeHandle() const
417 return mWindowSurface->GetNativeWindow();
420 void Window::SetAcceptFocus(bool accept)
422 mIsFocusAcceptable = accept;
424 mWindowBase->SetAcceptFocus(accept);
427 bool Window::IsFocusAcceptable() const
429 return mIsFocusAcceptable;
440 Dali::Window handle(this);
441 mVisibilityChangedSignal.Emit(handle, true);
443 WindowVisibilityObserver* observer(mAdaptor);
444 observer->OnWindowShown();
447 mSurface->SetFullSwapNextFrame();
449 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
460 Dali::Window handle(this);
461 mVisibilityChangedSignal.Emit(handle, false);
463 WindowVisibilityObserver* observer(mAdaptor);
464 observer->OnWindowHidden();
467 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
470 bool Window::IsVisible() const
472 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
473 return mVisible && !mIconified;
476 unsigned int Window::GetSupportedAuxiliaryHintCount() const
478 return mWindowBase->GetSupportedAuxiliaryHintCount();
481 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
483 return mWindowBase->GetSupportedAuxiliaryHint(index);
486 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
488 return mWindowBase->AddAuxiliaryHint(hint, value);
491 bool Window::RemoveAuxiliaryHint(unsigned int id)
493 return mWindowBase->RemoveAuxiliaryHint(id);
496 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
498 return mWindowBase->SetAuxiliaryHintValue(id, value);
501 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
503 return mWindowBase->GetAuxiliaryHintValue(id);
506 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
508 return mWindowBase->GetAuxiliaryHintId(hint);
511 void Window::SetInputRegion(const Rect<int>& inputRegion)
513 Rect<int> convertRegion = RecalculateRect(inputRegion);
515 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window (%p), WinId (%d), SetInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
517 mWindowBase->SetInputRegion(convertRegion);
520 void Window::SetType(WindowType type)
522 mWindowBase->SetType(type);
525 WindowType Window::GetType() const
527 return mWindowBase->GetType();
530 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
532 WindowType type = mWindowBase->GetType();
533 if(type != WindowType::NOTIFICATION)
535 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
536 return WindowOperationResult::INVALID_OPERATION;
539 return mWindowBase->SetNotificationLevel(level);
542 WindowNotificationLevel Window::GetNotificationLevel() const
544 WindowType type = mWindowBase->GetType();
545 if(type != WindowType::NOTIFICATION)
547 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
548 return WindowNotificationLevel::NONE;
551 return mWindowBase->GetNotificationLevel();
554 void Window::SetOpaqueState(bool opaque)
556 mOpaqueState = opaque;
558 mWindowBase->SetOpaqueState(opaque);
560 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
563 bool Window::IsOpaqueState() const
568 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
570 return mWindowBase->SetScreenOffMode(screenOffMode);
573 WindowScreenOffMode Window::GetScreenOffMode() const
575 return mWindowBase->GetScreenOffMode();
578 WindowOperationResult Window::SetBrightness(int brightness)
580 if(brightness < 0 || brightness > 100)
582 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
583 return WindowOperationResult::INVALID_OPERATION;
586 return mWindowBase->SetBrightness(brightness);
589 int Window::GetBrightness() const
591 return mWindowBase->GetBrightness();
594 void Window::SetSize(Dali::Window::WindowSize size)
596 PositionSize oldRect = mSurface->GetPositionSize();
598 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
600 PositionSize newRect = mSurface->GetPositionSize();
602 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
603 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
605 Uint16Pair newSize(newRect.width, newRect.height);
609 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
611 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
613 Dali::Window handle(this);
614 mResizeSignal.Emit(handle, newSize);
616 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
619 mSurface->SetFullSwapNextFrame();
621 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
624 Dali::Window::WindowSize Window::GetSize() const
626 PositionSize positionSize = mSurface->GetPositionSize();
628 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
631 void Window::SetPosition(Dali::Window::WindowPosition position)
633 PositionSize oldRect = mSurface->GetPositionSize();
635 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
637 mSurface->SetFullSwapNextFrame();
639 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
642 Dali::Window::WindowPosition Window::GetPosition() const
644 PositionSize positionSize = mSurface->GetPositionSize();
646 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
649 PositionSize Window::GetPositionSize() const
651 return mSurface->GetPositionSize();
654 void Window::SetPositionSize(PositionSize positionSize)
656 PositionSize oldRect = mSurface->GetPositionSize();
658 mWindowSurface->MoveResize(positionSize);
660 PositionSize newRect = mSurface->GetPositionSize();
662 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
663 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
665 Uint16Pair newSize(newRect.width, newRect.height);
669 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
671 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
672 Dali::Window handle(this);
673 mResizeSignal.Emit(handle, newSize);
674 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
677 mSurface->SetFullSwapNextFrame();
679 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
682 Dali::Layer Window::GetRootLayer() const
684 return mScene.GetRootLayer();
687 void Window::SetTransparency(bool transparent)
689 mWindowSurface->SetTransparency(transparent);
692 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
694 return mWindowBase->GrabKey(key, grabMode);
697 bool Window::UngrabKey(Dali::KEY key)
699 return mWindowBase->UngrabKey(key);
702 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
704 return mWindowBase->GrabKeyList(key, grabMode, result);
707 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
709 return mWindowBase->UngrabKeyList(key, result);
712 void Window::OnIconifyChanged(bool iconified)
720 Dali::Window handle(this);
721 mVisibilityChangedSignal.Emit(handle, false);
723 WindowVisibilityObserver* observer(mAdaptor);
724 observer->OnWindowHidden();
727 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
735 Dali::Window handle(this);
736 mVisibilityChangedSignal.Emit(handle, true);
738 WindowVisibilityObserver* observer(mAdaptor);
739 observer->OnWindowShown();
742 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
745 mSurface->SetFullSwapNextFrame();
748 void Window::OnFocusChanged(bool focusIn)
750 Dali::Window handle(this);
751 mFocusChangeSignal.Emit(handle, focusIn);
753 mSurface->SetFullSwapNextFrame();
755 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
759 bridge->WindowFocused(handle);
763 bridge->WindowUnfocused(handle);
768 void Window::OnOutputTransformed()
770 PositionSize positionSize = mSurface->GetPositionSize();
772 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
773 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
775 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
776 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
779 void Window::OnDeleteRequest()
781 mDeleteRequestSignal.Emit();
784 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
786 Dali::Window handle(this);
787 mTransitionEffectEventSignal.Emit(handle, state, type);
790 void Window::OnKeyboardRepeatSettingsChanged()
792 Dali::Window handle(this);
793 mKeyboardRepeatSettingsChangedSignal.Emit();
796 void Window::OnWindowRedrawRequest()
798 mAdaptor->RenderOnce();
801 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
803 SetPositionSize(positionSize);
806 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
808 FeedTouchPoint(point, timeStamp);
811 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
813 FeedWheelEvent(wheelEvent);
816 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
818 FeedKeyEvent(keyEvent);
821 void Window::OnRotation(const RotationEvent& rotation)
823 mRotationAngle = rotation.angle;
824 mWindowWidth = rotation.width;
825 mWindowHeight = rotation.height;
827 // Notify that the orientation is changed
828 mOrientation->OnOrientationChange(rotation);
830 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
832 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
833 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
835 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
837 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
839 Dali::Window handle(this);
840 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
842 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
845 void Window::OnPause()
849 mEventHandler->Pause();
853 void Window::OnResume()
857 mEventHandler->Resume();
860 mSurface->SetFullSwapNextFrame();
863 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
865 mAuxiliaryMessageSignal.Emit(key, value, options);
868 void Window::RecalculateTouchPosition(Integration::Point& point)
870 Vector2 position = point.GetScreenPosition();
871 Vector2 convertedPosition;
873 switch(mRotationAngle)
877 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
878 convertedPosition.y = position.x;
883 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
884 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
889 convertedPosition.x = position.y;
890 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
895 convertedPosition = position;
900 point.SetScreenPosition(convertedPosition);
903 Dali::Window Window::Get(Dali::Actor actor)
905 Internal::Adaptor::Window* windowImpl = nullptr;
907 if(Internal::Adaptor::Adaptor::IsAvailable())
909 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
910 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
913 return Dali::Window(windowImpl);
917 return Dali::Window();
920 void Window::SetParent(Dali::Window& parent)
922 if(DALI_UNLIKELY(parent))
924 mParentWindow = parent;
925 Dali::Window self = Dali::Window(this);
926 // check circular parent window setting
927 if(Dali::DevelWindow::GetParent(parent) == self)
929 Dali::DevelWindow::Unparent(parent);
931 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
935 void Window::SetParent(Dali::Window& parent, bool belowParent)
937 if(DALI_UNLIKELY(parent))
939 mParentWindow = parent;
940 Dali::Window self = Dali::Window(this);
941 // check circular parent window setting
942 if(Dali::DevelWindow::GetParent(parent) == self)
944 Dali::DevelWindow::Unparent(parent);
946 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
950 void Window::Unparent()
952 mWindowBase->SetParent(nullptr, false);
953 mParentWindow.Reset();
956 Dali::Window Window::GetParent()
958 return mParentWindow;
961 WindowOrientation Window::GetCurrentOrientation() const
963 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
964 return ConvertToOrientation(mRotationAngle);
967 int Window::GetPhysicalOrientation() const
969 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
972 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
974 Dali::Vector<float>::SizeType count = orientations.Count();
975 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
977 if(IsOrientationAvailable(orientations[index]) == false)
979 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
984 int convertedAngle = ConvertToAngle(orientations[index]);
986 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
988 if(mAvailableAngles[i] == convertedAngle)
997 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
998 mAvailableAngles.push_back(convertedAngle);
1001 SetAvailableAnlges(mAvailableAngles);
1004 int32_t Window::GetNativeId() const
1006 return mWindowBase->GetNativeWindowId();
1009 void Window::RequestMoveToServer()
1011 mWindowBase->RequestMoveToServer();
1014 void Window::RequestResizeToServer(WindowResizeDirection direction)
1016 mWindowBase->RequestResizeToServer(direction);
1019 void Window::EnableFloatingMode(bool enable)
1021 mWindowBase->EnableFloatingMode(enable);
1024 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1027 int screenWidth, screenHeight;
1029 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1031 if(mRotationAngle == 90)
1034 newRect.y = screenHeight - (rect.x + rect.width);
1035 newRect.width = rect.height;
1036 newRect.height = rect.width;
1038 else if(mRotationAngle == 180)
1040 newRect.x = screenWidth - (rect.x + rect.width);
1041 newRect.y = screenHeight - (rect.y + rect.height);
1042 newRect.width = rect.width;
1043 newRect.height = rect.height;
1045 else if(mRotationAngle == 270)
1047 newRect.x = screenWidth - (rect.y + rect.height);
1049 newRect.width = rect.height;
1050 newRect.height = rect.width;
1056 newRect.width = rect.width;
1057 newRect.height = rect.height;
1062 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1064 Rect<int> convertRegion = RecalculateRect(inputRegion);
1066 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
1067 mWindowBase->IncludeInputRegion(convertRegion);
1070 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1072 Rect<int> convertRegion = RecalculateRect(inputRegion);
1074 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
1075 mWindowBase->ExcludeInputRegion(convertRegion);
1078 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1080 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1081 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1082 mWindowRotationAcknowledgement = needAcknowledgement;
1085 void Window::SendRotationCompletedAcknowledgement()
1087 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1088 if(mWindowRotationAcknowledgement)
1090 SetRotationCompletedAcknowledgement();
1094 } // namespace Adaptor
1096 } // namespace Internal