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/public-api/actors/actor.h>
27 #include <dali/public-api/actors/camera-actor.h>
28 #include <dali/public-api/actors/layer.h>
29 #include <dali/public-api/adaptor-framework/window-enumerations.h>
30 #include <dali/public-api/rendering/frame-buffer.h>
34 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
35 #include <dali/devel-api/atspi-interfaces/accessible.h>
36 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
37 #include <dali/internal/graphics/gles/egl-graphics.h>
38 #include <dali/internal/window-system/common/event-handler.h>
39 #include <dali/internal/window-system/common/orientation-impl.h>
40 #include <dali/internal/window-system/common/render-surface-factory.h>
41 #include <dali/internal/window-system/common/window-base.h>
42 #include <dali/internal/window-system/common/window-factory.h>
43 #include <dali/internal/window-system/common/window-render-surface.h>
44 #include <dali/internal/window-system/common/window-system.h>
45 #include <dali/internal/window-system/common/window-visibility-observer.h>
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
58 } // unnamed namespace
60 Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
63 return Window::New(surface, name, className, windowData);
66 Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
68 Window* window = new Window();
69 window->mIsTransparent = windowData.GetTransparency();
70 window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
75 : mWindowSurface(nullptr),
78 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
83 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
84 mDeleteRequestSignal(),
87 mVisibilityChangedSignal(),
88 mTransitionEffectEventSignal(),
89 mKeyboardRepeatSettingsChangedSignal(),
90 mAuxiliaryMessageSignal(),
92 mOrientationChangedSignal(),
93 mMouseInOutEventSignal(),
94 mMouseRelativeEventSignal(),
95 mMoveCompletedSignal(),
96 mResizeCompletedSignal(),
97 mInsetsChangedSignal(),
98 mPointerConstraintsSignal(),
100 mIsTransparent(false),
101 mIsFocusAcceptable(true),
105 mWindowRotationAcknowledgement(false),
107 mIsWindowRotating(false),
108 mIsEnabledUserGeometry(false),
109 mIsEmittedWindowCreatedEvent(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);
170 mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
172 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
173 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
175 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
177 SetClass(name, className);
179 mOrientation = Orientation::New(this);
181 // Get OrientationMode
182 int screenWidth, screenHeight;
183 WindowSystem::GetScreenSize(screenWidth, screenHeight);
184 if(screenWidth > screenHeight)
186 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
190 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
193 mWindowWidth = positionSize.width;
194 mWindowHeight = positionSize.height;
196 bool isSetWithScreenSize = false;
197 if(mWindowWidth <= 0 || mWindowHeight <= 0)
199 mWindowWidth = screenWidth;
200 mWindowHeight = screenHeight;
201 isSetWithScreenSize = true;
202 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
205 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
207 SetUserGeometryPolicy();
211 mNativeWindowId = mWindowBase->GetNativeWindowId();
214 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
221 mWindowSurface->SetRenderNotification(renderNotification);
224 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
226 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
227 mEventHandler->AddObserver(*this);
229 // Add Window to bridge for ATSPI
230 auto bridge = Accessibility::Bridge::GetCurrentBridge();
232 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
233 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
237 OnAccessibilityEnabled();
241 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 FeedTouchPoint(point, timeStamp);
1065 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1067 FeedWheelEvent(wheelEvent);
1070 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1072 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);
1073 FeedKeyEvent(keyEvent);
1076 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1078 Dali::Window handle(this);
1080 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1083 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1085 Dali::Window handle(this);
1087 mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1090 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1092 Dali::Window handle(this);
1094 Vector2 newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1095 Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1097 mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1100 void Window::OnRotation(const RotationEvent& rotation)
1102 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1104 mRotationAngle = rotation.angle;
1105 mWindowWidth = rotation.width;
1106 mWindowHeight = rotation.height;
1108 mIsWindowRotating = true;
1109 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);
1111 // Notify that the orientation is changed
1112 mOrientation->OnOrientationChange(rotation);
1114 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1116 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1118 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1120 Dali::Window handle(this);
1121 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1122 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1124 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1127 void Window::OnRotationFinished()
1129 mIsWindowRotating = false;
1130 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1133 void Window::OnPause()
1137 mEventHandler->Pause();
1141 void Window::OnResume()
1145 mEventHandler->Resume();
1148 mSurface->SetFullSwapNextFrame();
1151 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1153 mAuxiliaryMessageSignal.Emit(key, value, options);
1156 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1158 mInsetsChangedSignal.Emit(partType, partState, insets);
1161 void Window::OnAccessibilityEnabled()
1163 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1164 auto rootLayer = mScene.GetRootLayer();
1165 auto accessible = Accessibility::Accessible::Get(rootLayer);
1166 bridge->AddTopLevelWindow(accessible);
1168 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1170 Dali::Window handle(this);
1171 if(!mIsEmittedWindowCreatedEvent)
1173 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1174 bridge->WindowCreated(handle);
1175 mIsEmittedWindowCreatedEvent = true;
1178 if(!mVisible || mIconified)
1183 bridge->WindowShown(handle);
1187 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1188 bridge->WindowFocused(handle);
1192 void Window::OnAccessibilityDisabled()
1194 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1195 auto rootLayer = mScene.GetRootLayer();
1196 auto accessible = Accessibility::Accessible::Get(rootLayer);
1197 bridge->RemoveTopLevelWindow(accessible);
1198 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1201 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1203 Dali::Window handle(this);
1204 mMoveCompletedSignal.Emit(handle, position);
1207 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1209 Dali::Window handle(this);
1210 mResizeCompletedSignal.Emit(handle, size);
1213 Vector2 Window::RecalculatePosition(const Vector2& position)
1215 Vector2 convertedPosition;
1217 switch(mRotationAngle)
1221 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1222 convertedPosition.y = position.x;
1227 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1228 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1233 convertedPosition.x = position.y;
1234 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1239 convertedPosition = position;
1243 return convertedPosition;
1246 Dali::Window Window::Get(Dali::Actor actor)
1248 Internal::Adaptor::Window* windowImpl = nullptr;
1250 if(Internal::Adaptor::Adaptor::IsAvailable())
1252 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1253 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1256 return Dali::Window(windowImpl);
1260 return Dali::Window();
1263 void Window::SetParent(Dali::Window& parent)
1265 if(DALI_UNLIKELY(parent))
1267 mParentWindow = parent;
1268 Dali::Window self = Dali::Window(this);
1269 // check circular parent window setting
1270 if(Dali::DevelWindow::GetParent(parent) == self)
1272 Dali::DevelWindow::Unparent(parent);
1274 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1278 void Window::SetParent(Dali::Window& parent, bool belowParent)
1280 if(DALI_UNLIKELY(parent))
1282 mParentWindow = parent;
1283 Dali::Window self = Dali::Window(this);
1284 // check circular parent window setting
1285 if(Dali::DevelWindow::GetParent(parent) == self)
1287 Dali::DevelWindow::Unparent(parent);
1289 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1293 void Window::Unparent()
1295 mWindowBase->SetParent(nullptr, false);
1296 mParentWindow.Reset();
1299 Dali::Window Window::GetParent()
1301 return mParentWindow;
1304 WindowOrientation Window::GetCurrentOrientation() const
1306 return ConvertToOrientation(mRotationAngle);
1309 int Window::GetPhysicalOrientation() const
1311 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1314 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1316 Dali::Vector<float>::SizeType count = orientations.Count();
1317 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1319 if(IsOrientationAvailable(orientations[index]) == false)
1321 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1326 int convertedAngle = ConvertToAngle(orientations[index]);
1328 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1330 if(mAvailableAngles[i] == convertedAngle)
1339 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1340 mAvailableAngles.push_back(convertedAngle);
1343 SetAvailableAnlges(mAvailableAngles);
1346 int32_t Window::GetNativeId() const
1348 return mWindowBase->GetNativeWindowId();
1351 void Window::RequestMoveToServer()
1353 SetUserGeometryPolicy();
1354 mWindowBase->RequestMoveToServer();
1357 void Window::RequestResizeToServer(WindowResizeDirection direction)
1359 SetUserGeometryPolicy();
1360 mWindowBase->RequestResizeToServer(direction);
1363 void Window::EnableFloatingMode(bool enable)
1365 mWindowBase->EnableFloatingMode(enable);
1368 bool Window::IsFloatingModeEnabled()
1370 return mWindowBase->IsFloatingModeEnabled();
1373 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1375 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);
1376 mWindowBase->IncludeInputRegion(inputRegion);
1379 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1381 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);
1382 mWindowBase->ExcludeInputRegion(inputRegion);
1385 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1387 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1388 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1389 mWindowRotationAcknowledgement = needAcknowledgement;
1392 void Window::SendRotationCompletedAcknowledgement()
1394 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1395 if(mWindowRotationAcknowledgement)
1397 SetRotationCompletedAcknowledgement();
1401 bool Window::IsWindowRotating() const
1403 return mIsWindowRotating;
1406 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1408 return mLastKeyEvent;
1411 void Window::SetUserGeometryPolicy()
1413 if(mIsEnabledUserGeometry == true)
1418 mIsEnabledUserGeometry = true;
1419 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1420 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1423 bool Window::PointerConstraintsLock()
1425 return mWindowBase->PointerConstraintsLock();
1428 bool Window::PointerConstraintsUnlock()
1430 return mWindowBase->PointerConstraintsUnlock();
1433 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1435 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1438 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1440 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1443 bool Window::PointerWarp(int32_t x, int32_t y)
1445 return mWindowBase->PointerWarp(x, y);
1448 void Window::CursorVisibleSet(bool visible)
1450 mWindowBase->CursorVisibleSet(visible);
1453 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1455 return mWindowBase->KeyboardGrab(deviceSubclass);
1458 bool Window::KeyboardUnGrab()
1460 return mWindowBase->KeyboardUnGrab();
1463 void Window::SetFullScreen(bool fullscreen)
1465 mWindowBase->SetFullScreen(fullscreen);
1468 bool Window::GetFullScreen()
1470 return mWindowBase->GetFullScreen();
1473 } // namespace Adaptor
1475 } // namespace Internal