2 * Copyright (c) 2022 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-bridge.h>
36 #include <dali/devel-api/atspi-interfaces/accessible.h>
37 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
38 #include <dali/internal/graphics/gles/egl-graphics.h>
39 #include <dali/internal/window-system/common/event-handler.h>
40 #include <dali/internal/window-system/common/orientation-impl.h>
41 #include <dali/internal/window-system/common/render-surface-factory.h>
42 #include <dali/internal/window-system/common/window-base.h>
43 #include <dali/internal/window-system/common/window-factory.h>
44 #include <dali/internal/window-system/common/window-render-surface.h>
45 #include <dali/internal/window-system/common/window-system.h>
46 #include <dali/internal/window-system/common/window-visibility-observer.h>
56 #if defined(DEBUG_ENABLED)
57 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
60 } // unnamed namespace
62 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
65 return Window::New(surface, positionSize, name, className, type, isTransparent);
68 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
70 Window* window = new Window();
71 window->mIsTransparent = isTransparent;
72 window->Initialize(surface, positionSize, name, className, type);
77 : mWindowSurface(nullptr),
79 mIsTransparent(false),
80 mIsFocusAcceptable(true),
83 mWindowRotationAcknowledgement(false),
85 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
89 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
91 mDeleteRequestSignal(),
94 mVisibilityChangedSignal(),
95 mTransitionEffectEventSignal(),
96 mKeyboardRepeatSettingsChangedSignal(),
97 mAuxiliaryMessageSignal()
103 auto bridge = Accessibility::Bridge::GetCurrentBridge();
104 auto rootLayer = mScene.GetRootLayer();
105 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
106 bridge->RemoveTopLevelWindow(accessible);
110 mAdaptor->RemoveWindow(this);
115 mEventHandler->RemoveObserver(*this);
119 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
121 // Create a window render surface
122 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
123 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
124 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
127 mWindowBase = mWindowSurface->GetWindowBase();
130 mWindowBase->SetType(type);
132 // Initialize for Ime window type
133 if(type == WindowType::IME)
135 mWindowBase->InitializeIme();
136 mWindowSurface->InitializeImeSurface();
140 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
141 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
142 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
143 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
144 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
145 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
146 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
147 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
149 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
151 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
153 SetClass(name, className);
155 mOrientation = Orientation::New(this);
157 // Get OrientationMode
158 int screenWidth, screenHeight;
159 WindowSystem::GetScreenSize(screenWidth, screenHeight);
160 if(screenWidth > screenHeight)
162 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
166 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
169 mNativeWindowId = mWindowBase->GetNativeWindowId();
172 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
174 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
175 mEventHandler->AddObserver(*this);
177 // Add Window to bridge for ATSPI
178 auto bridge = Accessibility::Bridge::GetCurrentBridge();
179 auto rootLayer = mScene.GetRootLayer();
180 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
181 bridge->AddTopLevelWindow(accessible);
183 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
184 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
186 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
187 // The show must be called after the adaptor is initialized.
191 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
193 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
196 void Window::SetClass(std::string name, std::string className)
199 mClassName = className;
200 mWindowBase->SetClass(name, className);
203 std::string Window::GetClassName() const
210 mWindowBase->Raise();
212 mSurface->SetFullSwapNextFrame();
214 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
219 mWindowBase->Lower();
221 mSurface->SetFullSwapNextFrame();
223 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
226 void Window::Activate()
228 mWindowBase->Activate();
230 mSurface->SetFullSwapNextFrame();
232 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
235 void Window::Maximize(bool maximize)
237 mWindowBase->Maximize(maximize);
239 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
242 bool Window::IsMaximized() const
244 return mWindowBase->IsMaximized();
247 void Window::Minimize(bool minimize)
249 mWindowBase->Minimize(minimize);
251 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
254 bool Window::IsMinimized() const
256 return mWindowBase->IsMinimized();
259 uint32_t Window::GetLayerCount() const
261 return mScene.GetLayerCount();
264 Dali::Layer Window::GetLayer(uint32_t depth) const
266 return mScene.GetLayer(depth);
269 Dali::RenderTaskList Window::GetRenderTaskList() const
271 return mScene.GetRenderTaskList();
274 std::string Window::GetNativeResourceId() const
276 return mWindowBase->GetNativeWindowResourceId();
279 void Window::AddAvailableOrientation(WindowOrientation orientation)
281 if(IsOrientationAvailable(orientation) == false)
287 int convertedAngle = ConvertToAngle(orientation);
288 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
289 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
291 if(mAvailableAngles[i] == convertedAngle)
300 mAvailableAngles.push_back(convertedAngle);
301 SetAvailableAnlges(mAvailableAngles);
305 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
307 if(IsOrientationAvailable(orientation) == false)
312 int convertedAngle = ConvertToAngle(orientation);
313 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
314 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
315 iter != mAvailableAngles.end();
318 if(*iter == convertedAngle)
320 mAvailableAngles.erase(iter);
325 SetAvailableAnlges(mAvailableAngles);
328 void Window::SetPreferredOrientation(WindowOrientation orientation)
330 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
332 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
335 mPreferredAngle = ConvertToAngle(orientation);
336 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
337 mWindowBase->SetPreferredAngle(mPreferredAngle);
340 WindowOrientation Window::GetPreferredOrientation()
342 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
343 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
344 return preferredOrientation;
347 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
349 int angle = ConvertToAngle(orientation);
350 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
353 void Window::SetAvailableAnlges(const std::vector<int>& angles)
355 if(angles.size() > 4)
357 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
361 mWindowBase->SetAvailableAnlges(angles);
364 int Window::ConvertToAngle(WindowOrientation orientation)
366 int convertAngle = static_cast<int>(orientation);
367 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
371 case WindowOrientation::LANDSCAPE:
376 case WindowOrientation::PORTRAIT:
381 case WindowOrientation::LANDSCAPE_INVERSE:
386 case WindowOrientation::PORTRAIT_INVERSE:
391 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
401 WindowOrientation Window::ConvertToOrientation(int angle) const
403 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
404 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
410 orientation = WindowOrientation::LANDSCAPE;
415 orientation = WindowOrientation::PORTRAIT;
420 orientation = WindowOrientation::LANDSCAPE_INVERSE;
425 orientation = WindowOrientation::PORTRAIT_INVERSE;
430 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
438 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
440 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
442 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
448 Dali::Any Window::GetNativeHandle() const
450 return mWindowSurface->GetNativeWindow();
453 void Window::SetAcceptFocus(bool accept)
455 mIsFocusAcceptable = accept;
457 mWindowBase->SetAcceptFocus(accept);
460 bool Window::IsFocusAcceptable() const
462 return mIsFocusAcceptable;
473 Dali::Window handle(this);
474 mVisibilityChangedSignal.Emit(handle, true);
476 WindowVisibilityObserver* observer(mAdaptor);
477 observer->OnWindowShown();
480 mSurface->SetFullSwapNextFrame();
482 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
493 Dali::Window handle(this);
494 mVisibilityChangedSignal.Emit(handle, false);
496 WindowVisibilityObserver* observer(mAdaptor);
497 observer->OnWindowHidden();
500 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
503 bool Window::IsVisible() const
505 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
506 return mVisible && !mIconified;
509 unsigned int Window::GetSupportedAuxiliaryHintCount() const
511 return mWindowBase->GetSupportedAuxiliaryHintCount();
514 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
516 return mWindowBase->GetSupportedAuxiliaryHint(index);
519 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
521 return mWindowBase->AddAuxiliaryHint(hint, value);
524 bool Window::RemoveAuxiliaryHint(unsigned int id)
526 return mWindowBase->RemoveAuxiliaryHint(id);
529 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
531 return mWindowBase->SetAuxiliaryHintValue(id, value);
534 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
536 return mWindowBase->GetAuxiliaryHintValue(id);
539 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
541 return mWindowBase->GetAuxiliaryHintId(hint);
544 void Window::SetInputRegion(const Rect<int>& inputRegion)
546 Rect<int> convertRegion = RecalculateRect(inputRegion);
548 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);
550 mWindowBase->SetInputRegion(convertRegion);
553 void Window::SetType(WindowType type)
555 mWindowBase->SetType(type);
558 WindowType Window::GetType() const
560 return mWindowBase->GetType();
563 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
565 WindowType type = mWindowBase->GetType();
566 if(type != WindowType::NOTIFICATION)
568 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
569 return WindowOperationResult::INVALID_OPERATION;
572 return mWindowBase->SetNotificationLevel(level);
575 WindowNotificationLevel Window::GetNotificationLevel() const
577 WindowType type = mWindowBase->GetType();
578 if(type != WindowType::NOTIFICATION)
580 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
581 return WindowNotificationLevel::NONE;
584 return mWindowBase->GetNotificationLevel();
587 void Window::SetOpaqueState(bool opaque)
589 mOpaqueState = opaque;
591 mWindowBase->SetOpaqueState(opaque);
593 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
596 bool Window::IsOpaqueState() const
601 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
603 return mWindowBase->SetScreenOffMode(screenOffMode);
606 WindowScreenOffMode Window::GetScreenOffMode() const
608 return mWindowBase->GetScreenOffMode();
611 WindowOperationResult Window::SetBrightness(int brightness)
613 if(brightness < 0 || brightness > 100)
615 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
616 return WindowOperationResult::INVALID_OPERATION;
619 return mWindowBase->SetBrightness(brightness);
622 int Window::GetBrightness() const
624 return mWindowBase->GetBrightness();
627 void Window::SetSize(Dali::Window::WindowSize size)
629 PositionSize oldRect = mSurface->GetPositionSize();
631 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
633 PositionSize newRect = mSurface->GetPositionSize();
635 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
636 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
638 Uint16Pair newSize(newRect.width, newRect.height);
642 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
644 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
646 Dali::Window handle(this);
647 mResizeSignal.Emit(handle, newSize);
649 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
652 mSurface->SetFullSwapNextFrame();
654 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
657 Dali::Window::WindowSize Window::GetSize() const
659 PositionSize positionSize = mSurface->GetPositionSize();
661 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
664 void Window::SetPosition(Dali::Window::WindowPosition position)
666 PositionSize oldRect = mSurface->GetPositionSize();
668 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
670 mSurface->SetFullSwapNextFrame();
672 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
675 Dali::Window::WindowPosition Window::GetPosition() const
677 PositionSize positionSize = mSurface->GetPositionSize();
679 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
682 PositionSize Window::GetPositionSize() const
684 return mSurface->GetPositionSize();
687 void Window::SetPositionSize(PositionSize positionSize)
689 PositionSize oldRect = mSurface->GetPositionSize();
691 mWindowSurface->MoveResize(positionSize);
693 PositionSize newRect = mSurface->GetPositionSize();
695 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
696 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
698 Uint16Pair newSize(newRect.width, newRect.height);
702 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
704 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
705 Dali::Window handle(this);
706 mResizeSignal.Emit(handle, newSize);
707 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
710 mSurface->SetFullSwapNextFrame();
712 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
715 Dali::Layer Window::GetRootLayer() const
717 return mScene.GetRootLayer();
720 void Window::SetTransparency(bool transparent)
722 mWindowSurface->SetTransparency(transparent);
725 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
727 return mWindowBase->GrabKey(key, grabMode);
730 bool Window::UngrabKey(Dali::KEY key)
732 return mWindowBase->UngrabKey(key);
735 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
737 return mWindowBase->GrabKeyList(key, grabMode, result);
740 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
742 return mWindowBase->UngrabKeyList(key, result);
745 void Window::OnIconifyChanged(bool iconified)
753 Dali::Window handle(this);
754 mVisibilityChangedSignal.Emit(handle, false);
756 WindowVisibilityObserver* observer(mAdaptor);
757 observer->OnWindowHidden();
760 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
768 Dali::Window handle(this);
769 mVisibilityChangedSignal.Emit(handle, true);
771 WindowVisibilityObserver* observer(mAdaptor);
772 observer->OnWindowShown();
775 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
778 mSurface->SetFullSwapNextFrame();
781 void Window::OnFocusChanged(bool focusIn)
783 Dali::Window handle(this);
784 mFocusChangeSignal.Emit(handle, focusIn);
786 mSurface->SetFullSwapNextFrame();
788 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
792 bridge->WindowFocused(handle);
796 bridge->WindowUnfocused(handle);
801 void Window::OnOutputTransformed()
803 PositionSize positionSize = mSurface->GetPositionSize();
805 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
806 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
808 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
809 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
812 void Window::OnDeleteRequest()
814 mDeleteRequestSignal.Emit();
817 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
819 Dali::Window handle(this);
820 mTransitionEffectEventSignal.Emit(handle, state, type);
823 void Window::OnKeyboardRepeatSettingsChanged()
825 Dali::Window handle(this);
826 mKeyboardRepeatSettingsChangedSignal.Emit();
829 void Window::OnWindowRedrawRequest()
831 mAdaptor->RenderOnce();
834 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
836 PositionSize oldRect = mSurface->GetPositionSize();
838 mWindowSurface->UpdatePositionSize(positionSize);
840 PositionSize newRect = positionSize;
842 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
843 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
845 Uint16Pair newSize(newRect.width, newRect.height);
849 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
851 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
852 Dali::Window handle(this);
853 mResizeSignal.Emit(handle, newSize);
854 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
857 mSurface->SetFullSwapNextFrame();
859 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
862 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
864 FeedTouchPoint(point, timeStamp);
867 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
869 FeedWheelEvent(wheelEvent);
872 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
874 FeedKeyEvent(keyEvent);
877 void Window::OnRotation(const RotationEvent& rotation)
879 mRotationAngle = rotation.angle;
880 mWindowWidth = rotation.width;
881 mWindowHeight = rotation.height;
883 // Notify that the orientation is changed
884 mOrientation->OnOrientationChange(rotation);
886 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
888 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
889 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
891 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
893 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
895 Dali::Window handle(this);
896 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
898 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
901 void Window::OnPause()
905 mEventHandler->Pause();
909 void Window::OnResume()
913 mEventHandler->Resume();
916 mSurface->SetFullSwapNextFrame();
919 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
921 mAuxiliaryMessageSignal.Emit(key, value, options);
924 void Window::OnAccessibilityEnabled()
926 auto bridge = Accessibility::Bridge::GetCurrentBridge();
927 auto rootLayer = mScene.GetRootLayer();
928 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
929 bridge->AddTopLevelWindow(accessible);
932 void Window::OnAccessibilityDisabled()
934 auto bridge = Accessibility::Bridge::GetCurrentBridge();
935 auto rootLayer = mScene.GetRootLayer();
936 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
937 bridge->RemoveTopLevelWindow(accessible);
940 void Window::RecalculateTouchPosition(Integration::Point& point)
942 Vector2 position = point.GetScreenPosition();
943 Vector2 convertedPosition;
945 switch(mRotationAngle)
949 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
950 convertedPosition.y = position.x;
955 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
956 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
961 convertedPosition.x = position.y;
962 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
967 convertedPosition = position;
972 point.SetScreenPosition(convertedPosition);
975 Dali::Window Window::Get(Dali::Actor actor)
977 Internal::Adaptor::Window* windowImpl = nullptr;
979 if(Internal::Adaptor::Adaptor::IsAvailable())
981 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
982 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
985 return Dali::Window(windowImpl);
989 return Dali::Window();
992 void Window::SetParent(Dali::Window& parent)
994 if(DALI_UNLIKELY(parent))
996 mParentWindow = parent;
997 Dali::Window self = Dali::Window(this);
998 // check circular parent window setting
999 if(Dali::DevelWindow::GetParent(parent) == self)
1001 Dali::DevelWindow::Unparent(parent);
1003 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1007 void Window::SetParent(Dali::Window& parent, bool belowParent)
1009 if(DALI_UNLIKELY(parent))
1011 mParentWindow = parent;
1012 Dali::Window self = Dali::Window(this);
1013 // check circular parent window setting
1014 if(Dali::DevelWindow::GetParent(parent) == self)
1016 Dali::DevelWindow::Unparent(parent);
1018 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1022 void Window::Unparent()
1024 mWindowBase->SetParent(nullptr, false);
1025 mParentWindow.Reset();
1028 Dali::Window Window::GetParent()
1030 return mParentWindow;
1033 WindowOrientation Window::GetCurrentOrientation() const
1035 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1036 return ConvertToOrientation(mRotationAngle);
1039 int Window::GetPhysicalOrientation() const
1041 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1044 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1046 Dali::Vector<float>::SizeType count = orientations.Count();
1047 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1049 if(IsOrientationAvailable(orientations[index]) == false)
1051 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1056 int convertedAngle = ConvertToAngle(orientations[index]);
1058 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1060 if(mAvailableAngles[i] == convertedAngle)
1069 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1070 mAvailableAngles.push_back(convertedAngle);
1073 SetAvailableAnlges(mAvailableAngles);
1076 int32_t Window::GetNativeId() const
1078 return mWindowBase->GetNativeWindowId();
1081 void Window::RequestMoveToServer()
1083 mWindowBase->RequestMoveToServer();
1086 void Window::RequestResizeToServer(WindowResizeDirection direction)
1088 mWindowBase->RequestResizeToServer(direction);
1091 void Window::EnableFloatingMode(bool enable)
1093 mWindowBase->EnableFloatingMode(enable);
1096 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1099 int screenWidth, screenHeight;
1101 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1103 if(mRotationAngle == 90)
1106 newRect.y = screenHeight - (rect.x + rect.width);
1107 newRect.width = rect.height;
1108 newRect.height = rect.width;
1110 else if(mRotationAngle == 180)
1112 newRect.x = screenWidth - (rect.x + rect.width);
1113 newRect.y = screenHeight - (rect.y + rect.height);
1114 newRect.width = rect.width;
1115 newRect.height = rect.height;
1117 else if(mRotationAngle == 270)
1119 newRect.x = screenWidth - (rect.y + rect.height);
1121 newRect.width = rect.height;
1122 newRect.height = rect.width;
1128 newRect.width = rect.width;
1129 newRect.height = rect.height;
1134 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1136 Rect<int> convertRegion = RecalculateRect(inputRegion);
1138 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);
1139 mWindowBase->IncludeInputRegion(convertRegion);
1142 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1144 Rect<int> convertRegion = RecalculateRect(inputRegion);
1146 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);
1147 mWindowBase->ExcludeInputRegion(convertRegion);
1150 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1152 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1153 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1154 mWindowRotationAcknowledgement = needAcknowledgement;
1157 void Window::SendRotationCompletedAcknowledgement()
1159 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1160 if(mWindowRotationAcknowledgement)
1162 SetRotationCompletedAcknowledgement();
1166 } // namespace Adaptor
1168 } // namespace Internal