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->mIsFrontBufferRendering = windowData.GetFrontBufferRendering();
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(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
106 mWindowRotationAcknowledgement(false),
108 mIsWindowRotating(false),
109 mIsEnabledUserGeometry(false),
110 mIsEmittedWindowCreatedEvent(false),
111 mIsFrontBufferRendering(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();
215 if(mIsFrontBufferRendering)
217 SetFrontBufferRendering(mIsFrontBufferRendering);
221 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
228 mWindowSurface->SetRenderNotification(renderNotification);
231 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
233 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
234 mEventHandler->AddObserver(*this);
236 if(mWindowBase->GetType() == WindowType::IME)
238 mWindowBase->InitializeIme();
239 mWindowSurface->InitializeImeSurface();
242 // Add Window to bridge for ATSPI
243 auto bridge = Accessibility::Bridge::GetCurrentBridge();
245 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
246 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
250 OnAccessibilityEnabled();
254 OnAccessibilityDisabled();
257 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
258 // The show must be called after the adaptor is initialized.
262 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
264 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
267 void Window::SetClass(std::string name, std::string className)
270 mClassName = className;
271 mWindowBase->SetClass(name, className);
274 std::string Window::GetClassName() const
281 mWindowBase->Raise();
283 mSurface->SetFullSwapNextFrame();
285 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
290 mWindowBase->Lower();
292 mSurface->SetFullSwapNextFrame();
294 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
297 void Window::Activate()
299 mWindowBase->Activate();
301 mSurface->SetFullSwapNextFrame();
303 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
306 void Window::Maximize(bool maximize)
308 mWindowBase->Maximize(maximize);
310 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
313 bool Window::IsMaximized() const
315 return mWindowBase->IsMaximized();
318 void Window::SetMaximumSize(Dali::Window::WindowSize size)
320 mWindowBase->SetMaximumSize(size);
323 void Window::Minimize(bool minimize)
325 mWindowBase->Minimize(minimize);
327 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
330 bool Window::IsMinimized() const
332 return mWindowBase->IsMinimized();
335 void Window::SetMimimumSize(Dali::Window::WindowSize size)
337 mWindowBase->SetMimimumSize(size);
340 uint32_t Window::GetLayerCount() const
342 return mScene.GetLayerCount();
345 Dali::Layer Window::GetLayer(uint32_t depth) const
347 return mScene.GetLayer(depth);
350 void Window::KeepRendering(float durationSeconds)
352 mScene.KeepRendering(durationSeconds);
355 void Window::SetPartialUpdateEnabled(bool enabled)
357 mScene.SetPartialUpdateEnabled(enabled);
360 bool Window::IsPartialUpdateEnabled() const
362 return mScene.IsPartialUpdateEnabled();
365 std::string Window::GetNativeResourceId() const
367 return mWindowBase->GetNativeWindowResourceId();
370 void Window::AddAvailableOrientation(WindowOrientation orientation)
372 if(IsOrientationAvailable(orientation) == false)
378 int convertedAngle = ConvertToAngle(orientation);
379 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
380 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
382 if(mAvailableAngles[i] == convertedAngle)
391 mAvailableAngles.push_back(convertedAngle);
392 SetAvailableAnlges(mAvailableAngles);
396 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
398 if(IsOrientationAvailable(orientation) == false)
403 int convertedAngle = ConvertToAngle(orientation);
404 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
405 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
406 iter != mAvailableAngles.end();
409 if(*iter == convertedAngle)
411 mAvailableAngles.erase(iter);
416 SetAvailableAnlges(mAvailableAngles);
419 void Window::SetPreferredOrientation(WindowOrientation orientation)
421 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
423 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
426 mPreferredAngle = ConvertToAngle(orientation);
427 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
428 mWindowBase->SetPreferredAngle(mPreferredAngle);
431 WindowOrientation Window::GetPreferredOrientation()
433 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
434 return preferredOrientation;
437 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
439 int angle = ConvertToAngle(orientation);
440 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
443 void Window::EmitAccessibilityHighlightSignal(bool highlight)
445 Dali::Window handle(this);
446 mAccessibilityHighlightSignal.Emit(handle, highlight);
449 void Window::SetAvailableAnlges(const std::vector<int>& angles)
451 if(angles.size() > 4)
453 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
457 mWindowBase->SetAvailableAnlges(angles);
460 int Window::ConvertToAngle(WindowOrientation orientation)
462 int convertAngle = static_cast<int>(orientation);
463 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
467 case WindowOrientation::LANDSCAPE:
472 case WindowOrientation::PORTRAIT:
477 case WindowOrientation::LANDSCAPE_INVERSE:
482 case WindowOrientation::PORTRAIT_INVERSE:
487 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
497 WindowOrientation Window::ConvertToOrientation(int angle) const
499 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
500 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
506 orientation = WindowOrientation::LANDSCAPE;
511 orientation = WindowOrientation::PORTRAIT;
516 orientation = WindowOrientation::LANDSCAPE_INVERSE;
521 orientation = WindowOrientation::PORTRAIT_INVERSE;
526 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
534 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
536 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
538 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
544 Dali::Any Window::GetNativeHandle() const
546 return mWindowSurface->GetNativeWindow();
549 void Window::SetAcceptFocus(bool accept)
551 mIsFocusAcceptable = accept;
553 mWindowBase->SetAcceptFocus(accept);
556 bool Window::IsFocusAcceptable() const
558 return mIsFocusAcceptable;
569 Dali::Window handle(this);
570 mVisibilityChangedSignal.Emit(handle, true);
571 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
573 WindowVisibilityObserver* observer(mAdaptor);
574 observer->OnWindowShown();
577 mSurface->SetFullSwapNextFrame();
579 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
590 Dali::Window handle(this);
591 mVisibilityChangedSignal.Emit(handle, false);
592 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
594 WindowVisibilityObserver* observer(mAdaptor);
595 observer->OnWindowHidden();
598 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
601 bool Window::IsVisible() const
603 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
604 return mVisible && !mIconified;
607 unsigned int Window::GetSupportedAuxiliaryHintCount() const
609 return mWindowBase->GetSupportedAuxiliaryHintCount();
612 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
614 return mWindowBase->GetSupportedAuxiliaryHint(index);
617 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
619 return mWindowBase->AddAuxiliaryHint(hint, value);
622 bool Window::RemoveAuxiliaryHint(unsigned int id)
624 return mWindowBase->RemoveAuxiliaryHint(id);
627 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
629 return mWindowBase->SetAuxiliaryHintValue(id, value);
632 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
634 return mWindowBase->GetAuxiliaryHintValue(id);
637 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
639 return mWindowBase->GetAuxiliaryHintId(hint);
642 void Window::SetInputRegion(const Rect<int>& inputRegion)
644 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);
645 mWindowBase->SetInputRegion(inputRegion);
648 void Window::SetType(WindowType type)
650 mWindowBase->SetType(type);
653 WindowType Window::GetType() const
655 return mWindowBase->GetType();
658 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
660 WindowType type = mWindowBase->GetType();
661 if(type != WindowType::NOTIFICATION)
663 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
664 return WindowOperationResult::INVALID_OPERATION;
667 return mWindowBase->SetNotificationLevel(level);
670 WindowNotificationLevel Window::GetNotificationLevel() const
672 WindowType type = mWindowBase->GetType();
673 if(type != WindowType::NOTIFICATION)
675 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
676 return WindowNotificationLevel::NONE;
679 return mWindowBase->GetNotificationLevel();
682 void Window::SetOpaqueState(bool opaque)
684 mOpaqueState = opaque;
686 mWindowBase->SetOpaqueState(opaque);
688 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
691 bool Window::IsOpaqueState() const
696 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
698 return mWindowBase->SetScreenOffMode(screenOffMode);
701 WindowScreenOffMode Window::GetScreenOffMode() const
703 return mWindowBase->GetScreenOffMode();
706 WindowOperationResult Window::SetBrightness(int brightness)
708 if(brightness < 0 || brightness > 100)
710 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
711 return WindowOperationResult::INVALID_OPERATION;
714 return mWindowBase->SetBrightness(brightness);
717 int Window::GetBrightness() const
719 return mWindowBase->GetBrightness();
722 void Window::SetSize(Dali::Window::WindowSize size)
724 PositionSize oldRect = GetPositionSize();
726 PositionSize newRect;
727 newRect.width = size.GetWidth();
728 newRect.height = size.GetHeight();
730 SetUserGeometryPolicy();
732 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
733 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
735 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
737 Uint16Pair newSize(newRect.width, newRect.height);
739 mWindowWidth = newRect.width;
740 mWindowHeight = newRect.height;
742 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);
744 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
746 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
748 Dali::Window handle(this);
749 mResizeSignal.Emit(handle, newSize);
751 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
754 mSurface->SetFullSwapNextFrame();
756 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
759 Dali::Window::WindowSize Window::GetSize() const
761 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
764 void Window::SetPosition(Dali::Window::WindowPosition position)
766 PositionSize oldRect = mSurface->GetPositionSize();
767 int32_t newX = position.GetX();
768 int32_t newY = position.GetY();
770 SetUserGeometryPolicy();
772 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
774 if((oldRect.x != newX) || (oldRect.y != newY))
776 Dali::Window handle(this);
777 Dali::Window::WindowPosition newPosition(newX, newY);
779 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
780 mMovedSignal.Emit(handle, newPosition);
783 mSurface->SetFullSwapNextFrame();
785 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
788 Dali::Window::WindowPosition Window::GetPosition() const
790 PositionSize positionSize = GetPositionSize();
791 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
794 PositionSize Window::GetPositionSize() const
796 PositionSize positionSize = mSurface->GetPositionSize();
797 positionSize.width = mWindowWidth;
798 positionSize.height = mWindowHeight;
802 void Window::SetPositionSize(PositionSize positionSize)
807 PositionSize oldRect = GetPositionSize();
808 Dali::Window handle(this);
810 SetUserGeometryPolicy();
812 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
817 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
824 mWindowSurface->MoveResize(positionSize);
827 // When window is moved, emit Moved Signal
830 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
831 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
832 mMovedSignal.Emit(handle, position);
835 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
838 Uint16Pair newSize(positionSize.width, positionSize.height);
840 mWindowWidth = positionSize.width;
841 mWindowHeight = positionSize.height;
843 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
845 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
847 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
849 mResizeSignal.Emit(handle, newSize);
850 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
853 mSurface->SetFullSwapNextFrame();
855 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
858 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
860 SetUserGeometryPolicy();
861 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
864 Dali::Layer Window::GetRootLayer() const
866 return mScene.GetRootLayer();
869 void Window::SetTransparency(bool transparent)
871 mWindowSurface->SetTransparency(transparent);
874 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
876 return mWindowBase->GrabKey(key, grabMode);
879 bool Window::UngrabKey(Dali::KEY key)
881 return mWindowBase->UngrabKey(key);
884 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
886 return mWindowBase->GrabKeyList(key, grabMode, result);
889 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
891 return mWindowBase->UngrabKeyList(key, result);
894 void Window::OnIconifyChanged(bool iconified)
896 const bool isActuallyChanged = (iconified != mIconified);
897 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
898 Dali::Window handle(this);
906 mVisibilityChangedSignal.Emit(handle, false);
907 bridge->WindowHidden(handle);
909 WindowVisibilityObserver* observer(mAdaptor);
910 observer->OnWindowHidden();
913 if(isActuallyChanged)
915 bridge->WindowMinimized(handle);
918 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
926 mVisibilityChangedSignal.Emit(handle, true);
927 bridge->WindowShown(handle);
929 WindowVisibilityObserver* observer(mAdaptor);
930 observer->OnWindowShown();
933 if(isActuallyChanged)
935 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
938 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
941 mSurface->SetFullSwapNextFrame();
944 void Window::OnMaximizeChanged(bool maximized)
946 const bool isActuallyChanged = (maximized != mMaximized);
948 if(isActuallyChanged)
950 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
951 Dali::Window handle(this);
956 bridge->WindowMaximized(handle);
961 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
966 void Window::OnFocusChanged(bool focusIn)
968 Dali::Window handle(this);
969 mFocusChangeSignal.Emit(handle, focusIn);
971 mSurface->SetFullSwapNextFrame();
972 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
976 bridge->WindowFocused(handle);
980 bridge->WindowUnfocused(handle);
986 void Window::OnOutputTransformed()
988 PositionSize positionSize = GetPositionSize();
990 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
992 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
993 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
996 void Window::OnDeleteRequest()
998 mDeleteRequestSignal.Emit();
1001 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1003 Dali::Window handle(this);
1004 mTransitionEffectEventSignal.Emit(handle, state, type);
1007 void Window::OnKeyboardRepeatSettingsChanged()
1009 Dali::Window handle(this);
1010 mKeyboardRepeatSettingsChangedSignal.Emit();
1013 void Window::OnWindowRedrawRequest()
1015 mAdaptor->RenderOnce();
1018 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1021 bool resize = false;
1023 Dali::Window handle(this);
1025 PositionSize oldRect = GetPositionSize();
1026 PositionSize newRect = positionSize;
1028 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1033 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1040 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);
1041 mWindowSurface->UpdatePositionSize(positionSize);
1044 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1046 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1047 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1048 mMovedSignal.Emit(handle, position);
1051 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1052 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1054 Uint16Pair newSize(newRect.width, newRect.height);
1056 mWindowWidth = newRect.width;
1057 mWindowHeight = newRect.height;
1059 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1061 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1063 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1064 mResizeSignal.Emit(handle, newSize);
1065 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1068 mSurface->SetFullSwapNextFrame();
1070 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1073 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1075 FeedTouchPoint(point, timeStamp);
1078 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1080 FeedWheelEvent(wheelEvent);
1083 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1085 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);
1086 FeedKeyEvent(keyEvent);
1089 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1091 Dali::Window handle(this);
1093 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1096 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1098 Dali::Window handle(this);
1100 mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1103 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1105 Dali::Window handle(this);
1107 Vector2 newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1108 Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1110 mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1113 void Window::OnRotation(const RotationEvent& rotation)
1115 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1117 mRotationAngle = rotation.angle;
1118 mWindowWidth = rotation.width;
1119 mWindowHeight = rotation.height;
1121 mIsWindowRotating = true;
1122 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);
1124 // Notify that the orientation is changed
1125 mOrientation->OnOrientationChange(rotation);
1127 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1129 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1131 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1133 Dali::Window handle(this);
1134 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1135 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1137 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1140 void Window::OnRotationFinished()
1142 mIsWindowRotating = false;
1143 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1146 void Window::OnPause()
1150 mEventHandler->Pause();
1154 void Window::OnResume()
1158 mEventHandler->Resume();
1161 mSurface->SetFullSwapNextFrame();
1164 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1166 mAuxiliaryMessageSignal.Emit(key, value, options);
1169 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1171 mInsetsChangedSignal.Emit(partType, partState, insets);
1174 void Window::OnAccessibilityEnabled()
1176 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1177 auto rootLayer = mScene.GetRootLayer();
1178 auto accessible = Accessibility::Accessible::Get(rootLayer);
1179 bridge->AddTopLevelWindow(accessible);
1181 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1183 Dali::Window handle(this);
1184 if(!mIsEmittedWindowCreatedEvent)
1186 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1187 bridge->WindowCreated(handle);
1188 mIsEmittedWindowCreatedEvent = true;
1191 if(!mVisible || mIconified)
1196 bridge->WindowShown(handle);
1200 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1201 bridge->WindowFocused(handle);
1205 void Window::OnAccessibilityDisabled()
1207 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1208 auto rootLayer = mScene.GetRootLayer();
1209 auto accessible = Accessibility::Accessible::Get(rootLayer);
1210 bridge->RemoveTopLevelWindow(accessible);
1211 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1214 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1216 Dali::Window handle(this);
1217 mMoveCompletedSignal.Emit(handle, position);
1220 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1222 Dali::Window handle(this);
1223 mResizeCompletedSignal.Emit(handle, size);
1226 Vector2 Window::RecalculatePosition(const Vector2& position)
1228 Vector2 convertedPosition;
1230 switch(mRotationAngle)
1234 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1235 convertedPosition.y = position.x;
1240 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1241 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1246 convertedPosition.x = position.y;
1247 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1252 convertedPosition = position;
1256 return convertedPosition;
1259 Dali::Window Window::Get(Dali::Actor actor)
1261 Internal::Adaptor::Window* windowImpl = nullptr;
1263 if(Internal::Adaptor::Adaptor::IsAvailable())
1265 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1266 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1269 return Dali::Window(windowImpl);
1273 return Dali::Window();
1276 void Window::SetParent(Dali::Window& parent)
1278 if(DALI_UNLIKELY(parent))
1280 mParentWindow = parent;
1281 Dali::Window self = Dali::Window(this);
1282 // check circular parent window setting
1283 if(Dali::DevelWindow::GetParent(parent) == self)
1285 Dali::DevelWindow::Unparent(parent);
1287 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1291 void Window::SetParent(Dali::Window& parent, bool belowParent)
1293 if(DALI_UNLIKELY(parent))
1295 mParentWindow = parent;
1296 Dali::Window self = Dali::Window(this);
1297 // check circular parent window setting
1298 if(Dali::DevelWindow::GetParent(parent) == self)
1300 Dali::DevelWindow::Unparent(parent);
1302 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1306 void Window::Unparent()
1308 mWindowBase->SetParent(nullptr, false);
1309 mParentWindow.Reset();
1312 Dali::Window Window::GetParent()
1314 return mParentWindow;
1317 WindowOrientation Window::GetCurrentOrientation() const
1319 return ConvertToOrientation(mRotationAngle);
1322 int Window::GetPhysicalOrientation() const
1324 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1327 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1329 Dali::Vector<float>::SizeType count = orientations.Count();
1330 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1332 if(IsOrientationAvailable(orientations[index]) == false)
1334 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1339 int convertedAngle = ConvertToAngle(orientations[index]);
1341 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1343 if(mAvailableAngles[i] == convertedAngle)
1352 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1353 mAvailableAngles.push_back(convertedAngle);
1356 SetAvailableAnlges(mAvailableAngles);
1359 int32_t Window::GetNativeId() const
1361 return mWindowBase->GetNativeWindowId();
1364 void Window::RequestMoveToServer()
1366 SetUserGeometryPolicy();
1367 mWindowBase->RequestMoveToServer();
1370 void Window::RequestResizeToServer(WindowResizeDirection direction)
1372 SetUserGeometryPolicy();
1373 mWindowBase->RequestResizeToServer(direction);
1376 void Window::EnableFloatingMode(bool enable)
1378 mWindowBase->EnableFloatingMode(enable);
1381 bool Window::IsFloatingModeEnabled()
1383 return mWindowBase->IsFloatingModeEnabled();
1386 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1388 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);
1389 mWindowBase->IncludeInputRegion(inputRegion);
1392 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1394 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);
1395 mWindowBase->ExcludeInputRegion(inputRegion);
1398 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1400 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1401 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1402 mWindowRotationAcknowledgement = needAcknowledgement;
1405 void Window::SendRotationCompletedAcknowledgement()
1407 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1408 if(mWindowRotationAcknowledgement)
1410 SetRotationCompletedAcknowledgement();
1414 bool Window::IsWindowRotating() const
1416 return mIsWindowRotating;
1419 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1421 return mLastKeyEvent;
1424 void Window::SetUserGeometryPolicy()
1426 if(mIsEnabledUserGeometry == true)
1431 mIsEnabledUserGeometry = true;
1432 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1433 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1436 bool Window::PointerConstraintsLock()
1438 return mWindowBase->PointerConstraintsLock();
1441 bool Window::PointerConstraintsUnlock()
1443 return mWindowBase->PointerConstraintsUnlock();
1446 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1448 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1451 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1453 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1456 bool Window::PointerWarp(int32_t x, int32_t y)
1458 return mWindowBase->PointerWarp(x, y);
1461 void Window::CursorVisibleSet(bool visible)
1463 mWindowBase->CursorVisibleSet(visible);
1466 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1468 return mWindowBase->KeyboardGrab(deviceSubclass);
1471 bool Window::KeyboardUnGrab()
1473 return mWindowBase->KeyboardUnGrab();
1476 void Window::SetFullScreen(bool fullscreen)
1478 mWindowBase->SetFullScreen(fullscreen);
1481 bool Window::GetFullScreen()
1483 return mWindowBase->GetFullScreen();
1486 void Window::SetFrontBufferRendering(bool enable)
1488 mWindowBase->SetFrontBufferRendering(enable);
1489 mWindowSurface->SetFrontBufferRendering(enable);
1492 bool Window::GetFrontBufferRendering()
1494 return mWindowBase->GetFrontBufferRendering();
1497 } // namespace Adaptor
1499 } // namespace Internal