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),
83 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
89 mDeleteRequestSignal(),
92 mVisibilityChangedSignal(),
93 mTransitionEffectEventSignal(),
94 mKeyboardRepeatSettingsChangedSignal()
102 auto bridge = Accessibility::Bridge::GetCurrentBridge();
103 auto rootLayer = mScene.GetRootLayer();
104 auto accessible = Accessibility::Accessible::Get(rootLayer);
105 bridge->RemoveTopLevelWindow(accessible);
107 mAdaptor->RemoveWindow(this);
112 mEventHandler->RemoveObserver(*this);
116 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
118 // Create a window render surface
119 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
120 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
121 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
124 mWindowBase = mWindowSurface->GetWindowBase();
127 mWindowBase->SetType(type);
129 // Initialize for Ime window type
130 if(type == WindowType::IME)
132 mWindowBase->InitializeIme();
133 mWindowSurface->InitializeImeSurface();
137 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
138 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
139 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
140 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
141 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
142 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
143 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
145 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
147 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
149 SetClass(name, className);
151 mOrientation = Orientation::New(this);
153 // Get OrientationMode
154 int screenWidth, screenHeight;
155 WindowSystem::GetScreenSize(screenWidth, screenHeight);
156 if(screenWidth > screenHeight)
158 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
162 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
165 mNativeWindowId = mWindowBase->GetNativeWindowId();
168 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
170 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
171 mEventHandler->AddObserver(*this);
173 auto bridge = Accessibility::Bridge::GetCurrentBridge();
174 auto rootLayer = mScene.GetRootLayer();
175 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
176 bridge->AddTopLevelWindow(accessible);
178 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
179 // The show must be called after the adaptor is initialized.
183 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
185 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
188 void Window::SetClass(std::string name, std::string className)
191 mClassName = className;
192 mWindowBase->SetClass(name, className);
195 std::string Window::GetClassName() const
202 mWindowBase->Raise();
204 mSurface->SetFullSwapNextFrame();
206 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
211 mWindowBase->Lower();
213 mSurface->SetFullSwapNextFrame();
215 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
218 void Window::Activate()
220 mWindowBase->Activate();
222 mSurface->SetFullSwapNextFrame();
224 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
227 uint32_t Window::GetLayerCount() const
229 return mScene.GetLayerCount();
232 Dali::Layer Window::GetLayer(uint32_t depth) const
234 return mScene.GetLayer(depth);
237 Dali::RenderTaskList Window::GetRenderTaskList() const
239 return mScene.GetRenderTaskList();
242 void Window::AddAvailableOrientation(WindowOrientation orientation)
244 if(IsOrientationAvailable(orientation) == false)
250 int convertedAngle = ConvertToAngle(orientation);
251 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
252 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
254 if(mAvailableAngles[i] == convertedAngle)
263 mAvailableAngles.push_back(convertedAngle);
264 SetAvailableAnlges(mAvailableAngles);
268 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
270 if(IsOrientationAvailable(orientation) == false)
275 int convertedAngle = ConvertToAngle(orientation);
276 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
277 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
278 iter != mAvailableAngles.end();
281 if(*iter == convertedAngle)
283 mAvailableAngles.erase(iter);
288 SetAvailableAnlges(mAvailableAngles);
291 void Window::SetPreferredOrientation(WindowOrientation orientation)
293 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
295 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
298 mPreferredAngle = ConvertToAngle(orientation);
299 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
300 mWindowBase->SetPreferredAngle(mPreferredAngle);
303 WindowOrientation Window::GetPreferredOrientation()
305 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
306 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
307 return preferredOrientation;
310 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
312 int angle = ConvertToAngle(orientation);
313 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
316 void Window::SetAvailableAnlges(const std::vector<int>& angles)
318 if(angles.size() > 4)
320 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
324 mWindowBase->SetAvailableAnlges(angles);
327 int Window::ConvertToAngle(WindowOrientation orientation)
329 int convertAngle = static_cast<int>(orientation);
330 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
334 case WindowOrientation::LANDSCAPE:
339 case WindowOrientation::PORTRAIT:
344 case WindowOrientation::LANDSCAPE_INVERSE:
349 case WindowOrientation::PORTRAIT_INVERSE:
354 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
364 WindowOrientation Window::ConvertToOrientation(int angle) const
366 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
367 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
373 orientation = WindowOrientation::LANDSCAPE;
378 orientation = WindowOrientation::PORTRAIT;
383 orientation = WindowOrientation::LANDSCAPE_INVERSE;
388 orientation = WindowOrientation::PORTRAIT_INVERSE;
393 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
401 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
403 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
405 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
411 Dali::Any Window::GetNativeHandle() const
413 return mWindowSurface->GetNativeWindow();
416 void Window::SetAcceptFocus(bool accept)
418 mIsFocusAcceptable = accept;
420 mWindowBase->SetAcceptFocus(accept);
423 bool Window::IsFocusAcceptable() const
425 return mIsFocusAcceptable;
436 WindowVisibilityObserver* observer(mAdaptor);
437 observer->OnWindowShown();
439 Dali::Window handle(this);
440 mVisibilityChangedSignal.Emit(handle, true);
443 mSurface->SetFullSwapNextFrame();
445 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
456 WindowVisibilityObserver* observer(mAdaptor);
457 observer->OnWindowHidden();
459 Dali::Window handle(this);
460 mVisibilityChangedSignal.Emit(handle, false);
463 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
466 bool Window::IsVisible() const
468 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
469 return mVisible && !mIconified;
472 unsigned int Window::GetSupportedAuxiliaryHintCount() const
474 return mWindowBase->GetSupportedAuxiliaryHintCount();
477 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
479 return mWindowBase->GetSupportedAuxiliaryHint(index);
482 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
484 return mWindowBase->AddAuxiliaryHint(hint, value);
487 bool Window::RemoveAuxiliaryHint(unsigned int id)
489 return mWindowBase->RemoveAuxiliaryHint(id);
492 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
494 return mWindowBase->SetAuxiliaryHintValue(id, value);
497 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
499 return mWindowBase->GetAuxiliaryHintValue(id);
502 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
504 return mWindowBase->GetAuxiliaryHintId(hint);
507 void Window::SetInputRegion(const Rect<int>& inputRegion)
509 mWindowBase->SetInputRegion(inputRegion);
511 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);
514 void Window::SetType(WindowType type)
516 mWindowBase->SetType(type);
519 WindowType Window::GetType() const
521 return mWindowBase->GetType();
524 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
526 WindowType type = mWindowBase->GetType();
527 if(type != WindowType::NOTIFICATION)
529 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
530 return WindowOperationResult::INVALID_OPERATION;
533 return mWindowBase->SetNotificationLevel(level);
536 WindowNotificationLevel Window::GetNotificationLevel() const
538 WindowType type = mWindowBase->GetType();
539 if(type != WindowType::NOTIFICATION)
541 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
542 return WindowNotificationLevel::NONE;
545 return mWindowBase->GetNotificationLevel();
548 void Window::SetOpaqueState(bool opaque)
550 mOpaqueState = opaque;
552 mWindowBase->SetOpaqueState(opaque);
554 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
557 bool Window::IsOpaqueState() const
562 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
564 return mWindowBase->SetScreenOffMode(screenOffMode);
567 WindowScreenOffMode Window::GetScreenOffMode() const
569 return mWindowBase->GetScreenOffMode();
572 WindowOperationResult Window::SetBrightness(int brightness)
574 if(brightness < 0 || brightness > 100)
576 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
577 return WindowOperationResult::INVALID_OPERATION;
580 return mWindowBase->SetBrightness(brightness);
583 int Window::GetBrightness() const
585 return mWindowBase->GetBrightness();
588 void Window::SetSize(Dali::Window::WindowSize size)
590 PositionSize oldRect = mSurface->GetPositionSize();
592 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
594 PositionSize newRect = mSurface->GetPositionSize();
596 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
597 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
599 Uint16Pair newSize(newRect.width, newRect.height);
603 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
605 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
607 Dali::Window handle(this);
608 mResizeSignal.Emit(handle, newSize);
610 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
613 mSurface->SetFullSwapNextFrame();
615 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
618 Dali::Window::WindowSize Window::GetSize() const
620 PositionSize positionSize = mSurface->GetPositionSize();
622 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
625 void Window::SetPosition(Dali::Window::WindowPosition position)
627 PositionSize oldRect = mSurface->GetPositionSize();
629 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
631 mSurface->SetFullSwapNextFrame();
633 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
636 Dali::Window::WindowPosition Window::GetPosition() const
638 PositionSize positionSize = mSurface->GetPositionSize();
640 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
643 PositionSize Window::GetPositionSize() const
645 return mSurface->GetPositionSize();
648 void Window::SetPositionSize(PositionSize positionSize)
650 PositionSize oldRect = mSurface->GetPositionSize();
652 mWindowSurface->MoveResize(positionSize);
654 PositionSize newRect = mSurface->GetPositionSize();
656 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
657 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
659 Uint16Pair newSize(newRect.width, newRect.height);
663 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
665 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
666 Dali::Window handle(this);
667 mResizeSignal.Emit(handle, newSize);
668 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
671 mSurface->SetFullSwapNextFrame();
673 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
676 Dali::Layer Window::GetRootLayer() const
678 return mScene.GetRootLayer();
681 void Window::SetTransparency(bool transparent)
683 mWindowSurface->SetTransparency(transparent);
686 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
688 return mWindowBase->GrabKey(key, grabMode);
691 bool Window::UngrabKey(Dali::KEY key)
693 return mWindowBase->UngrabKey(key);
696 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
698 return mWindowBase->GrabKeyList(key, grabMode, result);
701 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
703 return mWindowBase->UngrabKeyList(key, result);
706 void Window::OnIconifyChanged(bool iconified)
714 WindowVisibilityObserver* observer(mAdaptor);
715 observer->OnWindowHidden();
717 Dali::Window handle(this);
718 mVisibilityChangedSignal.Emit(handle, false);
721 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
729 WindowVisibilityObserver* observer(mAdaptor);
730 observer->OnWindowShown();
732 Dali::Window handle(this);
733 mVisibilityChangedSignal.Emit(handle, true);
736 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
739 mSurface->SetFullSwapNextFrame();
742 void Window::OnFocusChanged(bool focusIn)
744 Dali::Window handle(this);
745 mFocusChangeSignal.Emit(handle, focusIn);
747 mSurface->SetFullSwapNextFrame();
749 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
753 bridge->ApplicationShown();
757 bridge->ApplicationHidden();
762 void Window::OnOutputTransformed()
764 PositionSize positionSize = mSurface->GetPositionSize();
766 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
767 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
769 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
770 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
773 void Window::OnDeleteRequest()
775 mDeleteRequestSignal.Emit();
778 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
780 Dali::Window handle(this);
781 mTransitionEffectEventSignal.Emit(handle, state, type);
784 void Window::OnKeyboardRepeatSettingsChanged()
786 Dali::Window handle(this);
787 mKeyboardRepeatSettingsChangedSignal.Emit();
790 void Window::OnWindowRedrawRequest()
792 mAdaptor->RenderOnce();
795 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
797 SetPositionSize(positionSize);
800 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
802 FeedTouchPoint(point, timeStamp);
805 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
807 FeedWheelEvent(wheelEvent);
810 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
812 FeedKeyEvent(keyEvent);
815 void Window::OnRotation(const RotationEvent& rotation)
817 mRotationAngle = rotation.angle;
818 mWindowWidth = rotation.width;
819 mWindowHeight = rotation.height;
821 // Notify that the orientation is changed
822 mOrientation->OnOrientationChange(rotation);
824 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
826 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
827 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
829 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
831 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
833 Dali::Window handle(this);
834 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
836 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
839 void Window::OnPause()
843 mEventHandler->Pause();
847 void Window::OnResume()
851 mEventHandler->Resume();
854 mSurface->SetFullSwapNextFrame();
857 void Window::RecalculateTouchPosition(Integration::Point& point)
859 Vector2 position = point.GetScreenPosition();
860 Vector2 convertedPosition;
862 switch(mRotationAngle)
866 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
867 convertedPosition.y = position.x;
872 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
873 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
878 convertedPosition.x = position.y;
879 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
884 convertedPosition = position;
889 point.SetScreenPosition(convertedPosition);
892 Dali::Window Window::Get(Dali::Actor actor)
894 Internal::Adaptor::Window* windowImpl = nullptr;
896 if(Internal::Adaptor::Adaptor::IsAvailable())
898 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
899 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
902 return Dali::Window(windowImpl);
906 return Dali::Window();
909 void Window::SetParent(Dali::Window& parent)
911 if(DALI_UNLIKELY(parent))
913 mParentWindow = parent;
914 Dali::Window self = Dali::Window(this);
915 // check circular parent window setting
916 if(Dali::DevelWindow::GetParent(parent) == self)
918 Dali::DevelWindow::Unparent(parent);
920 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
924 void Window::Unparent()
926 mWindowBase->SetParent(nullptr);
927 mParentWindow.Reset();
930 Dali::Window Window::GetParent()
932 return mParentWindow;
935 WindowOrientation Window::GetCurrentOrientation() const
937 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
938 return ConvertToOrientation(mRotationAngle);
941 int Window::GetPhysicalOrientation() const
943 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
946 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
948 Dali::Vector<float>::SizeType count = orientations.Count();
949 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
951 if(IsOrientationAvailable(orientations[index]) == false)
953 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
958 int convertedAngle = ConvertToAngle(orientations[index]);
960 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
962 if(mAvailableAngles[i] == convertedAngle)
971 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
972 mAvailableAngles.push_back(convertedAngle);
975 SetAvailableAnlges(mAvailableAngles);
978 int32_t Window::GetNativeId() const
980 return mWindowBase->GetNativeWindowId();
983 void Window::RequestMoveToServer()
985 mWindowBase->RequestMoveToServer();
988 void Window::RequestResizeToServer(WindowResizeDirection direction)
990 mWindowBase->RequestResizeToServer(direction);
993 void Window::EnableFloatingMode(bool enable)
995 mWindowBase->EnableFloatingMode(enable);
998 } // namespace Adaptor
1000 } // namespace Internal