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 if(mWindowBase->GetType() == WindowType::IME)
231 mWindowBase->InitializeIme();
232 mWindowSurface->InitializeImeSurface();
235 // Add Window to bridge for ATSPI
236 auto bridge = Accessibility::Bridge::GetCurrentBridge();
238 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
239 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
243 OnAccessibilityEnabled();
247 OnAccessibilityDisabled();
250 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
251 // The show must be called after the adaptor is initialized.
255 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
257 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
260 void Window::SetClass(std::string name, std::string className)
263 mClassName = className;
264 mWindowBase->SetClass(name, className);
267 std::string Window::GetClassName() const
274 mWindowBase->Raise();
276 mSurface->SetFullSwapNextFrame();
278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
283 mWindowBase->Lower();
285 mSurface->SetFullSwapNextFrame();
287 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
290 void Window::Activate()
292 mWindowBase->Activate();
294 mSurface->SetFullSwapNextFrame();
296 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
299 void Window::Maximize(bool maximize)
301 mWindowBase->Maximize(maximize);
303 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
306 bool Window::IsMaximized() const
308 return mWindowBase->IsMaximized();
311 void Window::SetMaximumSize(Dali::Window::WindowSize size)
313 mWindowBase->SetMaximumSize(size);
316 void Window::Minimize(bool minimize)
318 mWindowBase->Minimize(minimize);
320 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
323 bool Window::IsMinimized() const
325 return mWindowBase->IsMinimized();
328 void Window::SetMimimumSize(Dali::Window::WindowSize size)
330 mWindowBase->SetMimimumSize(size);
333 uint32_t Window::GetLayerCount() const
335 return mScene.GetLayerCount();
338 Dali::Layer Window::GetLayer(uint32_t depth) const
340 return mScene.GetLayer(depth);
343 void Window::KeepRendering(float durationSeconds)
345 mScene.KeepRendering(durationSeconds);
348 void Window::SetPartialUpdateEnabled(bool enabled)
350 mScene.SetPartialUpdateEnabled(enabled);
353 bool Window::IsPartialUpdateEnabled() const
355 return mScene.IsPartialUpdateEnabled();
358 std::string Window::GetNativeResourceId() const
360 return mWindowBase->GetNativeWindowResourceId();
363 void Window::AddAvailableOrientation(WindowOrientation orientation)
365 if(IsOrientationAvailable(orientation) == false)
371 int convertedAngle = ConvertToAngle(orientation);
372 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
373 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
375 if(mAvailableAngles[i] == convertedAngle)
384 mAvailableAngles.push_back(convertedAngle);
385 SetAvailableAnlges(mAvailableAngles);
389 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
391 if(IsOrientationAvailable(orientation) == false)
396 int convertedAngle = ConvertToAngle(orientation);
397 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
398 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
399 iter != mAvailableAngles.end();
402 if(*iter == convertedAngle)
404 mAvailableAngles.erase(iter);
409 SetAvailableAnlges(mAvailableAngles);
412 void Window::SetPreferredOrientation(WindowOrientation orientation)
414 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
416 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
419 mPreferredAngle = ConvertToAngle(orientation);
420 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
421 mWindowBase->SetPreferredAngle(mPreferredAngle);
424 WindowOrientation Window::GetPreferredOrientation()
426 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
427 return preferredOrientation;
430 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
432 int angle = ConvertToAngle(orientation);
433 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
436 void Window::EmitAccessibilityHighlightSignal(bool highlight)
438 Dali::Window handle(this);
439 mAccessibilityHighlightSignal.Emit(handle, highlight);
442 void Window::SetAvailableAnlges(const std::vector<int>& angles)
444 if(angles.size() > 4)
446 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
450 mWindowBase->SetAvailableAnlges(angles);
453 int Window::ConvertToAngle(WindowOrientation orientation)
455 int convertAngle = static_cast<int>(orientation);
456 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
460 case WindowOrientation::LANDSCAPE:
465 case WindowOrientation::PORTRAIT:
470 case WindowOrientation::LANDSCAPE_INVERSE:
475 case WindowOrientation::PORTRAIT_INVERSE:
480 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
490 WindowOrientation Window::ConvertToOrientation(int angle) const
492 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
493 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
499 orientation = WindowOrientation::LANDSCAPE;
504 orientation = WindowOrientation::PORTRAIT;
509 orientation = WindowOrientation::LANDSCAPE_INVERSE;
514 orientation = WindowOrientation::PORTRAIT_INVERSE;
519 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
527 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
529 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
531 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
537 Dali::Any Window::GetNativeHandle() const
539 return mWindowSurface->GetNativeWindow();
542 void Window::SetAcceptFocus(bool accept)
544 mIsFocusAcceptable = accept;
546 mWindowBase->SetAcceptFocus(accept);
549 bool Window::IsFocusAcceptable() const
551 return mIsFocusAcceptable;
562 Dali::Window handle(this);
563 mVisibilityChangedSignal.Emit(handle, true);
564 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
566 WindowVisibilityObserver* observer(mAdaptor);
567 observer->OnWindowShown();
570 mSurface->SetFullSwapNextFrame();
572 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
583 Dali::Window handle(this);
584 mVisibilityChangedSignal.Emit(handle, false);
585 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
587 WindowVisibilityObserver* observer(mAdaptor);
588 observer->OnWindowHidden();
591 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
594 bool Window::IsVisible() const
596 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
597 return mVisible && !mIconified;
600 unsigned int Window::GetSupportedAuxiliaryHintCount() const
602 return mWindowBase->GetSupportedAuxiliaryHintCount();
605 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
607 return mWindowBase->GetSupportedAuxiliaryHint(index);
610 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
612 return mWindowBase->AddAuxiliaryHint(hint, value);
615 bool Window::RemoveAuxiliaryHint(unsigned int id)
617 return mWindowBase->RemoveAuxiliaryHint(id);
620 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
622 return mWindowBase->SetAuxiliaryHintValue(id, value);
625 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
627 return mWindowBase->GetAuxiliaryHintValue(id);
630 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
632 return mWindowBase->GetAuxiliaryHintId(hint);
635 void Window::SetInputRegion(const Rect<int>& inputRegion)
637 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);
638 mWindowBase->SetInputRegion(inputRegion);
641 void Window::SetType(WindowType type)
643 mWindowBase->SetType(type);
646 WindowType Window::GetType() const
648 return mWindowBase->GetType();
651 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
653 WindowType type = mWindowBase->GetType();
654 if(type != WindowType::NOTIFICATION)
656 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
657 return WindowOperationResult::INVALID_OPERATION;
660 return mWindowBase->SetNotificationLevel(level);
663 WindowNotificationLevel Window::GetNotificationLevel() const
665 WindowType type = mWindowBase->GetType();
666 if(type != WindowType::NOTIFICATION)
668 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
669 return WindowNotificationLevel::NONE;
672 return mWindowBase->GetNotificationLevel();
675 void Window::SetOpaqueState(bool opaque)
677 mOpaqueState = opaque;
679 mWindowBase->SetOpaqueState(opaque);
681 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
684 bool Window::IsOpaqueState() const
689 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
691 return mWindowBase->SetScreenOffMode(screenOffMode);
694 WindowScreenOffMode Window::GetScreenOffMode() const
696 return mWindowBase->GetScreenOffMode();
699 WindowOperationResult Window::SetBrightness(int brightness)
701 if(brightness < 0 || brightness > 100)
703 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
704 return WindowOperationResult::INVALID_OPERATION;
707 return mWindowBase->SetBrightness(brightness);
710 int Window::GetBrightness() const
712 return mWindowBase->GetBrightness();
715 void Window::SetSize(Dali::Window::WindowSize size)
717 PositionSize oldRect = GetPositionSize();
719 PositionSize newRect;
720 newRect.width = size.GetWidth();
721 newRect.height = size.GetHeight();
723 SetUserGeometryPolicy();
725 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
726 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
728 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
730 Uint16Pair newSize(newRect.width, newRect.height);
732 mWindowWidth = newRect.width;
733 mWindowHeight = newRect.height;
735 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);
737 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
739 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
741 Dali::Window handle(this);
742 mResizeSignal.Emit(handle, newSize);
744 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
747 mSurface->SetFullSwapNextFrame();
749 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
752 Dali::Window::WindowSize Window::GetSize() const
754 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
757 void Window::SetPosition(Dali::Window::WindowPosition position)
759 PositionSize oldRect = mSurface->GetPositionSize();
760 int32_t newX = position.GetX();
761 int32_t newY = position.GetY();
763 SetUserGeometryPolicy();
765 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
767 if((oldRect.x != newX) || (oldRect.y != newY))
769 Dali::Window handle(this);
770 Dali::Window::WindowPosition newPosition(newX, newY);
772 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
773 mMovedSignal.Emit(handle, newPosition);
776 mSurface->SetFullSwapNextFrame();
778 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
781 Dali::Window::WindowPosition Window::GetPosition() const
783 PositionSize positionSize = GetPositionSize();
784 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
787 PositionSize Window::GetPositionSize() const
789 PositionSize positionSize = mSurface->GetPositionSize();
790 positionSize.width = mWindowWidth;
791 positionSize.height = mWindowHeight;
795 void Window::SetPositionSize(PositionSize positionSize)
800 PositionSize oldRect = GetPositionSize();
801 Dali::Window handle(this);
803 SetUserGeometryPolicy();
805 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
810 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
817 mWindowSurface->MoveResize(positionSize);
820 // When window is moved, emit Moved Signal
823 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
824 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
825 mMovedSignal.Emit(handle, position);
828 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
831 Uint16Pair newSize(positionSize.width, positionSize.height);
833 mWindowWidth = positionSize.width;
834 mWindowHeight = positionSize.height;
836 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
838 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
840 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
842 mResizeSignal.Emit(handle, newSize);
843 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
846 mSurface->SetFullSwapNextFrame();
848 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
851 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
853 SetUserGeometryPolicy();
854 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
857 Dali::Layer Window::GetRootLayer() const
859 return mScene.GetRootLayer();
862 void Window::SetTransparency(bool transparent)
864 mWindowSurface->SetTransparency(transparent);
867 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
869 return mWindowBase->GrabKey(key, grabMode);
872 bool Window::UngrabKey(Dali::KEY key)
874 return mWindowBase->UngrabKey(key);
877 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
879 return mWindowBase->GrabKeyList(key, grabMode, result);
882 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
884 return mWindowBase->UngrabKeyList(key, result);
887 void Window::OnIconifyChanged(bool iconified)
889 const bool isActuallyChanged = (iconified != mIconified);
890 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
891 Dali::Window handle(this);
899 mVisibilityChangedSignal.Emit(handle, false);
900 bridge->WindowHidden(handle);
902 WindowVisibilityObserver* observer(mAdaptor);
903 observer->OnWindowHidden();
906 if(isActuallyChanged)
908 bridge->WindowMinimized(handle);
911 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
919 mVisibilityChangedSignal.Emit(handle, true);
920 bridge->WindowShown(handle);
922 WindowVisibilityObserver* observer(mAdaptor);
923 observer->OnWindowShown();
926 if(isActuallyChanged)
928 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
931 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
934 mSurface->SetFullSwapNextFrame();
937 void Window::OnMaximizeChanged(bool maximized)
939 const bool isActuallyChanged = (maximized != mMaximized);
941 if(isActuallyChanged)
943 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
944 Dali::Window handle(this);
949 bridge->WindowMaximized(handle);
954 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
959 void Window::OnFocusChanged(bool focusIn)
961 Dali::Window handle(this);
962 mFocusChangeSignal.Emit(handle, focusIn);
964 mSurface->SetFullSwapNextFrame();
965 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
969 bridge->WindowFocused(handle);
973 bridge->WindowUnfocused(handle);
979 void Window::OnOutputTransformed()
981 PositionSize positionSize = GetPositionSize();
983 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
985 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
986 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
989 void Window::OnDeleteRequest()
991 mDeleteRequestSignal.Emit();
994 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
996 Dali::Window handle(this);
997 mTransitionEffectEventSignal.Emit(handle, state, type);
1000 void Window::OnKeyboardRepeatSettingsChanged()
1002 Dali::Window handle(this);
1003 mKeyboardRepeatSettingsChangedSignal.Emit();
1006 void Window::OnWindowRedrawRequest()
1008 mAdaptor->RenderOnce();
1011 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1014 bool resize = false;
1016 Dali::Window handle(this);
1018 PositionSize oldRect = GetPositionSize();
1019 PositionSize newRect = positionSize;
1021 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1026 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1033 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);
1034 mWindowSurface->UpdatePositionSize(positionSize);
1037 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1039 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1040 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1041 mMovedSignal.Emit(handle, position);
1044 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1045 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1047 Uint16Pair newSize(newRect.width, newRect.height);
1049 mWindowWidth = newRect.width;
1050 mWindowHeight = newRect.height;
1052 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1054 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1056 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1057 mResizeSignal.Emit(handle, newSize);
1058 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1061 mSurface->SetFullSwapNextFrame();
1063 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1066 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1068 FeedTouchPoint(point, timeStamp);
1071 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1073 FeedWheelEvent(wheelEvent);
1076 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1078 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);
1079 FeedKeyEvent(keyEvent);
1082 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1084 Dali::Window handle(this);
1086 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1089 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1091 Dali::Window handle(this);
1093 mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1096 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1098 Dali::Window handle(this);
1100 Vector2 newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1101 Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1103 mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1106 void Window::OnRotation(const RotationEvent& rotation)
1108 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1110 mRotationAngle = rotation.angle;
1111 mWindowWidth = rotation.width;
1112 mWindowHeight = rotation.height;
1114 mIsWindowRotating = true;
1115 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);
1117 // Notify that the orientation is changed
1118 mOrientation->OnOrientationChange(rotation);
1120 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1122 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1124 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1126 Dali::Window handle(this);
1127 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1128 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1130 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1133 void Window::OnRotationFinished()
1135 mIsWindowRotating = false;
1136 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1139 void Window::OnPause()
1143 mEventHandler->Pause();
1147 void Window::OnResume()
1151 mEventHandler->Resume();
1154 mSurface->SetFullSwapNextFrame();
1157 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1159 mAuxiliaryMessageSignal.Emit(key, value, options);
1162 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1164 mInsetsChangedSignal.Emit(partType, partState, insets);
1167 void Window::OnAccessibilityEnabled()
1169 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1170 auto rootLayer = mScene.GetRootLayer();
1171 auto accessible = Accessibility::Accessible::Get(rootLayer);
1172 bridge->AddTopLevelWindow(accessible);
1174 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1176 Dali::Window handle(this);
1177 if(!mIsEmittedWindowCreatedEvent)
1179 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1180 bridge->WindowCreated(handle);
1181 mIsEmittedWindowCreatedEvent = true;
1184 if(!mVisible || mIconified)
1189 bridge->WindowShown(handle);
1193 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1194 bridge->WindowFocused(handle);
1198 void Window::OnAccessibilityDisabled()
1200 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1201 auto rootLayer = mScene.GetRootLayer();
1202 auto accessible = Accessibility::Accessible::Get(rootLayer);
1203 bridge->RemoveTopLevelWindow(accessible);
1204 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1207 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1209 Dali::Window handle(this);
1210 mMoveCompletedSignal.Emit(handle, position);
1213 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1215 Dali::Window handle(this);
1216 mResizeCompletedSignal.Emit(handle, size);
1219 Vector2 Window::RecalculatePosition(const Vector2& position)
1221 Vector2 convertedPosition;
1223 switch(mRotationAngle)
1227 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1228 convertedPosition.y = position.x;
1233 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1234 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1239 convertedPosition.x = position.y;
1240 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1245 convertedPosition = position;
1249 return convertedPosition;
1252 Dali::Window Window::Get(Dali::Actor actor)
1254 Internal::Adaptor::Window* windowImpl = nullptr;
1256 if(Internal::Adaptor::Adaptor::IsAvailable())
1258 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1259 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1262 return Dali::Window(windowImpl);
1266 return Dali::Window();
1269 void Window::SetParent(Dali::Window& parent)
1271 if(DALI_UNLIKELY(parent))
1273 mParentWindow = parent;
1274 Dali::Window self = Dali::Window(this);
1275 // check circular parent window setting
1276 if(Dali::DevelWindow::GetParent(parent) == self)
1278 Dali::DevelWindow::Unparent(parent);
1280 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1284 void Window::SetParent(Dali::Window& parent, bool belowParent)
1286 if(DALI_UNLIKELY(parent))
1288 mParentWindow = parent;
1289 Dali::Window self = Dali::Window(this);
1290 // check circular parent window setting
1291 if(Dali::DevelWindow::GetParent(parent) == self)
1293 Dali::DevelWindow::Unparent(parent);
1295 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1299 void Window::Unparent()
1301 mWindowBase->SetParent(nullptr, false);
1302 mParentWindow.Reset();
1305 Dali::Window Window::GetParent()
1307 return mParentWindow;
1310 WindowOrientation Window::GetCurrentOrientation() const
1312 return ConvertToOrientation(mRotationAngle);
1315 int Window::GetPhysicalOrientation() const
1317 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1320 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1322 Dali::Vector<float>::SizeType count = orientations.Count();
1323 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1325 if(IsOrientationAvailable(orientations[index]) == false)
1327 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1332 int convertedAngle = ConvertToAngle(orientations[index]);
1334 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1336 if(mAvailableAngles[i] == convertedAngle)
1345 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1346 mAvailableAngles.push_back(convertedAngle);
1349 SetAvailableAnlges(mAvailableAngles);
1352 int32_t Window::GetNativeId() const
1354 return mWindowBase->GetNativeWindowId();
1357 void Window::RequestMoveToServer()
1359 SetUserGeometryPolicy();
1360 mWindowBase->RequestMoveToServer();
1363 void Window::RequestResizeToServer(WindowResizeDirection direction)
1365 SetUserGeometryPolicy();
1366 mWindowBase->RequestResizeToServer(direction);
1369 void Window::EnableFloatingMode(bool enable)
1371 mWindowBase->EnableFloatingMode(enable);
1374 bool Window::IsFloatingModeEnabled()
1376 return mWindowBase->IsFloatingModeEnabled();
1379 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1381 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);
1382 mWindowBase->IncludeInputRegion(inputRegion);
1385 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1387 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);
1388 mWindowBase->ExcludeInputRegion(inputRegion);
1391 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1393 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1394 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1395 mWindowRotationAcknowledgement = needAcknowledgement;
1398 void Window::SendRotationCompletedAcknowledgement()
1400 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1401 if(mWindowRotationAcknowledgement)
1403 SetRotationCompletedAcknowledgement();
1407 bool Window::IsWindowRotating() const
1409 return mIsWindowRotating;
1412 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1414 return mLastKeyEvent;
1417 void Window::SetUserGeometryPolicy()
1419 if(mIsEnabledUserGeometry == true)
1424 mIsEnabledUserGeometry = true;
1425 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1426 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1429 bool Window::PointerConstraintsLock()
1431 return mWindowBase->PointerConstraintsLock();
1434 bool Window::PointerConstraintsUnlock()
1436 return mWindowBase->PointerConstraintsUnlock();
1439 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1441 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1444 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1446 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1449 bool Window::PointerWarp(int32_t x, int32_t y)
1451 return mWindowBase->PointerWarp(x, y);
1454 void Window::CursorVisibleSet(bool visible)
1456 mWindowBase->CursorVisibleSet(visible);
1459 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1461 return mWindowBase->KeyboardGrab(deviceSubclass);
1464 bool Window::KeyboardUnGrab()
1466 return mWindowBase->KeyboardUnGrab();
1469 void Window::SetFullScreen(bool fullscreen)
1471 mWindowBase->SetFullScreen(fullscreen);
1474 bool Window::GetFullScreen()
1476 return mWindowBase->GetFullScreen();
1479 void Window::SetFrontBufferRendering(bool enable)
1481 mWindowBase->SetFrontBufferRendering(enable);
1482 mWindowSurface->SetFrontBufferRendering(enable);
1485 bool Window::GetFrontBufferRendering()
1487 return mWindowBase->GetFrontBufferRendering();
1490 } // namespace Adaptor
1492 } // namespace Internal