2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/public-api/render-tasks/render-task-list.h>
32 #include <dali/public-api/render-tasks/render-task.h>
33 #include <dali/public-api/rendering/frame-buffer.h>
37 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
38 #include <dali/devel-api/atspi-interfaces/accessible.h>
39 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
40 #include <dali/internal/graphics/gles/egl-graphics.h>
41 #include <dali/internal/window-system/common/event-handler.h>
42 #include <dali/internal/window-system/common/orientation-impl.h>
43 #include <dali/internal/window-system/common/render-surface-factory.h>
44 #include <dali/internal/window-system/common/window-base.h>
45 #include <dali/internal/window-system/common/window-factory.h>
46 #include <dali/internal/window-system/common/window-render-surface.h>
47 #include <dali/internal/window-system/common/window-system.h>
48 #include <dali/internal/window-system/common/window-visibility-observer.h>
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
96 mOrientationChangedSignal(),
99 mIsTransparent(false),
100 mIsFocusAcceptable(true),
103 mWindowRotationAcknowledgement(false),
105 mIsWindowRotating(false)
113 auto bridge = Accessibility::Bridge::GetCurrentBridge();
114 auto rootLayer = mScene.GetRootLayer();
115 auto accessible = Accessibility::Accessible::Get(rootLayer);
116 bridge->RemoveTopLevelWindow(accessible);
117 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
118 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
121 if(DALI_LIKELY(mAdaptor))
123 mAdaptor->RemoveWindow(this);
128 mEventHandler->RemoveObserver(*this);
132 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
134 // Create a window render surface
135 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
136 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
137 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
140 mWindowBase = mWindowSurface->GetWindowBase();
143 mWindowBase->SetType(type);
145 // Initialize for Ime window type
146 if(type == WindowType::IME)
148 mWindowBase->InitializeIme();
149 mWindowSurface->InitializeImeSurface();
153 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
154 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
155 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
156 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
157 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
158 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
159 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
160 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
162 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
163 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
165 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
167 SetClass(name, className);
169 mOrientation = Orientation::New(this);
171 // Get OrientationMode
172 int screenWidth, screenHeight;
173 WindowSystem::GetScreenSize(screenWidth, screenHeight);
174 if(screenWidth > screenHeight)
176 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
180 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
183 if(positionSize.width <= 0 || positionSize.height <= 0)
185 mWindowWidth = screenWidth;
186 mWindowHeight = screenHeight;
190 mWindowWidth = positionSize.width;
191 mWindowHeight = positionSize.height;
195 mNativeWindowId = mWindowBase->GetNativeWindowId();
198 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
200 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
201 mEventHandler->AddObserver(*this);
203 // Add Window to bridge for ATSPI
204 auto bridge = Accessibility::Bridge::GetCurrentBridge();
207 auto rootLayer = mScene.GetRootLayer();
208 auto accessible = Accessibility::Accessible::Get(rootLayer);
209 bridge->AddTopLevelWindow(accessible);
212 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
213 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
215 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
216 // The show must be called after the adaptor is initialized.
220 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
222 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
225 void Window::SetClass(std::string name, std::string className)
228 mClassName = className;
229 mWindowBase->SetClass(name, className);
232 std::string Window::GetClassName() const
239 mWindowBase->Raise();
241 mSurface->SetFullSwapNextFrame();
243 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
248 mWindowBase->Lower();
250 mSurface->SetFullSwapNextFrame();
252 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
255 void Window::Activate()
257 mWindowBase->Activate();
259 mSurface->SetFullSwapNextFrame();
261 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
264 void Window::Maximize(bool maximize)
266 mWindowBase->Maximize(maximize);
268 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
271 bool Window::IsMaximized() const
273 return mWindowBase->IsMaximized();
276 void Window::SetMaximumSize(Dali::Window::WindowSize size)
278 mWindowBase->SetMaximumSize(size);
281 void Window::Minimize(bool minimize)
283 mWindowBase->Minimize(minimize);
285 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
288 bool Window::IsMinimized() const
290 return mWindowBase->IsMinimized();
293 void Window::SetMimimumSize(Dali::Window::WindowSize size)
295 mWindowBase->SetMimimumSize(size);
298 uint32_t Window::GetLayerCount() const
300 return mScene.GetLayerCount();
303 Dali::Layer Window::GetLayer(uint32_t depth) const
305 return mScene.GetLayer(depth);
308 Dali::RenderTaskList Window::GetRenderTaskList() const
310 return mScene.GetRenderTaskList();
313 std::string Window::GetNativeResourceId() const
315 return mWindowBase->GetNativeWindowResourceId();
318 void Window::AddAvailableOrientation(WindowOrientation orientation)
320 if(IsOrientationAvailable(orientation) == false)
326 int convertedAngle = ConvertToAngle(orientation);
327 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
328 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
330 if(mAvailableAngles[i] == convertedAngle)
339 mAvailableAngles.push_back(convertedAngle);
340 SetAvailableAnlges(mAvailableAngles);
344 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
346 if(IsOrientationAvailable(orientation) == false)
351 int convertedAngle = ConvertToAngle(orientation);
352 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
353 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
354 iter != mAvailableAngles.end();
357 if(*iter == convertedAngle)
359 mAvailableAngles.erase(iter);
364 SetAvailableAnlges(mAvailableAngles);
367 void Window::SetPreferredOrientation(WindowOrientation orientation)
369 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
371 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
374 mPreferredAngle = ConvertToAngle(orientation);
375 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
376 mWindowBase->SetPreferredAngle(mPreferredAngle);
379 WindowOrientation Window::GetPreferredOrientation()
381 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
382 return preferredOrientation;
385 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
387 int angle = ConvertToAngle(orientation);
388 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
391 void Window::EmitAccessibilityHighlightSignal(bool highlight)
393 Dali::Window handle(this);
394 mAccessibilityHighlightSignal.Emit(handle, highlight);
397 void Window::SetAvailableAnlges(const std::vector<int>& angles)
399 if(angles.size() > 4)
401 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
405 mWindowBase->SetAvailableAnlges(angles);
408 int Window::ConvertToAngle(WindowOrientation orientation)
410 int convertAngle = static_cast<int>(orientation);
411 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
415 case WindowOrientation::LANDSCAPE:
420 case WindowOrientation::PORTRAIT:
425 case WindowOrientation::LANDSCAPE_INVERSE:
430 case WindowOrientation::PORTRAIT_INVERSE:
435 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
445 WindowOrientation Window::ConvertToOrientation(int angle) const
447 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
448 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
454 orientation = WindowOrientation::LANDSCAPE;
459 orientation = WindowOrientation::PORTRAIT;
464 orientation = WindowOrientation::LANDSCAPE_INVERSE;
469 orientation = WindowOrientation::PORTRAIT_INVERSE;
474 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
482 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
484 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
486 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
492 Dali::Any Window::GetNativeHandle() const
494 return mWindowSurface->GetNativeWindow();
497 void Window::SetAcceptFocus(bool accept)
499 mIsFocusAcceptable = accept;
501 mWindowBase->SetAcceptFocus(accept);
504 bool Window::IsFocusAcceptable() const
506 return mIsFocusAcceptable;
517 Dali::Window handle(this);
518 mVisibilityChangedSignal.Emit(handle, true);
519 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
521 WindowVisibilityObserver* observer(mAdaptor);
522 observer->OnWindowShown();
525 mSurface->SetFullSwapNextFrame();
527 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
538 Dali::Window handle(this);
539 mVisibilityChangedSignal.Emit(handle, false);
540 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
542 WindowVisibilityObserver* observer(mAdaptor);
543 observer->OnWindowHidden();
546 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
549 bool Window::IsVisible() const
551 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
552 return mVisible && !mIconified;
555 unsigned int Window::GetSupportedAuxiliaryHintCount() const
557 return mWindowBase->GetSupportedAuxiliaryHintCount();
560 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
562 return mWindowBase->GetSupportedAuxiliaryHint(index);
565 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
567 return mWindowBase->AddAuxiliaryHint(hint, value);
570 bool Window::RemoveAuxiliaryHint(unsigned int id)
572 return mWindowBase->RemoveAuxiliaryHint(id);
575 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
577 return mWindowBase->SetAuxiliaryHintValue(id, value);
580 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
582 return mWindowBase->GetAuxiliaryHintValue(id);
585 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
587 return mWindowBase->GetAuxiliaryHintId(hint);
590 void Window::SetInputRegion(const Rect<int>& inputRegion)
592 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);
593 mWindowBase->SetInputRegion(inputRegion);
596 void Window::SetType(WindowType type)
598 mWindowBase->SetType(type);
601 WindowType Window::GetType() const
603 return mWindowBase->GetType();
606 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
608 WindowType type = mWindowBase->GetType();
609 if(type != WindowType::NOTIFICATION)
611 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
612 return WindowOperationResult::INVALID_OPERATION;
615 return mWindowBase->SetNotificationLevel(level);
618 WindowNotificationLevel Window::GetNotificationLevel() const
620 WindowType type = mWindowBase->GetType();
621 if(type != WindowType::NOTIFICATION)
623 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
624 return WindowNotificationLevel::NONE;
627 return mWindowBase->GetNotificationLevel();
630 void Window::SetOpaqueState(bool opaque)
632 mOpaqueState = opaque;
634 mWindowBase->SetOpaqueState(opaque);
636 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
639 bool Window::IsOpaqueState() const
644 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
646 return mWindowBase->SetScreenOffMode(screenOffMode);
649 WindowScreenOffMode Window::GetScreenOffMode() const
651 return mWindowBase->GetScreenOffMode();
654 WindowOperationResult Window::SetBrightness(int brightness)
656 if(brightness < 0 || brightness > 100)
658 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
659 return WindowOperationResult::INVALID_OPERATION;
662 return mWindowBase->SetBrightness(brightness);
665 int Window::GetBrightness() const
667 return mWindowBase->GetBrightness();
670 void Window::SetSize(Dali::Window::WindowSize size)
672 PositionSize oldRect = GetPositionSize();
674 PositionSize newRect;
675 newRect.width = size.GetWidth();
676 newRect.height = size.GetHeight();
678 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
679 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
681 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
683 Uint16Pair newSize(newRect.width, newRect.height);
685 mWindowWidth = newRect.width;
686 mWindowHeight = newRect.height;
688 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);
690 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
692 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
694 Dali::Window handle(this);
695 mResizeSignal.Emit(handle, newSize);
697 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
700 mSurface->SetFullSwapNextFrame();
702 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
705 Dali::Window::WindowSize Window::GetSize() const
707 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
710 void Window::SetPosition(Dali::Window::WindowPosition position)
712 PositionSize oldRect = mSurface->GetPositionSize();
713 int32_t newX = position.GetX();
714 int32_t newY = position.GetY();
716 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
718 if((oldRect.x != newX) || (oldRect.y != newY))
720 Dali::Window handle(this);
721 Dali::Window::WindowPosition newPosition(newX, newY);
723 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
724 mMovedSignal.Emit(handle, newPosition);
727 mSurface->SetFullSwapNextFrame();
729 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
732 Dali::Window::WindowPosition Window::GetPosition() const
734 PositionSize positionSize = GetPositionSize();
735 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
738 PositionSize Window::GetPositionSize() const
740 PositionSize positionSize = mSurface->GetPositionSize();
741 positionSize.width = mWindowWidth;
742 positionSize.height = mWindowHeight;
746 void Window::SetPositionSize(PositionSize positionSize)
751 PositionSize oldRect = GetPositionSize();
752 Dali::Window handle(this);
754 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
759 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
766 mWindowSurface->MoveResize(positionSize);
769 // When window is moved, emit Moved Signal
772 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
773 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
774 mMovedSignal.Emit(handle, position);
777 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
780 Uint16Pair newSize(positionSize.width, positionSize.height);
782 mWindowWidth = positionSize.width;
783 mWindowHeight = positionSize.height;
785 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
787 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
789 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
791 mResizeSignal.Emit(handle, newSize);
792 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
795 mSurface->SetFullSwapNextFrame();
797 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
800 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
802 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
805 Dali::Layer Window::GetRootLayer() const
807 return mScene.GetRootLayer();
810 void Window::SetTransparency(bool transparent)
812 mWindowSurface->SetTransparency(transparent);
815 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
817 return mWindowBase->GrabKey(key, grabMode);
820 bool Window::UngrabKey(Dali::KEY key)
822 return mWindowBase->UngrabKey(key);
825 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
827 return mWindowBase->GrabKeyList(key, grabMode, result);
830 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
832 return mWindowBase->UngrabKeyList(key, result);
835 void Window::OnIconifyChanged(bool iconified)
843 Dali::Window handle(this);
844 mVisibilityChangedSignal.Emit(handle, false);
845 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
847 if(DALI_LIKELY(mAdaptor))
849 WindowVisibilityObserver* observer(mAdaptor);
850 observer->OnWindowHidden();
854 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
862 Dali::Window handle(this);
863 mVisibilityChangedSignal.Emit(handle, true);
864 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
866 if(DALI_LIKELY(mAdaptor))
868 WindowVisibilityObserver* observer(mAdaptor);
869 observer->OnWindowShown();
873 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
876 mSurface->SetFullSwapNextFrame();
879 void Window::OnFocusChanged(bool focusIn)
881 Dali::Window handle(this);
882 mFocusChangeSignal.Emit(handle, focusIn);
884 mSurface->SetFullSwapNextFrame();
886 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
890 bridge->WindowFocused(handle);
894 bridge->WindowUnfocused(handle);
900 void Window::OnOutputTransformed()
902 PositionSize positionSize = GetPositionSize();
904 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
906 if(DALI_LIKELY(mAdaptor))
908 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
909 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
913 void Window::OnDeleteRequest()
915 mDeleteRequestSignal.Emit();
918 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
920 Dali::Window handle(this);
921 mTransitionEffectEventSignal.Emit(handle, state, type);
924 void Window::OnKeyboardRepeatSettingsChanged()
926 Dali::Window handle(this);
927 mKeyboardRepeatSettingsChangedSignal.Emit();
930 void Window::OnWindowRedrawRequest()
932 if(DALI_LIKELY(mAdaptor))
934 mAdaptor->RenderOnce();
938 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
943 Dali::Window handle(this);
945 PositionSize oldRect = GetPositionSize();
946 PositionSize newRect = positionSize;
948 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
953 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
960 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);
961 mWindowSurface->UpdatePositionSize(positionSize);
964 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
966 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
967 Dali::Window::WindowPosition position(newRect.x, newRect.y);
968 mMovedSignal.Emit(handle, position);
971 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
972 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
974 Uint16Pair newSize(newRect.width, newRect.height);
976 mWindowWidth = newRect.width;
977 mWindowHeight = newRect.height;
979 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
981 if(DALI_LIKELY(mAdaptor))
983 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
986 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
987 mResizeSignal.Emit(handle, newSize);
988 if(DALI_LIKELY(mAdaptor))
990 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
994 mSurface->SetFullSwapNextFrame();
996 if(DALI_LIKELY(mScene))
998 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1002 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1004 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1005 FeedTouchPoint(point, timeStamp);
1008 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1010 FeedWheelEvent(wheelEvent);
1013 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1015 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);
1016 FeedKeyEvent(keyEvent);
1019 void Window::OnRotation(const RotationEvent& rotation)
1021 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1023 mRotationAngle = rotation.angle;
1024 mWindowWidth = rotation.width;
1025 mWindowHeight = rotation.height;
1027 mIsWindowRotating = true;
1028 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);
1030 // Notify that the orientation is changed
1031 mOrientation->OnOrientationChange(rotation);
1033 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1035 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1037 if(DALI_LIKELY(mAdaptor))
1039 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1042 Dali::Window handle(this);
1043 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1044 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1046 if(DALI_LIKELY(mAdaptor))
1048 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1052 void Window::OnRotationFinished()
1054 mIsWindowRotating = false;
1055 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1058 void Window::OnPause()
1062 mEventHandler->Pause();
1066 void Window::OnResume()
1070 mEventHandler->Resume();
1073 mSurface->SetFullSwapNextFrame();
1076 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1078 mAuxiliaryMessageSignal.Emit(key, value, options);
1081 void Window::OnAccessibilityEnabled()
1083 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1084 auto rootLayer = mScene.GetRootLayer();
1085 auto accessible = Accessibility::Accessible::Get(rootLayer);
1086 bridge->AddTopLevelWindow(accessible);
1088 if(!mVisible || mIconified)
1093 Dali::Window handle(this);
1094 bridge->WindowShown(handle);
1098 bridge->WindowFocused(handle);
1102 void Window::OnAccessibilityDisabled()
1104 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1105 auto rootLayer = mScene.GetRootLayer();
1106 auto accessible = Accessibility::Accessible::Get(rootLayer);
1107 bridge->RemoveTopLevelWindow(accessible);
1110 Vector2 Window::RecalculatePosition(const Vector2& position)
1112 Vector2 convertedPosition;
1114 switch(mRotationAngle)
1118 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1119 convertedPosition.y = position.x;
1124 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1125 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1130 convertedPosition.x = position.y;
1131 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1136 convertedPosition = position;
1140 return convertedPosition;
1143 Dali::Window Window::Get(Dali::Actor actor)
1145 Internal::Adaptor::Window* windowImpl = nullptr;
1147 if(Internal::Adaptor::Adaptor::IsAvailable())
1149 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1150 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1153 return Dali::Window(windowImpl);
1157 return Dali::Window();
1160 void Window::SetParent(Dali::Window& parent)
1162 if(DALI_UNLIKELY(parent))
1164 mParentWindow = parent;
1165 Dali::Window self = Dali::Window(this);
1166 // check circular parent window setting
1167 if(Dali::DevelWindow::GetParent(parent) == self)
1169 Dali::DevelWindow::Unparent(parent);
1171 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1175 void Window::SetParent(Dali::Window& parent, bool belowParent)
1177 if(DALI_UNLIKELY(parent))
1179 mParentWindow = parent;
1180 Dali::Window self = Dali::Window(this);
1181 // check circular parent window setting
1182 if(Dali::DevelWindow::GetParent(parent) == self)
1184 Dali::DevelWindow::Unparent(parent);
1186 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1190 void Window::Unparent()
1192 mWindowBase->SetParent(nullptr, false);
1193 mParentWindow.Reset();
1196 Dali::Window Window::GetParent()
1198 return mParentWindow;
1201 WindowOrientation Window::GetCurrentOrientation() const
1203 return ConvertToOrientation(mRotationAngle);
1206 int Window::GetPhysicalOrientation() const
1208 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1211 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1213 Dali::Vector<float>::SizeType count = orientations.Count();
1214 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1216 if(IsOrientationAvailable(orientations[index]) == false)
1218 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1223 int convertedAngle = ConvertToAngle(orientations[index]);
1225 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1227 if(mAvailableAngles[i] == convertedAngle)
1236 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1237 mAvailableAngles.push_back(convertedAngle);
1240 SetAvailableAnlges(mAvailableAngles);
1243 int32_t Window::GetNativeId() const
1245 return mWindowBase->GetNativeWindowId();
1248 void Window::RequestMoveToServer()
1250 mWindowBase->RequestMoveToServer();
1253 void Window::RequestResizeToServer(WindowResizeDirection direction)
1255 mWindowBase->RequestResizeToServer(direction);
1258 void Window::EnableFloatingMode(bool enable)
1260 mWindowBase->EnableFloatingMode(enable);
1263 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1265 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);
1266 mWindowBase->IncludeInputRegion(inputRegion);
1269 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1271 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);
1272 mWindowBase->ExcludeInputRegion(inputRegion);
1275 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1277 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1278 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1279 mWindowRotationAcknowledgement = needAcknowledgement;
1282 void Window::SendRotationCompletedAcknowledgement()
1284 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1285 if(mWindowRotationAcknowledgement)
1287 SetRotationCompletedAcknowledgement();
1291 bool Window::IsWindowRotating() const
1293 return mIsWindowRotating;
1296 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1298 return mLastKeyEvent;
1301 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1303 return mLastTouchEvent;
1306 } // namespace Adaptor
1308 } // namespace Internal