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");
60 } // unnamed namespace
62 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
65 return Window::New(surface, positionSize, name, className, type, isTransparent);
68 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
70 Window* window = new Window();
71 window->mIsTransparent = isTransparent;
72 window->Initialize(surface, positionSize, name, className, type);
77 : mWindowSurface(nullptr),
80 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
85 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
86 mDeleteRequestSignal(),
89 mVisibilityChangedSignal(),
90 mTransitionEffectEventSignal(),
91 mKeyboardRepeatSettingsChangedSignal(),
92 mAuxiliaryMessageSignal(),
94 mOrientationChangedSignal(),
95 mMouseInOutEventSignal(),
96 mMoveCompletedSignal(),
97 mResizeCompletedSignal(),
98 mInsetsChangedSignal(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
105 mWindowRotationAcknowledgement(false),
107 mIsWindowRotating(false),
108 mIsEmittedWindowCreatedEvent(false)
116 auto bridge = Accessibility::Bridge::GetCurrentBridge();
117 auto rootLayer = mScene.GetRootLayer();
118 auto accessible = Accessibility::Accessible::Get(rootLayer);
119 bridge->RemoveTopLevelWindow(accessible);
120 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
121 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
124 if(DALI_LIKELY(mAdaptor))
126 mAdaptor->RemoveWindow(this);
131 mEventHandler->RemoveObserver(*this);
135 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
137 // Create a window render surface
138 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
139 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
140 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
143 mWindowBase = mWindowSurface->GetWindowBase();
146 mWindowBase->SetType(type);
148 // Initialize for Ime window type
149 if(type == WindowType::IME)
151 mWindowBase->InitializeIme();
152 mWindowSurface->InitializeImeSurface();
156 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
157 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
158 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
159 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
160 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
161 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
162 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
163 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
164 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
165 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
166 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
168 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
169 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
171 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
173 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
175 SetClass(name, className);
177 mOrientation = Orientation::New(this);
179 // Get OrientationMode
180 int screenWidth, screenHeight;
181 WindowSystem::GetScreenSize(screenWidth, screenHeight);
182 if(screenWidth > screenHeight)
184 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
188 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
191 if(positionSize.width <= 0 || positionSize.height <= 0)
193 mWindowWidth = screenWidth;
194 mWindowHeight = screenHeight;
198 mWindowWidth = positionSize.width;
199 mWindowHeight = positionSize.height;
203 mNativeWindowId = mWindowBase->GetNativeWindowId();
206 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
213 mWindowSurface->SetRenderNotification(renderNotification);
216 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
218 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
219 mEventHandler->AddObserver(*this);
221 // Add Window to bridge for ATSPI
222 auto bridge = Accessibility::Bridge::GetCurrentBridge();
224 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
225 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
229 OnAccessibilityEnabled();
233 OnAccessibilityDisabled();
236 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
237 // The show must be called after the adaptor is initialized.
241 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
243 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
246 void Window::SetClass(std::string name, std::string className)
249 mClassName = className;
250 mWindowBase->SetClass(name, className);
253 std::string Window::GetClassName() const
260 mWindowBase->Raise();
262 mSurface->SetFullSwapNextFrame();
264 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
269 mWindowBase->Lower();
271 mSurface->SetFullSwapNextFrame();
273 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
276 void Window::Activate()
278 mWindowBase->Activate();
280 mSurface->SetFullSwapNextFrame();
282 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
285 void Window::Maximize(bool maximize)
287 mWindowBase->Maximize(maximize);
289 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
292 bool Window::IsMaximized() const
294 return mWindowBase->IsMaximized();
297 void Window::SetMaximumSize(Dali::Window::WindowSize size)
299 mWindowBase->SetMaximumSize(size);
302 void Window::Minimize(bool minimize)
304 mWindowBase->Minimize(minimize);
306 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
309 bool Window::IsMinimized() const
311 return mWindowBase->IsMinimized();
314 void Window::SetMimimumSize(Dali::Window::WindowSize size)
316 mWindowBase->SetMimimumSize(size);
319 uint32_t Window::GetLayerCount() const
321 return mScene.GetLayerCount();
324 Dali::Layer Window::GetLayer(uint32_t depth) const
326 return mScene.GetLayer(depth);
329 std::string Window::GetNativeResourceId() const
331 return mWindowBase->GetNativeWindowResourceId();
334 void Window::AddAvailableOrientation(WindowOrientation orientation)
336 if(IsOrientationAvailable(orientation) == false)
342 int convertedAngle = ConvertToAngle(orientation);
343 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
344 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
346 if(mAvailableAngles[i] == convertedAngle)
355 mAvailableAngles.push_back(convertedAngle);
356 SetAvailableAnlges(mAvailableAngles);
360 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
362 if(IsOrientationAvailable(orientation) == false)
367 int convertedAngle = ConvertToAngle(orientation);
368 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
369 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
370 iter != mAvailableAngles.end();
373 if(*iter == convertedAngle)
375 mAvailableAngles.erase(iter);
380 SetAvailableAnlges(mAvailableAngles);
383 void Window::SetPreferredOrientation(WindowOrientation orientation)
385 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
387 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
390 mPreferredAngle = ConvertToAngle(orientation);
391 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
392 mWindowBase->SetPreferredAngle(mPreferredAngle);
395 WindowOrientation Window::GetPreferredOrientation()
397 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
398 return preferredOrientation;
401 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
403 int angle = ConvertToAngle(orientation);
404 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
407 void Window::EmitAccessibilityHighlightSignal(bool highlight)
409 Dali::Window handle(this);
410 mAccessibilityHighlightSignal.Emit(handle, highlight);
413 void Window::SetAvailableAnlges(const std::vector<int>& angles)
415 if(angles.size() > 4)
417 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
421 mWindowBase->SetAvailableAnlges(angles);
424 int Window::ConvertToAngle(WindowOrientation orientation)
426 int convertAngle = static_cast<int>(orientation);
427 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
431 case WindowOrientation::LANDSCAPE:
436 case WindowOrientation::PORTRAIT:
441 case WindowOrientation::LANDSCAPE_INVERSE:
446 case WindowOrientation::PORTRAIT_INVERSE:
451 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
461 WindowOrientation Window::ConvertToOrientation(int angle) const
463 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
464 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
470 orientation = WindowOrientation::LANDSCAPE;
475 orientation = WindowOrientation::PORTRAIT;
480 orientation = WindowOrientation::LANDSCAPE_INVERSE;
485 orientation = WindowOrientation::PORTRAIT_INVERSE;
490 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
498 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
500 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
502 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
508 Dali::Any Window::GetNativeHandle() const
510 return mWindowSurface->GetNativeWindow();
513 void Window::SetAcceptFocus(bool accept)
515 mIsFocusAcceptable = accept;
517 mWindowBase->SetAcceptFocus(accept);
520 bool Window::IsFocusAcceptable() const
522 return mIsFocusAcceptable;
533 Dali::Window handle(this);
534 mVisibilityChangedSignal.Emit(handle, true);
535 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
537 WindowVisibilityObserver* observer(mAdaptor);
538 observer->OnWindowShown();
541 mSurface->SetFullSwapNextFrame();
543 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
554 Dali::Window handle(this);
555 mVisibilityChangedSignal.Emit(handle, false);
556 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
558 WindowVisibilityObserver* observer(mAdaptor);
559 observer->OnWindowHidden();
562 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
565 bool Window::IsVisible() const
567 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
568 return mVisible && !mIconified;
571 unsigned int Window::GetSupportedAuxiliaryHintCount() const
573 return mWindowBase->GetSupportedAuxiliaryHintCount();
576 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
578 return mWindowBase->GetSupportedAuxiliaryHint(index);
581 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
583 return mWindowBase->AddAuxiliaryHint(hint, value);
586 bool Window::RemoveAuxiliaryHint(unsigned int id)
588 return mWindowBase->RemoveAuxiliaryHint(id);
591 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
593 return mWindowBase->SetAuxiliaryHintValue(id, value);
596 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
598 return mWindowBase->GetAuxiliaryHintValue(id);
601 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
603 return mWindowBase->GetAuxiliaryHintId(hint);
606 void Window::SetInputRegion(const Rect<int>& inputRegion)
608 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);
609 mWindowBase->SetInputRegion(inputRegion);
612 void Window::SetType(WindowType type)
614 mWindowBase->SetType(type);
617 WindowType Window::GetType() const
619 return mWindowBase->GetType();
622 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
624 WindowType type = mWindowBase->GetType();
625 if(type != WindowType::NOTIFICATION)
627 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
628 return WindowOperationResult::INVALID_OPERATION;
631 return mWindowBase->SetNotificationLevel(level);
634 WindowNotificationLevel Window::GetNotificationLevel() const
636 WindowType type = mWindowBase->GetType();
637 if(type != WindowType::NOTIFICATION)
639 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
640 return WindowNotificationLevel::NONE;
643 return mWindowBase->GetNotificationLevel();
646 void Window::SetOpaqueState(bool opaque)
648 mOpaqueState = opaque;
650 mWindowBase->SetOpaqueState(opaque);
652 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
655 bool Window::IsOpaqueState() const
660 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
662 return mWindowBase->SetScreenOffMode(screenOffMode);
665 WindowScreenOffMode Window::GetScreenOffMode() const
667 return mWindowBase->GetScreenOffMode();
670 WindowOperationResult Window::SetBrightness(int brightness)
672 if(brightness < 0 || brightness > 100)
674 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
675 return WindowOperationResult::INVALID_OPERATION;
678 return mWindowBase->SetBrightness(brightness);
681 int Window::GetBrightness() const
683 return mWindowBase->GetBrightness();
686 void Window::SetSize(Dali::Window::WindowSize size)
688 PositionSize oldRect = GetPositionSize();
690 PositionSize newRect;
691 newRect.width = size.GetWidth();
692 newRect.height = size.GetHeight();
694 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
695 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
697 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
699 Uint16Pair newSize(newRect.width, newRect.height);
701 mWindowWidth = newRect.width;
702 mWindowHeight = newRect.height;
704 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);
706 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
708 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
710 Dali::Window handle(this);
711 mResizeSignal.Emit(handle, newSize);
713 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
716 mSurface->SetFullSwapNextFrame();
718 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
721 Dali::Window::WindowSize Window::GetSize() const
723 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
726 void Window::SetPosition(Dali::Window::WindowPosition position)
728 PositionSize oldRect = mSurface->GetPositionSize();
729 int32_t newX = position.GetX();
730 int32_t newY = position.GetY();
732 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
734 if((oldRect.x != newX) || (oldRect.y != newY))
736 Dali::Window handle(this);
737 Dali::Window::WindowPosition newPosition(newX, newY);
739 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
740 mMovedSignal.Emit(handle, newPosition);
743 mSurface->SetFullSwapNextFrame();
745 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
748 Dali::Window::WindowPosition Window::GetPosition() const
750 PositionSize positionSize = GetPositionSize();
751 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
754 PositionSize Window::GetPositionSize() const
756 PositionSize positionSize = mSurface->GetPositionSize();
757 positionSize.width = mWindowWidth;
758 positionSize.height = mWindowHeight;
762 void Window::SetPositionSize(PositionSize positionSize)
767 PositionSize oldRect = GetPositionSize();
768 Dali::Window handle(this);
770 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
775 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
782 mWindowSurface->MoveResize(positionSize);
785 // When window is moved, emit Moved Signal
788 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
789 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
790 mMovedSignal.Emit(handle, position);
793 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
796 Uint16Pair newSize(positionSize.width, positionSize.height);
798 mWindowWidth = positionSize.width;
799 mWindowHeight = positionSize.height;
801 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
803 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
805 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
807 mResizeSignal.Emit(handle, newSize);
808 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
811 mSurface->SetFullSwapNextFrame();
813 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
816 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
818 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
821 Dali::Layer Window::GetRootLayer() const
823 return mScene.GetRootLayer();
826 void Window::SetTransparency(bool transparent)
828 mWindowSurface->SetTransparency(transparent);
831 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
833 return mWindowBase->GrabKey(key, grabMode);
836 bool Window::UngrabKey(Dali::KEY key)
838 return mWindowBase->UngrabKey(key);
841 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
843 return mWindowBase->GrabKeyList(key, grabMode, result);
846 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
848 return mWindowBase->UngrabKeyList(key, result);
851 void Window::OnIconifyChanged(bool iconified)
859 Dali::Window handle(this);
860 mVisibilityChangedSignal.Emit(handle, false);
861 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
863 if(DALI_LIKELY(mAdaptor))
865 WindowVisibilityObserver* observer(mAdaptor);
866 observer->OnWindowHidden();
870 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
878 Dali::Window handle(this);
879 mVisibilityChangedSignal.Emit(handle, true);
880 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
882 if(DALI_LIKELY(mAdaptor))
884 WindowVisibilityObserver* observer(mAdaptor);
885 observer->OnWindowShown();
889 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
892 mSurface->SetFullSwapNextFrame();
895 void Window::OnFocusChanged(bool focusIn)
897 Dali::Window handle(this);
898 mFocusChangeSignal.Emit(handle, focusIn);
900 mSurface->SetFullSwapNextFrame();
902 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
906 bridge->WindowFocused(handle);
910 bridge->WindowUnfocused(handle);
916 void Window::OnOutputTransformed()
918 PositionSize positionSize = GetPositionSize();
920 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
922 if(DALI_LIKELY(mAdaptor))
924 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
925 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
929 void Window::OnDeleteRequest()
931 mDeleteRequestSignal.Emit();
934 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
936 Dali::Window handle(this);
937 mTransitionEffectEventSignal.Emit(handle, state, type);
940 void Window::OnKeyboardRepeatSettingsChanged()
942 Dali::Window handle(this);
943 mKeyboardRepeatSettingsChangedSignal.Emit();
946 void Window::OnWindowRedrawRequest()
948 if(DALI_LIKELY(mAdaptor))
950 mAdaptor->RenderOnce();
954 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
959 Dali::Window handle(this);
961 PositionSize oldRect = GetPositionSize();
962 PositionSize newRect = positionSize;
964 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
969 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
976 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);
977 mWindowSurface->UpdatePositionSize(positionSize);
980 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
982 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
983 Dali::Window::WindowPosition position(newRect.x, newRect.y);
984 mMovedSignal.Emit(handle, position);
987 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
988 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
990 Uint16Pair newSize(newRect.width, newRect.height);
992 mWindowWidth = newRect.width;
993 mWindowHeight = newRect.height;
995 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
997 if(DALI_LIKELY(mAdaptor))
999 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1002 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1003 mResizeSignal.Emit(handle, newSize);
1004 if(DALI_LIKELY(mAdaptor))
1006 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1010 mSurface->SetFullSwapNextFrame();
1012 if(DALI_LIKELY(mScene))
1014 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1018 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1020 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1021 FeedTouchPoint(point, timeStamp);
1024 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1026 FeedWheelEvent(wheelEvent);
1029 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1031 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);
1032 FeedKeyEvent(keyEvent);
1035 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1037 Dali::Window handle(this);
1039 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1042 void Window::OnRotation(const RotationEvent& rotation)
1044 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1046 mRotationAngle = rotation.angle;
1047 mWindowWidth = rotation.width;
1048 mWindowHeight = rotation.height;
1050 mIsWindowRotating = true;
1051 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);
1053 // Notify that the orientation is changed
1054 mOrientation->OnOrientationChange(rotation);
1056 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1058 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1060 if(DALI_LIKELY(mAdaptor))
1062 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1065 Dali::Window handle(this);
1066 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1067 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1069 if(DALI_LIKELY(mAdaptor))
1071 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1075 void Window::OnRotationFinished()
1077 mIsWindowRotating = false;
1078 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1081 void Window::OnPause()
1085 mEventHandler->Pause();
1089 void Window::OnResume()
1093 mEventHandler->Resume();
1096 mSurface->SetFullSwapNextFrame();
1099 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1101 mAuxiliaryMessageSignal.Emit(key, value, options);
1104 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1106 mInsetsChangedSignal.Emit(partType, partState, insets);
1109 void Window::OnAccessibilityEnabled()
1111 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1112 auto rootLayer = mScene.GetRootLayer();
1113 auto accessible = Accessibility::Accessible::Get(rootLayer);
1114 bridge->AddTopLevelWindow(accessible);
1116 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1118 Dali::Window handle(this);
1119 if(!mIsEmittedWindowCreatedEvent)
1121 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1122 bridge->WindowCreated(handle);
1123 mIsEmittedWindowCreatedEvent = true;
1126 if(!mVisible || mIconified)
1131 bridge->WindowShown(handle);
1135 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1136 bridge->WindowFocused(handle);
1140 void Window::OnAccessibilityDisabled()
1142 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1143 auto rootLayer = mScene.GetRootLayer();
1144 auto accessible = Accessibility::Accessible::Get(rootLayer);
1145 bridge->RemoveTopLevelWindow(accessible);
1146 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1149 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1151 Dali::Window handle(this);
1152 mMoveCompletedSignal.Emit(handle, position);
1155 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1157 Dali::Window handle(this);
1158 mResizeCompletedSignal.Emit(handle, size);
1161 Vector2 Window::RecalculatePosition(const Vector2& position)
1163 Vector2 convertedPosition;
1165 switch(mRotationAngle)
1169 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1170 convertedPosition.y = position.x;
1175 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1176 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1181 convertedPosition.x = position.y;
1182 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1187 convertedPosition = position;
1191 return convertedPosition;
1194 Dali::Window Window::Get(Dali::Actor actor)
1196 Internal::Adaptor::Window* windowImpl = nullptr;
1198 if(Internal::Adaptor::Adaptor::IsAvailable())
1200 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1201 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1204 return Dali::Window(windowImpl);
1208 return Dali::Window();
1211 void Window::SetParent(Dali::Window& parent)
1213 if(DALI_UNLIKELY(parent))
1215 mParentWindow = parent;
1216 Dali::Window self = Dali::Window(this);
1217 // check circular parent window setting
1218 if(Dali::DevelWindow::GetParent(parent) == self)
1220 Dali::DevelWindow::Unparent(parent);
1222 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1226 void Window::SetParent(Dali::Window& parent, bool belowParent)
1228 if(DALI_UNLIKELY(parent))
1230 mParentWindow = parent;
1231 Dali::Window self = Dali::Window(this);
1232 // check circular parent window setting
1233 if(Dali::DevelWindow::GetParent(parent) == self)
1235 Dali::DevelWindow::Unparent(parent);
1237 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1241 void Window::Unparent()
1243 mWindowBase->SetParent(nullptr, false);
1244 mParentWindow.Reset();
1247 Dali::Window Window::GetParent()
1249 return mParentWindow;
1252 WindowOrientation Window::GetCurrentOrientation() const
1254 return ConvertToOrientation(mRotationAngle);
1257 int Window::GetPhysicalOrientation() const
1259 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1262 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1264 Dali::Vector<float>::SizeType count = orientations.Count();
1265 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1267 if(IsOrientationAvailable(orientations[index]) == false)
1269 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1274 int convertedAngle = ConvertToAngle(orientations[index]);
1276 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1278 if(mAvailableAngles[i] == convertedAngle)
1287 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1288 mAvailableAngles.push_back(convertedAngle);
1291 SetAvailableAnlges(mAvailableAngles);
1294 int32_t Window::GetNativeId() const
1296 return mWindowBase->GetNativeWindowId();
1299 void Window::RequestMoveToServer()
1301 mWindowBase->RequestMoveToServer();
1304 void Window::RequestResizeToServer(WindowResizeDirection direction)
1306 mWindowBase->RequestResizeToServer(direction);
1309 void Window::EnableFloatingMode(bool enable)
1311 mWindowBase->EnableFloatingMode(enable);
1314 bool Window::IsFloatingModeEnabled()
1316 return mWindowBase->IsFloatingModeEnabled();
1319 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1321 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);
1322 mWindowBase->IncludeInputRegion(inputRegion);
1325 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1327 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);
1328 mWindowBase->ExcludeInputRegion(inputRegion);
1331 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1333 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1334 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1335 mWindowRotationAcknowledgement = needAcknowledgement;
1338 void Window::SendRotationCompletedAcknowledgement()
1340 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1341 if(mWindowRotationAcknowledgement)
1343 SetRotationCompletedAcknowledgement();
1347 bool Window::IsWindowRotating() const
1349 return mIsWindowRotating;
1352 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1354 return mLastKeyEvent;
1357 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1359 return mLastTouchEvent;
1362 } // namespace Adaptor
1364 } // namespace Internal