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/render-tasks/render-task-list.h>
32 #include <dali/public-api/render-tasks/render-task.h>
33 #include <dali/public-api/rendering/frame-buffer.h>
37 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
38 #include <dali/devel-api/atspi-interfaces/accessible.h>
39 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
40 #include <dali/internal/graphics/gles/egl-graphics.h>
41 #include <dali/internal/window-system/common/event-handler.h>
42 #include <dali/internal/window-system/common/orientation-impl.h>
43 #include <dali/internal/window-system/common/render-surface-factory.h>
44 #include <dali/internal/window-system/common/window-base.h>
45 #include <dali/internal/window-system/common/window-factory.h>
46 #include <dali/internal/window-system/common/window-render-surface.h>
47 #include <dali/internal/window-system/common/window-system.h>
48 #include <dali/internal/window-system/common/window-visibility-observer.h>
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
96 mOrientationChangedSignal(),
97 mMouseInOutEventSignal(),
98 mMoveCompletedSignal(),
99 mResizeCompletedSignal(),
102 mIsTransparent(false),
103 mIsFocusAcceptable(true),
106 mWindowRotationAcknowledgement(false),
108 mIsWindowRotating(false)
116 auto bridge = Accessibility::Bridge::GetCurrentBridge();
117 auto rootLayer = mScene.GetRootLayer();
118 auto accessible = Accessibility::Accessible::Get(rootLayer);
119 bridge->RemoveTopLevelWindow(accessible);
120 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
121 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
124 if(DALI_LIKELY(mAdaptor))
126 mAdaptor->RemoveWindow(this);
131 mEventHandler->RemoveObserver(*this);
135 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
137 // Create a window render surface
138 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
139 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
140 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
143 mWindowBase = mWindowSurface->GetWindowBase();
146 mWindowBase->SetType(type);
148 // Initialize for Ime window type
149 if(type == WindowType::IME)
151 mWindowBase->InitializeIme();
152 mWindowSurface->InitializeImeSurface();
156 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
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 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
173 SetClass(name, className);
175 mOrientation = Orientation::New(this);
177 // Get OrientationMode
178 int screenWidth, screenHeight;
179 WindowSystem::GetScreenSize(screenWidth, screenHeight);
180 if(screenWidth > screenHeight)
182 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
186 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
189 if(positionSize.width <= 0 || positionSize.height <= 0)
191 mWindowWidth = screenWidth;
192 mWindowHeight = screenHeight;
196 mWindowWidth = positionSize.width;
197 mWindowHeight = positionSize.height;
201 mNativeWindowId = mWindowBase->GetNativeWindowId();
204 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
211 mWindowSurface->SetRenderNotification(renderNotification);
214 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
216 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
217 mEventHandler->AddObserver(*this);
219 // Add Window to bridge for ATSPI
220 auto bridge = Accessibility::Bridge::GetCurrentBridge();
223 auto rootLayer = mScene.GetRootLayer();
224 auto accessible = Accessibility::Accessible::Get(rootLayer);
225 bridge->AddTopLevelWindow(accessible);
228 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
229 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
231 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
232 // The show must be called after the adaptor is initialized.
236 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
238 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
241 void Window::SetClass(std::string name, std::string className)
244 mClassName = className;
245 mWindowBase->SetClass(name, className);
248 std::string Window::GetClassName() const
255 mWindowBase->Raise();
257 mSurface->SetFullSwapNextFrame();
259 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
264 mWindowBase->Lower();
266 mSurface->SetFullSwapNextFrame();
268 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
271 void Window::Activate()
273 mWindowBase->Activate();
275 mSurface->SetFullSwapNextFrame();
277 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
280 void Window::Maximize(bool maximize)
282 mWindowBase->Maximize(maximize);
284 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
287 bool Window::IsMaximized() const
289 return mWindowBase->IsMaximized();
292 void Window::SetMaximumSize(Dali::Window::WindowSize size)
294 mWindowBase->SetMaximumSize(size);
297 void Window::Minimize(bool minimize)
299 mWindowBase->Minimize(minimize);
301 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
304 bool Window::IsMinimized() const
306 return mWindowBase->IsMinimized();
309 void Window::SetMimimumSize(Dali::Window::WindowSize size)
311 mWindowBase->SetMimimumSize(size);
314 uint32_t Window::GetLayerCount() const
316 return mScene.GetLayerCount();
319 Dali::Layer Window::GetLayer(uint32_t depth) const
321 return mScene.GetLayer(depth);
324 Dali::RenderTaskList Window::GetRenderTaskList() const
326 return mScene.GetRenderTaskList();
329 std::string Window::GetNativeResourceId() const
331 return mWindowBase->GetNativeWindowResourceId();
334 void Window::AddAvailableOrientation(WindowOrientation orientation)
336 if(IsOrientationAvailable(orientation) == false)
342 int convertedAngle = ConvertToAngle(orientation);
343 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
344 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
346 if(mAvailableAngles[i] == convertedAngle)
355 mAvailableAngles.push_back(convertedAngle);
356 SetAvailableAnlges(mAvailableAngles);
360 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
362 if(IsOrientationAvailable(orientation) == false)
367 int convertedAngle = ConvertToAngle(orientation);
368 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
369 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
370 iter != mAvailableAngles.end();
373 if(*iter == convertedAngle)
375 mAvailableAngles.erase(iter);
380 SetAvailableAnlges(mAvailableAngles);
383 void Window::SetPreferredOrientation(WindowOrientation orientation)
385 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
387 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
390 mPreferredAngle = ConvertToAngle(orientation);
391 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
392 mWindowBase->SetPreferredAngle(mPreferredAngle);
395 WindowOrientation Window::GetPreferredOrientation()
397 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
398 return preferredOrientation;
401 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
403 int angle = ConvertToAngle(orientation);
404 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
407 void Window::EmitAccessibilityHighlightSignal(bool highlight)
409 Dali::Window handle(this);
410 mAccessibilityHighlightSignal.Emit(handle, highlight);
413 void Window::SetAvailableAnlges(const std::vector<int>& angles)
415 if(angles.size() > 4)
417 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
421 mWindowBase->SetAvailableAnlges(angles);
424 int Window::ConvertToAngle(WindowOrientation orientation)
426 int convertAngle = static_cast<int>(orientation);
427 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
431 case WindowOrientation::LANDSCAPE:
436 case WindowOrientation::PORTRAIT:
441 case WindowOrientation::LANDSCAPE_INVERSE:
446 case WindowOrientation::PORTRAIT_INVERSE:
451 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
461 WindowOrientation Window::ConvertToOrientation(int angle) const
463 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
464 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
470 orientation = WindowOrientation::LANDSCAPE;
475 orientation = WindowOrientation::PORTRAIT;
480 orientation = WindowOrientation::LANDSCAPE_INVERSE;
485 orientation = WindowOrientation::PORTRAIT_INVERSE;
490 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
498 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
500 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
502 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
508 Dali::Any Window::GetNativeHandle() const
510 return mWindowSurface->GetNativeWindow();
513 void Window::SetAcceptFocus(bool accept)
515 mIsFocusAcceptable = accept;
517 mWindowBase->SetAcceptFocus(accept);
520 bool Window::IsFocusAcceptable() const
522 return mIsFocusAcceptable;
533 Dali::Window handle(this);
534 mVisibilityChangedSignal.Emit(handle, true);
535 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
537 WindowVisibilityObserver* observer(mAdaptor);
538 observer->OnWindowShown();
541 mSurface->SetFullSwapNextFrame();
543 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
554 Dali::Window handle(this);
555 mVisibilityChangedSignal.Emit(handle, false);
556 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
558 WindowVisibilityObserver* observer(mAdaptor);
559 observer->OnWindowHidden();
562 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
565 bool Window::IsVisible() const
567 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
568 return mVisible && !mIconified;
571 unsigned int Window::GetSupportedAuxiliaryHintCount() const
573 return mWindowBase->GetSupportedAuxiliaryHintCount();
576 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
578 return mWindowBase->GetSupportedAuxiliaryHint(index);
581 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
583 return mWindowBase->AddAuxiliaryHint(hint, value);
586 bool Window::RemoveAuxiliaryHint(unsigned int id)
588 return mWindowBase->RemoveAuxiliaryHint(id);
591 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
593 return mWindowBase->SetAuxiliaryHintValue(id, value);
596 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
598 return mWindowBase->GetAuxiliaryHintValue(id);
601 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
603 return mWindowBase->GetAuxiliaryHintId(hint);
606 void Window::SetInputRegion(const Rect<int>& inputRegion)
608 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);
609 mWindowBase->SetInputRegion(inputRegion);
612 void Window::SetType(WindowType type)
614 mWindowBase->SetType(type);
617 WindowType Window::GetType() const
619 return mWindowBase->GetType();
622 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
624 WindowType type = mWindowBase->GetType();
625 if(type != WindowType::NOTIFICATION)
627 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
628 return WindowOperationResult::INVALID_OPERATION;
631 return mWindowBase->SetNotificationLevel(level);
634 WindowNotificationLevel Window::GetNotificationLevel() const
636 WindowType type = mWindowBase->GetType();
637 if(type != WindowType::NOTIFICATION)
639 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
640 return WindowNotificationLevel::NONE;
643 return mWindowBase->GetNotificationLevel();
646 void Window::SetOpaqueState(bool opaque)
648 mOpaqueState = opaque;
650 mWindowBase->SetOpaqueState(opaque);
652 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
655 bool Window::IsOpaqueState() const
660 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
662 return mWindowBase->SetScreenOffMode(screenOffMode);
665 WindowScreenOffMode Window::GetScreenOffMode() const
667 return mWindowBase->GetScreenOffMode();
670 WindowOperationResult Window::SetBrightness(int brightness)
672 if(brightness < 0 || brightness > 100)
674 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
675 return WindowOperationResult::INVALID_OPERATION;
678 return mWindowBase->SetBrightness(brightness);
681 int Window::GetBrightness() const
683 return mWindowBase->GetBrightness();
686 void Window::SetSize(Dali::Window::WindowSize size)
688 PositionSize oldRect = GetPositionSize();
690 PositionSize newRect;
691 newRect.width = size.GetWidth();
692 newRect.height = size.GetHeight();
694 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
695 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
697 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
699 Uint16Pair newSize(newRect.width, newRect.height);
701 mWindowWidth = newRect.width;
702 mWindowHeight = newRect.height;
704 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);
706 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
708 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
710 Dali::Window handle(this);
711 mResizeSignal.Emit(handle, newSize);
713 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
716 mSurface->SetFullSwapNextFrame();
718 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
721 Dali::Window::WindowSize Window::GetSize() const
723 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
726 void Window::SetPosition(Dali::Window::WindowPosition position)
728 PositionSize oldRect = mSurface->GetPositionSize();
729 int32_t newX = position.GetX();
730 int32_t newY = position.GetY();
732 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
734 if((oldRect.x != newX) || (oldRect.y != newY))
736 Dali::Window handle(this);
737 Dali::Window::WindowPosition newPosition(newX, newY);
739 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
740 mMovedSignal.Emit(handle, newPosition);
743 mSurface->SetFullSwapNextFrame();
745 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
748 Dali::Window::WindowPosition Window::GetPosition() const
750 PositionSize positionSize = GetPositionSize();
751 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
754 PositionSize Window::GetPositionSize() const
756 PositionSize positionSize = mSurface->GetPositionSize();
757 positionSize.width = mWindowWidth;
758 positionSize.height = mWindowHeight;
762 void Window::SetPositionSize(PositionSize positionSize)
767 PositionSize oldRect = GetPositionSize();
768 Dali::Window handle(this);
770 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
775 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
782 mWindowSurface->MoveResize(positionSize);
785 // When window is moved, emit Moved Signal
788 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
789 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
790 mMovedSignal.Emit(handle, position);
793 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
796 Uint16Pair newSize(positionSize.width, positionSize.height);
798 mWindowWidth = positionSize.width;
799 mWindowHeight = positionSize.height;
801 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
803 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
805 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
807 mResizeSignal.Emit(handle, newSize);
808 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
811 mSurface->SetFullSwapNextFrame();
813 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
816 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
818 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
821 Dali::Layer Window::GetRootLayer() const
823 return mScene.GetRootLayer();
826 void Window::SetTransparency(bool transparent)
828 mWindowSurface->SetTransparency(transparent);
831 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
833 return mWindowBase->GrabKey(key, grabMode);
836 bool Window::UngrabKey(Dali::KEY key)
838 return mWindowBase->UngrabKey(key);
841 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
843 return mWindowBase->GrabKeyList(key, grabMode, result);
846 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
848 return mWindowBase->UngrabKeyList(key, result);
851 void Window::OnIconifyChanged(bool iconified)
859 Dali::Window handle(this);
860 mVisibilityChangedSignal.Emit(handle, false);
861 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
863 if(DALI_LIKELY(mAdaptor))
865 WindowVisibilityObserver* observer(mAdaptor);
866 observer->OnWindowHidden();
870 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
878 Dali::Window handle(this);
879 mVisibilityChangedSignal.Emit(handle, true);
880 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
882 if(DALI_LIKELY(mAdaptor))
884 WindowVisibilityObserver* observer(mAdaptor);
885 observer->OnWindowShown();
889 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
892 mSurface->SetFullSwapNextFrame();
895 void Window::OnFocusChanged(bool focusIn)
897 Dali::Window handle(this);
898 mFocusChangeSignal.Emit(handle, focusIn);
900 mSurface->SetFullSwapNextFrame();
902 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
906 bridge->WindowFocused(handle);
910 bridge->WindowUnfocused(handle);
916 void Window::OnOutputTransformed()
918 PositionSize positionSize = GetPositionSize();
920 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
922 if(DALI_LIKELY(mAdaptor))
924 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
925 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
929 void Window::OnDeleteRequest()
931 mDeleteRequestSignal.Emit();
934 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
936 Dali::Window handle(this);
937 mTransitionEffectEventSignal.Emit(handle, state, type);
940 void Window::OnKeyboardRepeatSettingsChanged()
942 Dali::Window handle(this);
943 mKeyboardRepeatSettingsChangedSignal.Emit();
946 void Window::OnWindowRedrawRequest()
948 if(DALI_LIKELY(mAdaptor))
950 mAdaptor->RenderOnce();
954 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
959 Dali::Window handle(this);
961 PositionSize oldRect = GetPositionSize();
962 PositionSize newRect = positionSize;
964 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
969 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
976 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);
977 mWindowSurface->UpdatePositionSize(positionSize);
980 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
982 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
983 Dali::Window::WindowPosition position(newRect.x, newRect.y);
984 mMovedSignal.Emit(handle, position);
987 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
988 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
990 Uint16Pair newSize(newRect.width, newRect.height);
992 mWindowWidth = newRect.width;
993 mWindowHeight = newRect.height;
995 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
997 if(DALI_LIKELY(mAdaptor))
999 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1002 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1003 mResizeSignal.Emit(handle, newSize);
1004 if(DALI_LIKELY(mAdaptor))
1006 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1010 mSurface->SetFullSwapNextFrame();
1012 if(DALI_LIKELY(mScene))
1014 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1018 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1020 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1021 FeedTouchPoint(point, timeStamp);
1024 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1026 FeedWheelEvent(wheelEvent);
1029 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1031 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);
1032 FeedKeyEvent(keyEvent);
1035 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1037 Dali::Window handle(this);
1039 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1042 void Window::OnRotation(const RotationEvent& rotation)
1044 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1046 mRotationAngle = rotation.angle;
1047 mWindowWidth = rotation.width;
1048 mWindowHeight = rotation.height;
1050 mIsWindowRotating = true;
1051 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);
1053 // Notify that the orientation is changed
1054 mOrientation->OnOrientationChange(rotation);
1056 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1058 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1060 if(DALI_LIKELY(mAdaptor))
1062 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1065 Dali::Window handle(this);
1066 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1067 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1069 if(DALI_LIKELY(mAdaptor))
1071 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1075 void Window::OnRotationFinished()
1077 mIsWindowRotating = false;
1078 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1081 void Window::OnPause()
1085 mEventHandler->Pause();
1089 void Window::OnResume()
1093 mEventHandler->Resume();
1096 mSurface->SetFullSwapNextFrame();
1099 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1101 mAuxiliaryMessageSignal.Emit(key, value, options);
1104 void Window::OnAccessibilityEnabled()
1106 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1107 auto rootLayer = mScene.GetRootLayer();
1108 auto accessible = Accessibility::Accessible::Get(rootLayer);
1109 bridge->AddTopLevelWindow(accessible);
1111 if(!mVisible || mIconified)
1116 Dali::Window handle(this);
1117 bridge->WindowShown(handle);
1121 bridge->WindowFocused(handle);
1125 void Window::OnAccessibilityDisabled()
1127 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1128 auto rootLayer = mScene.GetRootLayer();
1129 auto accessible = Accessibility::Accessible::Get(rootLayer);
1130 bridge->RemoveTopLevelWindow(accessible);
1133 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1135 Dali::Window handle(this);
1136 mMoveCompletedSignal.Emit(handle, position);
1139 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1141 Dali::Window handle(this);
1142 mResizeCompletedSignal.Emit(handle, size);
1145 Vector2 Window::RecalculatePosition(const Vector2& position)
1147 Vector2 convertedPosition;
1149 switch(mRotationAngle)
1153 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1154 convertedPosition.y = position.x;
1159 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1160 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1165 convertedPosition.x = position.y;
1166 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1171 convertedPosition = position;
1175 return convertedPosition;
1178 Dali::Window Window::Get(Dali::Actor actor)
1180 Internal::Adaptor::Window* windowImpl = nullptr;
1182 if(Internal::Adaptor::Adaptor::IsAvailable())
1184 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1185 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1188 return Dali::Window(windowImpl);
1192 return Dali::Window();
1195 void Window::SetParent(Dali::Window& parent)
1197 if(DALI_UNLIKELY(parent))
1199 mParentWindow = parent;
1200 Dali::Window self = Dali::Window(this);
1201 // check circular parent window setting
1202 if(Dali::DevelWindow::GetParent(parent) == self)
1204 Dali::DevelWindow::Unparent(parent);
1206 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1210 void Window::SetParent(Dali::Window& parent, bool belowParent)
1212 if(DALI_UNLIKELY(parent))
1214 mParentWindow = parent;
1215 Dali::Window self = Dali::Window(this);
1216 // check circular parent window setting
1217 if(Dali::DevelWindow::GetParent(parent) == self)
1219 Dali::DevelWindow::Unparent(parent);
1221 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1225 void Window::Unparent()
1227 mWindowBase->SetParent(nullptr, false);
1228 mParentWindow.Reset();
1231 Dali::Window Window::GetParent()
1233 return mParentWindow;
1236 WindowOrientation Window::GetCurrentOrientation() const
1238 return ConvertToOrientation(mRotationAngle);
1241 int Window::GetPhysicalOrientation() const
1243 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1246 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1248 Dali::Vector<float>::SizeType count = orientations.Count();
1249 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1251 if(IsOrientationAvailable(orientations[index]) == false)
1253 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1258 int convertedAngle = ConvertToAngle(orientations[index]);
1260 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1262 if(mAvailableAngles[i] == convertedAngle)
1271 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1272 mAvailableAngles.push_back(convertedAngle);
1275 SetAvailableAnlges(mAvailableAngles);
1278 int32_t Window::GetNativeId() const
1280 return mWindowBase->GetNativeWindowId();
1283 void Window::RequestMoveToServer()
1285 mWindowBase->RequestMoveToServer();
1288 void Window::RequestResizeToServer(WindowResizeDirection direction)
1290 mWindowBase->RequestResizeToServer(direction);
1293 void Window::EnableFloatingMode(bool enable)
1295 mWindowBase->EnableFloatingMode(enable);
1298 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1300 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);
1301 mWindowBase->IncludeInputRegion(inputRegion);
1304 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1306 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);
1307 mWindowBase->ExcludeInputRegion(inputRegion);
1310 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1312 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1313 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1314 mWindowRotationAcknowledgement = needAcknowledgement;
1317 void Window::SendRotationCompletedAcknowledgement()
1319 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1320 if(mWindowRotationAcknowledgement)
1322 SetRotationCompletedAcknowledgement();
1326 bool Window::IsWindowRotating() const
1328 return mIsWindowRotating;
1331 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1333 return mLastKeyEvent;
1336 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1338 return mLastTouchEvent;
1341 } // namespace Adaptor
1343 } // namespace Internal