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 std::string& name, const std::string& className, const WindowData& windowData)
64 return Window::New(surface, name, className, windowData);
67 Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
69 Window* window = new Window();
70 window->mIsTransparent = windowData.GetTransparency();
71 window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
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 mMouseRelativeEventSignal(),
96 mMoveCompletedSignal(),
97 mResizeCompletedSignal(),
98 mInsetsChangedSignal(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
106 mWindowRotationAcknowledgement(false),
108 mIsWindowRotating(false),
109 mIsEnabledUserGeometry(false)
117 auto bridge = Accessibility::Bridge::GetCurrentBridge();
118 auto rootLayer = mScene.GetRootLayer();
119 auto accessible = Accessibility::Accessible::Get(rootLayer);
120 bridge->RemoveTopLevelWindow(accessible);
121 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
122 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
127 mAdaptor->RemoveWindow(this);
132 mEventHandler->RemoveObserver(*this);
136 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
138 // Create a window render surface
139 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
140 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
141 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
144 mWindowBase = mWindowSurface->GetWindowBase();
147 mWindowBase->SetType(type);
149 // Initialize for Ime window type
150 if(type == WindowType::IME)
152 mWindowBase->InitializeIme();
153 mWindowSurface->InitializeImeSurface();
157 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
158 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
159 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
160 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
161 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
162 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
163 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
164 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
165 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
166 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
167 mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
168 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
169 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
171 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
172 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
174 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
176 SetClass(name, className);
178 mOrientation = Orientation::New(this);
180 // Get OrientationMode
181 int screenWidth, screenHeight;
182 WindowSystem::GetScreenSize(screenWidth, screenHeight);
183 if(screenWidth > screenHeight)
185 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
189 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
192 mWindowWidth = positionSize.width;
193 mWindowHeight = positionSize.height;
195 bool isSetWithScreenSize = false;
196 if(mWindowWidth <= 0 || mWindowHeight <= 0)
198 mWindowWidth = screenWidth;
199 mWindowHeight = screenHeight;
200 isSetWithScreenSize = true;
201 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
204 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
206 SetUserGeometryPolicy();
210 mNativeWindowId = mWindowBase->GetNativeWindowId();
213 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
220 mWindowSurface->SetRenderNotification(renderNotification);
223 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
225 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
226 mEventHandler->AddObserver(*this);
228 // Add Window to bridge for ATSPI
229 auto bridge = Accessibility::Bridge::GetCurrentBridge();
232 auto rootLayer = mScene.GetRootLayer();
233 auto accessible = Accessibility::Accessible::Get(rootLayer);
234 bridge->AddTopLevelWindow(accessible);
236 // Emit Window create event
237 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
238 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
241 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
242 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
244 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
245 // The show must be called after the adaptor is initialized.
249 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
251 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
254 void Window::SetClass(std::string name, std::string className)
257 mClassName = className;
258 mWindowBase->SetClass(name, className);
261 std::string Window::GetClassName() const
268 mWindowBase->Raise();
270 mSurface->SetFullSwapNextFrame();
272 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
277 mWindowBase->Lower();
279 mSurface->SetFullSwapNextFrame();
281 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
284 void Window::Activate()
286 mWindowBase->Activate();
288 mSurface->SetFullSwapNextFrame();
290 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
293 void Window::Maximize(bool maximize)
295 mWindowBase->Maximize(maximize);
297 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
300 bool Window::IsMaximized() const
302 return mWindowBase->IsMaximized();
305 void Window::SetMaximumSize(Dali::Window::WindowSize size)
307 mWindowBase->SetMaximumSize(size);
310 void Window::Minimize(bool minimize)
312 mWindowBase->Minimize(minimize);
314 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
317 bool Window::IsMinimized() const
319 return mWindowBase->IsMinimized();
322 void Window::SetMimimumSize(Dali::Window::WindowSize size)
324 mWindowBase->SetMimimumSize(size);
327 uint32_t Window::GetLayerCount() const
329 return mScene.GetLayerCount();
332 Dali::Layer Window::GetLayer(uint32_t depth) const
334 return mScene.GetLayer(depth);
337 void Window::KeepRendering(float durationSeconds)
339 mScene.KeepRendering(durationSeconds);
342 void Window::SetPartialUpdateEnabled(bool enabled)
344 mScene.SetPartialUpdateEnabled(enabled);
347 bool Window::IsPartialUpdateEnabled() const
349 return mScene.IsPartialUpdateEnabled();
352 std::string Window::GetNativeResourceId() const
354 return mWindowBase->GetNativeWindowResourceId();
357 void Window::AddAvailableOrientation(WindowOrientation orientation)
359 if(IsOrientationAvailable(orientation) == false)
365 int convertedAngle = ConvertToAngle(orientation);
366 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
367 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
369 if(mAvailableAngles[i] == convertedAngle)
378 mAvailableAngles.push_back(convertedAngle);
379 SetAvailableAnlges(mAvailableAngles);
383 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
385 if(IsOrientationAvailable(orientation) == false)
390 int convertedAngle = ConvertToAngle(orientation);
391 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
392 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
393 iter != mAvailableAngles.end();
396 if(*iter == convertedAngle)
398 mAvailableAngles.erase(iter);
403 SetAvailableAnlges(mAvailableAngles);
406 void Window::SetPreferredOrientation(WindowOrientation orientation)
408 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
410 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
413 mPreferredAngle = ConvertToAngle(orientation);
414 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
415 mWindowBase->SetPreferredAngle(mPreferredAngle);
418 WindowOrientation Window::GetPreferredOrientation()
420 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
421 return preferredOrientation;
424 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
426 int angle = ConvertToAngle(orientation);
427 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
430 void Window::EmitAccessibilityHighlightSignal(bool highlight)
432 Dali::Window handle(this);
433 mAccessibilityHighlightSignal.Emit(handle, highlight);
436 void Window::SetAvailableAnlges(const std::vector<int>& angles)
438 if(angles.size() > 4)
440 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
444 mWindowBase->SetAvailableAnlges(angles);
447 int Window::ConvertToAngle(WindowOrientation orientation)
449 int convertAngle = static_cast<int>(orientation);
450 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
454 case WindowOrientation::LANDSCAPE:
459 case WindowOrientation::PORTRAIT:
464 case WindowOrientation::LANDSCAPE_INVERSE:
469 case WindowOrientation::PORTRAIT_INVERSE:
474 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
484 WindowOrientation Window::ConvertToOrientation(int angle) const
486 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
487 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
493 orientation = WindowOrientation::LANDSCAPE;
498 orientation = WindowOrientation::PORTRAIT;
503 orientation = WindowOrientation::LANDSCAPE_INVERSE;
508 orientation = WindowOrientation::PORTRAIT_INVERSE;
513 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
521 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
523 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
525 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
531 Dali::Any Window::GetNativeHandle() const
533 return mWindowSurface->GetNativeWindow();
536 void Window::SetAcceptFocus(bool accept)
538 mIsFocusAcceptable = accept;
540 mWindowBase->SetAcceptFocus(accept);
543 bool Window::IsFocusAcceptable() const
545 return mIsFocusAcceptable;
556 Dali::Window handle(this);
557 mVisibilityChangedSignal.Emit(handle, true);
558 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
560 WindowVisibilityObserver* observer(mAdaptor);
561 observer->OnWindowShown();
564 mSurface->SetFullSwapNextFrame();
566 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
577 Dali::Window handle(this);
578 mVisibilityChangedSignal.Emit(handle, false);
579 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
581 WindowVisibilityObserver* observer(mAdaptor);
582 observer->OnWindowHidden();
585 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
588 bool Window::IsVisible() const
590 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
591 return mVisible && !mIconified;
594 unsigned int Window::GetSupportedAuxiliaryHintCount() const
596 return mWindowBase->GetSupportedAuxiliaryHintCount();
599 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
601 return mWindowBase->GetSupportedAuxiliaryHint(index);
604 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
606 return mWindowBase->AddAuxiliaryHint(hint, value);
609 bool Window::RemoveAuxiliaryHint(unsigned int id)
611 return mWindowBase->RemoveAuxiliaryHint(id);
614 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
616 return mWindowBase->SetAuxiliaryHintValue(id, value);
619 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
621 return mWindowBase->GetAuxiliaryHintValue(id);
624 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
626 return mWindowBase->GetAuxiliaryHintId(hint);
629 void Window::SetInputRegion(const Rect<int>& inputRegion)
631 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);
632 mWindowBase->SetInputRegion(inputRegion);
635 void Window::SetType(WindowType type)
637 mWindowBase->SetType(type);
640 WindowType Window::GetType() const
642 return mWindowBase->GetType();
645 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
647 WindowType type = mWindowBase->GetType();
648 if(type != WindowType::NOTIFICATION)
650 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
651 return WindowOperationResult::INVALID_OPERATION;
654 return mWindowBase->SetNotificationLevel(level);
657 WindowNotificationLevel Window::GetNotificationLevel() const
659 WindowType type = mWindowBase->GetType();
660 if(type != WindowType::NOTIFICATION)
662 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
663 return WindowNotificationLevel::NONE;
666 return mWindowBase->GetNotificationLevel();
669 void Window::SetOpaqueState(bool opaque)
671 mOpaqueState = opaque;
673 mWindowBase->SetOpaqueState(opaque);
675 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
678 bool Window::IsOpaqueState() const
683 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
685 return mWindowBase->SetScreenOffMode(screenOffMode);
688 WindowScreenOffMode Window::GetScreenOffMode() const
690 return mWindowBase->GetScreenOffMode();
693 WindowOperationResult Window::SetBrightness(int brightness)
695 if(brightness < 0 || brightness > 100)
697 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
698 return WindowOperationResult::INVALID_OPERATION;
701 return mWindowBase->SetBrightness(brightness);
704 int Window::GetBrightness() const
706 return mWindowBase->GetBrightness();
709 void Window::SetSize(Dali::Window::WindowSize size)
711 PositionSize oldRect = GetPositionSize();
713 PositionSize newRect;
714 newRect.width = size.GetWidth();
715 newRect.height = size.GetHeight();
717 SetUserGeometryPolicy();
719 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
720 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
722 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
724 Uint16Pair newSize(newRect.width, newRect.height);
726 mWindowWidth = newRect.width;
727 mWindowHeight = newRect.height;
729 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);
731 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
733 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
735 Dali::Window handle(this);
736 mResizeSignal.Emit(handle, newSize);
738 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
741 mSurface->SetFullSwapNextFrame();
743 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
746 Dali::Window::WindowSize Window::GetSize() const
748 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
751 void Window::SetPosition(Dali::Window::WindowPosition position)
753 PositionSize oldRect = mSurface->GetPositionSize();
754 int32_t newX = position.GetX();
755 int32_t newY = position.GetY();
757 SetUserGeometryPolicy();
759 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
761 if((oldRect.x != newX) || (oldRect.y != newY))
763 Dali::Window handle(this);
764 Dali::Window::WindowPosition newPosition(newX, newY);
766 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
767 mMovedSignal.Emit(handle, newPosition);
770 mSurface->SetFullSwapNextFrame();
772 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
775 Dali::Window::WindowPosition Window::GetPosition() const
777 PositionSize positionSize = GetPositionSize();
778 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
781 PositionSize Window::GetPositionSize() const
783 PositionSize positionSize = mSurface->GetPositionSize();
784 positionSize.width = mWindowWidth;
785 positionSize.height = mWindowHeight;
789 void Window::SetPositionSize(PositionSize positionSize)
794 PositionSize oldRect = GetPositionSize();
795 Dali::Window handle(this);
797 SetUserGeometryPolicy();
799 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
804 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
811 mWindowSurface->MoveResize(positionSize);
814 // When window is moved, emit Moved Signal
817 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
818 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
819 mMovedSignal.Emit(handle, position);
822 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
825 Uint16Pair newSize(positionSize.width, positionSize.height);
827 mWindowWidth = positionSize.width;
828 mWindowHeight = positionSize.height;
830 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
832 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
834 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
836 mResizeSignal.Emit(handle, newSize);
837 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
840 mSurface->SetFullSwapNextFrame();
842 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
845 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
847 SetUserGeometryPolicy();
848 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
851 Dali::Layer Window::GetRootLayer() const
853 return mScene.GetRootLayer();
856 void Window::SetTransparency(bool transparent)
858 mWindowSurface->SetTransparency(transparent);
861 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
863 return mWindowBase->GrabKey(key, grabMode);
866 bool Window::UngrabKey(Dali::KEY key)
868 return mWindowBase->UngrabKey(key);
871 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
873 return mWindowBase->GrabKeyList(key, grabMode, result);
876 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
878 return mWindowBase->UngrabKeyList(key, result);
881 void Window::OnIconifyChanged(bool iconified)
883 const bool isActuallyChanged = (iconified != mIconified);
884 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
885 Dali::Window handle(this);
893 mVisibilityChangedSignal.Emit(handle, false);
894 bridge->WindowHidden(handle);
896 WindowVisibilityObserver* observer(mAdaptor);
897 observer->OnWindowHidden();
900 if(isActuallyChanged)
902 bridge->WindowMinimized(handle);
905 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
913 mVisibilityChangedSignal.Emit(handle, true);
914 bridge->WindowShown(handle);
916 WindowVisibilityObserver* observer(mAdaptor);
917 observer->OnWindowShown();
920 if(isActuallyChanged)
922 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
925 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
928 mSurface->SetFullSwapNextFrame();
931 void Window::OnMaximizeChanged(bool maximized)
933 const bool isActuallyChanged = (maximized != mMaximized);
935 if(isActuallyChanged)
937 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
938 Dali::Window handle(this);
943 bridge->WindowMaximized(handle);
948 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
953 void Window::OnFocusChanged(bool focusIn)
955 Dali::Window handle(this);
956 mFocusChangeSignal.Emit(handle, focusIn);
958 mSurface->SetFullSwapNextFrame();
959 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
963 bridge->WindowFocused(handle);
967 bridge->WindowUnfocused(handle);
973 void Window::OnOutputTransformed()
975 PositionSize positionSize = GetPositionSize();
977 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
979 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
980 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
983 void Window::OnDeleteRequest()
985 mDeleteRequestSignal.Emit();
988 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
990 Dali::Window handle(this);
991 mTransitionEffectEventSignal.Emit(handle, state, type);
994 void Window::OnKeyboardRepeatSettingsChanged()
996 Dali::Window handle(this);
997 mKeyboardRepeatSettingsChangedSignal.Emit();
1000 void Window::OnWindowRedrawRequest()
1002 mAdaptor->RenderOnce();
1005 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1008 bool resize = false;
1010 Dali::Window handle(this);
1012 PositionSize oldRect = GetPositionSize();
1013 PositionSize newRect = positionSize;
1015 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1020 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1027 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);
1028 mWindowSurface->UpdatePositionSize(positionSize);
1031 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1033 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1034 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1035 mMovedSignal.Emit(handle, position);
1038 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1039 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1041 Uint16Pair newSize(newRect.width, newRect.height);
1043 mWindowWidth = newRect.width;
1044 mWindowHeight = newRect.height;
1046 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1048 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1050 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1051 mResizeSignal.Emit(handle, newSize);
1052 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1055 mSurface->SetFullSwapNextFrame();
1057 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1060 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1062 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1063 FeedTouchPoint(point, timeStamp);
1066 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1068 FeedWheelEvent(wheelEvent);
1071 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1073 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);
1074 FeedKeyEvent(keyEvent);
1077 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1079 Dali::Window handle(this);
1081 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1084 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& MouseRelativeEvent)
1086 Dali::Window handle(this);
1088 mMouseRelativeEventSignal.Emit(handle, MouseRelativeEvent);
1091 void Window::OnRotation(const RotationEvent& rotation)
1093 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1095 mRotationAngle = rotation.angle;
1096 mWindowWidth = rotation.width;
1097 mWindowHeight = rotation.height;
1099 mIsWindowRotating = true;
1100 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);
1102 // Notify that the orientation is changed
1103 mOrientation->OnOrientationChange(rotation);
1105 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1107 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1109 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1111 Dali::Window handle(this);
1112 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1113 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1115 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1118 void Window::OnRotationFinished()
1120 mIsWindowRotating = false;
1121 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1124 void Window::OnPause()
1128 mEventHandler->Pause();
1132 void Window::OnResume()
1136 mEventHandler->Resume();
1139 mSurface->SetFullSwapNextFrame();
1142 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1144 mAuxiliaryMessageSignal.Emit(key, value, options);
1147 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1149 mInsetsChangedSignal.Emit(partType, partState, insets);
1152 void Window::OnAccessibilityEnabled()
1154 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1155 auto rootLayer = mScene.GetRootLayer();
1156 auto accessible = Accessibility::Accessible::Get(rootLayer);
1157 bridge->AddTopLevelWindow(accessible);
1159 if(!mVisible || mIconified)
1164 Dali::Window handle(this);
1165 bridge->WindowShown(handle);
1169 bridge->WindowFocused(handle);
1173 void Window::OnAccessibilityDisabled()
1175 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1176 auto rootLayer = mScene.GetRootLayer();
1177 auto accessible = Accessibility::Accessible::Get(rootLayer);
1178 bridge->RemoveTopLevelWindow(accessible);
1181 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1183 Dali::Window handle(this);
1184 mMoveCompletedSignal.Emit(handle, position);
1187 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1189 Dali::Window handle(this);
1190 mResizeCompletedSignal.Emit(handle, size);
1193 Vector2 Window::RecalculatePosition(const Vector2& position)
1195 Vector2 convertedPosition;
1197 switch(mRotationAngle)
1201 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1202 convertedPosition.y = position.x;
1207 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1208 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1213 convertedPosition.x = position.y;
1214 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1219 convertedPosition = position;
1223 return convertedPosition;
1226 Dali::Window Window::Get(Dali::Actor actor)
1228 Internal::Adaptor::Window* windowImpl = nullptr;
1230 if(Internal::Adaptor::Adaptor::IsAvailable())
1232 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1233 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1236 return Dali::Window(windowImpl);
1240 return Dali::Window();
1243 void Window::SetParent(Dali::Window& parent)
1245 if(DALI_UNLIKELY(parent))
1247 mParentWindow = parent;
1248 Dali::Window self = Dali::Window(this);
1249 // check circular parent window setting
1250 if(Dali::DevelWindow::GetParent(parent) == self)
1252 Dali::DevelWindow::Unparent(parent);
1254 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1258 void Window::SetParent(Dali::Window& parent, bool belowParent)
1260 if(DALI_UNLIKELY(parent))
1262 mParentWindow = parent;
1263 Dali::Window self = Dali::Window(this);
1264 // check circular parent window setting
1265 if(Dali::DevelWindow::GetParent(parent) == self)
1267 Dali::DevelWindow::Unparent(parent);
1269 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1273 void Window::Unparent()
1275 mWindowBase->SetParent(nullptr, false);
1276 mParentWindow.Reset();
1279 Dali::Window Window::GetParent()
1281 return mParentWindow;
1284 WindowOrientation Window::GetCurrentOrientation() const
1286 return ConvertToOrientation(mRotationAngle);
1289 int Window::GetPhysicalOrientation() const
1291 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1294 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1296 Dali::Vector<float>::SizeType count = orientations.Count();
1297 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1299 if(IsOrientationAvailable(orientations[index]) == false)
1301 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1306 int convertedAngle = ConvertToAngle(orientations[index]);
1308 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1310 if(mAvailableAngles[i] == convertedAngle)
1319 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1320 mAvailableAngles.push_back(convertedAngle);
1323 SetAvailableAnlges(mAvailableAngles);
1326 int32_t Window::GetNativeId() const
1328 return mWindowBase->GetNativeWindowId();
1331 void Window::RequestMoveToServer()
1333 SetUserGeometryPolicy();
1334 mWindowBase->RequestMoveToServer();
1337 void Window::RequestResizeToServer(WindowResizeDirection direction)
1339 SetUserGeometryPolicy();
1340 mWindowBase->RequestResizeToServer(direction);
1343 void Window::EnableFloatingMode(bool enable)
1345 mWindowBase->EnableFloatingMode(enable);
1348 bool Window::IsFloatingModeEnabled()
1350 return mWindowBase->IsFloatingModeEnabled();
1353 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1355 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);
1356 mWindowBase->IncludeInputRegion(inputRegion);
1359 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1361 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);
1362 mWindowBase->ExcludeInputRegion(inputRegion);
1365 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1367 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1368 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1369 mWindowRotationAcknowledgement = needAcknowledgement;
1372 void Window::SendRotationCompletedAcknowledgement()
1374 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1375 if(mWindowRotationAcknowledgement)
1377 SetRotationCompletedAcknowledgement();
1381 bool Window::IsWindowRotating() const
1383 return mIsWindowRotating;
1386 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1388 return mLastKeyEvent;
1391 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1393 return mLastTouchEvent;
1396 void Window::SetUserGeometryPolicy()
1398 if(mIsEnabledUserGeometry == true)
1403 mIsEnabledUserGeometry = true;
1404 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1405 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1408 bool Window::PointerConstraintsLock()
1410 return mWindowBase->PointerConstraintsLock();
1413 bool Window::PointerConstraintsUnlock()
1415 return mWindowBase->PointerConstraintsUnlock();
1418 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1420 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1423 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1425 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1428 bool Window::PointerWarp(int32_t x, int32_t y)
1430 return mWindowBase->PointerWarp(x, y);
1433 void Window::CursorVisibleSet(bool visible)
1435 mWindowBase->CursorVisibleSet(visible);
1438 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1440 return mWindowBase->KeyboardGrab(deviceSubclass);
1443 bool Window::KeyboardUnGrab()
1445 return mWindowBase->KeyboardUnGrab();
1448 } // namespace Adaptor
1450 } // namespace Internal