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()
103 auto bridge = Accessibility::Bridge::GetCurrentBridge();
104 auto rootLayer = mScene.GetRootLayer();
105 auto accessible = Accessibility::Accessible::Get(rootLayer);
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, 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 auto bridge = Accessibility::Bridge::GetCurrentBridge();
175 auto rootLayer = mScene.GetRootLayer();
176 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
177 bridge->AddTopLevelWindow(accessible);
179 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
180 // The show must be called after the adaptor is initialized.
184 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
186 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
189 void Window::SetClass(std::string name, std::string className)
192 mClassName = className;
193 mWindowBase->SetClass(name, className);
196 std::string Window::GetClassName() const
203 mWindowBase->Raise();
205 mSurface->SetFullSwapNextFrame();
207 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
212 mWindowBase->Lower();
214 mSurface->SetFullSwapNextFrame();
216 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
219 void Window::Activate()
221 mWindowBase->Activate();
223 mSurface->SetFullSwapNextFrame();
225 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
228 uint32_t Window::GetLayerCount() const
230 return mScene.GetLayerCount();
233 Dali::Layer Window::GetLayer(uint32_t depth) const
235 return mScene.GetLayer(depth);
238 Dali::RenderTaskList Window::GetRenderTaskList() const
240 return mScene.GetRenderTaskList();
243 void Window::AddAvailableOrientation(WindowOrientation orientation)
245 if(IsOrientationAvailable(orientation) == false)
251 int convertedAngle = ConvertToAngle(orientation);
252 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
253 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
255 if(mAvailableAngles[i] == convertedAngle)
264 mAvailableAngles.push_back(convertedAngle);
265 SetAvailableAnlges(mAvailableAngles);
269 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
271 if(IsOrientationAvailable(orientation) == false)
276 int convertedAngle = ConvertToAngle(orientation);
277 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
278 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
279 iter != mAvailableAngles.end();
282 if(*iter == convertedAngle)
284 mAvailableAngles.erase(iter);
289 SetAvailableAnlges(mAvailableAngles);
292 void Window::SetPreferredOrientation(WindowOrientation orientation)
294 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
296 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
299 mPreferredAngle = ConvertToAngle(orientation);
300 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
301 mWindowBase->SetPreferredAngle(mPreferredAngle);
304 WindowOrientation Window::GetPreferredOrientation()
306 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
307 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
308 return preferredOrientation;
311 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
313 int angle = ConvertToAngle(orientation);
314 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
317 void Window::SetAvailableAnlges(const std::vector<int>& angles)
319 if(angles.size() > 4)
321 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
325 mWindowBase->SetAvailableAnlges(angles);
328 int Window::ConvertToAngle(WindowOrientation orientation)
330 int convertAngle = static_cast<int>(orientation);
331 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
335 case WindowOrientation::LANDSCAPE:
340 case WindowOrientation::PORTRAIT:
345 case WindowOrientation::LANDSCAPE_INVERSE:
350 case WindowOrientation::PORTRAIT_INVERSE:
355 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
365 WindowOrientation Window::ConvertToOrientation(int angle) const
367 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
368 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
374 orientation = WindowOrientation::LANDSCAPE;
379 orientation = WindowOrientation::PORTRAIT;
384 orientation = WindowOrientation::LANDSCAPE_INVERSE;
389 orientation = WindowOrientation::PORTRAIT_INVERSE;
394 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
402 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
404 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
406 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
412 Dali::Any Window::GetNativeHandle() const
414 return mWindowSurface->GetNativeWindow();
417 void Window::SetAcceptFocus(bool accept)
419 mIsFocusAcceptable = accept;
421 mWindowBase->SetAcceptFocus(accept);
424 bool Window::IsFocusAcceptable() const
426 return mIsFocusAcceptable;
437 Dali::Window handle(this);
438 mVisibilityChangedSignal.Emit(handle, true);
440 WindowVisibilityObserver* observer(mAdaptor);
441 observer->OnWindowShown();
444 mSurface->SetFullSwapNextFrame();
446 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
457 Dali::Window handle(this);
458 mVisibilityChangedSignal.Emit(handle, false);
460 WindowVisibilityObserver* observer(mAdaptor);
461 observer->OnWindowHidden();
464 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
467 bool Window::IsVisible() const
469 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
470 return mVisible && !mIconified;
473 unsigned int Window::GetSupportedAuxiliaryHintCount() const
475 return mWindowBase->GetSupportedAuxiliaryHintCount();
478 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
480 return mWindowBase->GetSupportedAuxiliaryHint(index);
483 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
485 return mWindowBase->AddAuxiliaryHint(hint, value);
488 bool Window::RemoveAuxiliaryHint(unsigned int id)
490 return mWindowBase->RemoveAuxiliaryHint(id);
493 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
495 return mWindowBase->SetAuxiliaryHintValue(id, value);
498 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
500 return mWindowBase->GetAuxiliaryHintValue(id);
503 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
505 return mWindowBase->GetAuxiliaryHintId(hint);
508 void Window::SetInputRegion(const Rect<int>& inputRegion)
510 Rect<int> convertRegion = RecalculateRect(inputRegion);
512 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);
514 mWindowBase->SetInputRegion(convertRegion);
517 void Window::SetType(WindowType type)
519 mWindowBase->SetType(type);
522 WindowType Window::GetType() const
524 return mWindowBase->GetType();
527 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
529 WindowType type = mWindowBase->GetType();
530 if(type != WindowType::NOTIFICATION)
532 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
533 return WindowOperationResult::INVALID_OPERATION;
536 return mWindowBase->SetNotificationLevel(level);
539 WindowNotificationLevel Window::GetNotificationLevel() const
541 WindowType type = mWindowBase->GetType();
542 if(type != WindowType::NOTIFICATION)
544 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
545 return WindowNotificationLevel::NONE;
548 return mWindowBase->GetNotificationLevel();
551 void Window::SetOpaqueState(bool opaque)
553 mOpaqueState = opaque;
555 mWindowBase->SetOpaqueState(opaque);
557 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
560 bool Window::IsOpaqueState() const
565 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
567 return mWindowBase->SetScreenOffMode(screenOffMode);
570 WindowScreenOffMode Window::GetScreenOffMode() const
572 return mWindowBase->GetScreenOffMode();
575 WindowOperationResult Window::SetBrightness(int brightness)
577 if(brightness < 0 || brightness > 100)
579 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
580 return WindowOperationResult::INVALID_OPERATION;
583 return mWindowBase->SetBrightness(brightness);
586 int Window::GetBrightness() const
588 return mWindowBase->GetBrightness();
591 void Window::SetSize(Dali::Window::WindowSize size)
593 PositionSize oldRect = mSurface->GetPositionSize();
595 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
597 PositionSize newRect = mSurface->GetPositionSize();
599 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
600 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
602 Uint16Pair newSize(newRect.width, newRect.height);
606 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
608 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
610 Dali::Window handle(this);
611 mResizeSignal.Emit(handle, newSize);
613 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
616 mSurface->SetFullSwapNextFrame();
618 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
621 Dali::Window::WindowSize Window::GetSize() const
623 PositionSize positionSize = mSurface->GetPositionSize();
625 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
628 void Window::SetPosition(Dali::Window::WindowPosition position)
630 PositionSize oldRect = mSurface->GetPositionSize();
632 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
634 mSurface->SetFullSwapNextFrame();
636 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
639 Dali::Window::WindowPosition Window::GetPosition() const
641 PositionSize positionSize = mSurface->GetPositionSize();
643 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
646 PositionSize Window::GetPositionSize() const
648 return mSurface->GetPositionSize();
651 void Window::SetPositionSize(PositionSize positionSize)
653 PositionSize oldRect = mSurface->GetPositionSize();
655 mWindowSurface->MoveResize(positionSize);
657 PositionSize newRect = mSurface->GetPositionSize();
659 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
660 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
662 Uint16Pair newSize(newRect.width, newRect.height);
666 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
668 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
669 Dali::Window handle(this);
670 mResizeSignal.Emit(handle, newSize);
671 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
674 mSurface->SetFullSwapNextFrame();
676 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
679 Dali::Layer Window::GetRootLayer() const
681 return mScene.GetRootLayer();
684 void Window::SetTransparency(bool transparent)
686 mWindowSurface->SetTransparency(transparent);
689 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
691 return mWindowBase->GrabKey(key, grabMode);
694 bool Window::UngrabKey(Dali::KEY key)
696 return mWindowBase->UngrabKey(key);
699 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
701 return mWindowBase->GrabKeyList(key, grabMode, result);
704 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
706 return mWindowBase->UngrabKeyList(key, result);
709 void Window::OnIconifyChanged(bool iconified)
717 Dali::Window handle(this);
718 mVisibilityChangedSignal.Emit(handle, false);
720 WindowVisibilityObserver* observer(mAdaptor);
721 observer->OnWindowHidden();
724 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
732 Dali::Window handle(this);
733 mVisibilityChangedSignal.Emit(handle, true);
735 WindowVisibilityObserver* observer(mAdaptor);
736 observer->OnWindowShown();
739 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
742 mSurface->SetFullSwapNextFrame();
745 void Window::OnFocusChanged(bool focusIn)
747 Dali::Window handle(this);
748 mFocusChangeSignal.Emit(handle, focusIn);
750 mSurface->SetFullSwapNextFrame();
752 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
756 bridge->WindowShown();
760 bridge->WindowHidden();
765 void Window::OnOutputTransformed()
767 PositionSize positionSize = mSurface->GetPositionSize();
769 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
770 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
772 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
773 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
776 void Window::OnDeleteRequest()
778 mDeleteRequestSignal.Emit();
781 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
783 Dali::Window handle(this);
784 mTransitionEffectEventSignal.Emit(handle, state, type);
787 void Window::OnKeyboardRepeatSettingsChanged()
789 Dali::Window handle(this);
790 mKeyboardRepeatSettingsChangedSignal.Emit();
793 void Window::OnWindowRedrawRequest()
795 mAdaptor->RenderOnce();
798 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
800 SetPositionSize(positionSize);
803 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
805 FeedTouchPoint(point, timeStamp);
808 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
810 FeedWheelEvent(wheelEvent);
813 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
815 FeedKeyEvent(keyEvent);
818 void Window::OnRotation(const RotationEvent& rotation)
820 mRotationAngle = rotation.angle;
821 mWindowWidth = rotation.width;
822 mWindowHeight = rotation.height;
824 // Notify that the orientation is changed
825 mOrientation->OnOrientationChange(rotation);
827 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
829 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
830 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
832 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
834 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
836 Dali::Window handle(this);
837 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
839 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
842 void Window::OnPause()
846 mEventHandler->Pause();
850 void Window::OnResume()
854 mEventHandler->Resume();
857 mSurface->SetFullSwapNextFrame();
860 void Window::RecalculateTouchPosition(Integration::Point& point)
862 Vector2 position = point.GetScreenPosition();
863 Vector2 convertedPosition;
865 switch(mRotationAngle)
869 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
870 convertedPosition.y = position.x;
875 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
876 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
881 convertedPosition.x = position.y;
882 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
887 convertedPosition = position;
892 point.SetScreenPosition(convertedPosition);
895 Dali::Window Window::Get(Dali::Actor actor)
897 Internal::Adaptor::Window* windowImpl = nullptr;
899 if(Internal::Adaptor::Adaptor::IsAvailable())
901 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
902 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
905 return Dali::Window(windowImpl);
909 return Dali::Window();
912 void Window::SetParent(Dali::Window& parent)
914 if(DALI_UNLIKELY(parent))
916 mParentWindow = parent;
917 Dali::Window self = Dali::Window(this);
918 // check circular parent window setting
919 if(Dali::DevelWindow::GetParent(parent) == self)
921 Dali::DevelWindow::Unparent(parent);
923 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
927 void Window::SetParent(Dali::Window& parent, bool belowParent)
929 if(DALI_UNLIKELY(parent))
931 mParentWindow = parent;
932 Dali::Window self = Dali::Window(this);
933 // check circular parent window setting
934 if(Dali::DevelWindow::GetParent(parent) == self)
936 Dali::DevelWindow::Unparent(parent);
938 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
942 void Window::Unparent()
944 mWindowBase->SetParent(nullptr, false);
945 mParentWindow.Reset();
948 Dali::Window Window::GetParent()
950 return mParentWindow;
953 WindowOrientation Window::GetCurrentOrientation() const
955 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
956 return ConvertToOrientation(mRotationAngle);
959 int Window::GetPhysicalOrientation() const
961 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
964 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
966 Dali::Vector<float>::SizeType count = orientations.Count();
967 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
969 if(IsOrientationAvailable(orientations[index]) == false)
971 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
976 int convertedAngle = ConvertToAngle(orientations[index]);
978 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
980 if(mAvailableAngles[i] == convertedAngle)
989 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
990 mAvailableAngles.push_back(convertedAngle);
993 SetAvailableAnlges(mAvailableAngles);
996 int32_t Window::GetNativeId() const
998 return mWindowBase->GetNativeWindowId();
1001 void Window::RequestMoveToServer()
1003 mWindowBase->RequestMoveToServer();
1006 void Window::RequestResizeToServer(WindowResizeDirection direction)
1008 mWindowBase->RequestResizeToServer(direction);
1011 void Window::EnableFloatingMode(bool enable)
1013 mWindowBase->EnableFloatingMode(enable);
1016 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1019 int screenWidth, screenHeight;
1021 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1023 if(mRotationAngle == 90)
1026 newRect.y = screenHeight - (rect.x + rect.width);
1027 newRect.width = rect.height;
1028 newRect.height = rect.width;
1030 else if(mRotationAngle == 180)
1032 newRect.x = screenWidth - (rect.x + rect.width);
1033 newRect.y = screenHeight - (rect.y + rect.height);
1034 newRect.width = rect.width;
1035 newRect.height = rect.height;
1037 else if(mRotationAngle == 270)
1039 newRect.x = screenWidth - (rect.y + rect.height);
1041 newRect.width = rect.height;
1042 newRect.height = rect.width;
1048 newRect.width = rect.width;
1049 newRect.height = rect.height;
1054 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1056 Rect<int> convertRegion = RecalculateRect(inputRegion);
1058 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);
1059 mWindowBase->IncludeInputRegion(convertRegion);
1062 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1064 Rect<int> convertRegion = RecalculateRect(inputRegion);
1066 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);
1067 mWindowBase->ExcludeInputRegion(convertRegion);
1070 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1072 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1073 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1074 mWindowRotationAcknowledgement = needAcknowledgement;
1077 void Window::SendRotationCompletedAcknowledgement()
1079 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1080 if(mWindowRotationAcknowledgement)
1082 SetRotationCompletedAcknowledgement();
1086 } // namespace Adaptor
1088 } // namespace Internal