2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/public-api/rendering/frame-buffer.h>
35 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
36 #include <dali/devel-api/atspi-interfaces/accessible.h>
37 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
38 #include <dali/internal/graphics/gles/egl-graphics.h>
39 #include <dali/internal/window-system/common/event-handler.h>
40 #include <dali/internal/window-system/common/orientation-impl.h>
41 #include <dali/internal/window-system/common/render-surface-factory.h>
42 #include <dali/internal/window-system/common/window-base.h>
43 #include <dali/internal/window-system/common/window-factory.h>
44 #include <dali/internal/window-system/common/window-render-surface.h>
45 #include <dali/internal/window-system/common/window-system.h>
46 #include <dali/internal/window-system/common/window-visibility-observer.h>
56 #if defined(DEBUG_ENABLED)
57 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
59 } // unnamed namespace
61 Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
64 return Window::New(surface, name, className, windowData);
67 Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
69 Window* window = new Window();
70 window->mIsTransparent = windowData.GetTransparency();
71 window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
76 : mWindowSurface(nullptr),
79 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
84 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
85 mDeleteRequestSignal(),
88 mVisibilityChangedSignal(),
89 mTransitionEffectEventSignal(),
90 mKeyboardRepeatSettingsChangedSignal(),
91 mAuxiliaryMessageSignal(),
93 mOrientationChangedSignal(),
94 mMouseInOutEventSignal(),
95 mMouseRelativeEventSignal(),
96 mMoveCompletedSignal(),
97 mResizeCompletedSignal(),
98 mInsetsChangedSignal(),
99 mPointerConstraintsSignal(),
102 mIsTransparent(false),
103 mIsFocusAcceptable(true),
107 mWindowRotationAcknowledgement(false),
109 mIsWindowRotating(false),
110 mIsEnabledUserGeometry(false),
111 mIsEmittedWindowCreatedEvent(false)
119 auto bridge = Accessibility::Bridge::GetCurrentBridge();
120 auto rootLayer = mScene.GetRootLayer();
121 auto accessible = Accessibility::Accessible::Get(rootLayer);
122 bridge->RemoveTopLevelWindow(accessible);
123 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
124 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
129 mAdaptor->RemoveWindow(this);
134 mEventHandler->RemoveObserver(*this);
138 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
140 // Create a window render surface
141 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
142 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
143 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
146 mWindowBase = mWindowSurface->GetWindowBase();
149 mWindowBase->SetType(type);
151 // Initialize for Ime window type
152 if(type == WindowType::IME)
154 mWindowBase->InitializeIme();
155 mWindowSurface->InitializeImeSurface();
159 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
160 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
161 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
162 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
163 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
164 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
165 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
166 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
167 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
168 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
169 mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
170 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
171 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
172 mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
174 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
175 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
177 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
179 SetClass(name, className);
181 mOrientation = Orientation::New(this);
183 // Get OrientationMode
184 int screenWidth, screenHeight;
185 WindowSystem::GetScreenSize(screenWidth, screenHeight);
186 if(screenWidth > screenHeight)
188 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
192 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
195 mWindowWidth = positionSize.width;
196 mWindowHeight = positionSize.height;
198 bool isSetWithScreenSize = false;
199 if(mWindowWidth <= 0 || mWindowHeight <= 0)
201 mWindowWidth = screenWidth;
202 mWindowHeight = screenHeight;
203 isSetWithScreenSize = true;
204 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
207 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
209 SetUserGeometryPolicy();
213 mNativeWindowId = mWindowBase->GetNativeWindowId();
216 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
223 mWindowSurface->SetRenderNotification(renderNotification);
226 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
228 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
229 mEventHandler->AddObserver(*this);
231 // Add Window to bridge for ATSPI
232 auto bridge = Accessibility::Bridge::GetCurrentBridge();
234 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
235 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
239 OnAccessibilityEnabled();
243 OnAccessibilityDisabled();
246 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
247 // The show must be called after the adaptor is initialized.
251 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
253 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
256 void Window::SetClass(std::string name, std::string className)
259 mClassName = className;
260 mWindowBase->SetClass(name, className);
263 std::string Window::GetClassName() const
270 mWindowBase->Raise();
272 mSurface->SetFullSwapNextFrame();
274 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
279 mWindowBase->Lower();
281 mSurface->SetFullSwapNextFrame();
283 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
286 void Window::Activate()
288 mWindowBase->Activate();
290 mSurface->SetFullSwapNextFrame();
292 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
295 void Window::Maximize(bool maximize)
297 mWindowBase->Maximize(maximize);
299 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
302 bool Window::IsMaximized() const
304 return mWindowBase->IsMaximized();
307 void Window::SetMaximumSize(Dali::Window::WindowSize size)
309 mWindowBase->SetMaximumSize(size);
312 void Window::Minimize(bool minimize)
314 mWindowBase->Minimize(minimize);
316 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
319 bool Window::IsMinimized() const
321 return mWindowBase->IsMinimized();
324 void Window::SetMimimumSize(Dali::Window::WindowSize size)
326 mWindowBase->SetMimimumSize(size);
329 uint32_t Window::GetLayerCount() const
331 return mScene.GetLayerCount();
334 Dali::Layer Window::GetLayer(uint32_t depth) const
336 return mScene.GetLayer(depth);
339 void Window::KeepRendering(float durationSeconds)
341 mScene.KeepRendering(durationSeconds);
344 void Window::SetPartialUpdateEnabled(bool enabled)
346 mScene.SetPartialUpdateEnabled(enabled);
349 bool Window::IsPartialUpdateEnabled() const
351 return mScene.IsPartialUpdateEnabled();
354 std::string Window::GetNativeResourceId() const
356 return mWindowBase->GetNativeWindowResourceId();
359 void Window::AddAvailableOrientation(WindowOrientation orientation)
361 if(IsOrientationAvailable(orientation) == false)
367 int convertedAngle = ConvertToAngle(orientation);
368 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
369 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
371 if(mAvailableAngles[i] == convertedAngle)
380 mAvailableAngles.push_back(convertedAngle);
381 SetAvailableAnlges(mAvailableAngles);
385 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
387 if(IsOrientationAvailable(orientation) == false)
392 int convertedAngle = ConvertToAngle(orientation);
393 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
394 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
395 iter != mAvailableAngles.end();
398 if(*iter == convertedAngle)
400 mAvailableAngles.erase(iter);
405 SetAvailableAnlges(mAvailableAngles);
408 void Window::SetPreferredOrientation(WindowOrientation orientation)
410 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
412 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
415 mPreferredAngle = ConvertToAngle(orientation);
416 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
417 mWindowBase->SetPreferredAngle(mPreferredAngle);
420 WindowOrientation Window::GetPreferredOrientation()
422 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
423 return preferredOrientation;
426 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
428 int angle = ConvertToAngle(orientation);
429 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
432 void Window::EmitAccessibilityHighlightSignal(bool highlight)
434 Dali::Window handle(this);
435 mAccessibilityHighlightSignal.Emit(handle, highlight);
438 void Window::SetAvailableAnlges(const std::vector<int>& angles)
440 if(angles.size() > 4)
442 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
446 mWindowBase->SetAvailableAnlges(angles);
449 int Window::ConvertToAngle(WindowOrientation orientation)
451 int convertAngle = static_cast<int>(orientation);
452 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
456 case WindowOrientation::LANDSCAPE:
461 case WindowOrientation::PORTRAIT:
466 case WindowOrientation::LANDSCAPE_INVERSE:
471 case WindowOrientation::PORTRAIT_INVERSE:
476 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
486 WindowOrientation Window::ConvertToOrientation(int angle) const
488 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
489 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
495 orientation = WindowOrientation::LANDSCAPE;
500 orientation = WindowOrientation::PORTRAIT;
505 orientation = WindowOrientation::LANDSCAPE_INVERSE;
510 orientation = WindowOrientation::PORTRAIT_INVERSE;
515 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
523 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
525 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
527 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
533 Dali::Any Window::GetNativeHandle() const
535 return mWindowSurface->GetNativeWindow();
538 void Window::SetAcceptFocus(bool accept)
540 mIsFocusAcceptable = accept;
542 mWindowBase->SetAcceptFocus(accept);
545 bool Window::IsFocusAcceptable() const
547 return mIsFocusAcceptable;
558 Dali::Window handle(this);
559 mVisibilityChangedSignal.Emit(handle, true);
560 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
562 WindowVisibilityObserver* observer(mAdaptor);
563 observer->OnWindowShown();
566 mSurface->SetFullSwapNextFrame();
568 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
579 Dali::Window handle(this);
580 mVisibilityChangedSignal.Emit(handle, false);
581 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
583 WindowVisibilityObserver* observer(mAdaptor);
584 observer->OnWindowHidden();
587 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
590 bool Window::IsVisible() const
592 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
593 return mVisible && !mIconified;
596 unsigned int Window::GetSupportedAuxiliaryHintCount() const
598 return mWindowBase->GetSupportedAuxiliaryHintCount();
601 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
603 return mWindowBase->GetSupportedAuxiliaryHint(index);
606 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
608 return mWindowBase->AddAuxiliaryHint(hint, value);
611 bool Window::RemoveAuxiliaryHint(unsigned int id)
613 return mWindowBase->RemoveAuxiliaryHint(id);
616 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
618 return mWindowBase->SetAuxiliaryHintValue(id, value);
621 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
623 return mWindowBase->GetAuxiliaryHintValue(id);
626 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
628 return mWindowBase->GetAuxiliaryHintId(hint);
631 void Window::SetInputRegion(const Rect<int>& inputRegion)
633 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);
634 mWindowBase->SetInputRegion(inputRegion);
637 void Window::SetType(WindowType type)
639 mWindowBase->SetType(type);
642 WindowType Window::GetType() const
644 return mWindowBase->GetType();
647 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
649 WindowType type = mWindowBase->GetType();
650 if(type != WindowType::NOTIFICATION)
652 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
653 return WindowOperationResult::INVALID_OPERATION;
656 return mWindowBase->SetNotificationLevel(level);
659 WindowNotificationLevel Window::GetNotificationLevel() const
661 WindowType type = mWindowBase->GetType();
662 if(type != WindowType::NOTIFICATION)
664 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
665 return WindowNotificationLevel::NONE;
668 return mWindowBase->GetNotificationLevel();
671 void Window::SetOpaqueState(bool opaque)
673 mOpaqueState = opaque;
675 mWindowBase->SetOpaqueState(opaque);
677 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
680 bool Window::IsOpaqueState() const
685 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
687 return mWindowBase->SetScreenOffMode(screenOffMode);
690 WindowScreenOffMode Window::GetScreenOffMode() const
692 return mWindowBase->GetScreenOffMode();
695 WindowOperationResult Window::SetBrightness(int brightness)
697 if(brightness < 0 || brightness > 100)
699 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
700 return WindowOperationResult::INVALID_OPERATION;
703 return mWindowBase->SetBrightness(brightness);
706 int Window::GetBrightness() const
708 return mWindowBase->GetBrightness();
711 void Window::SetSize(Dali::Window::WindowSize size)
713 PositionSize oldRect = GetPositionSize();
715 PositionSize newRect;
716 newRect.width = size.GetWidth();
717 newRect.height = size.GetHeight();
719 SetUserGeometryPolicy();
721 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
722 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
724 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
726 Uint16Pair newSize(newRect.width, newRect.height);
728 mWindowWidth = newRect.width;
729 mWindowHeight = newRect.height;
731 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);
733 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
735 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
737 Dali::Window handle(this);
738 mResizeSignal.Emit(handle, newSize);
740 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
743 mSurface->SetFullSwapNextFrame();
745 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
748 Dali::Window::WindowSize Window::GetSize() const
750 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
753 void Window::SetPosition(Dali::Window::WindowPosition position)
755 PositionSize oldRect = mSurface->GetPositionSize();
756 int32_t newX = position.GetX();
757 int32_t newY = position.GetY();
759 SetUserGeometryPolicy();
761 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
763 if((oldRect.x != newX) || (oldRect.y != newY))
765 Dali::Window handle(this);
766 Dali::Window::WindowPosition newPosition(newX, newY);
768 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
769 mMovedSignal.Emit(handle, newPosition);
772 mSurface->SetFullSwapNextFrame();
774 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
777 Dali::Window::WindowPosition Window::GetPosition() const
779 PositionSize positionSize = GetPositionSize();
780 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
783 PositionSize Window::GetPositionSize() const
785 PositionSize positionSize = mSurface->GetPositionSize();
786 positionSize.width = mWindowWidth;
787 positionSize.height = mWindowHeight;
791 void Window::SetPositionSize(PositionSize positionSize)
796 PositionSize oldRect = GetPositionSize();
797 Dali::Window handle(this);
799 SetUserGeometryPolicy();
801 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
806 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
813 mWindowSurface->MoveResize(positionSize);
816 // When window is moved, emit Moved Signal
819 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
820 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
821 mMovedSignal.Emit(handle, position);
824 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
827 Uint16Pair newSize(positionSize.width, positionSize.height);
829 mWindowWidth = positionSize.width;
830 mWindowHeight = positionSize.height;
832 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
834 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
836 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
838 mResizeSignal.Emit(handle, newSize);
839 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
842 mSurface->SetFullSwapNextFrame();
844 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
847 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
849 SetUserGeometryPolicy();
850 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
853 Dali::Layer Window::GetRootLayer() const
855 return mScene.GetRootLayer();
858 void Window::SetTransparency(bool transparent)
860 mWindowSurface->SetTransparency(transparent);
863 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
865 return mWindowBase->GrabKey(key, grabMode);
868 bool Window::UngrabKey(Dali::KEY key)
870 return mWindowBase->UngrabKey(key);
873 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
875 return mWindowBase->GrabKeyList(key, grabMode, result);
878 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
880 return mWindowBase->UngrabKeyList(key, result);
883 void Window::OnIconifyChanged(bool iconified)
885 const bool isActuallyChanged = (iconified != mIconified);
886 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
887 Dali::Window handle(this);
895 mVisibilityChangedSignal.Emit(handle, false);
896 bridge->WindowHidden(handle);
898 WindowVisibilityObserver* observer(mAdaptor);
899 observer->OnWindowHidden();
902 if(isActuallyChanged)
904 bridge->WindowMinimized(handle);
907 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
915 mVisibilityChangedSignal.Emit(handle, true);
916 bridge->WindowShown(handle);
918 WindowVisibilityObserver* observer(mAdaptor);
919 observer->OnWindowShown();
922 if(isActuallyChanged)
924 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
927 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
930 mSurface->SetFullSwapNextFrame();
933 void Window::OnMaximizeChanged(bool maximized)
935 const bool isActuallyChanged = (maximized != mMaximized);
937 if(isActuallyChanged)
939 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
940 Dali::Window handle(this);
945 bridge->WindowMaximized(handle);
950 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
955 void Window::OnFocusChanged(bool focusIn)
957 Dali::Window handle(this);
958 mFocusChangeSignal.Emit(handle, focusIn);
960 mSurface->SetFullSwapNextFrame();
961 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
965 bridge->WindowFocused(handle);
969 bridge->WindowUnfocused(handle);
975 void Window::OnOutputTransformed()
977 PositionSize positionSize = GetPositionSize();
979 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
981 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
982 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
985 void Window::OnDeleteRequest()
987 mDeleteRequestSignal.Emit();
990 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
992 Dali::Window handle(this);
993 mTransitionEffectEventSignal.Emit(handle, state, type);
996 void Window::OnKeyboardRepeatSettingsChanged()
998 Dali::Window handle(this);
999 mKeyboardRepeatSettingsChangedSignal.Emit();
1002 void Window::OnWindowRedrawRequest()
1004 mAdaptor->RenderOnce();
1007 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1010 bool resize = false;
1012 Dali::Window handle(this);
1014 PositionSize oldRect = GetPositionSize();
1015 PositionSize newRect = positionSize;
1017 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1022 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1029 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);
1030 mWindowSurface->UpdatePositionSize(positionSize);
1033 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1035 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1036 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1037 mMovedSignal.Emit(handle, position);
1040 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1041 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1043 Uint16Pair newSize(newRect.width, newRect.height);
1045 mWindowWidth = newRect.width;
1046 mWindowHeight = newRect.height;
1048 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1050 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1052 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1053 mResizeSignal.Emit(handle, newSize);
1054 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1057 mSurface->SetFullSwapNextFrame();
1059 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1062 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1064 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1065 FeedTouchPoint(point, timeStamp);
1068 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1070 FeedWheelEvent(wheelEvent);
1073 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1075 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);
1076 FeedKeyEvent(keyEvent);
1079 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1081 Dali::Window handle(this);
1083 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1086 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1088 Dali::Window handle(this);
1090 mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1093 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1095 Dali::Window handle(this);
1097 Vector2 newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1098 Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1100 mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1103 void Window::OnRotation(const RotationEvent& rotation)
1105 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1107 mRotationAngle = rotation.angle;
1108 mWindowWidth = rotation.width;
1109 mWindowHeight = rotation.height;
1111 mIsWindowRotating = true;
1112 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);
1114 // Notify that the orientation is changed
1115 mOrientation->OnOrientationChange(rotation);
1117 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1119 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1121 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1123 Dali::Window handle(this);
1124 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1125 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1127 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1130 void Window::OnRotationFinished()
1132 mIsWindowRotating = false;
1133 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1136 void Window::OnPause()
1140 mEventHandler->Pause();
1144 void Window::OnResume()
1148 mEventHandler->Resume();
1151 mSurface->SetFullSwapNextFrame();
1154 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1156 mAuxiliaryMessageSignal.Emit(key, value, options);
1159 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1161 mInsetsChangedSignal.Emit(partType, partState, insets);
1164 void Window::OnAccessibilityEnabled()
1166 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1167 auto rootLayer = mScene.GetRootLayer();
1168 auto accessible = Accessibility::Accessible::Get(rootLayer);
1169 bridge->AddTopLevelWindow(accessible);
1171 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1173 Dali::Window handle(this);
1174 if(!mIsEmittedWindowCreatedEvent)
1176 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1177 bridge->WindowCreated(handle);
1178 mIsEmittedWindowCreatedEvent = true;
1181 if(!mVisible || mIconified)
1186 bridge->WindowShown(handle);
1190 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1191 bridge->WindowFocused(handle);
1195 void Window::OnAccessibilityDisabled()
1197 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1198 auto rootLayer = mScene.GetRootLayer();
1199 auto accessible = Accessibility::Accessible::Get(rootLayer);
1200 bridge->RemoveTopLevelWindow(accessible);
1201 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1204 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1206 Dali::Window handle(this);
1207 mMoveCompletedSignal.Emit(handle, position);
1210 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1212 Dali::Window handle(this);
1213 mResizeCompletedSignal.Emit(handle, size);
1216 Vector2 Window::RecalculatePosition(const Vector2& position)
1218 Vector2 convertedPosition;
1220 switch(mRotationAngle)
1224 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1225 convertedPosition.y = position.x;
1230 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1231 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1236 convertedPosition.x = position.y;
1237 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1242 convertedPosition = position;
1246 return convertedPosition;
1249 Dali::Window Window::Get(Dali::Actor actor)
1251 Internal::Adaptor::Window* windowImpl = nullptr;
1253 if(Internal::Adaptor::Adaptor::IsAvailable())
1255 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1256 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1259 return Dali::Window(windowImpl);
1263 return Dali::Window();
1266 void Window::SetParent(Dali::Window& parent)
1268 if(DALI_UNLIKELY(parent))
1270 mParentWindow = parent;
1271 Dali::Window self = Dali::Window(this);
1272 // check circular parent window setting
1273 if(Dali::DevelWindow::GetParent(parent) == self)
1275 Dali::DevelWindow::Unparent(parent);
1277 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1281 void Window::SetParent(Dali::Window& parent, bool belowParent)
1283 if(DALI_UNLIKELY(parent))
1285 mParentWindow = parent;
1286 Dali::Window self = Dali::Window(this);
1287 // check circular parent window setting
1288 if(Dali::DevelWindow::GetParent(parent) == self)
1290 Dali::DevelWindow::Unparent(parent);
1292 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1296 void Window::Unparent()
1298 mWindowBase->SetParent(nullptr, false);
1299 mParentWindow.Reset();
1302 Dali::Window Window::GetParent()
1304 return mParentWindow;
1307 WindowOrientation Window::GetCurrentOrientation() const
1309 return ConvertToOrientation(mRotationAngle);
1312 int Window::GetPhysicalOrientation() const
1314 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1317 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1319 Dali::Vector<float>::SizeType count = orientations.Count();
1320 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1322 if(IsOrientationAvailable(orientations[index]) == false)
1324 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1329 int convertedAngle = ConvertToAngle(orientations[index]);
1331 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1333 if(mAvailableAngles[i] == convertedAngle)
1342 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1343 mAvailableAngles.push_back(convertedAngle);
1346 SetAvailableAnlges(mAvailableAngles);
1349 int32_t Window::GetNativeId() const
1351 return mWindowBase->GetNativeWindowId();
1354 void Window::RequestMoveToServer()
1356 SetUserGeometryPolicy();
1357 mWindowBase->RequestMoveToServer();
1360 void Window::RequestResizeToServer(WindowResizeDirection direction)
1362 SetUserGeometryPolicy();
1363 mWindowBase->RequestResizeToServer(direction);
1366 void Window::EnableFloatingMode(bool enable)
1368 mWindowBase->EnableFloatingMode(enable);
1371 bool Window::IsFloatingModeEnabled()
1373 return mWindowBase->IsFloatingModeEnabled();
1376 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1378 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);
1379 mWindowBase->IncludeInputRegion(inputRegion);
1382 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1384 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);
1385 mWindowBase->ExcludeInputRegion(inputRegion);
1388 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1390 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1391 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1392 mWindowRotationAcknowledgement = needAcknowledgement;
1395 void Window::SendRotationCompletedAcknowledgement()
1397 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1398 if(mWindowRotationAcknowledgement)
1400 SetRotationCompletedAcknowledgement();
1404 bool Window::IsWindowRotating() const
1406 return mIsWindowRotating;
1409 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1411 return mLastKeyEvent;
1414 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1416 return mLastTouchEvent;
1419 void Window::SetUserGeometryPolicy()
1421 if(mIsEnabledUserGeometry == true)
1426 mIsEnabledUserGeometry = true;
1427 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1428 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1431 bool Window::PointerConstraintsLock()
1433 return mWindowBase->PointerConstraintsLock();
1436 bool Window::PointerConstraintsUnlock()
1438 return mWindowBase->PointerConstraintsUnlock();
1441 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1443 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1446 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1448 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1451 bool Window::PointerWarp(int32_t x, int32_t y)
1453 return mWindowBase->PointerWarp(x, y);
1456 void Window::CursorVisibleSet(bool visible)
1458 mWindowBase->CursorVisibleSet(visible);
1461 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1463 return mWindowBase->KeyboardGrab(deviceSubclass);
1466 bool Window::KeyboardUnGrab()
1468 return mWindowBase->KeyboardUnGrab();
1471 } // namespace Adaptor
1473 } // namespace Internal