2 * Copyright (c) 2023 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/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.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");
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),
79 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
84 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
85 mDeleteRequestSignal(),
88 mVisibilityChangedSignal(),
89 mTransitionEffectEventSignal(),
90 mKeyboardRepeatSettingsChangedSignal(),
91 mAuxiliaryMessageSignal(),
93 mOrientationChangedSignal(),
94 mMouseInOutEventSignal(),
95 mMoveCompletedSignal(),
96 mResizeCompletedSignal(),
99 mIsTransparent(false),
100 mIsFocusAcceptable(true),
104 mWindowRotationAcknowledgement(false),
106 mIsWindowRotating(false),
107 mIsEnabledUserGeometry(false)
115 auto bridge = Accessibility::Bridge::GetCurrentBridge();
116 auto rootLayer = mScene.GetRootLayer();
117 auto accessible = Accessibility::Accessible::Get(rootLayer);
118 bridge->RemoveTopLevelWindow(accessible);
119 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
120 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
125 mAdaptor->RemoveWindow(this);
130 mEventHandler->RemoveObserver(*this);
134 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
136 // Create a window render surface
137 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
138 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
139 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
142 mWindowBase = mWindowSurface->GetWindowBase();
145 mWindowBase->SetType(type);
147 // Initialize for Ime window type
148 if(type == WindowType::IME)
150 mWindowBase->InitializeIme();
151 mWindowSurface->InitializeImeSurface();
155 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
156 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
157 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
158 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
159 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
160 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
161 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
162 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
163 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
164 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
165 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
166 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
168 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
169 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
171 SetClass(name, className);
173 mOrientation = Orientation::New(this);
175 // Get OrientationMode
176 int screenWidth, screenHeight;
177 WindowSystem::GetScreenSize(screenWidth, screenHeight);
178 if(screenWidth > screenHeight)
180 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
184 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
187 mWindowWidth = positionSize.width;
188 mWindowHeight = positionSize.height;
190 bool isSetWithScreenSize = false;
191 if(mWindowWidth <= 0 || mWindowHeight <= 0)
193 mWindowWidth = screenWidth;
194 mWindowHeight = screenHeight;
195 isSetWithScreenSize = true;
196 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
199 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
201 SetUserGeometryPolicy();
205 mNativeWindowId = mWindowBase->GetNativeWindowId();
208 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
215 mWindowSurface->SetRenderNotification(renderNotification);
218 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
220 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
221 mEventHandler->AddObserver(*this);
223 // Add Window to bridge for ATSPI
224 auto bridge = Accessibility::Bridge::GetCurrentBridge();
227 auto rootLayer = mScene.GetRootLayer();
228 auto accessible = Accessibility::Accessible::Get(rootLayer);
229 bridge->AddTopLevelWindow(accessible);
231 // Emit Window create event
232 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
233 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
236 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
237 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
239 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
240 // The show must be called after the adaptor is initialized.
244 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
246 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
249 void Window::SetClass(std::string name, std::string className)
252 mClassName = className;
253 mWindowBase->SetClass(name, className);
256 std::string Window::GetClassName() const
263 mWindowBase->Raise();
265 mSurface->SetFullSwapNextFrame();
267 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
272 mWindowBase->Lower();
274 mSurface->SetFullSwapNextFrame();
276 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
279 void Window::Activate()
281 mWindowBase->Activate();
283 mSurface->SetFullSwapNextFrame();
285 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
288 void Window::Maximize(bool maximize)
290 mWindowBase->Maximize(maximize);
292 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
295 bool Window::IsMaximized() const
297 return mWindowBase->IsMaximized();
300 void Window::SetMaximumSize(Dali::Window::WindowSize size)
302 mWindowBase->SetMaximumSize(size);
305 void Window::Minimize(bool minimize)
307 mWindowBase->Minimize(minimize);
309 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
312 bool Window::IsMinimized() const
314 return mWindowBase->IsMinimized();
317 void Window::SetMimimumSize(Dali::Window::WindowSize size)
319 mWindowBase->SetMimimumSize(size);
322 uint32_t Window::GetLayerCount() const
324 return mScene.GetLayerCount();
327 Dali::Layer Window::GetLayer(uint32_t depth) const
329 return mScene.GetLayer(depth);
332 void Window::KeepRendering(float durationSeconds)
334 mScene.KeepRendering(durationSeconds);
337 std::string Window::GetNativeResourceId() const
339 return mWindowBase->GetNativeWindowResourceId();
342 void Window::AddAvailableOrientation(WindowOrientation orientation)
344 if(IsOrientationAvailable(orientation) == false)
350 int convertedAngle = ConvertToAngle(orientation);
351 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
352 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
354 if(mAvailableAngles[i] == convertedAngle)
363 mAvailableAngles.push_back(convertedAngle);
364 SetAvailableAnlges(mAvailableAngles);
368 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
370 if(IsOrientationAvailable(orientation) == false)
375 int convertedAngle = ConvertToAngle(orientation);
376 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
377 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
378 iter != mAvailableAngles.end();
381 if(*iter == convertedAngle)
383 mAvailableAngles.erase(iter);
388 SetAvailableAnlges(mAvailableAngles);
391 void Window::SetPreferredOrientation(WindowOrientation orientation)
393 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
395 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
398 mPreferredAngle = ConvertToAngle(orientation);
399 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
400 mWindowBase->SetPreferredAngle(mPreferredAngle);
403 WindowOrientation Window::GetPreferredOrientation()
405 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
406 return preferredOrientation;
409 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
411 int angle = ConvertToAngle(orientation);
412 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
415 void Window::EmitAccessibilityHighlightSignal(bool highlight)
417 Dali::Window handle(this);
418 mAccessibilityHighlightSignal.Emit(handle, highlight);
421 void Window::SetAvailableAnlges(const std::vector<int>& angles)
423 if(angles.size() > 4)
425 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
429 mWindowBase->SetAvailableAnlges(angles);
432 int Window::ConvertToAngle(WindowOrientation orientation)
434 int convertAngle = static_cast<int>(orientation);
435 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
439 case WindowOrientation::LANDSCAPE:
444 case WindowOrientation::PORTRAIT:
449 case WindowOrientation::LANDSCAPE_INVERSE:
454 case WindowOrientation::PORTRAIT_INVERSE:
459 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
469 WindowOrientation Window::ConvertToOrientation(int angle) const
471 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
472 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
478 orientation = WindowOrientation::LANDSCAPE;
483 orientation = WindowOrientation::PORTRAIT;
488 orientation = WindowOrientation::LANDSCAPE_INVERSE;
493 orientation = WindowOrientation::PORTRAIT_INVERSE;
498 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
506 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
508 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
510 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
516 Dali::Any Window::GetNativeHandle() const
518 return mWindowSurface->GetNativeWindow();
521 void Window::SetAcceptFocus(bool accept)
523 mIsFocusAcceptable = accept;
525 mWindowBase->SetAcceptFocus(accept);
528 bool Window::IsFocusAcceptable() const
530 return mIsFocusAcceptable;
541 Dali::Window handle(this);
542 mVisibilityChangedSignal.Emit(handle, true);
543 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
545 WindowVisibilityObserver* observer(mAdaptor);
546 observer->OnWindowShown();
549 mSurface->SetFullSwapNextFrame();
551 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
562 Dali::Window handle(this);
563 mVisibilityChangedSignal.Emit(handle, false);
564 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
566 WindowVisibilityObserver* observer(mAdaptor);
567 observer->OnWindowHidden();
570 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
573 bool Window::IsVisible() const
575 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
576 return mVisible && !mIconified;
579 unsigned int Window::GetSupportedAuxiliaryHintCount() const
581 return mWindowBase->GetSupportedAuxiliaryHintCount();
584 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
586 return mWindowBase->GetSupportedAuxiliaryHint(index);
589 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
591 return mWindowBase->AddAuxiliaryHint(hint, value);
594 bool Window::RemoveAuxiliaryHint(unsigned int id)
596 return mWindowBase->RemoveAuxiliaryHint(id);
599 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
601 return mWindowBase->SetAuxiliaryHintValue(id, value);
604 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
606 return mWindowBase->GetAuxiliaryHintValue(id);
609 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
611 return mWindowBase->GetAuxiliaryHintId(hint);
614 void Window::SetInputRegion(const Rect<int>& inputRegion)
616 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
617 mWindowBase->SetInputRegion(inputRegion);
620 void Window::SetType(WindowType type)
622 mWindowBase->SetType(type);
625 WindowType Window::GetType() const
627 return mWindowBase->GetType();
630 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
632 WindowType type = mWindowBase->GetType();
633 if(type != WindowType::NOTIFICATION)
635 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
636 return WindowOperationResult::INVALID_OPERATION;
639 return mWindowBase->SetNotificationLevel(level);
642 WindowNotificationLevel Window::GetNotificationLevel() const
644 WindowType type = mWindowBase->GetType();
645 if(type != WindowType::NOTIFICATION)
647 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
648 return WindowNotificationLevel::NONE;
651 return mWindowBase->GetNotificationLevel();
654 void Window::SetOpaqueState(bool opaque)
656 mOpaqueState = opaque;
658 mWindowBase->SetOpaqueState(opaque);
660 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
663 bool Window::IsOpaqueState() const
668 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
670 return mWindowBase->SetScreenOffMode(screenOffMode);
673 WindowScreenOffMode Window::GetScreenOffMode() const
675 return mWindowBase->GetScreenOffMode();
678 WindowOperationResult Window::SetBrightness(int brightness)
680 if(brightness < 0 || brightness > 100)
682 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
683 return WindowOperationResult::INVALID_OPERATION;
686 return mWindowBase->SetBrightness(brightness);
689 int Window::GetBrightness() const
691 return mWindowBase->GetBrightness();
694 void Window::SetSize(Dali::Window::WindowSize size)
696 PositionSize oldRect = GetPositionSize();
698 PositionSize newRect;
699 newRect.width = size.GetWidth();
700 newRect.height = size.GetHeight();
702 SetUserGeometryPolicy();
704 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
705 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
707 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
709 Uint16Pair newSize(newRect.width, newRect.height);
711 mWindowWidth = newRect.width;
712 mWindowHeight = newRect.height;
714 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetSize(): (%d, %d), [%d x %d]\n", this, mNativeWindowId, mRotationAngle, oldRect.x, oldRect.y, newRect.width, newRect.height);
716 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
718 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
720 Dali::Window handle(this);
721 mResizeSignal.Emit(handle, newSize);
723 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
726 mSurface->SetFullSwapNextFrame();
728 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
731 Dali::Window::WindowSize Window::GetSize() const
733 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
736 void Window::SetPosition(Dali::Window::WindowPosition position)
738 PositionSize oldRect = mSurface->GetPositionSize();
739 int32_t newX = position.GetX();
740 int32_t newY = position.GetY();
742 SetUserGeometryPolicy();
744 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
746 if((oldRect.x != newX) || (oldRect.y != newY))
748 Dali::Window handle(this);
749 Dali::Window::WindowPosition newPosition(newX, newY);
751 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
752 mMovedSignal.Emit(handle, newPosition);
755 mSurface->SetFullSwapNextFrame();
757 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
760 Dali::Window::WindowPosition Window::GetPosition() const
762 PositionSize positionSize = GetPositionSize();
763 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
766 PositionSize Window::GetPositionSize() const
768 PositionSize positionSize = mSurface->GetPositionSize();
769 positionSize.width = mWindowWidth;
770 positionSize.height = mWindowHeight;
774 void Window::SetPositionSize(PositionSize positionSize)
779 PositionSize oldRect = GetPositionSize();
780 Dali::Window handle(this);
782 SetUserGeometryPolicy();
784 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
789 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
796 mWindowSurface->MoveResize(positionSize);
799 // When window is moved, emit Moved Signal
802 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
803 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
804 mMovedSignal.Emit(handle, position);
807 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
810 Uint16Pair newSize(positionSize.width, positionSize.height);
812 mWindowWidth = positionSize.width;
813 mWindowHeight = positionSize.height;
815 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
817 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
819 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
821 mResizeSignal.Emit(handle, newSize);
822 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
825 mSurface->SetFullSwapNextFrame();
827 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
830 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
832 SetUserGeometryPolicy();
833 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
836 Dali::Layer Window::GetRootLayer() const
838 return mScene.GetRootLayer();
841 void Window::SetTransparency(bool transparent)
843 mWindowSurface->SetTransparency(transparent);
846 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
848 return mWindowBase->GrabKey(key, grabMode);
851 bool Window::UngrabKey(Dali::KEY key)
853 return mWindowBase->UngrabKey(key);
856 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
858 return mWindowBase->GrabKeyList(key, grabMode, result);
861 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
863 return mWindowBase->UngrabKeyList(key, result);
866 void Window::OnIconifyChanged(bool iconified)
868 const bool isActuallyChanged = (iconified != mIconified);
869 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
870 Dali::Window handle(this);
878 mVisibilityChangedSignal.Emit(handle, false);
879 bridge->WindowHidden(handle);
881 WindowVisibilityObserver* observer(mAdaptor);
882 observer->OnWindowHidden();
885 if(isActuallyChanged)
887 bridge->WindowMinimized(handle);
890 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
898 mVisibilityChangedSignal.Emit(handle, true);
899 bridge->WindowShown(handle);
901 WindowVisibilityObserver* observer(mAdaptor);
902 observer->OnWindowShown();
905 if(isActuallyChanged)
907 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
910 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
913 mSurface->SetFullSwapNextFrame();
916 void Window::OnMaximizeChanged(bool maximized)
918 const bool isActuallyChanged = (maximized != mMaximized);
920 if(isActuallyChanged)
922 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
923 Dali::Window handle(this);
928 bridge->WindowMaximized(handle);
933 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
938 void Window::OnFocusChanged(bool focusIn)
940 Dali::Window handle(this);
941 mFocusChangeSignal.Emit(handle, focusIn);
943 mSurface->SetFullSwapNextFrame();
944 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
948 bridge->WindowFocused(handle);
952 bridge->WindowUnfocused(handle);
958 void Window::OnOutputTransformed()
960 PositionSize positionSize = GetPositionSize();
962 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
964 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
965 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
968 void Window::OnDeleteRequest()
970 mDeleteRequestSignal.Emit();
973 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
975 Dali::Window handle(this);
976 mTransitionEffectEventSignal.Emit(handle, state, type);
979 void Window::OnKeyboardRepeatSettingsChanged()
981 Dali::Window handle(this);
982 mKeyboardRepeatSettingsChangedSignal.Emit();
985 void Window::OnWindowRedrawRequest()
987 mAdaptor->RenderOnce();
990 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
995 Dali::Window handle(this);
997 PositionSize oldRect = GetPositionSize();
998 PositionSize newRect = positionSize;
1000 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1005 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1012 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), position or size is updated by server , (%d, %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.x, newRect.y, newRect.width, newRect.height);
1013 mWindowSurface->UpdatePositionSize(positionSize);
1016 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1018 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1019 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1020 mMovedSignal.Emit(handle, position);
1023 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1024 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1026 Uint16Pair newSize(newRect.width, newRect.height);
1028 mWindowWidth = newRect.width;
1029 mWindowHeight = newRect.height;
1031 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1033 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1035 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1036 mResizeSignal.Emit(handle, newSize);
1037 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1040 mSurface->SetFullSwapNextFrame();
1042 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1045 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1047 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1048 FeedTouchPoint(point, timeStamp);
1051 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1053 FeedWheelEvent(wheelEvent);
1056 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1058 mLastKeyEvent = Dali::DevelKeyEvent::New(keyEvent.keyName, keyEvent.logicalKey, keyEvent.keyString, keyEvent.keyCode, keyEvent.keyModifier, keyEvent.time, static_cast<Dali::KeyEvent::State>(keyEvent.state), keyEvent.compose, keyEvent.deviceName, keyEvent.deviceClass, keyEvent.deviceSubclass);
1059 FeedKeyEvent(keyEvent);
1062 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1064 Dali::Window handle(this);
1066 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1069 void Window::OnRotation(const RotationEvent& rotation)
1071 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1073 mRotationAngle = rotation.angle;
1074 mWindowWidth = rotation.width;
1075 mWindowHeight = rotation.height;
1077 mIsWindowRotating = true;
1078 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), angle(%d), Window Rotation (%d , %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newPositionSize.x, newPositionSize.y, mWindowWidth, mWindowHeight);
1080 // Notify that the orientation is changed
1081 mOrientation->OnOrientationChange(rotation);
1083 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1085 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1087 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1089 Dali::Window handle(this);
1090 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1091 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1093 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1096 void Window::OnRotationFinished()
1098 mIsWindowRotating = false;
1099 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1102 void Window::OnPause()
1106 mEventHandler->Pause();
1110 void Window::OnResume()
1114 mEventHandler->Resume();
1117 mSurface->SetFullSwapNextFrame();
1120 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1122 mAuxiliaryMessageSignal.Emit(key, value, options);
1125 void Window::OnAccessibilityEnabled()
1127 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1128 auto rootLayer = mScene.GetRootLayer();
1129 auto accessible = Accessibility::Accessible::Get(rootLayer);
1130 bridge->AddTopLevelWindow(accessible);
1132 if(!mVisible || mIconified)
1137 Dali::Window handle(this);
1138 bridge->WindowShown(handle);
1142 bridge->WindowFocused(handle);
1146 void Window::OnAccessibilityDisabled()
1148 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1149 auto rootLayer = mScene.GetRootLayer();
1150 auto accessible = Accessibility::Accessible::Get(rootLayer);
1151 bridge->RemoveTopLevelWindow(accessible);
1154 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1156 Dali::Window handle(this);
1157 mMoveCompletedSignal.Emit(handle, position);
1160 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1162 Dali::Window handle(this);
1163 mResizeCompletedSignal.Emit(handle, size);
1166 Vector2 Window::RecalculatePosition(const Vector2& position)
1168 Vector2 convertedPosition;
1170 switch(mRotationAngle)
1174 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1175 convertedPosition.y = position.x;
1180 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1181 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1186 convertedPosition.x = position.y;
1187 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1192 convertedPosition = position;
1196 return convertedPosition;
1199 Dali::Window Window::Get(Dali::Actor actor)
1201 Internal::Adaptor::Window* windowImpl = nullptr;
1203 if(Internal::Adaptor::Adaptor::IsAvailable())
1205 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1206 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1209 return Dali::Window(windowImpl);
1213 return Dali::Window();
1216 void Window::SetParent(Dali::Window& parent)
1218 if(DALI_UNLIKELY(parent))
1220 mParentWindow = parent;
1221 Dali::Window self = Dali::Window(this);
1222 // check circular parent window setting
1223 if(Dali::DevelWindow::GetParent(parent) == self)
1225 Dali::DevelWindow::Unparent(parent);
1227 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1231 void Window::SetParent(Dali::Window& parent, bool belowParent)
1233 if(DALI_UNLIKELY(parent))
1235 mParentWindow = parent;
1236 Dali::Window self = Dali::Window(this);
1237 // check circular parent window setting
1238 if(Dali::DevelWindow::GetParent(parent) == self)
1240 Dali::DevelWindow::Unparent(parent);
1242 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1246 void Window::Unparent()
1248 mWindowBase->SetParent(nullptr, false);
1249 mParentWindow.Reset();
1252 Dali::Window Window::GetParent()
1254 return mParentWindow;
1257 WindowOrientation Window::GetCurrentOrientation() const
1259 return ConvertToOrientation(mRotationAngle);
1262 int Window::GetPhysicalOrientation() const
1264 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1267 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1269 Dali::Vector<float>::SizeType count = orientations.Count();
1270 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1272 if(IsOrientationAvailable(orientations[index]) == false)
1274 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1279 int convertedAngle = ConvertToAngle(orientations[index]);
1281 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1283 if(mAvailableAngles[i] == convertedAngle)
1292 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1293 mAvailableAngles.push_back(convertedAngle);
1296 SetAvailableAnlges(mAvailableAngles);
1299 int32_t Window::GetNativeId() const
1301 return mWindowBase->GetNativeWindowId();
1304 void Window::RequestMoveToServer()
1306 SetUserGeometryPolicy();
1307 mWindowBase->RequestMoveToServer();
1310 void Window::RequestResizeToServer(WindowResizeDirection direction)
1312 SetUserGeometryPolicy();
1313 mWindowBase->RequestResizeToServer(direction);
1316 void Window::EnableFloatingMode(bool enable)
1318 mWindowBase->EnableFloatingMode(enable);
1321 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1323 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1324 mWindowBase->IncludeInputRegion(inputRegion);
1327 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1329 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1330 mWindowBase->ExcludeInputRegion(inputRegion);
1333 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1335 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1336 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1337 mWindowRotationAcknowledgement = needAcknowledgement;
1340 void Window::SendRotationCompletedAcknowledgement()
1342 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1343 if(mWindowRotationAcknowledgement)
1345 SetRotationCompletedAcknowledgement();
1349 bool Window::IsWindowRotating() const
1351 return mIsWindowRotating;
1354 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1356 return mLastKeyEvent;
1359 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1361 return mLastTouchEvent;
1364 void Window::SetUserGeometryPolicy()
1366 if(mIsEnabledUserGeometry == true)
1371 mIsEnabledUserGeometry = true;
1372 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1373 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1376 } // namespace Adaptor
1378 } // namespace Internal