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 void Window::SetPartialUpdateEnabled(bool enabled)
339 mScene.SetPartialUpdateEnabled(enabled);
342 bool Window::IsPartialUpdateEnabled() const
344 return mScene.IsPartialUpdateEnabled();
347 std::string Window::GetNativeResourceId() const
349 return mWindowBase->GetNativeWindowResourceId();
352 void Window::AddAvailableOrientation(WindowOrientation orientation)
354 if(IsOrientationAvailable(orientation) == false)
360 int convertedAngle = ConvertToAngle(orientation);
361 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
362 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
364 if(mAvailableAngles[i] == convertedAngle)
373 mAvailableAngles.push_back(convertedAngle);
374 SetAvailableAnlges(mAvailableAngles);
378 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
380 if(IsOrientationAvailable(orientation) == false)
385 int convertedAngle = ConvertToAngle(orientation);
386 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
387 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
388 iter != mAvailableAngles.end();
391 if(*iter == convertedAngle)
393 mAvailableAngles.erase(iter);
398 SetAvailableAnlges(mAvailableAngles);
401 void Window::SetPreferredOrientation(WindowOrientation orientation)
403 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
405 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
408 mPreferredAngle = ConvertToAngle(orientation);
409 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
410 mWindowBase->SetPreferredAngle(mPreferredAngle);
413 WindowOrientation Window::GetPreferredOrientation()
415 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
416 return preferredOrientation;
419 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
421 int angle = ConvertToAngle(orientation);
422 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
425 void Window::EmitAccessibilityHighlightSignal(bool highlight)
427 Dali::Window handle(this);
428 mAccessibilityHighlightSignal.Emit(handle, highlight);
431 void Window::SetAvailableAnlges(const std::vector<int>& angles)
433 if(angles.size() > 4)
435 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
439 mWindowBase->SetAvailableAnlges(angles);
442 int Window::ConvertToAngle(WindowOrientation orientation)
444 int convertAngle = static_cast<int>(orientation);
445 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
449 case WindowOrientation::LANDSCAPE:
454 case WindowOrientation::PORTRAIT:
459 case WindowOrientation::LANDSCAPE_INVERSE:
464 case WindowOrientation::PORTRAIT_INVERSE:
469 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
479 WindowOrientation Window::ConvertToOrientation(int angle) const
481 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
482 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
488 orientation = WindowOrientation::LANDSCAPE;
493 orientation = WindowOrientation::PORTRAIT;
498 orientation = WindowOrientation::LANDSCAPE_INVERSE;
503 orientation = WindowOrientation::PORTRAIT_INVERSE;
508 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
516 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
518 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
520 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
526 Dali::Any Window::GetNativeHandle() const
528 return mWindowSurface->GetNativeWindow();
531 void Window::SetAcceptFocus(bool accept)
533 mIsFocusAcceptable = accept;
535 mWindowBase->SetAcceptFocus(accept);
538 bool Window::IsFocusAcceptable() const
540 return mIsFocusAcceptable;
551 Dali::Window handle(this);
552 mVisibilityChangedSignal.Emit(handle, true);
553 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
555 WindowVisibilityObserver* observer(mAdaptor);
556 observer->OnWindowShown();
559 mSurface->SetFullSwapNextFrame();
561 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
572 Dali::Window handle(this);
573 mVisibilityChangedSignal.Emit(handle, false);
574 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
576 WindowVisibilityObserver* observer(mAdaptor);
577 observer->OnWindowHidden();
580 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
583 bool Window::IsVisible() const
585 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
586 return mVisible && !mIconified;
589 unsigned int Window::GetSupportedAuxiliaryHintCount() const
591 return mWindowBase->GetSupportedAuxiliaryHintCount();
594 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
596 return mWindowBase->GetSupportedAuxiliaryHint(index);
599 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
601 return mWindowBase->AddAuxiliaryHint(hint, value);
604 bool Window::RemoveAuxiliaryHint(unsigned int id)
606 return mWindowBase->RemoveAuxiliaryHint(id);
609 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
611 return mWindowBase->SetAuxiliaryHintValue(id, value);
614 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
616 return mWindowBase->GetAuxiliaryHintValue(id);
619 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
621 return mWindowBase->GetAuxiliaryHintId(hint);
624 void Window::SetInputRegion(const Rect<int>& inputRegion)
626 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);
627 mWindowBase->SetInputRegion(inputRegion);
630 void Window::SetType(WindowType type)
632 mWindowBase->SetType(type);
635 WindowType Window::GetType() const
637 return mWindowBase->GetType();
640 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
642 WindowType type = mWindowBase->GetType();
643 if(type != WindowType::NOTIFICATION)
645 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
646 return WindowOperationResult::INVALID_OPERATION;
649 return mWindowBase->SetNotificationLevel(level);
652 WindowNotificationLevel Window::GetNotificationLevel() const
654 WindowType type = mWindowBase->GetType();
655 if(type != WindowType::NOTIFICATION)
657 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
658 return WindowNotificationLevel::NONE;
661 return mWindowBase->GetNotificationLevel();
664 void Window::SetOpaqueState(bool opaque)
666 mOpaqueState = opaque;
668 mWindowBase->SetOpaqueState(opaque);
670 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
673 bool Window::IsOpaqueState() const
678 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
680 return mWindowBase->SetScreenOffMode(screenOffMode);
683 WindowScreenOffMode Window::GetScreenOffMode() const
685 return mWindowBase->GetScreenOffMode();
688 WindowOperationResult Window::SetBrightness(int brightness)
690 if(brightness < 0 || brightness > 100)
692 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
693 return WindowOperationResult::INVALID_OPERATION;
696 return mWindowBase->SetBrightness(brightness);
699 int Window::GetBrightness() const
701 return mWindowBase->GetBrightness();
704 void Window::SetSize(Dali::Window::WindowSize size)
706 PositionSize oldRect = GetPositionSize();
708 PositionSize newRect;
709 newRect.width = size.GetWidth();
710 newRect.height = size.GetHeight();
712 SetUserGeometryPolicy();
714 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
715 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
717 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
719 Uint16Pair newSize(newRect.width, newRect.height);
721 mWindowWidth = newRect.width;
722 mWindowHeight = newRect.height;
724 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);
726 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
728 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
730 Dali::Window handle(this);
731 mResizeSignal.Emit(handle, newSize);
733 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
736 mSurface->SetFullSwapNextFrame();
738 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
741 Dali::Window::WindowSize Window::GetSize() const
743 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
746 void Window::SetPosition(Dali::Window::WindowPosition position)
748 PositionSize oldRect = mSurface->GetPositionSize();
749 int32_t newX = position.GetX();
750 int32_t newY = position.GetY();
752 SetUserGeometryPolicy();
754 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
756 if((oldRect.x != newX) || (oldRect.y != newY))
758 Dali::Window handle(this);
759 Dali::Window::WindowPosition newPosition(newX, newY);
761 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
762 mMovedSignal.Emit(handle, newPosition);
765 mSurface->SetFullSwapNextFrame();
767 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
770 Dali::Window::WindowPosition Window::GetPosition() const
772 PositionSize positionSize = GetPositionSize();
773 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
776 PositionSize Window::GetPositionSize() const
778 PositionSize positionSize = mSurface->GetPositionSize();
779 positionSize.width = mWindowWidth;
780 positionSize.height = mWindowHeight;
784 void Window::SetPositionSize(PositionSize positionSize)
789 PositionSize oldRect = GetPositionSize();
790 Dali::Window handle(this);
792 SetUserGeometryPolicy();
794 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
799 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
806 mWindowSurface->MoveResize(positionSize);
809 // When window is moved, emit Moved Signal
812 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
813 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
814 mMovedSignal.Emit(handle, position);
817 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
820 Uint16Pair newSize(positionSize.width, positionSize.height);
822 mWindowWidth = positionSize.width;
823 mWindowHeight = positionSize.height;
825 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
827 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
829 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
831 mResizeSignal.Emit(handle, newSize);
832 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
835 mSurface->SetFullSwapNextFrame();
837 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
840 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
842 SetUserGeometryPolicy();
843 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
846 Dali::Layer Window::GetRootLayer() const
848 return mScene.GetRootLayer();
851 void Window::SetTransparency(bool transparent)
853 mWindowSurface->SetTransparency(transparent);
856 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
858 return mWindowBase->GrabKey(key, grabMode);
861 bool Window::UngrabKey(Dali::KEY key)
863 return mWindowBase->UngrabKey(key);
866 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
868 return mWindowBase->GrabKeyList(key, grabMode, result);
871 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
873 return mWindowBase->UngrabKeyList(key, result);
876 void Window::OnIconifyChanged(bool iconified)
878 const bool isActuallyChanged = (iconified != mIconified);
879 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
880 Dali::Window handle(this);
888 mVisibilityChangedSignal.Emit(handle, false);
889 bridge->WindowHidden(handle);
891 WindowVisibilityObserver* observer(mAdaptor);
892 observer->OnWindowHidden();
895 if(isActuallyChanged)
897 bridge->WindowMinimized(handle);
900 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
908 mVisibilityChangedSignal.Emit(handle, true);
909 bridge->WindowShown(handle);
911 WindowVisibilityObserver* observer(mAdaptor);
912 observer->OnWindowShown();
915 if(isActuallyChanged)
917 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
920 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
923 mSurface->SetFullSwapNextFrame();
926 void Window::OnMaximizeChanged(bool maximized)
928 const bool isActuallyChanged = (maximized != mMaximized);
930 if(isActuallyChanged)
932 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
933 Dali::Window handle(this);
938 bridge->WindowMaximized(handle);
943 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
948 void Window::OnFocusChanged(bool focusIn)
950 Dali::Window handle(this);
951 mFocusChangeSignal.Emit(handle, focusIn);
953 mSurface->SetFullSwapNextFrame();
954 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
958 bridge->WindowFocused(handle);
962 bridge->WindowUnfocused(handle);
968 void Window::OnOutputTransformed()
970 PositionSize positionSize = GetPositionSize();
972 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
974 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
975 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
978 void Window::OnDeleteRequest()
980 mDeleteRequestSignal.Emit();
983 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
985 Dali::Window handle(this);
986 mTransitionEffectEventSignal.Emit(handle, state, type);
989 void Window::OnKeyboardRepeatSettingsChanged()
991 Dali::Window handle(this);
992 mKeyboardRepeatSettingsChangedSignal.Emit();
995 void Window::OnWindowRedrawRequest()
997 mAdaptor->RenderOnce();
1000 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1003 bool resize = false;
1005 Dali::Window handle(this);
1007 PositionSize oldRect = GetPositionSize();
1008 PositionSize newRect = positionSize;
1010 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1015 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1022 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);
1023 mWindowSurface->UpdatePositionSize(positionSize);
1026 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1028 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1029 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1030 mMovedSignal.Emit(handle, position);
1033 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1034 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1036 Uint16Pair newSize(newRect.width, newRect.height);
1038 mWindowWidth = newRect.width;
1039 mWindowHeight = newRect.height;
1041 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1043 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1045 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1046 mResizeSignal.Emit(handle, newSize);
1047 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1050 mSurface->SetFullSwapNextFrame();
1052 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1055 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1057 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1058 FeedTouchPoint(point, timeStamp);
1061 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1063 FeedWheelEvent(wheelEvent);
1066 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1068 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);
1069 FeedKeyEvent(keyEvent);
1072 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1074 Dali::Window handle(this);
1076 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1079 void Window::OnRotation(const RotationEvent& rotation)
1081 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1083 mRotationAngle = rotation.angle;
1084 mWindowWidth = rotation.width;
1085 mWindowHeight = rotation.height;
1087 mIsWindowRotating = true;
1088 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);
1090 // Notify that the orientation is changed
1091 mOrientation->OnOrientationChange(rotation);
1093 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1095 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1097 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1099 Dali::Window handle(this);
1100 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1101 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1103 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1106 void Window::OnRotationFinished()
1108 mIsWindowRotating = false;
1109 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1112 void Window::OnPause()
1116 mEventHandler->Pause();
1120 void Window::OnResume()
1124 mEventHandler->Resume();
1127 mSurface->SetFullSwapNextFrame();
1130 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1132 mAuxiliaryMessageSignal.Emit(key, value, options);
1135 void Window::OnAccessibilityEnabled()
1137 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1138 auto rootLayer = mScene.GetRootLayer();
1139 auto accessible = Accessibility::Accessible::Get(rootLayer);
1140 bridge->AddTopLevelWindow(accessible);
1142 if(!mVisible || mIconified)
1147 Dali::Window handle(this);
1148 bridge->WindowShown(handle);
1152 bridge->WindowFocused(handle);
1156 void Window::OnAccessibilityDisabled()
1158 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1159 auto rootLayer = mScene.GetRootLayer();
1160 auto accessible = Accessibility::Accessible::Get(rootLayer);
1161 bridge->RemoveTopLevelWindow(accessible);
1164 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1166 Dali::Window handle(this);
1167 mMoveCompletedSignal.Emit(handle, position);
1170 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1172 Dali::Window handle(this);
1173 mResizeCompletedSignal.Emit(handle, size);
1176 Vector2 Window::RecalculatePosition(const Vector2& position)
1178 Vector2 convertedPosition;
1180 switch(mRotationAngle)
1184 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1185 convertedPosition.y = position.x;
1190 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1191 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1196 convertedPosition.x = position.y;
1197 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1202 convertedPosition = position;
1206 return convertedPosition;
1209 Dali::Window Window::Get(Dali::Actor actor)
1211 Internal::Adaptor::Window* windowImpl = nullptr;
1213 if(Internal::Adaptor::Adaptor::IsAvailable())
1215 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1216 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1219 return Dali::Window(windowImpl);
1223 return Dali::Window();
1226 void Window::SetParent(Dali::Window& parent)
1228 if(DALI_UNLIKELY(parent))
1230 mParentWindow = parent;
1231 Dali::Window self = Dali::Window(this);
1232 // check circular parent window setting
1233 if(Dali::DevelWindow::GetParent(parent) == self)
1235 Dali::DevelWindow::Unparent(parent);
1237 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1241 void Window::SetParent(Dali::Window& parent, bool belowParent)
1243 if(DALI_UNLIKELY(parent))
1245 mParentWindow = parent;
1246 Dali::Window self = Dali::Window(this);
1247 // check circular parent window setting
1248 if(Dali::DevelWindow::GetParent(parent) == self)
1250 Dali::DevelWindow::Unparent(parent);
1252 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1256 void Window::Unparent()
1258 mWindowBase->SetParent(nullptr, false);
1259 mParentWindow.Reset();
1262 Dali::Window Window::GetParent()
1264 return mParentWindow;
1267 WindowOrientation Window::GetCurrentOrientation() const
1269 return ConvertToOrientation(mRotationAngle);
1272 int Window::GetPhysicalOrientation() const
1274 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1277 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1279 Dali::Vector<float>::SizeType count = orientations.Count();
1280 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1282 if(IsOrientationAvailable(orientations[index]) == false)
1284 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1289 int convertedAngle = ConvertToAngle(orientations[index]);
1291 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1293 if(mAvailableAngles[i] == convertedAngle)
1302 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1303 mAvailableAngles.push_back(convertedAngle);
1306 SetAvailableAnlges(mAvailableAngles);
1309 int32_t Window::GetNativeId() const
1311 return mWindowBase->GetNativeWindowId();
1314 void Window::RequestMoveToServer()
1316 SetUserGeometryPolicy();
1317 mWindowBase->RequestMoveToServer();
1320 void Window::RequestResizeToServer(WindowResizeDirection direction)
1322 SetUserGeometryPolicy();
1323 mWindowBase->RequestResizeToServer(direction);
1326 void Window::EnableFloatingMode(bool enable)
1328 mWindowBase->EnableFloatingMode(enable);
1331 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1333 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);
1334 mWindowBase->IncludeInputRegion(inputRegion);
1337 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1339 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);
1340 mWindowBase->ExcludeInputRegion(inputRegion);
1343 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1345 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1346 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1347 mWindowRotationAcknowledgement = needAcknowledgement;
1350 void Window::SendRotationCompletedAcknowledgement()
1352 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1353 if(mWindowRotationAcknowledgement)
1355 SetRotationCompletedAcknowledgement();
1359 bool Window::IsWindowRotating() const
1361 return mIsWindowRotating;
1364 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1366 return mLastKeyEvent;
1369 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1371 return mLastTouchEvent;
1374 void Window::SetUserGeometryPolicy()
1376 if(mIsEnabledUserGeometry == true)
1381 mIsEnabledUserGeometry = true;
1382 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1383 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1386 } // namespace Adaptor
1388 } // namespace Internal