2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/public-api/actors/actor.h>
27 #include <dali/public-api/actors/camera-actor.h>
28 #include <dali/public-api/actors/layer.h>
29 #include <dali/public-api/adaptor-framework/window-enumerations.h>
30 #include <dali/public-api/rendering/frame-buffer.h>
34 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
35 #include <dali/devel-api/atspi-interfaces/accessible.h>
36 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
37 #include <dali/internal/graphics/gles/egl-graphics.h>
38 #include <dali/internal/window-system/common/event-handler.h>
39 #include <dali/internal/window-system/common/orientation-impl.h>
40 #include <dali/internal/window-system/common/render-surface-factory.h>
41 #include <dali/internal/window-system/common/window-base.h>
42 #include <dali/internal/window-system/common/window-factory.h>
43 #include <dali/internal/window-system/common/window-render-surface.h>
44 #include <dali/internal/window-system/common/window-system.h>
45 #include <dali/internal/window-system/common/window-visibility-observer.h>
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
58 } // unnamed namespace
60 Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
63 return Window::New(surface, name, className, windowData);
66 Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
68 Window* window = new Window();
69 window->mIsTransparent = windowData.GetTransparency();
70 window->mIsFrontBufferRendering = windowData.GetFrontBufferRendering();
71 window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
76 : mWindowSurface(nullptr),
79 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
84 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
85 mDeleteRequestSignal(),
88 mVisibilityChangedSignal(),
89 mTransitionEffectEventSignal(),
90 mKeyboardRepeatSettingsChangedSignal(),
91 mAuxiliaryMessageSignal(),
93 mOrientationChangedSignal(),
94 mMouseInOutEventSignal(),
95 mMouseRelativeEventSignal(),
96 mMoveCompletedSignal(),
97 mResizeCompletedSignal(),
98 mInsetsChangedSignal(),
99 mPointerConstraintsSignal(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
106 mWindowRotationAcknowledgement(false),
108 mIsWindowRotating(false),
109 mIsEnabledUserGeometry(false),
110 mIsEmittedWindowCreatedEvent(false),
111 mIsFrontBufferRendering(false)
119 auto bridge = Accessibility::Bridge::GetCurrentBridge();
120 auto rootLayer = mScene.GetRootLayer();
121 auto accessible = Accessibility::Accessible::Get(rootLayer);
122 bridge->RemoveTopLevelWindow(accessible);
123 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
124 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
129 mAdaptor->RemoveWindow(this);
134 mEventHandler->RemoveObserver(*this);
138 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
140 // Create a window render surface
141 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
142 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
143 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
146 mWindowBase = mWindowSurface->GetWindowBase();
149 mWindowBase->SetType(type);
151 // Initialize for Ime window type
152 if(type == WindowType::IME)
154 mWindowBase->InitializeIme();
155 mWindowSurface->InitializeImeSurface();
159 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
160 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
161 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
162 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
163 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
164 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
165 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
166 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
167 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
168 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
169 mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
170 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
171 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
172 mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
174 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
175 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
177 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
179 SetClass(name, className);
181 mOrientation = Orientation::New(this);
183 // Get OrientationMode
184 int screenWidth, screenHeight;
185 WindowSystem::GetScreenSize(screenWidth, screenHeight);
186 if(screenWidth > screenHeight)
188 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
192 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
195 mWindowWidth = positionSize.width;
196 mWindowHeight = positionSize.height;
198 bool isSetWithScreenSize = false;
199 if(mWindowWidth <= 0 || mWindowHeight <= 0)
201 mWindowWidth = screenWidth;
202 mWindowHeight = screenHeight;
203 isSetWithScreenSize = true;
204 DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
207 if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
209 SetUserGeometryPolicy();
213 mNativeWindowId = mWindowBase->GetNativeWindowId();
215 if(mIsFrontBufferRendering)
217 SetFrontBufferRendering(mIsFrontBufferRendering);
221 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
228 mWindowSurface->SetRenderNotification(renderNotification);
231 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
233 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
234 mEventHandler->AddObserver(*this);
236 if(mWindowBase->GetType() == WindowType::IME)
238 mWindowBase->InitializeIme();
239 mWindowSurface->InitializeImeSurface();
242 // Add Window to bridge for ATSPI
243 auto bridge = Accessibility::Bridge::GetCurrentBridge();
245 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
246 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
250 OnAccessibilityEnabled();
254 OnAccessibilityDisabled();
259 bool isGeometry = Dali::Internal::Adaptor::WindowSystem::IsGeometryHittestEnabled();
260 mScene.SetGeometryHittestEnabled(isGeometry);
262 mScene.SetNativeId(GetNativeId());
265 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
266 // The show must be called after the adaptor is initialized.
270 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
272 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
275 void Window::SetClass(std::string name, std::string className)
278 mClassName = className;
279 mWindowBase->SetClass(name, className);
282 std::string Window::GetClassName() const
289 mWindowBase->Raise();
291 mSurface->SetFullSwapNextFrame();
293 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
298 mWindowBase->Lower();
300 mSurface->SetFullSwapNextFrame();
302 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
305 void Window::Activate()
307 mWindowBase->Activate();
309 mSurface->SetFullSwapNextFrame();
311 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
314 void Window::Maximize(bool maximize)
316 mWindowBase->Maximize(maximize);
318 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
321 bool Window::IsMaximized() const
323 return mWindowBase->IsMaximized();
326 void Window::SetMaximumSize(Dali::Window::WindowSize size)
328 mWindowBase->SetMaximumSize(size);
331 void Window::Minimize(bool minimize)
333 mWindowBase->Minimize(minimize);
335 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
338 bool Window::IsMinimized() const
340 return mWindowBase->IsMinimized();
343 void Window::SetMimimumSize(Dali::Window::WindowSize size)
345 mWindowBase->SetMimimumSize(size);
348 uint32_t Window::GetLayerCount() const
350 return mScene.GetLayerCount();
353 Dali::Layer Window::GetLayer(uint32_t depth) const
355 return mScene.GetLayer(depth);
358 void Window::KeepRendering(float durationSeconds)
360 mScene.KeepRendering(durationSeconds);
363 void Window::SetPartialUpdateEnabled(bool enabled)
365 mScene.SetPartialUpdateEnabled(enabled);
368 bool Window::IsPartialUpdateEnabled() const
370 return mScene.IsPartialUpdateEnabled();
373 std::string Window::GetNativeResourceId() const
375 return mWindowBase->GetNativeWindowResourceId();
378 void Window::AddAvailableOrientation(WindowOrientation orientation)
380 if(IsOrientationAvailable(orientation) == false)
386 int convertedAngle = ConvertToAngle(orientation);
387 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
388 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
390 if(mAvailableAngles[i] == convertedAngle)
399 mAvailableAngles.push_back(convertedAngle);
400 SetAvailableAnlges(mAvailableAngles);
404 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
406 if(IsOrientationAvailable(orientation) == false)
411 int convertedAngle = ConvertToAngle(orientation);
412 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
413 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
414 iter != mAvailableAngles.end();
417 if(*iter == convertedAngle)
419 mAvailableAngles.erase(iter);
424 SetAvailableAnlges(mAvailableAngles);
427 void Window::SetPreferredOrientation(WindowOrientation orientation)
429 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
431 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
434 mPreferredAngle = ConvertToAngle(orientation);
435 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
436 mWindowBase->SetPreferredAngle(mPreferredAngle);
439 WindowOrientation Window::GetPreferredOrientation()
441 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
442 return preferredOrientation;
445 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
447 int angle = ConvertToAngle(orientation);
448 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
451 void Window::EmitAccessibilityHighlightSignal(bool highlight)
453 Dali::Window handle(this);
454 mAccessibilityHighlightSignal.Emit(handle, highlight);
457 void Window::SetAvailableAnlges(const std::vector<int>& angles)
459 if(angles.size() > 4)
461 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
465 mWindowBase->SetAvailableAnlges(angles);
468 int Window::ConvertToAngle(WindowOrientation orientation)
470 int convertAngle = static_cast<int>(orientation);
471 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
475 case WindowOrientation::LANDSCAPE:
480 case WindowOrientation::PORTRAIT:
485 case WindowOrientation::LANDSCAPE_INVERSE:
490 case WindowOrientation::PORTRAIT_INVERSE:
495 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
505 WindowOrientation Window::ConvertToOrientation(int angle) const
507 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
508 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
514 orientation = WindowOrientation::LANDSCAPE;
519 orientation = WindowOrientation::PORTRAIT;
524 orientation = WindowOrientation::LANDSCAPE_INVERSE;
529 orientation = WindowOrientation::PORTRAIT_INVERSE;
534 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
542 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
544 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
546 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
552 Dali::Any Window::GetNativeHandle() const
554 return mWindowSurface->GetNativeWindow();
557 void Window::SetAcceptFocus(bool accept)
559 mIsFocusAcceptable = accept;
561 mWindowBase->SetAcceptFocus(accept);
564 bool Window::IsFocusAcceptable() const
566 return mIsFocusAcceptable;
577 Dali::Window handle(this);
578 mVisibilityChangedSignal.Emit(handle, true);
579 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
581 WindowVisibilityObserver* observer(mAdaptor);
582 observer->OnWindowShown();
585 mSurface->SetFullSwapNextFrame();
587 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
598 Dali::Window handle(this);
599 mVisibilityChangedSignal.Emit(handle, false);
600 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
602 WindowVisibilityObserver* observer(mAdaptor);
603 observer->OnWindowHidden();
606 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
609 bool Window::IsVisible() const
611 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
612 return mVisible && !mIconified;
615 unsigned int Window::GetSupportedAuxiliaryHintCount() const
617 return mWindowBase->GetSupportedAuxiliaryHintCount();
620 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
622 return mWindowBase->GetSupportedAuxiliaryHint(index);
625 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
627 return mWindowBase->AddAuxiliaryHint(hint, value);
630 bool Window::RemoveAuxiliaryHint(unsigned int id)
632 return mWindowBase->RemoveAuxiliaryHint(id);
635 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
637 return mWindowBase->SetAuxiliaryHintValue(id, value);
640 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
642 return mWindowBase->GetAuxiliaryHintValue(id);
645 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
647 return mWindowBase->GetAuxiliaryHintId(hint);
650 void Window::SetInputRegion(const Rect<int>& inputRegion)
652 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);
653 mWindowBase->SetInputRegion(inputRegion);
656 void Window::SetType(WindowType type)
658 mWindowBase->SetType(type);
661 WindowType Window::GetType() const
663 return mWindowBase->GetType();
666 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
668 WindowType type = mWindowBase->GetType();
669 if(type != WindowType::NOTIFICATION)
671 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
672 return WindowOperationResult::INVALID_OPERATION;
675 return mWindowBase->SetNotificationLevel(level);
678 WindowNotificationLevel Window::GetNotificationLevel() const
680 WindowType type = mWindowBase->GetType();
681 if(type != WindowType::NOTIFICATION)
683 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
684 return WindowNotificationLevel::NONE;
687 return mWindowBase->GetNotificationLevel();
690 void Window::SetOpaqueState(bool opaque)
692 mOpaqueState = opaque;
694 mWindowBase->SetOpaqueState(opaque);
696 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
699 bool Window::IsOpaqueState() const
704 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
706 return mWindowBase->SetScreenOffMode(screenOffMode);
709 WindowScreenOffMode Window::GetScreenOffMode() const
711 return mWindowBase->GetScreenOffMode();
714 WindowOperationResult Window::SetBrightness(int brightness)
716 if(brightness < 0 || brightness > 100)
718 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
719 return WindowOperationResult::INVALID_OPERATION;
722 return mWindowBase->SetBrightness(brightness);
725 int Window::GetBrightness() const
727 return mWindowBase->GetBrightness();
730 void Window::SetSize(Dali::Window::WindowSize size)
732 PositionSize oldRect = GetPositionSize();
734 PositionSize newRect;
735 newRect.width = size.GetWidth();
736 newRect.height = size.GetHeight();
738 SetUserGeometryPolicy();
740 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
741 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
743 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
745 Uint16Pair newSize(newRect.width, newRect.height);
747 mWindowWidth = newRect.width;
748 mWindowHeight = newRect.height;
750 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);
752 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
754 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
756 Dali::Window handle(this);
757 mResizeSignal.Emit(handle, newSize);
759 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
761 if(Dali::Accessibility::IsUp())
763 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
767 mSurface->SetFullSwapNextFrame();
770 Dali::Window::WindowSize Window::GetSize() const
772 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
775 void Window::SetPosition(Dali::Window::WindowPosition position)
777 PositionSize oldRect = mSurface->GetPositionSize();
778 int32_t newX = position.GetX();
779 int32_t newY = position.GetY();
781 SetUserGeometryPolicy();
783 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
785 if((oldRect.x != newX) || (oldRect.y != newY))
787 Dali::Window handle(this);
788 Dali::Window::WindowPosition newPosition(newX, newY);
790 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
791 mMovedSignal.Emit(handle, newPosition);
793 if(Dali::Accessibility::IsUp())
795 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
799 mSurface->SetFullSwapNextFrame();
802 Dali::Window::WindowPosition Window::GetPosition() const
804 PositionSize positionSize = GetPositionSize();
805 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
808 PositionSize Window::GetPositionSize() const
810 PositionSize positionSize = mSurface->GetPositionSize();
811 positionSize.width = mWindowWidth;
812 positionSize.height = mWindowHeight;
816 void Window::SetPositionSize(PositionSize positionSize)
821 PositionSize oldRect = GetPositionSize();
822 Dali::Window handle(this);
824 SetUserGeometryPolicy();
826 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
831 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
838 mWindowSurface->MoveResize(positionSize);
841 // When window is moved, emit Moved Signal
844 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
845 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
846 mMovedSignal.Emit(handle, position);
849 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
852 Uint16Pair newSize(positionSize.width, positionSize.height);
854 mWindowWidth = positionSize.width;
855 mWindowHeight = positionSize.height;
857 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
859 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
861 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
863 mResizeSignal.Emit(handle, newSize);
864 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
867 if((moved || resize) && Dali::Accessibility::IsUp())
869 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
872 mSurface->SetFullSwapNextFrame();
875 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
877 SetUserGeometryPolicy();
878 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
881 Dali::Layer Window::GetRootLayer() const
883 return mScene.GetRootLayer();
886 void Window::SetTransparency(bool transparent)
888 mWindowSurface->SetTransparency(transparent);
891 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
893 return mWindowBase->GrabKey(key, grabMode);
896 bool Window::UngrabKey(Dali::KEY key)
898 return mWindowBase->UngrabKey(key);
901 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
903 return mWindowBase->GrabKeyList(key, grabMode, result);
906 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
908 return mWindowBase->UngrabKeyList(key, result);
911 void Window::OnIconifyChanged(bool iconified)
913 const bool isActuallyChanged = (iconified != mIconified);
914 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
915 Dali::Window handle(this);
923 mVisibilityChangedSignal.Emit(handle, false);
924 bridge->WindowHidden(handle);
926 WindowVisibilityObserver* observer(mAdaptor);
927 observer->OnWindowHidden();
930 if(isActuallyChanged)
932 bridge->WindowMinimized(handle);
935 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
943 mVisibilityChangedSignal.Emit(handle, true);
944 bridge->WindowShown(handle);
946 WindowVisibilityObserver* observer(mAdaptor);
947 observer->OnWindowShown();
950 if(isActuallyChanged)
952 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
955 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
958 mSurface->SetFullSwapNextFrame();
961 void Window::OnMaximizeChanged(bool maximized)
963 const bool isActuallyChanged = (maximized != mMaximized);
965 if(isActuallyChanged)
967 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
968 Dali::Window handle(this);
973 bridge->WindowMaximized(handle);
978 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
983 void Window::OnFocusChanged(bool focusIn)
985 Dali::Window handle(this);
986 mFocusChangeSignal.Emit(handle, focusIn);
988 mSurface->SetFullSwapNextFrame();
989 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
993 bridge->WindowFocused(handle);
997 bridge->WindowUnfocused(handle);
1003 void Window::OnOutputTransformed()
1005 PositionSize positionSize = GetPositionSize();
1007 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1009 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
1010 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
1013 void Window::OnDeleteRequest()
1015 mDeleteRequestSignal.Emit();
1018 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1020 Dali::Window handle(this);
1021 mTransitionEffectEventSignal.Emit(handle, state, type);
1024 void Window::OnKeyboardRepeatSettingsChanged()
1026 Dali::Window handle(this);
1027 mKeyboardRepeatSettingsChangedSignal.Emit();
1030 void Window::OnWindowRedrawRequest()
1032 mAdaptor->RenderOnce();
1035 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1038 bool resize = false;
1040 Dali::Window handle(this);
1042 PositionSize oldRect = GetPositionSize();
1043 PositionSize newRect = positionSize;
1045 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1050 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1057 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);
1058 mWindowSurface->UpdatePositionSize(positionSize);
1061 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1063 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1064 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1065 mMovedSignal.Emit(handle, position);
1068 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1069 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1071 Uint16Pair newSize(newRect.width, newRect.height);
1073 mWindowWidth = newRect.width;
1074 mWindowHeight = newRect.height;
1076 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1078 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1080 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1081 mResizeSignal.Emit(handle, newSize);
1082 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1085 if((moved || resize) && Dali::Accessibility::IsUp())
1087 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1090 mSurface->SetFullSwapNextFrame();
1093 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1095 FeedTouchPoint(point, timeStamp);
1098 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1100 FeedWheelEvent(wheelEvent);
1103 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1105 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);
1106 DevelKeyEvent::SetWindowId(mLastKeyEvent, keyEvent.windowId);
1107 FeedKeyEvent(keyEvent);
1110 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1112 Dali::Window handle(this);
1114 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1117 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1119 Dali::Window handle(this);
1121 mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1124 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1126 Dali::Window handle(this);
1128 Vector2 newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1129 Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1131 mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1134 void Window::OnRotation(const RotationEvent& rotation)
1136 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1138 mRotationAngle = rotation.angle;
1139 mWindowWidth = rotation.width;
1140 mWindowHeight = rotation.height;
1142 mIsWindowRotating = true;
1143 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);
1145 // Notify that the orientation is changed
1146 mOrientation->OnOrientationChange(rotation);
1148 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1150 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1152 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1154 Dali::Window handle(this);
1155 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1156 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1158 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1161 void Window::OnRotationFinished()
1163 mIsWindowRotating = false;
1164 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1167 void Window::OnPause()
1171 mEventHandler->Pause();
1175 void Window::OnResume()
1179 mEventHandler->Resume();
1182 mSurface->SetFullSwapNextFrame();
1185 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1187 mAuxiliaryMessageSignal.Emit(key, value, options);
1190 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1192 mInsetsChangedSignal.Emit(partType, partState, insets);
1195 void Window::OnAccessibilityEnabled()
1197 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1198 auto rootLayer = mScene.GetRootLayer();
1199 auto accessible = Accessibility::Accessible::Get(rootLayer);
1200 bridge->AddTopLevelWindow(accessible);
1202 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1204 Dali::Window handle(this);
1205 if(!mIsEmittedWindowCreatedEvent)
1207 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1208 bridge->WindowCreated(handle);
1209 mIsEmittedWindowCreatedEvent = true;
1212 if(!mVisible || mIconified)
1217 bridge->WindowShown(handle);
1221 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1222 bridge->WindowFocused(handle);
1226 void Window::OnAccessibilityDisabled()
1228 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1229 auto rootLayer = mScene.GetRootLayer();
1230 auto accessible = Accessibility::Accessible::Get(rootLayer);
1231 bridge->RemoveTopLevelWindow(accessible);
1232 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1235 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1237 Dali::Window handle(this);
1238 mMoveCompletedSignal.Emit(handle, position);
1241 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1243 Dali::Window handle(this);
1244 mResizeCompletedSignal.Emit(handle, size);
1247 Vector2 Window::RecalculatePosition(const Vector2& position)
1249 Vector2 convertedPosition;
1251 switch(mRotationAngle)
1255 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1256 convertedPosition.y = position.x;
1261 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1262 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1267 convertedPosition.x = position.y;
1268 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1273 convertedPosition = position;
1277 return convertedPosition;
1280 Dali::Window Window::Get(Dali::Actor actor)
1282 Internal::Adaptor::Window* windowImpl = nullptr;
1284 if(Internal::Adaptor::Adaptor::IsAvailable())
1286 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1287 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1290 return Dali::Window(windowImpl);
1294 return Dali::Window();
1297 void Window::SetParent(Dali::Window& parent)
1299 if(DALI_UNLIKELY(parent))
1301 mParentWindow = parent;
1302 Dali::Window self = Dali::Window(this);
1303 // check circular parent window setting
1304 if(Dali::DevelWindow::GetParent(parent) == self)
1306 Dali::DevelWindow::Unparent(parent);
1308 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1312 void Window::SetParent(Dali::Window& parent, bool belowParent)
1314 if(DALI_UNLIKELY(parent))
1316 mParentWindow = parent;
1317 Dali::Window self = Dali::Window(this);
1318 // check circular parent window setting
1319 if(Dali::DevelWindow::GetParent(parent) == self)
1321 Dali::DevelWindow::Unparent(parent);
1323 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1327 void Window::Unparent()
1329 mWindowBase->SetParent(nullptr, false);
1330 mParentWindow.Reset();
1333 Dali::Window Window::GetParent()
1335 return mParentWindow;
1338 WindowOrientation Window::GetCurrentOrientation() const
1340 return ConvertToOrientation(mRotationAngle);
1343 int Window::GetPhysicalOrientation() const
1345 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1348 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1350 Dali::Vector<float>::SizeType count = orientations.Count();
1351 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1353 if(IsOrientationAvailable(orientations[index]) == false)
1355 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1360 int convertedAngle = ConvertToAngle(orientations[index]);
1362 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1364 if(mAvailableAngles[i] == convertedAngle)
1373 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1374 mAvailableAngles.push_back(convertedAngle);
1377 SetAvailableAnlges(mAvailableAngles);
1380 int32_t Window::GetNativeId() const
1382 return mWindowBase->GetNativeWindowId();
1385 void Window::RequestMoveToServer()
1387 SetUserGeometryPolicy();
1388 mWindowBase->RequestMoveToServer();
1391 void Window::RequestResizeToServer(WindowResizeDirection direction)
1393 SetUserGeometryPolicy();
1394 mWindowBase->RequestResizeToServer(direction);
1397 void Window::EnableFloatingMode(bool enable)
1399 mWindowBase->EnableFloatingMode(enable);
1402 bool Window::IsFloatingModeEnabled()
1404 return mWindowBase->IsFloatingModeEnabled();
1407 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1409 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);
1410 mWindowBase->IncludeInputRegion(inputRegion);
1413 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1415 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);
1416 mWindowBase->ExcludeInputRegion(inputRegion);
1419 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1421 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1422 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1423 mWindowRotationAcknowledgement = needAcknowledgement;
1426 void Window::SendRotationCompletedAcknowledgement()
1428 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1429 if(mWindowRotationAcknowledgement)
1431 SetRotationCompletedAcknowledgement();
1435 bool Window::IsWindowRotating() const
1437 return mIsWindowRotating;
1440 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1442 return mLastKeyEvent;
1445 void Window::SetUserGeometryPolicy()
1447 if(mIsEnabledUserGeometry == true)
1452 mIsEnabledUserGeometry = true;
1453 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1454 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1457 bool Window::PointerConstraintsLock()
1459 return mWindowBase->PointerConstraintsLock();
1462 bool Window::PointerConstraintsUnlock()
1464 return mWindowBase->PointerConstraintsUnlock();
1467 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1469 mWindowBase->LockedPointerRegionSet(x, y, width, height);
1472 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1474 mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1477 bool Window::PointerWarp(int32_t x, int32_t y)
1479 return mWindowBase->PointerWarp(x, y);
1482 void Window::CursorVisibleSet(bool visible)
1484 mWindowBase->CursorVisibleSet(visible);
1487 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1489 return mWindowBase->KeyboardGrab(deviceSubclass);
1492 bool Window::KeyboardUnGrab()
1494 return mWindowBase->KeyboardUnGrab();
1497 void Window::SetFullScreen(bool fullscreen)
1499 mWindowBase->SetFullScreen(fullscreen);
1502 bool Window::GetFullScreen()
1504 return mWindowBase->GetFullScreen();
1507 void Window::SetFrontBufferRendering(bool enable)
1509 mWindowBase->SetFrontBufferRendering(enable);
1510 mWindowSurface->SetFrontBufferRendering(enable);
1513 bool Window::GetFrontBufferRendering()
1515 return mWindowBase->GetFrontBufferRendering();
1518 } // namespace Adaptor
1520 } // namespace Internal