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 PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
64 return Window::New(surface, positionSize, name, className, type, isTransparent);
67 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
69 Window* window = new Window();
70 window->mIsTransparent = isTransparent;
71 window->Initialize(surface, positionSize, name, className, type);
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(),
99 mIsTransparent(false),
100 mIsFocusAcceptable(true),
104 mWindowRotationAcknowledgement(false),
106 mIsWindowRotating(false)
114 auto bridge = Accessibility::Bridge::GetCurrentBridge();
115 auto rootLayer = mScene.GetRootLayer();
116 auto accessible = Accessibility::Accessible::Get(rootLayer);
117 bridge->RemoveTopLevelWindow(accessible);
118 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
119 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
124 mAdaptor->RemoveWindow(this);
129 mEventHandler->RemoveObserver(*this);
133 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
135 // Create a window render surface
136 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
137 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
138 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
141 mWindowBase = mWindowSurface->GetWindowBase();
144 mWindowBase->SetType(type);
146 // Initialize for Ime window type
147 if(type == WindowType::IME)
149 mWindowBase->InitializeIme();
150 mWindowSurface->InitializeImeSurface();
154 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
155 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
156 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
157 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
158 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
159 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
160 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
161 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
162 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
163 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
164 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
165 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
167 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
168 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
170 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
172 SetClass(name, className);
174 mOrientation = Orientation::New(this);
176 // Get OrientationMode
177 int screenWidth, screenHeight;
178 WindowSystem::GetScreenSize(screenWidth, screenHeight);
179 if(screenWidth > screenHeight)
181 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
185 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
188 if(positionSize.width <= 0 || positionSize.height <= 0)
190 mWindowWidth = screenWidth;
191 mWindowHeight = screenHeight;
195 mWindowWidth = positionSize.width;
196 mWindowHeight = positionSize.height;
200 mNativeWindowId = mWindowBase->GetNativeWindowId();
203 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
210 mWindowSurface->SetRenderNotification(renderNotification);
213 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
215 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
216 mEventHandler->AddObserver(*this);
218 // Add Window to bridge for ATSPI
219 auto bridge = Accessibility::Bridge::GetCurrentBridge();
222 auto rootLayer = mScene.GetRootLayer();
223 auto accessible = Accessibility::Accessible::Get(rootLayer);
224 bridge->AddTopLevelWindow(accessible);
226 // Emit Window create event
227 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
228 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
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 void Window::KeepRendering(float durationSeconds)
329 mScene.KeepRendering(durationSeconds);
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->Move(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)
856 const bool isActuallyChanged = (iconified != mIconified);
857 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
858 Dali::Window handle(this);
866 mVisibilityChangedSignal.Emit(handle, false);
867 bridge->WindowHidden(handle);
869 WindowVisibilityObserver* observer(mAdaptor);
870 observer->OnWindowHidden();
873 if(isActuallyChanged)
875 bridge->WindowMinimized(handle);
878 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
886 mVisibilityChangedSignal.Emit(handle, true);
887 bridge->WindowShown(handle);
889 WindowVisibilityObserver* observer(mAdaptor);
890 observer->OnWindowShown();
893 if(isActuallyChanged)
895 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
898 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
901 mSurface->SetFullSwapNextFrame();
904 void Window::OnMaximizeChanged(bool maximized)
906 const bool isActuallyChanged = (maximized != mMaximized);
908 if(isActuallyChanged)
910 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
911 Dali::Window handle(this);
916 bridge->WindowMaximized(handle);
921 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
926 void Window::OnFocusChanged(bool focusIn)
928 Dali::Window handle(this);
929 mFocusChangeSignal.Emit(handle, focusIn);
931 mSurface->SetFullSwapNextFrame();
932 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
936 bridge->WindowFocused(handle);
940 bridge->WindowUnfocused(handle);
946 void Window::OnOutputTransformed()
948 PositionSize positionSize = GetPositionSize();
950 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
952 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
953 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
956 void Window::OnDeleteRequest()
958 mDeleteRequestSignal.Emit();
961 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
963 Dali::Window handle(this);
964 mTransitionEffectEventSignal.Emit(handle, state, type);
967 void Window::OnKeyboardRepeatSettingsChanged()
969 Dali::Window handle(this);
970 mKeyboardRepeatSettingsChangedSignal.Emit();
973 void Window::OnWindowRedrawRequest()
975 mAdaptor->RenderOnce();
978 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
983 Dali::Window handle(this);
985 PositionSize oldRect = GetPositionSize();
986 PositionSize newRect = positionSize;
988 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
993 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1000 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);
1001 mWindowSurface->UpdatePositionSize(positionSize);
1004 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1006 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1007 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1008 mMovedSignal.Emit(handle, position);
1011 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1012 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1014 Uint16Pair newSize(newRect.width, newRect.height);
1016 mWindowWidth = newRect.width;
1017 mWindowHeight = newRect.height;
1019 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1021 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1023 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1024 mResizeSignal.Emit(handle, newSize);
1025 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1028 mSurface->SetFullSwapNextFrame();
1030 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1033 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1035 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1036 FeedTouchPoint(point, timeStamp);
1039 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1041 FeedWheelEvent(wheelEvent);
1044 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1046 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);
1047 FeedKeyEvent(keyEvent);
1050 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1052 Dali::Window handle(this);
1054 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1057 void Window::OnRotation(const RotationEvent& rotation)
1059 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1061 mRotationAngle = rotation.angle;
1062 mWindowWidth = rotation.width;
1063 mWindowHeight = rotation.height;
1065 mIsWindowRotating = true;
1066 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);
1068 // Notify that the orientation is changed
1069 mOrientation->OnOrientationChange(rotation);
1071 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1073 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1075 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1077 Dali::Window handle(this);
1078 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1079 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1081 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1084 void Window::OnRotationFinished()
1086 mIsWindowRotating = false;
1087 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1090 void Window::OnPause()
1094 mEventHandler->Pause();
1098 void Window::OnResume()
1102 mEventHandler->Resume();
1105 mSurface->SetFullSwapNextFrame();
1108 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1110 mAuxiliaryMessageSignal.Emit(key, value, options);
1113 void Window::OnAccessibilityEnabled()
1115 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1116 auto rootLayer = mScene.GetRootLayer();
1117 auto accessible = Accessibility::Accessible::Get(rootLayer);
1118 bridge->AddTopLevelWindow(accessible);
1120 if(!mVisible || mIconified)
1125 Dali::Window handle(this);
1126 bridge->WindowShown(handle);
1130 bridge->WindowFocused(handle);
1134 void Window::OnAccessibilityDisabled()
1136 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1137 auto rootLayer = mScene.GetRootLayer();
1138 auto accessible = Accessibility::Accessible::Get(rootLayer);
1139 bridge->RemoveTopLevelWindow(accessible);
1142 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1144 Dali::Window handle(this);
1145 mMoveCompletedSignal.Emit(handle, position);
1148 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1150 Dali::Window handle(this);
1151 mResizeCompletedSignal.Emit(handle, size);
1154 Vector2 Window::RecalculatePosition(const Vector2& position)
1156 Vector2 convertedPosition;
1158 switch(mRotationAngle)
1162 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1163 convertedPosition.y = position.x;
1168 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1169 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1174 convertedPosition.x = position.y;
1175 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1180 convertedPosition = position;
1184 return convertedPosition;
1187 Dali::Window Window::Get(Dali::Actor actor)
1189 Internal::Adaptor::Window* windowImpl = nullptr;
1191 if(Internal::Adaptor::Adaptor::IsAvailable())
1193 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1194 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1197 return Dali::Window(windowImpl);
1201 return Dali::Window();
1204 void Window::SetParent(Dali::Window& parent)
1206 if(DALI_UNLIKELY(parent))
1208 mParentWindow = parent;
1209 Dali::Window self = Dali::Window(this);
1210 // check circular parent window setting
1211 if(Dali::DevelWindow::GetParent(parent) == self)
1213 Dali::DevelWindow::Unparent(parent);
1215 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1219 void Window::SetParent(Dali::Window& parent, bool belowParent)
1221 if(DALI_UNLIKELY(parent))
1223 mParentWindow = parent;
1224 Dali::Window self = Dali::Window(this);
1225 // check circular parent window setting
1226 if(Dali::DevelWindow::GetParent(parent) == self)
1228 Dali::DevelWindow::Unparent(parent);
1230 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1234 void Window::Unparent()
1236 mWindowBase->SetParent(nullptr, false);
1237 mParentWindow.Reset();
1240 Dali::Window Window::GetParent()
1242 return mParentWindow;
1245 WindowOrientation Window::GetCurrentOrientation() const
1247 return ConvertToOrientation(mRotationAngle);
1250 int Window::GetPhysicalOrientation() const
1252 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1255 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1257 Dali::Vector<float>::SizeType count = orientations.Count();
1258 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1260 if(IsOrientationAvailable(orientations[index]) == false)
1262 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1267 int convertedAngle = ConvertToAngle(orientations[index]);
1269 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1271 if(mAvailableAngles[i] == convertedAngle)
1280 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1281 mAvailableAngles.push_back(convertedAngle);
1284 SetAvailableAnlges(mAvailableAngles);
1287 int32_t Window::GetNativeId() const
1289 return mWindowBase->GetNativeWindowId();
1292 void Window::RequestMoveToServer()
1294 mWindowBase->RequestMoveToServer();
1297 void Window::RequestResizeToServer(WindowResizeDirection direction)
1299 mWindowBase->RequestResizeToServer(direction);
1302 void Window::EnableFloatingMode(bool enable)
1304 mWindowBase->EnableFloatingMode(enable);
1307 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1309 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);
1310 mWindowBase->IncludeInputRegion(inputRegion);
1313 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1315 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);
1316 mWindowBase->ExcludeInputRegion(inputRegion);
1319 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1321 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1322 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1323 mWindowRotationAcknowledgement = needAcknowledgement;
1326 void Window::SendRotationCompletedAcknowledgement()
1328 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1329 if(mWindowRotationAcknowledgement)
1331 SetRotationCompletedAcknowledgement();
1335 bool Window::IsWindowRotating() const
1337 return mIsWindowRotating;
1340 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1342 return mLastKeyEvent;
1345 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1347 return mLastTouchEvent;
1350 } // namespace Adaptor
1352 } // namespace Internal