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");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
96 mOrientationChangedSignal(),
97 mMouseInOutEventSignal(),
98 mMoveCompletedSignal(),
99 mResizeCompletedSignal(),
100 mInsetsChangedSignal(),
103 mIsTransparent(false),
104 mIsFocusAcceptable(true),
107 mWindowRotationAcknowledgement(false),
109 mIsWindowRotating(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);
125 if(DALI_LIKELY(mAdaptor))
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->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 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
176 SetClass(name, className);
178 mOrientation = Orientation::New(this);
180 // Get OrientationMode
181 int screenWidth, screenHeight;
182 WindowSystem::GetScreenSize(screenWidth, screenHeight);
183 if(screenWidth > screenHeight)
185 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
189 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
192 if(positionSize.width <= 0 || positionSize.height <= 0)
194 mWindowWidth = screenWidth;
195 mWindowHeight = screenHeight;
199 mWindowWidth = positionSize.width;
200 mWindowHeight = positionSize.height;
204 mNativeWindowId = mWindowBase->GetNativeWindowId();
207 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
214 mWindowSurface->SetRenderNotification(renderNotification);
217 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
219 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
220 mEventHandler->AddObserver(*this);
222 // Add Window to bridge for ATSPI
223 auto bridge = Accessibility::Bridge::GetCurrentBridge();
226 auto rootLayer = mScene.GetRootLayer();
227 auto accessible = Accessibility::Accessible::Get(rootLayer);
228 bridge->AddTopLevelWindow(accessible);
231 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
232 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
234 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
235 // The show must be called after the adaptor is initialized.
239 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
241 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
244 void Window::SetClass(std::string name, std::string className)
247 mClassName = className;
248 mWindowBase->SetClass(name, className);
251 std::string Window::GetClassName() const
258 mWindowBase->Raise();
260 mSurface->SetFullSwapNextFrame();
262 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
267 mWindowBase->Lower();
269 mSurface->SetFullSwapNextFrame();
271 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
274 void Window::Activate()
276 mWindowBase->Activate();
278 mSurface->SetFullSwapNextFrame();
280 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
283 void Window::Maximize(bool maximize)
285 mWindowBase->Maximize(maximize);
287 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
290 bool Window::IsMaximized() const
292 return mWindowBase->IsMaximized();
295 void Window::SetMaximumSize(Dali::Window::WindowSize size)
297 mWindowBase->SetMaximumSize(size);
300 void Window::Minimize(bool minimize)
302 mWindowBase->Minimize(minimize);
304 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
307 bool Window::IsMinimized() const
309 return mWindowBase->IsMinimized();
312 void Window::SetMimimumSize(Dali::Window::WindowSize size)
314 mWindowBase->SetMimimumSize(size);
317 uint32_t Window::GetLayerCount() const
319 return mScene.GetLayerCount();
322 Dali::Layer Window::GetLayer(uint32_t depth) const
324 return mScene.GetLayer(depth);
327 Dali::RenderTaskList Window::GetRenderTaskList() const
329 return mScene.GetRenderTaskList();
332 std::string Window::GetNativeResourceId() const
334 return mWindowBase->GetNativeWindowResourceId();
337 void Window::AddAvailableOrientation(WindowOrientation orientation)
339 if(IsOrientationAvailable(orientation) == false)
345 int convertedAngle = ConvertToAngle(orientation);
346 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
347 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
349 if(mAvailableAngles[i] == convertedAngle)
358 mAvailableAngles.push_back(convertedAngle);
359 SetAvailableAnlges(mAvailableAngles);
363 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
365 if(IsOrientationAvailable(orientation) == false)
370 int convertedAngle = ConvertToAngle(orientation);
371 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
372 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
373 iter != mAvailableAngles.end();
376 if(*iter == convertedAngle)
378 mAvailableAngles.erase(iter);
383 SetAvailableAnlges(mAvailableAngles);
386 void Window::SetPreferredOrientation(WindowOrientation orientation)
388 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
390 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
393 mPreferredAngle = ConvertToAngle(orientation);
394 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
395 mWindowBase->SetPreferredAngle(mPreferredAngle);
398 WindowOrientation Window::GetPreferredOrientation()
400 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
401 return preferredOrientation;
404 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
406 int angle = ConvertToAngle(orientation);
407 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
410 void Window::EmitAccessibilityHighlightSignal(bool highlight)
412 Dali::Window handle(this);
413 mAccessibilityHighlightSignal.Emit(handle, highlight);
416 void Window::SetAvailableAnlges(const std::vector<int>& angles)
418 if(angles.size() > 4)
420 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
424 mWindowBase->SetAvailableAnlges(angles);
427 int Window::ConvertToAngle(WindowOrientation orientation)
429 int convertAngle = static_cast<int>(orientation);
430 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
434 case WindowOrientation::LANDSCAPE:
439 case WindowOrientation::PORTRAIT:
444 case WindowOrientation::LANDSCAPE_INVERSE:
449 case WindowOrientation::PORTRAIT_INVERSE:
454 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
464 WindowOrientation Window::ConvertToOrientation(int angle) const
466 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
467 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
473 orientation = WindowOrientation::LANDSCAPE;
478 orientation = WindowOrientation::PORTRAIT;
483 orientation = WindowOrientation::LANDSCAPE_INVERSE;
488 orientation = WindowOrientation::PORTRAIT_INVERSE;
493 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
501 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
503 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
505 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
511 Dali::Any Window::GetNativeHandle() const
513 return mWindowSurface->GetNativeWindow();
516 void Window::SetAcceptFocus(bool accept)
518 mIsFocusAcceptable = accept;
520 mWindowBase->SetAcceptFocus(accept);
523 bool Window::IsFocusAcceptable() const
525 return mIsFocusAcceptable;
536 Dali::Window handle(this);
537 mVisibilityChangedSignal.Emit(handle, true);
538 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
540 WindowVisibilityObserver* observer(mAdaptor);
541 observer->OnWindowShown();
544 mSurface->SetFullSwapNextFrame();
546 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
557 Dali::Window handle(this);
558 mVisibilityChangedSignal.Emit(handle, false);
559 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
561 WindowVisibilityObserver* observer(mAdaptor);
562 observer->OnWindowHidden();
565 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
568 bool Window::IsVisible() const
570 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
571 return mVisible && !mIconified;
574 unsigned int Window::GetSupportedAuxiliaryHintCount() const
576 return mWindowBase->GetSupportedAuxiliaryHintCount();
579 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
581 return mWindowBase->GetSupportedAuxiliaryHint(index);
584 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
586 return mWindowBase->AddAuxiliaryHint(hint, value);
589 bool Window::RemoveAuxiliaryHint(unsigned int id)
591 return mWindowBase->RemoveAuxiliaryHint(id);
594 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
596 return mWindowBase->SetAuxiliaryHintValue(id, value);
599 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
601 return mWindowBase->GetAuxiliaryHintValue(id);
604 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
606 return mWindowBase->GetAuxiliaryHintId(hint);
609 void Window::SetInputRegion(const Rect<int>& inputRegion)
611 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);
612 mWindowBase->SetInputRegion(inputRegion);
615 void Window::SetType(WindowType type)
617 mWindowBase->SetType(type);
620 WindowType Window::GetType() const
622 return mWindowBase->GetType();
625 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
627 WindowType type = mWindowBase->GetType();
628 if(type != WindowType::NOTIFICATION)
630 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
631 return WindowOperationResult::INVALID_OPERATION;
634 return mWindowBase->SetNotificationLevel(level);
637 WindowNotificationLevel Window::GetNotificationLevel() const
639 WindowType type = mWindowBase->GetType();
640 if(type != WindowType::NOTIFICATION)
642 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
643 return WindowNotificationLevel::NONE;
646 return mWindowBase->GetNotificationLevel();
649 void Window::SetOpaqueState(bool opaque)
651 mOpaqueState = opaque;
653 mWindowBase->SetOpaqueState(opaque);
655 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
658 bool Window::IsOpaqueState() const
663 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
665 return mWindowBase->SetScreenOffMode(screenOffMode);
668 WindowScreenOffMode Window::GetScreenOffMode() const
670 return mWindowBase->GetScreenOffMode();
673 WindowOperationResult Window::SetBrightness(int brightness)
675 if(brightness < 0 || brightness > 100)
677 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
678 return WindowOperationResult::INVALID_OPERATION;
681 return mWindowBase->SetBrightness(brightness);
684 int Window::GetBrightness() const
686 return mWindowBase->GetBrightness();
689 void Window::SetSize(Dali::Window::WindowSize size)
691 PositionSize oldRect = GetPositionSize();
693 PositionSize newRect;
694 newRect.width = size.GetWidth();
695 newRect.height = size.GetHeight();
697 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
698 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
700 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
702 Uint16Pair newSize(newRect.width, newRect.height);
704 mWindowWidth = newRect.width;
705 mWindowHeight = newRect.height;
707 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);
709 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
711 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
713 Dali::Window handle(this);
714 mResizeSignal.Emit(handle, newSize);
716 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
719 mSurface->SetFullSwapNextFrame();
721 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
724 Dali::Window::WindowSize Window::GetSize() const
726 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
729 void Window::SetPosition(Dali::Window::WindowPosition position)
731 PositionSize oldRect = mSurface->GetPositionSize();
732 int32_t newX = position.GetX();
733 int32_t newY = position.GetY();
735 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
737 if((oldRect.x != newX) || (oldRect.y != newY))
739 Dali::Window handle(this);
740 Dali::Window::WindowPosition newPosition(newX, newY);
742 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
743 mMovedSignal.Emit(handle, newPosition);
746 mSurface->SetFullSwapNextFrame();
748 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
751 Dali::Window::WindowPosition Window::GetPosition() const
753 PositionSize positionSize = GetPositionSize();
754 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
757 PositionSize Window::GetPositionSize() const
759 PositionSize positionSize = mSurface->GetPositionSize();
760 positionSize.width = mWindowWidth;
761 positionSize.height = mWindowHeight;
765 void Window::SetPositionSize(PositionSize positionSize)
770 PositionSize oldRect = GetPositionSize();
771 Dali::Window handle(this);
773 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
778 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
785 mWindowSurface->MoveResize(positionSize);
788 // When window is moved, emit Moved Signal
791 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
792 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
793 mMovedSignal.Emit(handle, position);
796 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
799 Uint16Pair newSize(positionSize.width, positionSize.height);
801 mWindowWidth = positionSize.width;
802 mWindowHeight = positionSize.height;
804 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
806 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
808 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
810 mResizeSignal.Emit(handle, newSize);
811 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
814 mSurface->SetFullSwapNextFrame();
816 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
819 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
821 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
824 Dali::Layer Window::GetRootLayer() const
826 return mScene.GetRootLayer();
829 void Window::SetTransparency(bool transparent)
831 mWindowSurface->SetTransparency(transparent);
834 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
836 return mWindowBase->GrabKey(key, grabMode);
839 bool Window::UngrabKey(Dali::KEY key)
841 return mWindowBase->UngrabKey(key);
844 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
846 return mWindowBase->GrabKeyList(key, grabMode, result);
849 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
851 return mWindowBase->UngrabKeyList(key, result);
854 void Window::OnIconifyChanged(bool iconified)
862 Dali::Window handle(this);
863 mVisibilityChangedSignal.Emit(handle, false);
864 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
866 if(DALI_LIKELY(mAdaptor))
868 WindowVisibilityObserver* observer(mAdaptor);
869 observer->OnWindowHidden();
873 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
881 Dali::Window handle(this);
882 mVisibilityChangedSignal.Emit(handle, true);
883 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
885 if(DALI_LIKELY(mAdaptor))
887 WindowVisibilityObserver* observer(mAdaptor);
888 observer->OnWindowShown();
892 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
895 mSurface->SetFullSwapNextFrame();
898 void Window::OnFocusChanged(bool focusIn)
900 Dali::Window handle(this);
901 mFocusChangeSignal.Emit(handle, focusIn);
903 mSurface->SetFullSwapNextFrame();
905 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
909 bridge->WindowFocused(handle);
913 bridge->WindowUnfocused(handle);
919 void Window::OnOutputTransformed()
921 PositionSize positionSize = GetPositionSize();
923 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
925 if(DALI_LIKELY(mAdaptor))
927 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
928 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
932 void Window::OnDeleteRequest()
934 mDeleteRequestSignal.Emit();
937 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
939 Dali::Window handle(this);
940 mTransitionEffectEventSignal.Emit(handle, state, type);
943 void Window::OnKeyboardRepeatSettingsChanged()
945 Dali::Window handle(this);
946 mKeyboardRepeatSettingsChangedSignal.Emit();
949 void Window::OnWindowRedrawRequest()
951 if(DALI_LIKELY(mAdaptor))
953 mAdaptor->RenderOnce();
957 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
962 Dali::Window handle(this);
964 PositionSize oldRect = GetPositionSize();
965 PositionSize newRect = positionSize;
967 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
972 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
979 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);
980 mWindowSurface->UpdatePositionSize(positionSize);
983 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
985 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
986 Dali::Window::WindowPosition position(newRect.x, newRect.y);
987 mMovedSignal.Emit(handle, position);
990 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
991 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
993 Uint16Pair newSize(newRect.width, newRect.height);
995 mWindowWidth = newRect.width;
996 mWindowHeight = newRect.height;
998 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1000 if(DALI_LIKELY(mAdaptor))
1002 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1005 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1006 mResizeSignal.Emit(handle, newSize);
1007 if(DALI_LIKELY(mAdaptor))
1009 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1013 mSurface->SetFullSwapNextFrame();
1015 if(DALI_LIKELY(mScene))
1017 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1021 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1023 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1024 FeedTouchPoint(point, timeStamp);
1027 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1029 FeedWheelEvent(wheelEvent);
1032 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1034 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);
1035 FeedKeyEvent(keyEvent);
1038 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1040 Dali::Window handle(this);
1042 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1045 void Window::OnRotation(const RotationEvent& rotation)
1047 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1049 mRotationAngle = rotation.angle;
1050 mWindowWidth = rotation.width;
1051 mWindowHeight = rotation.height;
1053 mIsWindowRotating = true;
1054 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);
1056 // Notify that the orientation is changed
1057 mOrientation->OnOrientationChange(rotation);
1059 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1061 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1063 if(DALI_LIKELY(mAdaptor))
1065 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1068 Dali::Window handle(this);
1069 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1070 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1072 if(DALI_LIKELY(mAdaptor))
1074 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1078 void Window::OnRotationFinished()
1080 mIsWindowRotating = false;
1081 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1084 void Window::OnPause()
1088 mEventHandler->Pause();
1092 void Window::OnResume()
1096 mEventHandler->Resume();
1099 mSurface->SetFullSwapNextFrame();
1102 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1104 mAuxiliaryMessageSignal.Emit(key, value, options);
1107 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1109 mInsetsChangedSignal.Emit(partType, partState, insets);
1112 void Window::OnAccessibilityEnabled()
1114 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1115 auto rootLayer = mScene.GetRootLayer();
1116 auto accessible = Accessibility::Accessible::Get(rootLayer);
1117 bridge->AddTopLevelWindow(accessible);
1119 if(!mVisible || mIconified)
1124 Dali::Window handle(this);
1125 bridge->WindowShown(handle);
1129 bridge->WindowFocused(handle);
1133 void Window::OnAccessibilityDisabled()
1135 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1136 auto rootLayer = mScene.GetRootLayer();
1137 auto accessible = Accessibility::Accessible::Get(rootLayer);
1138 bridge->RemoveTopLevelWindow(accessible);
1141 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1143 Dali::Window handle(this);
1144 mMoveCompletedSignal.Emit(handle, position);
1147 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1149 Dali::Window handle(this);
1150 mResizeCompletedSignal.Emit(handle, size);
1153 Vector2 Window::RecalculatePosition(const Vector2& position)
1155 Vector2 convertedPosition;
1157 switch(mRotationAngle)
1161 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1162 convertedPosition.y = position.x;
1167 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1168 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1173 convertedPosition.x = position.y;
1174 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1179 convertedPosition = position;
1183 return convertedPosition;
1186 Dali::Window Window::Get(Dali::Actor actor)
1188 Internal::Adaptor::Window* windowImpl = nullptr;
1190 if(Internal::Adaptor::Adaptor::IsAvailable())
1192 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1193 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1196 return Dali::Window(windowImpl);
1200 return Dali::Window();
1203 void Window::SetParent(Dali::Window& parent)
1205 if(DALI_UNLIKELY(parent))
1207 mParentWindow = parent;
1208 Dali::Window self = Dali::Window(this);
1209 // check circular parent window setting
1210 if(Dali::DevelWindow::GetParent(parent) == self)
1212 Dali::DevelWindow::Unparent(parent);
1214 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1218 void Window::SetParent(Dali::Window& parent, bool belowParent)
1220 if(DALI_UNLIKELY(parent))
1222 mParentWindow = parent;
1223 Dali::Window self = Dali::Window(this);
1224 // check circular parent window setting
1225 if(Dali::DevelWindow::GetParent(parent) == self)
1227 Dali::DevelWindow::Unparent(parent);
1229 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1233 void Window::Unparent()
1235 mWindowBase->SetParent(nullptr, false);
1236 mParentWindow.Reset();
1239 Dali::Window Window::GetParent()
1241 return mParentWindow;
1244 WindowOrientation Window::GetCurrentOrientation() const
1246 return ConvertToOrientation(mRotationAngle);
1249 int Window::GetPhysicalOrientation() const
1251 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1254 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1256 Dali::Vector<float>::SizeType count = orientations.Count();
1257 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1259 if(IsOrientationAvailable(orientations[index]) == false)
1261 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1266 int convertedAngle = ConvertToAngle(orientations[index]);
1268 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1270 if(mAvailableAngles[i] == convertedAngle)
1279 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1280 mAvailableAngles.push_back(convertedAngle);
1283 SetAvailableAnlges(mAvailableAngles);
1286 int32_t Window::GetNativeId() const
1288 return mWindowBase->GetNativeWindowId();
1291 void Window::RequestMoveToServer()
1293 mWindowBase->RequestMoveToServer();
1296 void Window::RequestResizeToServer(WindowResizeDirection direction)
1298 mWindowBase->RequestResizeToServer(direction);
1301 void Window::EnableFloatingMode(bool enable)
1303 mWindowBase->EnableFloatingMode(enable);
1306 bool Window::IsFloatingModeEnabled()
1308 return mWindowBase->IsFloatingModeEnabled();
1311 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1313 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);
1314 mWindowBase->IncludeInputRegion(inputRegion);
1317 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1319 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);
1320 mWindowBase->ExcludeInputRegion(inputRegion);
1323 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1325 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1326 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1327 mWindowRotationAcknowledgement = needAcknowledgement;
1330 void Window::SendRotationCompletedAcknowledgement()
1332 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1333 if(mWindowRotationAcknowledgement)
1335 SetRotationCompletedAcknowledgement();
1339 bool Window::IsWindowRotating() const
1341 return mIsWindowRotating;
1344 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1346 return mLastKeyEvent;
1349 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1351 return mLastTouchEvent;
1354 } // namespace Adaptor
1356 } // namespace Internal