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 mMoveCompletedSignal(),
96 mResizeCompletedSignal(),
97 mInsetsChangedSignal(),
100 mIsTransparent(false),
101 mIsFocusAcceptable(true),
105 mWindowRotationAcknowledgement(false),
107 mIsWindowRotating(false),
108 mIsEnabledUserGeometry(false)
116 auto bridge = Accessibility::Bridge::GetCurrentBridge();
117 auto rootLayer = mScene.GetRootLayer();
118 auto accessible = Accessibility::Accessible::Get(rootLayer);
119 bridge->RemoveTopLevelWindow(accessible);
120 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
121 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
126 mAdaptor->RemoveWindow(this);
131 mEventHandler->RemoveObserver(*this);
135 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
137 // Create a window render surface
138 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
139 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
140 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
143 mWindowBase = mWindowSurface->GetWindowBase();
146 mWindowBase->SetType(type);
148 // Initialize for Ime window type
149 if(type == WindowType::IME)
151 mWindowBase->InitializeIme();
152 mWindowSurface->InitializeImeSurface();
156 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
157 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
158 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
159 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
160 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
161 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
162 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
163 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
164 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
165 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
166 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
167 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
169 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
170 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
172 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
174 SetClass(name, className);
176 mOrientation = Orientation::New(this);
178 // Get OrientationMode
179 int screenWidth, screenHeight;
180 WindowSystem::GetScreenSize(screenWidth, screenHeight);
181 if(screenWidth > screenHeight)
183 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
187 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
190 mWindowWidth = positionSize.width;
191 mWindowHeight = positionSize.height;
193 bool isSetWithScreenSize = false;
194 if(mWindowWidth <= 0 || mWindowHeight <= 0)
196 mWindowWidth = screenWidth;
197 mWindowHeight = screenHeight;
198 isSetWithScreenSize = true;
199 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
202 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
204 SetUserGeometryPolicy();
208 mNativeWindowId = mWindowBase->GetNativeWindowId();
211 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
218 mWindowSurface->SetRenderNotification(renderNotification);
221 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
223 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
224 mEventHandler->AddObserver(*this);
226 // Add Window to bridge for ATSPI
227 auto bridge = Accessibility::Bridge::GetCurrentBridge();
230 auto rootLayer = mScene.GetRootLayer();
231 auto accessible = Accessibility::Accessible::Get(rootLayer);
232 bridge->AddTopLevelWindow(accessible);
234 // Emit Window create event
235 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
236 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
239 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
240 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
242 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
243 // The show must be called after the adaptor is initialized.
247 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
249 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
252 void Window::SetClass(std::string name, std::string className)
255 mClassName = className;
256 mWindowBase->SetClass(name, className);
259 std::string Window::GetClassName() const
266 mWindowBase->Raise();
268 mSurface->SetFullSwapNextFrame();
270 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
275 mWindowBase->Lower();
277 mSurface->SetFullSwapNextFrame();
279 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
282 void Window::Activate()
284 mWindowBase->Activate();
286 mSurface->SetFullSwapNextFrame();
288 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
291 void Window::Maximize(bool maximize)
293 mWindowBase->Maximize(maximize);
295 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
298 bool Window::IsMaximized() const
300 return mWindowBase->IsMaximized();
303 void Window::SetMaximumSize(Dali::Window::WindowSize size)
305 mWindowBase->SetMaximumSize(size);
308 void Window::Minimize(bool minimize)
310 mWindowBase->Minimize(minimize);
312 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
315 bool Window::IsMinimized() const
317 return mWindowBase->IsMinimized();
320 void Window::SetMimimumSize(Dali::Window::WindowSize size)
322 mWindowBase->SetMimimumSize(size);
325 uint32_t Window::GetLayerCount() const
327 return mScene.GetLayerCount();
330 Dali::Layer Window::GetLayer(uint32_t depth) const
332 return mScene.GetLayer(depth);
335 void Window::KeepRendering(float durationSeconds)
337 mScene.KeepRendering(durationSeconds);
340 void Window::SetPartialUpdateEnabled(bool enabled)
342 mScene.SetPartialUpdateEnabled(enabled);
345 bool Window::IsPartialUpdateEnabled() const
347 return mScene.IsPartialUpdateEnabled();
350 std::string Window::GetNativeResourceId() const
352 return mWindowBase->GetNativeWindowResourceId();
355 void Window::AddAvailableOrientation(WindowOrientation orientation)
357 if(IsOrientationAvailable(orientation) == false)
363 int convertedAngle = ConvertToAngle(orientation);
364 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
365 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
367 if(mAvailableAngles[i] == convertedAngle)
376 mAvailableAngles.push_back(convertedAngle);
377 SetAvailableAnlges(mAvailableAngles);
381 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
383 if(IsOrientationAvailable(orientation) == false)
388 int convertedAngle = ConvertToAngle(orientation);
389 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
390 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
391 iter != mAvailableAngles.end();
394 if(*iter == convertedAngle)
396 mAvailableAngles.erase(iter);
401 SetAvailableAnlges(mAvailableAngles);
404 void Window::SetPreferredOrientation(WindowOrientation orientation)
406 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
408 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
411 mPreferredAngle = ConvertToAngle(orientation);
412 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
413 mWindowBase->SetPreferredAngle(mPreferredAngle);
416 WindowOrientation Window::GetPreferredOrientation()
418 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
419 return preferredOrientation;
422 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
424 int angle = ConvertToAngle(orientation);
425 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
428 void Window::EmitAccessibilityHighlightSignal(bool highlight)
430 Dali::Window handle(this);
431 mAccessibilityHighlightSignal.Emit(handle, highlight);
434 void Window::SetAvailableAnlges(const std::vector<int>& angles)
436 if(angles.size() > 4)
438 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
442 mWindowBase->SetAvailableAnlges(angles);
445 int Window::ConvertToAngle(WindowOrientation orientation)
447 int convertAngle = static_cast<int>(orientation);
448 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
452 case WindowOrientation::LANDSCAPE:
457 case WindowOrientation::PORTRAIT:
462 case WindowOrientation::LANDSCAPE_INVERSE:
467 case WindowOrientation::PORTRAIT_INVERSE:
472 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
482 WindowOrientation Window::ConvertToOrientation(int angle) const
484 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
485 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
491 orientation = WindowOrientation::LANDSCAPE;
496 orientation = WindowOrientation::PORTRAIT;
501 orientation = WindowOrientation::LANDSCAPE_INVERSE;
506 orientation = WindowOrientation::PORTRAIT_INVERSE;
511 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
519 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
521 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
523 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
529 Dali::Any Window::GetNativeHandle() const
531 return mWindowSurface->GetNativeWindow();
534 void Window::SetAcceptFocus(bool accept)
536 mIsFocusAcceptable = accept;
538 mWindowBase->SetAcceptFocus(accept);
541 bool Window::IsFocusAcceptable() const
543 return mIsFocusAcceptable;
554 Dali::Window handle(this);
555 mVisibilityChangedSignal.Emit(handle, true);
556 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
558 WindowVisibilityObserver* observer(mAdaptor);
559 observer->OnWindowShown();
562 mSurface->SetFullSwapNextFrame();
564 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
575 Dali::Window handle(this);
576 mVisibilityChangedSignal.Emit(handle, false);
577 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
579 WindowVisibilityObserver* observer(mAdaptor);
580 observer->OnWindowHidden();
583 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
586 bool Window::IsVisible() const
588 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
589 return mVisible && !mIconified;
592 unsigned int Window::GetSupportedAuxiliaryHintCount() const
594 return mWindowBase->GetSupportedAuxiliaryHintCount();
597 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
599 return mWindowBase->GetSupportedAuxiliaryHint(index);
602 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
604 return mWindowBase->AddAuxiliaryHint(hint, value);
607 bool Window::RemoveAuxiliaryHint(unsigned int id)
609 return mWindowBase->RemoveAuxiliaryHint(id);
612 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
614 return mWindowBase->SetAuxiliaryHintValue(id, value);
617 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
619 return mWindowBase->GetAuxiliaryHintValue(id);
622 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
624 return mWindowBase->GetAuxiliaryHintId(hint);
627 void Window::SetInputRegion(const Rect<int>& inputRegion)
629 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);
630 mWindowBase->SetInputRegion(inputRegion);
633 void Window::SetType(WindowType type)
635 mWindowBase->SetType(type);
638 WindowType Window::GetType() const
640 return mWindowBase->GetType();
643 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
645 WindowType type = mWindowBase->GetType();
646 if(type != WindowType::NOTIFICATION)
648 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
649 return WindowOperationResult::INVALID_OPERATION;
652 return mWindowBase->SetNotificationLevel(level);
655 WindowNotificationLevel Window::GetNotificationLevel() const
657 WindowType type = mWindowBase->GetType();
658 if(type != WindowType::NOTIFICATION)
660 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
661 return WindowNotificationLevel::NONE;
664 return mWindowBase->GetNotificationLevel();
667 void Window::SetOpaqueState(bool opaque)
669 mOpaqueState = opaque;
671 mWindowBase->SetOpaqueState(opaque);
673 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
676 bool Window::IsOpaqueState() const
681 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
683 return mWindowBase->SetScreenOffMode(screenOffMode);
686 WindowScreenOffMode Window::GetScreenOffMode() const
688 return mWindowBase->GetScreenOffMode();
691 WindowOperationResult Window::SetBrightness(int brightness)
693 if(brightness < 0 || brightness > 100)
695 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
696 return WindowOperationResult::INVALID_OPERATION;
699 return mWindowBase->SetBrightness(brightness);
702 int Window::GetBrightness() const
704 return mWindowBase->GetBrightness();
707 void Window::SetSize(Dali::Window::WindowSize size)
709 PositionSize oldRect = GetPositionSize();
711 PositionSize newRect;
712 newRect.width = size.GetWidth();
713 newRect.height = size.GetHeight();
715 SetUserGeometryPolicy();
717 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
718 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
720 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
722 Uint16Pair newSize(newRect.width, newRect.height);
724 mWindowWidth = newRect.width;
725 mWindowHeight = newRect.height;
727 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);
729 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
731 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
733 Dali::Window handle(this);
734 mResizeSignal.Emit(handle, newSize);
736 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
739 mSurface->SetFullSwapNextFrame();
741 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
744 Dali::Window::WindowSize Window::GetSize() const
746 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
749 void Window::SetPosition(Dali::Window::WindowPosition position)
751 PositionSize oldRect = mSurface->GetPositionSize();
752 int32_t newX = position.GetX();
753 int32_t newY = position.GetY();
755 SetUserGeometryPolicy();
757 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
759 if((oldRect.x != newX) || (oldRect.y != newY))
761 Dali::Window handle(this);
762 Dali::Window::WindowPosition newPosition(newX, newY);
764 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
765 mMovedSignal.Emit(handle, newPosition);
768 mSurface->SetFullSwapNextFrame();
770 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
773 Dali::Window::WindowPosition Window::GetPosition() const
775 PositionSize positionSize = GetPositionSize();
776 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
779 PositionSize Window::GetPositionSize() const
781 PositionSize positionSize = mSurface->GetPositionSize();
782 positionSize.width = mWindowWidth;
783 positionSize.height = mWindowHeight;
787 void Window::SetPositionSize(PositionSize positionSize)
792 PositionSize oldRect = GetPositionSize();
793 Dali::Window handle(this);
795 SetUserGeometryPolicy();
797 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
802 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
809 mWindowSurface->MoveResize(positionSize);
812 // When window is moved, emit Moved Signal
815 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
816 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
817 mMovedSignal.Emit(handle, position);
820 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
823 Uint16Pair newSize(positionSize.width, positionSize.height);
825 mWindowWidth = positionSize.width;
826 mWindowHeight = positionSize.height;
828 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
830 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
832 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
834 mResizeSignal.Emit(handle, newSize);
835 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
838 mSurface->SetFullSwapNextFrame();
840 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
843 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
845 SetUserGeometryPolicy();
846 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
849 Dali::Layer Window::GetRootLayer() const
851 return mScene.GetRootLayer();
854 void Window::SetTransparency(bool transparent)
856 mWindowSurface->SetTransparency(transparent);
859 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
861 return mWindowBase->GrabKey(key, grabMode);
864 bool Window::UngrabKey(Dali::KEY key)
866 return mWindowBase->UngrabKey(key);
869 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
871 return mWindowBase->GrabKeyList(key, grabMode, result);
874 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
876 return mWindowBase->UngrabKeyList(key, result);
879 void Window::OnIconifyChanged(bool iconified)
881 const bool isActuallyChanged = (iconified != mIconified);
882 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
883 Dali::Window handle(this);
891 mVisibilityChangedSignal.Emit(handle, false);
892 bridge->WindowHidden(handle);
894 WindowVisibilityObserver* observer(mAdaptor);
895 observer->OnWindowHidden();
898 if(isActuallyChanged)
900 bridge->WindowMinimized(handle);
903 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
911 mVisibilityChangedSignal.Emit(handle, true);
912 bridge->WindowShown(handle);
914 WindowVisibilityObserver* observer(mAdaptor);
915 observer->OnWindowShown();
918 if(isActuallyChanged)
920 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
923 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
926 mSurface->SetFullSwapNextFrame();
929 void Window::OnMaximizeChanged(bool maximized)
931 const bool isActuallyChanged = (maximized != mMaximized);
933 if(isActuallyChanged)
935 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
936 Dali::Window handle(this);
941 bridge->WindowMaximized(handle);
946 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
951 void Window::OnFocusChanged(bool focusIn)
953 Dali::Window handle(this);
954 mFocusChangeSignal.Emit(handle, focusIn);
956 mSurface->SetFullSwapNextFrame();
957 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
961 bridge->WindowFocused(handle);
965 bridge->WindowUnfocused(handle);
971 void Window::OnOutputTransformed()
973 PositionSize positionSize = GetPositionSize();
975 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
977 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
978 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
981 void Window::OnDeleteRequest()
983 mDeleteRequestSignal.Emit();
986 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
988 Dali::Window handle(this);
989 mTransitionEffectEventSignal.Emit(handle, state, type);
992 void Window::OnKeyboardRepeatSettingsChanged()
994 Dali::Window handle(this);
995 mKeyboardRepeatSettingsChangedSignal.Emit();
998 void Window::OnWindowRedrawRequest()
1000 mAdaptor->RenderOnce();
1003 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1006 bool resize = false;
1008 Dali::Window handle(this);
1010 PositionSize oldRect = GetPositionSize();
1011 PositionSize newRect = positionSize;
1013 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1018 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1025 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);
1026 mWindowSurface->UpdatePositionSize(positionSize);
1029 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1031 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1032 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1033 mMovedSignal.Emit(handle, position);
1036 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1037 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1039 Uint16Pair newSize(newRect.width, newRect.height);
1041 mWindowWidth = newRect.width;
1042 mWindowHeight = newRect.height;
1044 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1046 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1048 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1049 mResizeSignal.Emit(handle, newSize);
1050 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1053 mSurface->SetFullSwapNextFrame();
1055 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1058 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1060 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1061 FeedTouchPoint(point, timeStamp);
1064 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1066 FeedWheelEvent(wheelEvent);
1069 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1071 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);
1072 FeedKeyEvent(keyEvent);
1075 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1077 Dali::Window handle(this);
1079 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1082 void Window::OnRotation(const RotationEvent& rotation)
1084 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1086 mRotationAngle = rotation.angle;
1087 mWindowWidth = rotation.width;
1088 mWindowHeight = rotation.height;
1090 mIsWindowRotating = true;
1091 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);
1093 // Notify that the orientation is changed
1094 mOrientation->OnOrientationChange(rotation);
1096 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1098 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1100 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1102 Dali::Window handle(this);
1103 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1104 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1106 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1109 void Window::OnRotationFinished()
1111 mIsWindowRotating = false;
1112 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1115 void Window::OnPause()
1119 mEventHandler->Pause();
1123 void Window::OnResume()
1127 mEventHandler->Resume();
1130 mSurface->SetFullSwapNextFrame();
1133 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1135 mAuxiliaryMessageSignal.Emit(key, value, options);
1138 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1140 mInsetsChangedSignal.Emit(partType, partState, insets);
1143 void Window::OnAccessibilityEnabled()
1145 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1146 auto rootLayer = mScene.GetRootLayer();
1147 auto accessible = Accessibility::Accessible::Get(rootLayer);
1148 bridge->AddTopLevelWindow(accessible);
1150 if(!mVisible || mIconified)
1155 Dali::Window handle(this);
1156 bridge->WindowShown(handle);
1160 bridge->WindowFocused(handle);
1164 void Window::OnAccessibilityDisabled()
1166 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1167 auto rootLayer = mScene.GetRootLayer();
1168 auto accessible = Accessibility::Accessible::Get(rootLayer);
1169 bridge->RemoveTopLevelWindow(accessible);
1172 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1174 Dali::Window handle(this);
1175 mMoveCompletedSignal.Emit(handle, position);
1178 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1180 Dali::Window handle(this);
1181 mResizeCompletedSignal.Emit(handle, size);
1184 Vector2 Window::RecalculatePosition(const Vector2& position)
1186 Vector2 convertedPosition;
1188 switch(mRotationAngle)
1192 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1193 convertedPosition.y = position.x;
1198 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1199 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1204 convertedPosition.x = position.y;
1205 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1210 convertedPosition = position;
1214 return convertedPosition;
1217 Dali::Window Window::Get(Dali::Actor actor)
1219 Internal::Adaptor::Window* windowImpl = nullptr;
1221 if(Internal::Adaptor::Adaptor::IsAvailable())
1223 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1224 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1227 return Dali::Window(windowImpl);
1231 return Dali::Window();
1234 void Window::SetParent(Dali::Window& parent)
1236 if(DALI_UNLIKELY(parent))
1238 mParentWindow = parent;
1239 Dali::Window self = Dali::Window(this);
1240 // check circular parent window setting
1241 if(Dali::DevelWindow::GetParent(parent) == self)
1243 Dali::DevelWindow::Unparent(parent);
1245 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1249 void Window::SetParent(Dali::Window& parent, bool belowParent)
1251 if(DALI_UNLIKELY(parent))
1253 mParentWindow = parent;
1254 Dali::Window self = Dali::Window(this);
1255 // check circular parent window setting
1256 if(Dali::DevelWindow::GetParent(parent) == self)
1258 Dali::DevelWindow::Unparent(parent);
1260 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1264 void Window::Unparent()
1266 mWindowBase->SetParent(nullptr, false);
1267 mParentWindow.Reset();
1270 Dali::Window Window::GetParent()
1272 return mParentWindow;
1275 WindowOrientation Window::GetCurrentOrientation() const
1277 return ConvertToOrientation(mRotationAngle);
1280 int Window::GetPhysicalOrientation() const
1282 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1285 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1287 Dali::Vector<float>::SizeType count = orientations.Count();
1288 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1290 if(IsOrientationAvailable(orientations[index]) == false)
1292 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1297 int convertedAngle = ConvertToAngle(orientations[index]);
1299 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1301 if(mAvailableAngles[i] == convertedAngle)
1310 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1311 mAvailableAngles.push_back(convertedAngle);
1314 SetAvailableAnlges(mAvailableAngles);
1317 int32_t Window::GetNativeId() const
1319 return mWindowBase->GetNativeWindowId();
1322 void Window::RequestMoveToServer()
1324 SetUserGeometryPolicy();
1325 mWindowBase->RequestMoveToServer();
1328 void Window::RequestResizeToServer(WindowResizeDirection direction)
1330 SetUserGeometryPolicy();
1331 mWindowBase->RequestResizeToServer(direction);
1334 void Window::EnableFloatingMode(bool enable)
1336 mWindowBase->EnableFloatingMode(enable);
1339 bool Window::IsFloatingModeEnabled()
1341 return mWindowBase->IsFloatingModeEnabled();
1344 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1346 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);
1347 mWindowBase->IncludeInputRegion(inputRegion);
1350 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1352 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);
1353 mWindowBase->ExcludeInputRegion(inputRegion);
1356 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1358 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1359 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1360 mWindowRotationAcknowledgement = needAcknowledgement;
1363 void Window::SendRotationCompletedAcknowledgement()
1365 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1366 if(mWindowRotationAcknowledgement)
1368 SetRotationCompletedAcknowledgement();
1372 bool Window::IsWindowRotating() const
1374 return mIsWindowRotating;
1377 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1379 return mLastKeyEvent;
1382 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1384 return mLastTouchEvent;
1387 void Window::SetUserGeometryPolicy()
1389 if(mIsEnabledUserGeometry == true)
1394 mIsEnabledUserGeometry = true;
1395 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1396 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1399 } // namespace Adaptor
1401 } // namespace Internal