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);
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 Rect<int> convertRegion = RecalculateRect(inputRegion);
594 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window (%p), WinId (%d), SetInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
596 mWindowBase->SetInputRegion(convertRegion);
599 void Window::SetType(WindowType type)
601 mWindowBase->SetType(type);
604 WindowType Window::GetType() const
606 return mWindowBase->GetType();
609 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
611 WindowType type = mWindowBase->GetType();
612 if(type != WindowType::NOTIFICATION)
614 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
615 return WindowOperationResult::INVALID_OPERATION;
618 return mWindowBase->SetNotificationLevel(level);
621 WindowNotificationLevel Window::GetNotificationLevel() const
623 WindowType type = mWindowBase->GetType();
624 if(type != WindowType::NOTIFICATION)
626 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
627 return WindowNotificationLevel::NONE;
630 return mWindowBase->GetNotificationLevel();
633 void Window::SetOpaqueState(bool opaque)
635 mOpaqueState = opaque;
637 mWindowBase->SetOpaqueState(opaque);
639 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
642 bool Window::IsOpaqueState() const
647 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
649 return mWindowBase->SetScreenOffMode(screenOffMode);
652 WindowScreenOffMode Window::GetScreenOffMode() const
654 return mWindowBase->GetScreenOffMode();
657 WindowOperationResult Window::SetBrightness(int brightness)
659 if(brightness < 0 || brightness > 100)
661 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
662 return WindowOperationResult::INVALID_OPERATION;
665 return mWindowBase->SetBrightness(brightness);
668 int Window::GetBrightness() const
670 return mWindowBase->GetBrightness();
673 void Window::SetSize(Dali::Window::WindowSize size)
675 PositionSize oldRect = GetPositionSize();
677 PositionSize newRect;
678 newRect.width = size.GetWidth();
679 newRect.height = size.GetHeight();
681 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
682 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
684 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
686 Uint16Pair newSize(newRect.width, newRect.height);
688 mWindowWidth = newRect.width;
689 mWindowHeight = newRect.height;
691 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);
693 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
695 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
697 Dali::Window handle(this);
698 mResizeSignal.Emit(handle, newSize);
700 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
703 mSurface->SetFullSwapNextFrame();
705 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
708 Dali::Window::WindowSize Window::GetSize() const
710 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
713 void Window::SetPosition(Dali::Window::WindowPosition position)
715 PositionSize oldRect = mSurface->GetPositionSize();
716 int32_t newX = position.GetX();
717 int32_t newY = position.GetY();
719 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
721 if((oldRect.x != newX) || (oldRect.y != newY))
723 Dali::Window handle(this);
724 Dali::Window::WindowPosition newPosition(newX, newY);
726 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
727 mMovedSignal.Emit(handle, newPosition);
730 mSurface->SetFullSwapNextFrame();
732 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
735 Dali::Window::WindowPosition Window::GetPosition() const
737 PositionSize positionSize = GetPositionSize();
738 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
741 PositionSize Window::GetPositionSize() const
743 PositionSize positionSize = mSurface->GetPositionSize();
744 positionSize.width = mWindowWidth;
745 positionSize.height = mWindowHeight;
749 void Window::SetPositionSize(PositionSize positionSize)
754 PositionSize oldRect = GetPositionSize();
755 Dali::Window handle(this);
757 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
762 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
769 mWindowSurface->MoveResize(positionSize);
772 // When window is moved, emit Moved Signal
775 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
776 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
777 mMovedSignal.Emit(handle, position);
780 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
783 Uint16Pair newSize(positionSize.width, positionSize.height);
785 mWindowWidth = positionSize.width;
786 mWindowHeight = positionSize.height;
788 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
790 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
792 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
794 mResizeSignal.Emit(handle, newSize);
795 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
798 mSurface->SetFullSwapNextFrame();
800 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
803 Dali::Layer Window::GetRootLayer() const
805 return mScene.GetRootLayer();
808 void Window::SetTransparency(bool transparent)
810 mWindowSurface->SetTransparency(transparent);
813 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
815 return mWindowBase->GrabKey(key, grabMode);
818 bool Window::UngrabKey(Dali::KEY key)
820 return mWindowBase->UngrabKey(key);
823 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
825 return mWindowBase->GrabKeyList(key, grabMode, result);
828 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
830 return mWindowBase->UngrabKeyList(key, result);
833 void Window::OnIconifyChanged(bool iconified)
841 Dali::Window handle(this);
842 mVisibilityChangedSignal.Emit(handle, false);
843 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
845 WindowVisibilityObserver* observer(mAdaptor);
846 observer->OnWindowHidden();
849 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
857 Dali::Window handle(this);
858 mVisibilityChangedSignal.Emit(handle, true);
859 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
861 WindowVisibilityObserver* observer(mAdaptor);
862 observer->OnWindowShown();
865 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
868 mSurface->SetFullSwapNextFrame();
871 void Window::OnFocusChanged(bool focusIn)
873 Dali::Window handle(this);
874 mFocusChangeSignal.Emit(handle, focusIn);
876 mSurface->SetFullSwapNextFrame();
878 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
882 bridge->WindowFocused(handle);
886 bridge->WindowUnfocused(handle);
892 void Window::OnOutputTransformed()
894 PositionSize positionSize = GetPositionSize();
896 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
898 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
899 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
902 void Window::OnDeleteRequest()
904 mDeleteRequestSignal.Emit();
907 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
909 Dali::Window handle(this);
910 mTransitionEffectEventSignal.Emit(handle, state, type);
913 void Window::OnKeyboardRepeatSettingsChanged()
915 Dali::Window handle(this);
916 mKeyboardRepeatSettingsChangedSignal.Emit();
919 void Window::OnWindowRedrawRequest()
921 mAdaptor->RenderOnce();
924 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
929 Dali::Window handle(this);
931 PositionSize oldRect = GetPositionSize();
932 PositionSize newRect = positionSize;
934 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
939 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
946 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);
947 mWindowSurface->UpdatePositionSize(positionSize);
950 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
952 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
953 Dali::Window::WindowPosition position(newRect.x, newRect.y);
954 mMovedSignal.Emit(handle, position);
957 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
958 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
960 Uint16Pair newSize(newRect.width, newRect.height);
962 mWindowWidth = newRect.width;
963 mWindowHeight = newRect.height;
965 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
967 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
969 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
970 mResizeSignal.Emit(handle, newSize);
971 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
974 mSurface->SetFullSwapNextFrame();
976 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
979 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
981 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
982 FeedTouchPoint(point, timeStamp);
985 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
987 FeedWheelEvent(wheelEvent);
990 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
992 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);
993 FeedKeyEvent(keyEvent);
996 void Window::OnRotation(const RotationEvent& rotation)
998 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1000 mRotationAngle = rotation.angle;
1001 mWindowWidth = rotation.width;
1002 mWindowHeight = rotation.height;
1004 mIsWindowRotating = true;
1005 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);
1007 // Notify that the orientation is changed
1008 mOrientation->OnOrientationChange(rotation);
1010 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1012 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1014 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1016 Dali::Window handle(this);
1017 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1018 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1020 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1023 void Window::OnRotationFinished()
1025 mIsWindowRotating = false;
1026 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1029 void Window::OnPause()
1033 mEventHandler->Pause();
1037 void Window::OnResume()
1041 mEventHandler->Resume();
1044 mSurface->SetFullSwapNextFrame();
1047 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1049 mAuxiliaryMessageSignal.Emit(key, value, options);
1052 void Window::OnAccessibilityEnabled()
1054 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1055 auto rootLayer = mScene.GetRootLayer();
1056 auto accessible = Accessibility::Accessible::Get(rootLayer);
1057 bridge->AddTopLevelWindow(accessible);
1059 if(!mVisible || mIconified)
1064 Dali::Window handle(this);
1065 bridge->WindowShown(handle);
1069 bridge->WindowFocused(handle);
1073 void Window::OnAccessibilityDisabled()
1075 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1076 auto rootLayer = mScene.GetRootLayer();
1077 auto accessible = Accessibility::Accessible::Get(rootLayer);
1078 bridge->RemoveTopLevelWindow(accessible);
1081 void Window::RecalculateTouchPosition(Integration::Point& point)
1083 Vector2 position = point.GetScreenPosition();
1084 Vector2 convertedPosition;
1086 switch(mRotationAngle)
1090 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1091 convertedPosition.y = position.x;
1096 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1097 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1102 convertedPosition.x = position.y;
1103 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1108 convertedPosition = position;
1113 point.SetScreenPosition(convertedPosition);
1116 Dali::Window Window::Get(Dali::Actor actor)
1118 Internal::Adaptor::Window* windowImpl = nullptr;
1120 if(Internal::Adaptor::Adaptor::IsAvailable())
1122 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1123 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1126 return Dali::Window(windowImpl);
1130 return Dali::Window();
1133 void Window::SetParent(Dali::Window& parent)
1135 if(DALI_UNLIKELY(parent))
1137 mParentWindow = parent;
1138 Dali::Window self = Dali::Window(this);
1139 // check circular parent window setting
1140 if(Dali::DevelWindow::GetParent(parent) == self)
1142 Dali::DevelWindow::Unparent(parent);
1144 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1148 void Window::SetParent(Dali::Window& parent, bool belowParent)
1150 if(DALI_UNLIKELY(parent))
1152 mParentWindow = parent;
1153 Dali::Window self = Dali::Window(this);
1154 // check circular parent window setting
1155 if(Dali::DevelWindow::GetParent(parent) == self)
1157 Dali::DevelWindow::Unparent(parent);
1159 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1163 void Window::Unparent()
1165 mWindowBase->SetParent(nullptr, false);
1166 mParentWindow.Reset();
1169 Dali::Window Window::GetParent()
1171 return mParentWindow;
1174 WindowOrientation Window::GetCurrentOrientation() const
1176 return ConvertToOrientation(mRotationAngle);
1179 int Window::GetPhysicalOrientation() const
1181 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1184 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1186 Dali::Vector<float>::SizeType count = orientations.Count();
1187 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1189 if(IsOrientationAvailable(orientations[index]) == false)
1191 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1196 int convertedAngle = ConvertToAngle(orientations[index]);
1198 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1200 if(mAvailableAngles[i] == convertedAngle)
1209 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1210 mAvailableAngles.push_back(convertedAngle);
1213 SetAvailableAnlges(mAvailableAngles);
1216 int32_t Window::GetNativeId() const
1218 return mWindowBase->GetNativeWindowId();
1221 void Window::RequestMoveToServer()
1223 mWindowBase->RequestMoveToServer();
1226 void Window::RequestResizeToServer(WindowResizeDirection direction)
1228 mWindowBase->RequestResizeToServer(direction);
1231 void Window::EnableFloatingMode(bool enable)
1233 mWindowBase->EnableFloatingMode(enable);
1236 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1239 int screenWidth, screenHeight;
1241 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1243 if(mRotationAngle == 90)
1246 newRect.y = screenHeight - (rect.x + rect.width);
1247 newRect.width = rect.height;
1248 newRect.height = rect.width;
1250 else if(mRotationAngle == 180)
1252 newRect.x = screenWidth - (rect.x + rect.width);
1253 newRect.y = screenHeight - (rect.y + rect.height);
1254 newRect.width = rect.width;
1255 newRect.height = rect.height;
1257 else if(mRotationAngle == 270)
1259 newRect.x = screenWidth - (rect.y + rect.height);
1261 newRect.width = rect.height;
1262 newRect.height = rect.width;
1268 newRect.width = rect.width;
1269 newRect.height = rect.height;
1274 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1276 Rect<int> convertRegion = RecalculateRect(inputRegion);
1278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
1279 mWindowBase->IncludeInputRegion(convertRegion);
1282 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1284 Rect<int> convertRegion = RecalculateRect(inputRegion);
1286 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
1287 mWindowBase->ExcludeInputRegion(convertRegion);
1290 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1292 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1293 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1294 mWindowRotationAcknowledgement = needAcknowledgement;
1297 void Window::SendRotationCompletedAcknowledgement()
1299 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1300 if(mWindowRotationAcknowledgement)
1302 SetRotationCompletedAcknowledgement();
1306 bool Window::IsWindowRotating() const
1308 return mIsWindowRotating;
1311 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1313 return mLastKeyEvent;
1316 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1318 return mLastTouchEvent;
1321 } // namespace Adaptor
1323 } // namespace Internal