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 mWindowBase->SetInputRegion(inputRegion);
512 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);
515 void Window::SetType(WindowType type)
517 mWindowBase->SetType(type);
520 WindowType Window::GetType() const
522 return mWindowBase->GetType();
525 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
527 WindowType type = mWindowBase->GetType();
528 if(type != WindowType::NOTIFICATION)
530 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
531 return WindowOperationResult::INVALID_OPERATION;
534 return mWindowBase->SetNotificationLevel(level);
537 WindowNotificationLevel Window::GetNotificationLevel() const
539 WindowType type = mWindowBase->GetType();
540 if(type != WindowType::NOTIFICATION)
542 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
543 return WindowNotificationLevel::NONE;
546 return mWindowBase->GetNotificationLevel();
549 void Window::SetOpaqueState(bool opaque)
551 mOpaqueState = opaque;
553 mWindowBase->SetOpaqueState(opaque);
555 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
558 bool Window::IsOpaqueState() const
563 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
565 return mWindowBase->SetScreenOffMode(screenOffMode);
568 WindowScreenOffMode Window::GetScreenOffMode() const
570 return mWindowBase->GetScreenOffMode();
573 WindowOperationResult Window::SetBrightness(int brightness)
575 if(brightness < 0 || brightness > 100)
577 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
578 return WindowOperationResult::INVALID_OPERATION;
581 return mWindowBase->SetBrightness(brightness);
584 int Window::GetBrightness() const
586 return mWindowBase->GetBrightness();
589 void Window::SetSize(Dali::Window::WindowSize size)
591 PositionSize oldRect = mSurface->GetPositionSize();
593 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
595 PositionSize newRect = mSurface->GetPositionSize();
597 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
598 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
600 Uint16Pair newSize(newRect.width, newRect.height);
604 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
606 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
608 Dali::Window handle(this);
609 mResizeSignal.Emit(handle, newSize);
611 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
614 mSurface->SetFullSwapNextFrame();
616 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
619 Dali::Window::WindowSize Window::GetSize() const
621 PositionSize positionSize = mSurface->GetPositionSize();
623 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
626 void Window::SetPosition(Dali::Window::WindowPosition position)
628 PositionSize oldRect = mSurface->GetPositionSize();
630 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
632 mSurface->SetFullSwapNextFrame();
634 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
637 Dali::Window::WindowPosition Window::GetPosition() const
639 PositionSize positionSize = mSurface->GetPositionSize();
641 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
644 PositionSize Window::GetPositionSize() const
646 return mSurface->GetPositionSize();
649 void Window::SetPositionSize(PositionSize positionSize)
651 PositionSize oldRect = mSurface->GetPositionSize();
653 mWindowSurface->MoveResize(positionSize);
655 PositionSize newRect = mSurface->GetPositionSize();
657 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
658 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
660 Uint16Pair newSize(newRect.width, newRect.height);
664 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
666 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
667 Dali::Window handle(this);
668 mResizeSignal.Emit(handle, newSize);
669 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
672 mSurface->SetFullSwapNextFrame();
674 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
677 Dali::Layer Window::GetRootLayer() const
679 return mScene.GetRootLayer();
682 void Window::SetTransparency(bool transparent)
684 mWindowSurface->SetTransparency(transparent);
687 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
689 return mWindowBase->GrabKey(key, grabMode);
692 bool Window::UngrabKey(Dali::KEY key)
694 return mWindowBase->UngrabKey(key);
697 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
699 return mWindowBase->GrabKeyList(key, grabMode, result);
702 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
704 return mWindowBase->UngrabKeyList(key, result);
707 void Window::OnIconifyChanged(bool iconified)
715 Dali::Window handle(this);
716 mVisibilityChangedSignal.Emit(handle, false);
718 WindowVisibilityObserver* observer(mAdaptor);
719 observer->OnWindowHidden();
722 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
730 Dali::Window handle(this);
731 mVisibilityChangedSignal.Emit(handle, true);
733 WindowVisibilityObserver* observer(mAdaptor);
734 observer->OnWindowShown();
737 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
740 mSurface->SetFullSwapNextFrame();
743 void Window::OnFocusChanged(bool focusIn)
745 Dali::Window handle(this);
746 mFocusChangeSignal.Emit(handle, focusIn);
748 mSurface->SetFullSwapNextFrame();
750 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
754 bridge->WindowShown();
758 bridge->WindowHidden();
763 void Window::OnOutputTransformed()
765 PositionSize positionSize = mSurface->GetPositionSize();
767 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
768 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
770 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
771 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
774 void Window::OnDeleteRequest()
776 mDeleteRequestSignal.Emit();
779 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
781 Dali::Window handle(this);
782 mTransitionEffectEventSignal.Emit(handle, state, type);
785 void Window::OnKeyboardRepeatSettingsChanged()
787 Dali::Window handle(this);
788 mKeyboardRepeatSettingsChangedSignal.Emit();
791 void Window::OnWindowRedrawRequest()
793 mAdaptor->RenderOnce();
796 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
798 SetPositionSize(positionSize);
801 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
803 FeedTouchPoint(point, timeStamp);
806 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
808 FeedWheelEvent(wheelEvent);
811 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
813 FeedKeyEvent(keyEvent);
816 void Window::OnRotation(const RotationEvent& rotation)
818 mRotationAngle = rotation.angle;
819 mWindowWidth = rotation.width;
820 mWindowHeight = rotation.height;
822 // Notify that the orientation is changed
823 mOrientation->OnOrientationChange(rotation);
825 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
827 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
828 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
830 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
832 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
834 Dali::Window handle(this);
835 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
837 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
840 void Window::OnPause()
844 mEventHandler->Pause();
848 void Window::OnResume()
852 mEventHandler->Resume();
855 mSurface->SetFullSwapNextFrame();
858 void Window::RecalculateTouchPosition(Integration::Point& point)
860 Vector2 position = point.GetScreenPosition();
861 Vector2 convertedPosition;
863 switch(mRotationAngle)
867 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
868 convertedPosition.y = position.x;
873 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
874 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
879 convertedPosition.x = position.y;
880 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
885 convertedPosition = position;
890 point.SetScreenPosition(convertedPosition);
893 Dali::Window Window::Get(Dali::Actor actor)
895 Internal::Adaptor::Window* windowImpl = nullptr;
897 if(Internal::Adaptor::Adaptor::IsAvailable())
899 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
900 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
903 return Dali::Window(windowImpl);
907 return Dali::Window();
910 void Window::SetParent(Dali::Window& parent)
912 if(DALI_UNLIKELY(parent))
914 mParentWindow = parent;
915 Dali::Window self = Dali::Window(this);
916 // check circular parent window setting
917 if(Dali::DevelWindow::GetParent(parent) == self)
919 Dali::DevelWindow::Unparent(parent);
921 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
925 void Window::SetParent(Dali::Window& parent, bool belowParent)
927 if(DALI_UNLIKELY(parent))
929 mParentWindow = parent;
930 Dali::Window self = Dali::Window(this);
931 // check circular parent window setting
932 if(Dali::DevelWindow::GetParent(parent) == self)
934 Dali::DevelWindow::Unparent(parent);
936 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
940 void Window::Unparent()
942 mWindowBase->SetParent(nullptr, false);
943 mParentWindow.Reset();
946 Dali::Window Window::GetParent()
948 return mParentWindow;
951 WindowOrientation Window::GetCurrentOrientation() const
953 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
954 return ConvertToOrientation(mRotationAngle);
957 int Window::GetPhysicalOrientation() const
959 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
962 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
964 Dali::Vector<float>::SizeType count = orientations.Count();
965 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
967 if(IsOrientationAvailable(orientations[index]) == false)
969 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
974 int convertedAngle = ConvertToAngle(orientations[index]);
976 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
978 if(mAvailableAngles[i] == convertedAngle)
987 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
988 mAvailableAngles.push_back(convertedAngle);
991 SetAvailableAnlges(mAvailableAngles);
994 int32_t Window::GetNativeId() const
996 return mWindowBase->GetNativeWindowId();
999 void Window::RequestMoveToServer()
1001 mWindowBase->RequestMoveToServer();
1004 void Window::RequestResizeToServer(WindowResizeDirection direction)
1006 mWindowBase->RequestResizeToServer(direction);
1009 void Window::EnableFloatingMode(bool enable)
1011 mWindowBase->EnableFloatingMode(enable);
1014 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1016 mWindowBase->IncludeInputRegion(inputRegion);
1019 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1021 mWindowBase->ExcludeInputRegion(inputRegion);
1024 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1026 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1027 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1028 mWindowRotationAcknowledgement = needAcknowledgement;
1031 void Window::SendRotationCompletedAcknowledgement()
1033 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1034 if(mWindowRotationAcknowledgement)
1036 SetRotationCompletedAcknowledgement();
1040 } // namespace Adaptor
1042 } // namespace Internal