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()
101 auto bridge = Accessibility::Bridge::GetCurrentBridge();
102 auto rootLayer = mScene.GetRootLayer();
103 auto accessible = Accessibility::Accessible::Get(rootLayer);
104 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, WindowType type)
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->SetType(type);
130 // Initialize for Ime window type
131 if(type == WindowType::IME)
133 mWindowBase->InitializeIme();
134 mWindowSurface->InitializeImeSurface();
138 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
139 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
140 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
141 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
142 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
143 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
144 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
146 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
148 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
150 SetClass(name, className);
152 mOrientation = Orientation::New(this);
154 // Get OrientationMode
155 int screenWidth, screenHeight;
156 WindowSystem::GetScreenSize(screenWidth, screenHeight);
157 if(screenWidth > screenHeight)
159 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
163 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
166 mNativeWindowId = mWindowBase->GetNativeWindowId();
169 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
171 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
172 mEventHandler->AddObserver(*this);
174 // Add Window to bridge for ATSPI
175 auto bridge = Accessibility::Bridge::GetCurrentBridge();
176 auto rootLayer = mScene.GetRootLayer();
177 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
178 bridge->AddTopLevelWindow(accessible);
180 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
181 // The show must be called after the adaptor is initialized.
185 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
187 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
190 void Window::SetClass(std::string name, std::string className)
193 mClassName = className;
194 mWindowBase->SetClass(name, className);
197 std::string Window::GetClassName() const
204 mWindowBase->Raise();
206 mSurface->SetFullSwapNextFrame();
208 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
213 mWindowBase->Lower();
215 mSurface->SetFullSwapNextFrame();
217 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
220 void Window::Activate()
222 mWindowBase->Activate();
224 mSurface->SetFullSwapNextFrame();
226 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
229 uint32_t Window::GetLayerCount() const
231 return mScene.GetLayerCount();
234 Dali::Layer Window::GetLayer(uint32_t depth) const
236 return mScene.GetLayer(depth);
239 Dali::RenderTaskList Window::GetRenderTaskList() const
241 return mScene.GetRenderTaskList();
244 void Window::AddAvailableOrientation(WindowOrientation orientation)
246 if(IsOrientationAvailable(orientation) == false)
252 int convertedAngle = ConvertToAngle(orientation);
253 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
254 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
256 if(mAvailableAngles[i] == convertedAngle)
265 mAvailableAngles.push_back(convertedAngle);
266 SetAvailableAnlges(mAvailableAngles);
270 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
272 if(IsOrientationAvailable(orientation) == false)
277 int convertedAngle = ConvertToAngle(orientation);
278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
279 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
280 iter != mAvailableAngles.end();
283 if(*iter == convertedAngle)
285 mAvailableAngles.erase(iter);
290 SetAvailableAnlges(mAvailableAngles);
293 void Window::SetPreferredOrientation(WindowOrientation orientation)
295 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
297 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
300 mPreferredAngle = ConvertToAngle(orientation);
301 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
302 mWindowBase->SetPreferredAngle(mPreferredAngle);
305 WindowOrientation Window::GetPreferredOrientation()
307 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
308 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
309 return preferredOrientation;
312 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
314 int angle = ConvertToAngle(orientation);
315 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
318 void Window::SetAvailableAnlges(const std::vector<int>& angles)
320 if(angles.size() > 4)
322 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
326 mWindowBase->SetAvailableAnlges(angles);
329 int Window::ConvertToAngle(WindowOrientation orientation)
331 int convertAngle = static_cast<int>(orientation);
332 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
336 case WindowOrientation::LANDSCAPE:
341 case WindowOrientation::PORTRAIT:
346 case WindowOrientation::LANDSCAPE_INVERSE:
351 case WindowOrientation::PORTRAIT_INVERSE:
356 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
366 WindowOrientation Window::ConvertToOrientation(int angle) const
368 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
369 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
375 orientation = WindowOrientation::LANDSCAPE;
380 orientation = WindowOrientation::PORTRAIT;
385 orientation = WindowOrientation::LANDSCAPE_INVERSE;
390 orientation = WindowOrientation::PORTRAIT_INVERSE;
395 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
403 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
405 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
407 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
413 Dali::Any Window::GetNativeHandle() const
415 return mWindowSurface->GetNativeWindow();
418 void Window::SetAcceptFocus(bool accept)
420 mIsFocusAcceptable = accept;
422 mWindowBase->SetAcceptFocus(accept);
425 bool Window::IsFocusAcceptable() const
427 return mIsFocusAcceptable;
438 Dali::Window handle(this);
439 mVisibilityChangedSignal.Emit(handle, true);
441 WindowVisibilityObserver* observer(mAdaptor);
442 observer->OnWindowShown();
445 mSurface->SetFullSwapNextFrame();
447 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
458 Dali::Window handle(this);
459 mVisibilityChangedSignal.Emit(handle, false);
461 WindowVisibilityObserver* observer(mAdaptor);
462 observer->OnWindowHidden();
465 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
468 bool Window::IsVisible() const
470 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
471 return mVisible && !mIconified;
474 unsigned int Window::GetSupportedAuxiliaryHintCount() const
476 return mWindowBase->GetSupportedAuxiliaryHintCount();
479 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
481 return mWindowBase->GetSupportedAuxiliaryHint(index);
484 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
486 return mWindowBase->AddAuxiliaryHint(hint, value);
489 bool Window::RemoveAuxiliaryHint(unsigned int id)
491 return mWindowBase->RemoveAuxiliaryHint(id);
494 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
496 return mWindowBase->SetAuxiliaryHintValue(id, value);
499 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
501 return mWindowBase->GetAuxiliaryHintValue(id);
504 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
506 return mWindowBase->GetAuxiliaryHintId(hint);
509 void Window::SetInputRegion(const Rect<int>& inputRegion)
511 Rect<int> convertRegion = RecalculateRect(inputRegion);
513 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);
515 mWindowBase->SetInputRegion(convertRegion);
518 void Window::SetType(WindowType type)
520 mWindowBase->SetType(type);
523 WindowType Window::GetType() const
525 return mWindowBase->GetType();
528 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
530 WindowType type = mWindowBase->GetType();
531 if(type != WindowType::NOTIFICATION)
533 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
534 return WindowOperationResult::INVALID_OPERATION;
537 return mWindowBase->SetNotificationLevel(level);
540 WindowNotificationLevel Window::GetNotificationLevel() const
542 WindowType type = mWindowBase->GetType();
543 if(type != WindowType::NOTIFICATION)
545 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
546 return WindowNotificationLevel::NONE;
549 return mWindowBase->GetNotificationLevel();
552 void Window::SetOpaqueState(bool opaque)
554 mOpaqueState = opaque;
556 mWindowBase->SetOpaqueState(opaque);
558 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
561 bool Window::IsOpaqueState() const
566 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
568 return mWindowBase->SetScreenOffMode(screenOffMode);
571 WindowScreenOffMode Window::GetScreenOffMode() const
573 return mWindowBase->GetScreenOffMode();
576 WindowOperationResult Window::SetBrightness(int brightness)
578 if(brightness < 0 || brightness > 100)
580 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
581 return WindowOperationResult::INVALID_OPERATION;
584 return mWindowBase->SetBrightness(brightness);
587 int Window::GetBrightness() const
589 return mWindowBase->GetBrightness();
592 void Window::SetSize(Dali::Window::WindowSize size)
594 PositionSize oldRect = mSurface->GetPositionSize();
596 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
598 PositionSize newRect = mSurface->GetPositionSize();
600 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
601 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
603 Uint16Pair newSize(newRect.width, newRect.height);
607 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
609 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
611 Dali::Window handle(this);
612 mResizeSignal.Emit(handle, newSize);
614 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
617 mSurface->SetFullSwapNextFrame();
619 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
622 Dali::Window::WindowSize Window::GetSize() const
624 PositionSize positionSize = mSurface->GetPositionSize();
626 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
629 void Window::SetPosition(Dali::Window::WindowPosition position)
631 PositionSize oldRect = mSurface->GetPositionSize();
633 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
635 mSurface->SetFullSwapNextFrame();
637 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
640 Dali::Window::WindowPosition Window::GetPosition() const
642 PositionSize positionSize = mSurface->GetPositionSize();
644 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
647 PositionSize Window::GetPositionSize() const
649 return mSurface->GetPositionSize();
652 void Window::SetPositionSize(PositionSize positionSize)
654 PositionSize oldRect = mSurface->GetPositionSize();
656 mWindowSurface->MoveResize(positionSize);
658 PositionSize newRect = mSurface->GetPositionSize();
660 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
661 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
663 Uint16Pair newSize(newRect.width, newRect.height);
667 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
669 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
670 Dali::Window handle(this);
671 mResizeSignal.Emit(handle, newSize);
672 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
675 mSurface->SetFullSwapNextFrame();
677 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
680 Dali::Layer Window::GetRootLayer() const
682 return mScene.GetRootLayer();
685 void Window::SetTransparency(bool transparent)
687 mWindowSurface->SetTransparency(transparent);
690 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
692 return mWindowBase->GrabKey(key, grabMode);
695 bool Window::UngrabKey(Dali::KEY key)
697 return mWindowBase->UngrabKey(key);
700 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
702 return mWindowBase->GrabKeyList(key, grabMode, result);
705 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
707 return mWindowBase->UngrabKeyList(key, result);
710 void Window::OnIconifyChanged(bool iconified)
718 Dali::Window handle(this);
719 mVisibilityChangedSignal.Emit(handle, false);
721 WindowVisibilityObserver* observer(mAdaptor);
722 observer->OnWindowHidden();
725 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
733 Dali::Window handle(this);
734 mVisibilityChangedSignal.Emit(handle, true);
736 WindowVisibilityObserver* observer(mAdaptor);
737 observer->OnWindowShown();
740 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
743 mSurface->SetFullSwapNextFrame();
746 void Window::OnFocusChanged(bool focusIn)
748 Dali::Window handle(this);
749 mFocusChangeSignal.Emit(handle, focusIn);
751 mSurface->SetFullSwapNextFrame();
753 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
757 bridge->WindowFocused(handle);
761 bridge->WindowUnfocused(handle);
766 void Window::OnOutputTransformed()
768 PositionSize positionSize = mSurface->GetPositionSize();
770 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
771 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
773 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
774 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
777 void Window::OnDeleteRequest()
779 mDeleteRequestSignal.Emit();
782 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
784 Dali::Window handle(this);
785 mTransitionEffectEventSignal.Emit(handle, state, type);
788 void Window::OnKeyboardRepeatSettingsChanged()
790 Dali::Window handle(this);
791 mKeyboardRepeatSettingsChangedSignal.Emit();
794 void Window::OnWindowRedrawRequest()
796 mAdaptor->RenderOnce();
799 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
801 SetPositionSize(positionSize);
804 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
806 FeedTouchPoint(point, timeStamp);
809 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
811 FeedWheelEvent(wheelEvent);
814 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
816 FeedKeyEvent(keyEvent);
819 void Window::OnRotation(const RotationEvent& rotation)
821 mRotationAngle = rotation.angle;
822 mWindowWidth = rotation.width;
823 mWindowHeight = rotation.height;
825 // Notify that the orientation is changed
826 mOrientation->OnOrientationChange(rotation);
828 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
830 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
831 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
833 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
835 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
837 Dali::Window handle(this);
838 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
840 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
843 void Window::OnPause()
847 mEventHandler->Pause();
851 void Window::OnResume()
855 mEventHandler->Resume();
858 mSurface->SetFullSwapNextFrame();
861 void Window::RecalculateTouchPosition(Integration::Point& point)
863 Vector2 position = point.GetScreenPosition();
864 Vector2 convertedPosition;
866 switch(mRotationAngle)
870 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
871 convertedPosition.y = position.x;
876 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
877 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
882 convertedPosition.x = position.y;
883 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
888 convertedPosition = position;
893 point.SetScreenPosition(convertedPosition);
896 Dali::Window Window::Get(Dali::Actor actor)
898 Internal::Adaptor::Window* windowImpl = nullptr;
900 if(Internal::Adaptor::Adaptor::IsAvailable())
902 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
903 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
906 return Dali::Window(windowImpl);
910 return Dali::Window();
913 void Window::SetParent(Dali::Window& parent)
915 if(DALI_UNLIKELY(parent))
917 mParentWindow = parent;
918 Dali::Window self = Dali::Window(this);
919 // check circular parent window setting
920 if(Dali::DevelWindow::GetParent(parent) == self)
922 Dali::DevelWindow::Unparent(parent);
924 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
928 void Window::SetParent(Dali::Window& parent, bool belowParent)
930 if(DALI_UNLIKELY(parent))
932 mParentWindow = parent;
933 Dali::Window self = Dali::Window(this);
934 // check circular parent window setting
935 if(Dali::DevelWindow::GetParent(parent) == self)
937 Dali::DevelWindow::Unparent(parent);
939 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
943 void Window::Unparent()
945 mWindowBase->SetParent(nullptr, false);
946 mParentWindow.Reset();
949 Dali::Window Window::GetParent()
951 return mParentWindow;
954 WindowOrientation Window::GetCurrentOrientation() const
956 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
957 return ConvertToOrientation(mRotationAngle);
960 int Window::GetPhysicalOrientation() const
962 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
965 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
967 Dali::Vector<float>::SizeType count = orientations.Count();
968 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
970 if(IsOrientationAvailable(orientations[index]) == false)
972 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
977 int convertedAngle = ConvertToAngle(orientations[index]);
979 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
981 if(mAvailableAngles[i] == convertedAngle)
990 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
991 mAvailableAngles.push_back(convertedAngle);
994 SetAvailableAnlges(mAvailableAngles);
997 int32_t Window::GetNativeId() const
999 return mWindowBase->GetNativeWindowId();
1002 void Window::RequestMoveToServer()
1004 mWindowBase->RequestMoveToServer();
1007 void Window::RequestResizeToServer(WindowResizeDirection direction)
1009 mWindowBase->RequestResizeToServer(direction);
1012 void Window::EnableFloatingMode(bool enable)
1014 mWindowBase->EnableFloatingMode(enable);
1017 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1020 int screenWidth, screenHeight;
1022 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1024 if(mRotationAngle == 90)
1027 newRect.y = screenHeight - (rect.x + rect.width);
1028 newRect.width = rect.height;
1029 newRect.height = rect.width;
1031 else if(mRotationAngle == 180)
1033 newRect.x = screenWidth - (rect.x + rect.width);
1034 newRect.y = screenHeight - (rect.y + rect.height);
1035 newRect.width = rect.width;
1036 newRect.height = rect.height;
1038 else if(mRotationAngle == 270)
1040 newRect.x = screenWidth - (rect.y + rect.height);
1042 newRect.width = rect.height;
1043 newRect.height = rect.width;
1049 newRect.width = rect.width;
1050 newRect.height = rect.height;
1055 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1057 Rect<int> convertRegion = RecalculateRect(inputRegion);
1059 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);
1060 mWindowBase->IncludeInputRegion(convertRegion);
1063 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1065 Rect<int> convertRegion = RecalculateRect(inputRegion);
1067 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);
1068 mWindowBase->ExcludeInputRegion(convertRegion);
1071 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1073 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1074 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1075 mWindowRotationAcknowledgement = needAcknowledgement;
1078 void Window::SendRotationCompletedAcknowledgement()
1080 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1081 if(mWindowRotationAcknowledgement)
1083 SetRotationCompletedAcknowledgement();
1087 } // namespace Adaptor
1089 } // namespace Internal