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/render-tasks/render-task-list.h>
32 #include <dali/public-api/render-tasks/render-task.h>
33 #include <dali/public-api/rendering/frame-buffer.h>
37 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
38 #include <dali/devel-api/atspi-interfaces/accessible.h>
39 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
40 #include <dali/internal/graphics/gles/egl-graphics.h>
41 #include <dali/internal/window-system/common/event-handler.h>
42 #include <dali/internal/window-system/common/orientation-impl.h>
43 #include <dali/internal/window-system/common/render-surface-factory.h>
44 #include <dali/internal/window-system/common/window-base.h>
45 #include <dali/internal/window-system/common/window-factory.h>
46 #include <dali/internal/window-system/common/window-render-surface.h>
47 #include <dali/internal/window-system/common/window-system.h>
48 #include <dali/internal/window-system/common/window-visibility-observer.h>
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
61 } // unnamed namespace
63 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
66 return Window::New(surface, positionSize, name, className, type, isTransparent);
69 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
71 Window* window = new Window();
72 window->mIsTransparent = isTransparent;
73 window->Initialize(surface, positionSize, name, className, type);
78 : mWindowSurface(nullptr),
81 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
86 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
87 mDeleteRequestSignal(),
90 mVisibilityChangedSignal(),
91 mTransitionEffectEventSignal(),
92 mKeyboardRepeatSettingsChangedSignal(),
93 mAuxiliaryMessageSignal(),
95 mOrientationChangedSignal(),
96 mMouseInOutEventSignal(),
97 mMoveCompletedSignal(),
98 mResizeCompletedSignal(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
106 mWindowRotationAcknowledgement(false),
108 mIsWindowRotating(false),
109 mIsEnabledUserGeometry(false)
117 auto bridge = Accessibility::Bridge::GetCurrentBridge();
118 auto rootLayer = mScene.GetRootLayer();
119 auto accessible = Accessibility::Accessible::Get(rootLayer);
120 bridge->RemoveTopLevelWindow(accessible);
121 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
122 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
127 mAdaptor->RemoveWindow(this);
132 mEventHandler->RemoveObserver(*this);
136 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
138 // Create a window render surface
139 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
140 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
141 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
144 mWindowBase = mWindowSurface->GetWindowBase();
147 mWindowBase->SetType(type);
149 // Initialize for Ime window type
150 if(type == WindowType::IME)
152 mWindowBase->InitializeIme();
153 mWindowSurface->InitializeImeSurface();
157 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
158 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
159 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
160 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
161 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
162 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
163 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
164 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
165 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
166 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
167 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
168 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
170 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
171 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
173 SetClass(name, className);
175 mOrientation = Orientation::New(this);
177 // Get OrientationMode
178 int screenWidth, screenHeight;
179 WindowSystem::GetScreenSize(screenWidth, screenHeight);
180 if(screenWidth > screenHeight)
182 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
186 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
189 mWindowWidth = positionSize.width;
190 mWindowHeight = positionSize.height;
192 bool isSetWithScreenSize = false;
193 if(mWindowWidth <= 0 || mWindowHeight <= 0)
195 mWindowWidth = screenWidth;
196 mWindowHeight = screenHeight;
197 isSetWithScreenSize = true;
198 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
201 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
203 SetUserGeometryPolicy();
207 mNativeWindowId = mWindowBase->GetNativeWindowId();
210 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
217 mWindowSurface->SetRenderNotification(renderNotification);
220 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
222 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
223 mEventHandler->AddObserver(*this);
225 // Add Window to bridge for ATSPI
226 auto bridge = Accessibility::Bridge::GetCurrentBridge();
229 auto rootLayer = mScene.GetRootLayer();
230 auto accessible = Accessibility::Accessible::Get(rootLayer);
231 bridge->AddTopLevelWindow(accessible);
233 // Emit Window create event
234 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
235 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
238 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
239 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
241 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
242 // The show must be called after the adaptor is initialized.
246 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
248 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
251 void Window::SetClass(std::string name, std::string className)
254 mClassName = className;
255 mWindowBase->SetClass(name, className);
258 std::string Window::GetClassName() const
265 mWindowBase->Raise();
267 mSurface->SetFullSwapNextFrame();
269 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
274 mWindowBase->Lower();
276 mSurface->SetFullSwapNextFrame();
278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
281 void Window::Activate()
283 mWindowBase->Activate();
285 mSurface->SetFullSwapNextFrame();
287 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
290 void Window::Maximize(bool maximize)
292 mWindowBase->Maximize(maximize);
294 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
297 bool Window::IsMaximized() const
299 return mWindowBase->IsMaximized();
302 void Window::SetMaximumSize(Dali::Window::WindowSize size)
304 mWindowBase->SetMaximumSize(size);
307 void Window::Minimize(bool minimize)
309 mWindowBase->Minimize(minimize);
311 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
314 bool Window::IsMinimized() const
316 return mWindowBase->IsMinimized();
319 void Window::SetMimimumSize(Dali::Window::WindowSize size)
321 mWindowBase->SetMimimumSize(size);
324 uint32_t Window::GetLayerCount() const
326 return mScene.GetLayerCount();
329 Dali::Layer Window::GetLayer(uint32_t depth) const
331 return mScene.GetLayer(depth);
334 Dali::RenderTaskList Window::GetRenderTaskList() const
336 return mScene.GetRenderTaskList();
339 void Window::KeepRendering(float durationSeconds)
341 mScene.KeepRendering(durationSeconds);
344 std::string Window::GetNativeResourceId() const
346 return mWindowBase->GetNativeWindowResourceId();
349 void Window::AddAvailableOrientation(WindowOrientation orientation)
351 if(IsOrientationAvailable(orientation) == false)
357 int convertedAngle = ConvertToAngle(orientation);
358 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
359 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
361 if(mAvailableAngles[i] == convertedAngle)
370 mAvailableAngles.push_back(convertedAngle);
371 SetAvailableAnlges(mAvailableAngles);
375 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
377 if(IsOrientationAvailable(orientation) == false)
382 int convertedAngle = ConvertToAngle(orientation);
383 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
384 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
385 iter != mAvailableAngles.end();
388 if(*iter == convertedAngle)
390 mAvailableAngles.erase(iter);
395 SetAvailableAnlges(mAvailableAngles);
398 void Window::SetPreferredOrientation(WindowOrientation orientation)
400 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
402 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
405 mPreferredAngle = ConvertToAngle(orientation);
406 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
407 mWindowBase->SetPreferredAngle(mPreferredAngle);
410 WindowOrientation Window::GetPreferredOrientation()
412 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
413 return preferredOrientation;
416 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
418 int angle = ConvertToAngle(orientation);
419 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
422 void Window::EmitAccessibilityHighlightSignal(bool highlight)
424 Dali::Window handle(this);
425 mAccessibilityHighlightSignal.Emit(handle, highlight);
428 void Window::SetAvailableAnlges(const std::vector<int>& angles)
430 if(angles.size() > 4)
432 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
436 mWindowBase->SetAvailableAnlges(angles);
439 int Window::ConvertToAngle(WindowOrientation orientation)
441 int convertAngle = static_cast<int>(orientation);
442 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
446 case WindowOrientation::LANDSCAPE:
451 case WindowOrientation::PORTRAIT:
456 case WindowOrientation::LANDSCAPE_INVERSE:
461 case WindowOrientation::PORTRAIT_INVERSE:
466 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
476 WindowOrientation Window::ConvertToOrientation(int angle) const
478 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
479 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
485 orientation = WindowOrientation::LANDSCAPE;
490 orientation = WindowOrientation::PORTRAIT;
495 orientation = WindowOrientation::LANDSCAPE_INVERSE;
500 orientation = WindowOrientation::PORTRAIT_INVERSE;
505 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
513 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
515 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
517 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
523 Dali::Any Window::GetNativeHandle() const
525 return mWindowSurface->GetNativeWindow();
528 void Window::SetAcceptFocus(bool accept)
530 mIsFocusAcceptable = accept;
532 mWindowBase->SetAcceptFocus(accept);
535 bool Window::IsFocusAcceptable() const
537 return mIsFocusAcceptable;
548 Dali::Window handle(this);
549 mVisibilityChangedSignal.Emit(handle, true);
550 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
552 WindowVisibilityObserver* observer(mAdaptor);
553 observer->OnWindowShown();
556 mSurface->SetFullSwapNextFrame();
558 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
569 Dali::Window handle(this);
570 mVisibilityChangedSignal.Emit(handle, false);
571 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
573 WindowVisibilityObserver* observer(mAdaptor);
574 observer->OnWindowHidden();
577 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
580 bool Window::IsVisible() const
582 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
583 return mVisible && !mIconified;
586 unsigned int Window::GetSupportedAuxiliaryHintCount() const
588 return mWindowBase->GetSupportedAuxiliaryHintCount();
591 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
593 return mWindowBase->GetSupportedAuxiliaryHint(index);
596 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
598 return mWindowBase->AddAuxiliaryHint(hint, value);
601 bool Window::RemoveAuxiliaryHint(unsigned int id)
603 return mWindowBase->RemoveAuxiliaryHint(id);
606 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
608 return mWindowBase->SetAuxiliaryHintValue(id, value);
611 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
613 return mWindowBase->GetAuxiliaryHintValue(id);
616 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
618 return mWindowBase->GetAuxiliaryHintId(hint);
621 void Window::SetInputRegion(const Rect<int>& inputRegion)
623 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);
624 mWindowBase->SetInputRegion(inputRegion);
627 void Window::SetType(WindowType type)
629 mWindowBase->SetType(type);
632 WindowType Window::GetType() const
634 return mWindowBase->GetType();
637 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
639 WindowType type = mWindowBase->GetType();
640 if(type != WindowType::NOTIFICATION)
642 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
643 return WindowOperationResult::INVALID_OPERATION;
646 return mWindowBase->SetNotificationLevel(level);
649 WindowNotificationLevel Window::GetNotificationLevel() const
651 WindowType type = mWindowBase->GetType();
652 if(type != WindowType::NOTIFICATION)
654 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
655 return WindowNotificationLevel::NONE;
658 return mWindowBase->GetNotificationLevel();
661 void Window::SetOpaqueState(bool opaque)
663 mOpaqueState = opaque;
665 mWindowBase->SetOpaqueState(opaque);
667 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
670 bool Window::IsOpaqueState() const
675 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
677 return mWindowBase->SetScreenOffMode(screenOffMode);
680 WindowScreenOffMode Window::GetScreenOffMode() const
682 return mWindowBase->GetScreenOffMode();
685 WindowOperationResult Window::SetBrightness(int brightness)
687 if(brightness < 0 || brightness > 100)
689 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
690 return WindowOperationResult::INVALID_OPERATION;
693 return mWindowBase->SetBrightness(brightness);
696 int Window::GetBrightness() const
698 return mWindowBase->GetBrightness();
701 void Window::SetSize(Dali::Window::WindowSize size)
703 PositionSize oldRect = GetPositionSize();
705 PositionSize newRect;
706 newRect.width = size.GetWidth();
707 newRect.height = size.GetHeight();
709 SetUserGeometryPolicy();
711 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
712 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
714 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
716 Uint16Pair newSize(newRect.width, newRect.height);
718 mWindowWidth = newRect.width;
719 mWindowHeight = newRect.height;
721 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);
723 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
725 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
727 Dali::Window handle(this);
728 mResizeSignal.Emit(handle, newSize);
730 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
733 mSurface->SetFullSwapNextFrame();
735 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
738 Dali::Window::WindowSize Window::GetSize() const
740 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
743 void Window::SetPosition(Dali::Window::WindowPosition position)
745 PositionSize oldRect = mSurface->GetPositionSize();
746 int32_t newX = position.GetX();
747 int32_t newY = position.GetY();
749 SetUserGeometryPolicy();
751 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
753 if((oldRect.x != newX) || (oldRect.y != newY))
755 Dali::Window handle(this);
756 Dali::Window::WindowPosition newPosition(newX, newY);
758 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
759 mMovedSignal.Emit(handle, newPosition);
762 mSurface->SetFullSwapNextFrame();
764 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
767 Dali::Window::WindowPosition Window::GetPosition() const
769 PositionSize positionSize = GetPositionSize();
770 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
773 PositionSize Window::GetPositionSize() const
775 PositionSize positionSize = mSurface->GetPositionSize();
776 positionSize.width = mWindowWidth;
777 positionSize.height = mWindowHeight;
781 void Window::SetPositionSize(PositionSize positionSize)
786 PositionSize oldRect = GetPositionSize();
787 Dali::Window handle(this);
789 SetUserGeometryPolicy();
791 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
796 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
803 mWindowSurface->MoveResize(positionSize);
806 // When window is moved, emit Moved Signal
809 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
810 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
811 mMovedSignal.Emit(handle, position);
814 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
817 Uint16Pair newSize(positionSize.width, positionSize.height);
819 mWindowWidth = positionSize.width;
820 mWindowHeight = positionSize.height;
822 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
824 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
826 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
828 mResizeSignal.Emit(handle, newSize);
829 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
832 mSurface->SetFullSwapNextFrame();
834 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
837 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
839 SetUserGeometryPolicy();
840 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
843 Dali::Layer Window::GetRootLayer() const
845 return mScene.GetRootLayer();
848 void Window::SetTransparency(bool transparent)
850 mWindowSurface->SetTransparency(transparent);
853 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
855 return mWindowBase->GrabKey(key, grabMode);
858 bool Window::UngrabKey(Dali::KEY key)
860 return mWindowBase->UngrabKey(key);
863 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
865 return mWindowBase->GrabKeyList(key, grabMode, result);
868 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
870 return mWindowBase->UngrabKeyList(key, result);
873 void Window::OnIconifyChanged(bool iconified)
875 const bool isActuallyChanged = (iconified != mIconified);
876 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
877 Dali::Window handle(this);
885 mVisibilityChangedSignal.Emit(handle, false);
886 bridge->WindowHidden(handle);
888 WindowVisibilityObserver* observer(mAdaptor);
889 observer->OnWindowHidden();
892 if(isActuallyChanged)
894 bridge->WindowMinimized(handle);
897 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
905 mVisibilityChangedSignal.Emit(handle, true);
906 bridge->WindowShown(handle);
908 WindowVisibilityObserver* observer(mAdaptor);
909 observer->OnWindowShown();
912 if(isActuallyChanged)
914 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
917 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
920 mSurface->SetFullSwapNextFrame();
923 void Window::OnMaximizeChanged(bool maximized)
925 const bool isActuallyChanged = (maximized != mMaximized);
927 if(isActuallyChanged)
929 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
930 Dali::Window handle(this);
935 bridge->WindowMaximized(handle);
940 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
945 void Window::OnFocusChanged(bool focusIn)
947 Dali::Window handle(this);
948 mFocusChangeSignal.Emit(handle, focusIn);
950 mSurface->SetFullSwapNextFrame();
951 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
955 bridge->WindowFocused(handle);
959 bridge->WindowUnfocused(handle);
965 void Window::OnOutputTransformed()
967 PositionSize positionSize = GetPositionSize();
969 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
971 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
972 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
975 void Window::OnDeleteRequest()
977 mDeleteRequestSignal.Emit();
980 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
982 Dali::Window handle(this);
983 mTransitionEffectEventSignal.Emit(handle, state, type);
986 void Window::OnKeyboardRepeatSettingsChanged()
988 Dali::Window handle(this);
989 mKeyboardRepeatSettingsChangedSignal.Emit();
992 void Window::OnWindowRedrawRequest()
994 mAdaptor->RenderOnce();
997 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1000 bool resize = false;
1002 Dali::Window handle(this);
1004 PositionSize oldRect = GetPositionSize();
1005 PositionSize newRect = positionSize;
1007 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1012 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1019 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);
1020 mWindowSurface->UpdatePositionSize(positionSize);
1023 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1025 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1026 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1027 mMovedSignal.Emit(handle, position);
1030 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1031 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1033 Uint16Pair newSize(newRect.width, newRect.height);
1035 mWindowWidth = newRect.width;
1036 mWindowHeight = newRect.height;
1038 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1040 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1042 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1043 mResizeSignal.Emit(handle, newSize);
1044 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1047 mSurface->SetFullSwapNextFrame();
1049 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1052 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1054 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1055 FeedTouchPoint(point, timeStamp);
1058 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1060 FeedWheelEvent(wheelEvent);
1063 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1065 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);
1066 FeedKeyEvent(keyEvent);
1069 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1071 Dali::Window handle(this);
1073 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1076 void Window::OnRotation(const RotationEvent& rotation)
1078 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1080 mRotationAngle = rotation.angle;
1081 mWindowWidth = rotation.width;
1082 mWindowHeight = rotation.height;
1084 mIsWindowRotating = true;
1085 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);
1087 // Notify that the orientation is changed
1088 mOrientation->OnOrientationChange(rotation);
1090 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1092 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1094 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1096 Dali::Window handle(this);
1097 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1098 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1100 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1103 void Window::OnRotationFinished()
1105 mIsWindowRotating = false;
1106 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1109 void Window::OnPause()
1113 mEventHandler->Pause();
1117 void Window::OnResume()
1121 mEventHandler->Resume();
1124 mSurface->SetFullSwapNextFrame();
1127 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1129 mAuxiliaryMessageSignal.Emit(key, value, options);
1132 void Window::OnAccessibilityEnabled()
1134 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1135 auto rootLayer = mScene.GetRootLayer();
1136 auto accessible = Accessibility::Accessible::Get(rootLayer);
1137 bridge->AddTopLevelWindow(accessible);
1139 if(!mVisible || mIconified)
1144 Dali::Window handle(this);
1145 bridge->WindowShown(handle);
1149 bridge->WindowFocused(handle);
1153 void Window::OnAccessibilityDisabled()
1155 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1156 auto rootLayer = mScene.GetRootLayer();
1157 auto accessible = Accessibility::Accessible::Get(rootLayer);
1158 bridge->RemoveTopLevelWindow(accessible);
1161 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1163 Dali::Window handle(this);
1164 mMoveCompletedSignal.Emit(handle, position);
1167 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1169 Dali::Window handle(this);
1170 mResizeCompletedSignal.Emit(handle, size);
1173 Vector2 Window::RecalculatePosition(const Vector2& position)
1175 Vector2 convertedPosition;
1177 switch(mRotationAngle)
1181 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1182 convertedPosition.y = position.x;
1187 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1188 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1193 convertedPosition.x = position.y;
1194 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1199 convertedPosition = position;
1203 return convertedPosition;
1206 Dali::Window Window::Get(Dali::Actor actor)
1208 Internal::Adaptor::Window* windowImpl = nullptr;
1210 if(Internal::Adaptor::Adaptor::IsAvailable())
1212 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1213 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1216 return Dali::Window(windowImpl);
1220 return Dali::Window();
1223 void Window::SetParent(Dali::Window& parent)
1225 if(DALI_UNLIKELY(parent))
1227 mParentWindow = parent;
1228 Dali::Window self = Dali::Window(this);
1229 // check circular parent window setting
1230 if(Dali::DevelWindow::GetParent(parent) == self)
1232 Dali::DevelWindow::Unparent(parent);
1234 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1238 void Window::SetParent(Dali::Window& parent, bool belowParent)
1240 if(DALI_UNLIKELY(parent))
1242 mParentWindow = parent;
1243 Dali::Window self = Dali::Window(this);
1244 // check circular parent window setting
1245 if(Dali::DevelWindow::GetParent(parent) == self)
1247 Dali::DevelWindow::Unparent(parent);
1249 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1253 void Window::Unparent()
1255 mWindowBase->SetParent(nullptr, false);
1256 mParentWindow.Reset();
1259 Dali::Window Window::GetParent()
1261 return mParentWindow;
1264 WindowOrientation Window::GetCurrentOrientation() const
1266 return ConvertToOrientation(mRotationAngle);
1269 int Window::GetPhysicalOrientation() const
1271 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1274 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1276 Dali::Vector<float>::SizeType count = orientations.Count();
1277 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1279 if(IsOrientationAvailable(orientations[index]) == false)
1281 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1286 int convertedAngle = ConvertToAngle(orientations[index]);
1288 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1290 if(mAvailableAngles[i] == convertedAngle)
1299 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1300 mAvailableAngles.push_back(convertedAngle);
1303 SetAvailableAnlges(mAvailableAngles);
1306 int32_t Window::GetNativeId() const
1308 return mWindowBase->GetNativeWindowId();
1311 void Window::RequestMoveToServer()
1313 SetUserGeometryPolicy();
1314 mWindowBase->RequestMoveToServer();
1317 void Window::RequestResizeToServer(WindowResizeDirection direction)
1319 SetUserGeometryPolicy();
1320 mWindowBase->RequestResizeToServer(direction);
1323 void Window::EnableFloatingMode(bool enable)
1325 mWindowBase->EnableFloatingMode(enable);
1328 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1330 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);
1331 mWindowBase->IncludeInputRegion(inputRegion);
1334 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1336 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);
1337 mWindowBase->ExcludeInputRegion(inputRegion);
1340 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1342 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1343 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1344 mWindowRotationAcknowledgement = needAcknowledgement;
1347 void Window::SendRotationCompletedAcknowledgement()
1349 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1350 if(mWindowRotationAcknowledgement)
1352 SetRotationCompletedAcknowledgement();
1356 bool Window::IsWindowRotating() const
1358 return mIsWindowRotating;
1361 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1363 return mLastKeyEvent;
1366 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1368 return mLastTouchEvent;
1371 void Window::SetUserGeometryPolicy()
1373 if(mIsEnabledUserGeometry == true)
1378 mIsEnabledUserGeometry = true;
1379 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1380 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1383 } // namespace Adaptor
1385 } // namespace Internal