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),
86 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
90 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
92 mDeleteRequestSignal(),
95 mVisibilityChangedSignal(),
96 mTransitionEffectEventSignal(),
97 mKeyboardRepeatSettingsChangedSignal(),
98 mAuxiliaryMessageSignal()
106 auto bridge = Accessibility::Bridge::GetCurrentBridge();
107 auto rootLayer = mScene.GetRootLayer();
108 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
109 bridge->RemoveTopLevelWindow(accessible);
114 mAdaptor->RemoveWindow(this);
119 mEventHandler->RemoveObserver(*this);
123 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
125 // Create a window render surface
126 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
127 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
128 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
131 mWindowBase = mWindowSurface->GetWindowBase();
134 mWindowBase->SetType(type);
136 // Initialize for Ime window type
137 if(type == WindowType::IME)
139 mWindowBase->InitializeIme();
140 mWindowSurface->InitializeImeSurface();
144 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
145 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
146 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
147 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
148 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
149 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
150 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
151 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
153 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
155 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
157 SetClass(name, className);
159 mOrientation = Orientation::New(this);
161 // Get OrientationMode
162 int screenWidth, screenHeight;
163 WindowSystem::GetScreenSize(screenWidth, screenHeight);
164 if(screenWidth > screenHeight)
166 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
170 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
173 mNativeWindowId = mWindowBase->GetNativeWindowId();
176 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
178 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
179 mEventHandler->AddObserver(*this);
181 // Add Window to bridge for ATSPI
182 auto bridge = Accessibility::Bridge::GetCurrentBridge();
185 auto rootLayer = mScene.GetRootLayer();
186 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
187 bridge->AddTopLevelWindow(accessible);
190 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
191 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
193 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
194 // The show must be called after the adaptor is initialized.
198 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
200 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
203 void Window::SetClass(std::string name, std::string className)
206 mClassName = className;
207 mWindowBase->SetClass(name, className);
210 std::string Window::GetClassName() const
217 mWindowBase->Raise();
219 mSurface->SetFullSwapNextFrame();
221 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
226 mWindowBase->Lower();
228 mSurface->SetFullSwapNextFrame();
230 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
233 void Window::Activate()
235 mWindowBase->Activate();
237 mSurface->SetFullSwapNextFrame();
239 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
242 void Window::Maximize(bool maximize)
244 mWindowBase->Maximize(maximize);
246 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
249 bool Window::IsMaximized() const
251 return mWindowBase->IsMaximized();
254 void Window::Minimize(bool minimize)
256 mWindowBase->Minimize(minimize);
258 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
261 bool Window::IsMinimized() const
263 return mWindowBase->IsMinimized();
266 uint32_t Window::GetLayerCount() const
268 return mScene.GetLayerCount();
271 Dali::Layer Window::GetLayer(uint32_t depth) const
273 return mScene.GetLayer(depth);
276 Dali::RenderTaskList Window::GetRenderTaskList() const
278 return mScene.GetRenderTaskList();
281 std::string Window::GetNativeResourceId() const
283 return mWindowBase->GetNativeWindowResourceId();
286 void Window::AddAvailableOrientation(WindowOrientation orientation)
288 if(IsOrientationAvailable(orientation) == false)
294 int convertedAngle = ConvertToAngle(orientation);
295 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
296 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
298 if(mAvailableAngles[i] == convertedAngle)
307 mAvailableAngles.push_back(convertedAngle);
308 SetAvailableAnlges(mAvailableAngles);
312 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
314 if(IsOrientationAvailable(orientation) == false)
319 int convertedAngle = ConvertToAngle(orientation);
320 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
321 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
322 iter != mAvailableAngles.end();
325 if(*iter == convertedAngle)
327 mAvailableAngles.erase(iter);
332 SetAvailableAnlges(mAvailableAngles);
335 void Window::SetPreferredOrientation(WindowOrientation orientation)
337 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
339 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
342 mPreferredAngle = ConvertToAngle(orientation);
343 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
344 mWindowBase->SetPreferredAngle(mPreferredAngle);
347 WindowOrientation Window::GetPreferredOrientation()
349 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
350 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
351 return preferredOrientation;
354 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
356 int angle = ConvertToAngle(orientation);
357 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
360 void Window::EmitAccessibilityHighlightSignal(bool highlight)
362 Dali::Window handle(this);
363 mAccessibilityHighlightSignal.Emit(handle, highlight);
366 void Window::SetAvailableAnlges(const std::vector<int>& angles)
368 if(angles.size() > 4)
370 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
374 mWindowBase->SetAvailableAnlges(angles);
377 int Window::ConvertToAngle(WindowOrientation orientation)
379 int convertAngle = static_cast<int>(orientation);
380 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
384 case WindowOrientation::LANDSCAPE:
389 case WindowOrientation::PORTRAIT:
394 case WindowOrientation::LANDSCAPE_INVERSE:
399 case WindowOrientation::PORTRAIT_INVERSE:
404 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
414 WindowOrientation Window::ConvertToOrientation(int angle) const
416 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
417 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
423 orientation = WindowOrientation::LANDSCAPE;
428 orientation = WindowOrientation::PORTRAIT;
433 orientation = WindowOrientation::LANDSCAPE_INVERSE;
438 orientation = WindowOrientation::PORTRAIT_INVERSE;
443 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
451 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
453 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
455 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
461 Dali::Any Window::GetNativeHandle() const
463 return mWindowSurface->GetNativeWindow();
466 void Window::SetAcceptFocus(bool accept)
468 mIsFocusAcceptable = accept;
470 mWindowBase->SetAcceptFocus(accept);
473 bool Window::IsFocusAcceptable() const
475 return mIsFocusAcceptable;
486 Dali::Window handle(this);
487 mVisibilityChangedSignal.Emit(handle, true);
488 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
490 WindowVisibilityObserver* observer(mAdaptor);
491 observer->OnWindowShown();
494 mSurface->SetFullSwapNextFrame();
496 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
507 Dali::Window handle(this);
508 mVisibilityChangedSignal.Emit(handle, false);
509 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
511 WindowVisibilityObserver* observer(mAdaptor);
512 observer->OnWindowHidden();
515 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
518 bool Window::IsVisible() const
520 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
521 return mVisible && !mIconified;
524 unsigned int Window::GetSupportedAuxiliaryHintCount() const
526 return mWindowBase->GetSupportedAuxiliaryHintCount();
529 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
531 return mWindowBase->GetSupportedAuxiliaryHint(index);
534 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
536 return mWindowBase->AddAuxiliaryHint(hint, value);
539 bool Window::RemoveAuxiliaryHint(unsigned int id)
541 return mWindowBase->RemoveAuxiliaryHint(id);
544 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
546 return mWindowBase->SetAuxiliaryHintValue(id, value);
549 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
551 return mWindowBase->GetAuxiliaryHintValue(id);
554 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
556 return mWindowBase->GetAuxiliaryHintId(hint);
559 void Window::SetInputRegion(const Rect<int>& inputRegion)
561 Rect<int> convertRegion = RecalculateRect(inputRegion);
563 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);
565 mWindowBase->SetInputRegion(convertRegion);
568 void Window::SetType(WindowType type)
570 mWindowBase->SetType(type);
573 WindowType Window::GetType() const
575 return mWindowBase->GetType();
578 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
580 WindowType type = mWindowBase->GetType();
581 if(type != WindowType::NOTIFICATION)
583 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
584 return WindowOperationResult::INVALID_OPERATION;
587 return mWindowBase->SetNotificationLevel(level);
590 WindowNotificationLevel Window::GetNotificationLevel() const
592 WindowType type = mWindowBase->GetType();
593 if(type != WindowType::NOTIFICATION)
595 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
596 return WindowNotificationLevel::NONE;
599 return mWindowBase->GetNotificationLevel();
602 void Window::SetOpaqueState(bool opaque)
604 mOpaqueState = opaque;
606 mWindowBase->SetOpaqueState(opaque);
608 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
611 bool Window::IsOpaqueState() const
616 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
618 return mWindowBase->SetScreenOffMode(screenOffMode);
621 WindowScreenOffMode Window::GetScreenOffMode() const
623 return mWindowBase->GetScreenOffMode();
626 WindowOperationResult Window::SetBrightness(int brightness)
628 if(brightness < 0 || brightness > 100)
630 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
631 return WindowOperationResult::INVALID_OPERATION;
634 return mWindowBase->SetBrightness(brightness);
637 int Window::GetBrightness() const
639 return mWindowBase->GetBrightness();
642 void Window::SetSize(Dali::Window::WindowSize size)
644 PositionSize oldRect = mSurface->GetPositionSize();
646 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
648 PositionSize newRect = mSurface->GetPositionSize();
650 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
651 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
653 Uint16Pair newSize(newRect.width, newRect.height);
657 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
659 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
661 Dali::Window handle(this);
662 mResizeSignal.Emit(handle, newSize);
664 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
667 mSurface->SetFullSwapNextFrame();
669 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
672 Dali::Window::WindowSize Window::GetSize() const
674 PositionSize positionSize = mSurface->GetPositionSize();
676 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
679 void Window::SetPosition(Dali::Window::WindowPosition position)
681 PositionSize oldRect = mSurface->GetPositionSize();
683 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
685 mSurface->SetFullSwapNextFrame();
687 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
690 Dali::Window::WindowPosition Window::GetPosition() const
692 PositionSize positionSize = mSurface->GetPositionSize();
694 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
697 PositionSize Window::GetPositionSize() const
699 return mSurface->GetPositionSize();
702 void Window::SetPositionSize(PositionSize positionSize)
704 PositionSize oldRect = mSurface->GetPositionSize();
706 mWindowSurface->MoveResize(positionSize);
708 PositionSize newRect = mSurface->GetPositionSize();
710 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
711 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
713 Uint16Pair newSize(newRect.width, newRect.height);
717 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
719 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
720 Dali::Window handle(this);
721 mResizeSignal.Emit(handle, newSize);
722 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
725 mSurface->SetFullSwapNextFrame();
727 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
730 Dali::Layer Window::GetRootLayer() const
732 return mScene.GetRootLayer();
735 void Window::SetTransparency(bool transparent)
737 mWindowSurface->SetTransparency(transparent);
740 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
742 return mWindowBase->GrabKey(key, grabMode);
745 bool Window::UngrabKey(Dali::KEY key)
747 return mWindowBase->UngrabKey(key);
750 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
752 return mWindowBase->GrabKeyList(key, grabMode, result);
755 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
757 return mWindowBase->UngrabKeyList(key, result);
760 void Window::OnIconifyChanged(bool iconified)
768 Dali::Window handle(this);
769 mVisibilityChangedSignal.Emit(handle, false);
770 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
772 WindowVisibilityObserver* observer(mAdaptor);
773 observer->OnWindowHidden();
776 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
784 Dali::Window handle(this);
785 mVisibilityChangedSignal.Emit(handle, true);
786 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
788 WindowVisibilityObserver* observer(mAdaptor);
789 observer->OnWindowShown();
792 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
795 mSurface->SetFullSwapNextFrame();
798 void Window::OnFocusChanged(bool focusIn)
800 Dali::Window handle(this);
801 mFocusChangeSignal.Emit(handle, focusIn);
803 mSurface->SetFullSwapNextFrame();
805 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
809 bridge->WindowFocused(handle);
813 bridge->WindowUnfocused(handle);
819 void Window::OnOutputTransformed()
821 PositionSize positionSize = mSurface->GetPositionSize();
823 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
824 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
826 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
827 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
830 void Window::OnDeleteRequest()
832 mDeleteRequestSignal.Emit();
835 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
837 Dali::Window handle(this);
838 mTransitionEffectEventSignal.Emit(handle, state, type);
841 void Window::OnKeyboardRepeatSettingsChanged()
843 Dali::Window handle(this);
844 mKeyboardRepeatSettingsChangedSignal.Emit();
847 void Window::OnWindowRedrawRequest()
849 mAdaptor->RenderOnce();
852 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
854 PositionSize oldRect = mSurface->GetPositionSize();
856 mWindowSurface->UpdatePositionSize(positionSize);
858 PositionSize newRect = positionSize;
860 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
861 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
863 Uint16Pair newSize(newRect.width, newRect.height);
867 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
869 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
870 Dali::Window handle(this);
871 mResizeSignal.Emit(handle, newSize);
872 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
875 mSurface->SetFullSwapNextFrame();
877 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
880 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
882 FeedTouchPoint(point, timeStamp);
885 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
887 FeedWheelEvent(wheelEvent);
890 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
892 FeedKeyEvent(keyEvent);
895 void Window::OnRotation(const RotationEvent& rotation)
897 mRotationAngle = rotation.angle;
898 mWindowWidth = rotation.width;
899 mWindowHeight = rotation.height;
901 // Notify that the orientation is changed
902 mOrientation->OnOrientationChange(rotation);
904 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
906 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
907 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
909 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
911 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
913 Dali::Window handle(this);
914 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
916 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
919 void Window::OnPause()
923 mEventHandler->Pause();
927 void Window::OnResume()
931 mEventHandler->Resume();
934 mSurface->SetFullSwapNextFrame();
937 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
939 mAuxiliaryMessageSignal.Emit(key, value, options);
942 void Window::OnAccessibilityEnabled()
944 auto bridge = Accessibility::Bridge::GetCurrentBridge();
945 auto rootLayer = mScene.GetRootLayer();
946 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
947 bridge->AddTopLevelWindow(accessible);
951 Dali::Window handle(this);
952 bridge->WindowFocused(handle);
956 void Window::OnAccessibilityDisabled()
958 auto bridge = Accessibility::Bridge::GetCurrentBridge();
959 auto rootLayer = mScene.GetRootLayer();
960 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
961 bridge->RemoveTopLevelWindow(accessible);
964 void Window::RecalculateTouchPosition(Integration::Point& point)
966 Vector2 position = point.GetScreenPosition();
967 Vector2 convertedPosition;
969 switch(mRotationAngle)
973 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
974 convertedPosition.y = position.x;
979 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
980 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
985 convertedPosition.x = position.y;
986 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
991 convertedPosition = position;
996 point.SetScreenPosition(convertedPosition);
999 Dali::Window Window::Get(Dali::Actor actor)
1001 Internal::Adaptor::Window* windowImpl = nullptr;
1003 if(Internal::Adaptor::Adaptor::IsAvailable())
1005 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1006 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1009 return Dali::Window(windowImpl);
1013 return Dali::Window();
1016 void Window::SetParent(Dali::Window& parent)
1018 if(DALI_UNLIKELY(parent))
1020 mParentWindow = parent;
1021 Dali::Window self = Dali::Window(this);
1022 // check circular parent window setting
1023 if(Dali::DevelWindow::GetParent(parent) == self)
1025 Dali::DevelWindow::Unparent(parent);
1027 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1031 void Window::SetParent(Dali::Window& parent, bool belowParent)
1033 if(DALI_UNLIKELY(parent))
1035 mParentWindow = parent;
1036 Dali::Window self = Dali::Window(this);
1037 // check circular parent window setting
1038 if(Dali::DevelWindow::GetParent(parent) == self)
1040 Dali::DevelWindow::Unparent(parent);
1042 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1046 void Window::Unparent()
1048 mWindowBase->SetParent(nullptr, false);
1049 mParentWindow.Reset();
1052 Dali::Window Window::GetParent()
1054 return mParentWindow;
1057 WindowOrientation Window::GetCurrentOrientation() const
1059 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1060 return ConvertToOrientation(mRotationAngle);
1063 int Window::GetPhysicalOrientation() const
1065 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1068 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1070 Dali::Vector<float>::SizeType count = orientations.Count();
1071 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1073 if(IsOrientationAvailable(orientations[index]) == false)
1075 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1080 int convertedAngle = ConvertToAngle(orientations[index]);
1082 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1084 if(mAvailableAngles[i] == convertedAngle)
1093 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1094 mAvailableAngles.push_back(convertedAngle);
1097 SetAvailableAnlges(mAvailableAngles);
1100 int32_t Window::GetNativeId() const
1102 return mWindowBase->GetNativeWindowId();
1105 void Window::RequestMoveToServer()
1107 mWindowBase->RequestMoveToServer();
1110 void Window::RequestResizeToServer(WindowResizeDirection direction)
1112 mWindowBase->RequestResizeToServer(direction);
1115 void Window::EnableFloatingMode(bool enable)
1117 mWindowBase->EnableFloatingMode(enable);
1120 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1123 int screenWidth, screenHeight;
1125 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1127 if(mRotationAngle == 90)
1130 newRect.y = screenHeight - (rect.x + rect.width);
1131 newRect.width = rect.height;
1132 newRect.height = rect.width;
1134 else if(mRotationAngle == 180)
1136 newRect.x = screenWidth - (rect.x + rect.width);
1137 newRect.y = screenHeight - (rect.y + rect.height);
1138 newRect.width = rect.width;
1139 newRect.height = rect.height;
1141 else if(mRotationAngle == 270)
1143 newRect.x = screenWidth - (rect.y + rect.height);
1145 newRect.width = rect.height;
1146 newRect.height = rect.width;
1152 newRect.width = rect.width;
1153 newRect.height = rect.height;
1158 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1160 Rect<int> convertRegion = RecalculateRect(inputRegion);
1162 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);
1163 mWindowBase->IncludeInputRegion(convertRegion);
1166 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1168 Rect<int> convertRegion = RecalculateRect(inputRegion);
1170 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);
1171 mWindowBase->ExcludeInputRegion(convertRegion);
1174 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1176 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1177 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1178 mWindowRotationAcknowledgement = needAcknowledgement;
1181 void Window::SendRotationCompletedAcknowledgement()
1183 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1184 if(mWindowRotationAcknowledgement)
1186 SetRotationCompletedAcknowledgement();
1190 } // namespace Adaptor
1192 } // namespace Internal