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/integration-api/core.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/public-api/actors/actor.h>
26 #include <dali/public-api/actors/camera-actor.h>
27 #include <dali/public-api/actors/layer.h>
28 #include <dali/public-api/adaptor-framework/window-enumerations.h>
29 #include <dali/public-api/render-tasks/render-task-list.h>
30 #include <dali/public-api/render-tasks/render-task.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),
79 mIsTransparent(false),
80 mIsFocusAcceptable(true),
83 mWindowRotationAcknowledgement(false),
86 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
90 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
92 mDeleteRequestSignal(),
95 mVisibilityChangedSignal(),
96 mTransitionEffectEventSignal(),
97 mKeyboardRepeatSettingsChangedSignal(),
98 mAuxiliaryMessageSignal()
106 auto bridge = Accessibility::Bridge::GetCurrentBridge();
107 auto rootLayer = mScene.GetRootLayer();
108 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
109 bridge->RemoveTopLevelWindow(accessible);
114 mAdaptor->RemoveWindow(this);
119 mEventHandler->RemoveObserver(*this);
123 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
125 // Create a window render surface
126 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
127 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
128 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
131 mWindowBase = mWindowSurface->GetWindowBase();
134 mWindowBase->SetType(type);
136 // Initialize for Ime window type
137 if(type == WindowType::IME)
139 mWindowBase->InitializeIme();
140 mWindowSurface->InitializeImeSurface();
144 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
145 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
146 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
147 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
148 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
149 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
150 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
151 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
153 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
155 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
157 SetClass(name, className);
159 mOrientation = Orientation::New(this);
161 // Get OrientationMode
162 int screenWidth, screenHeight;
163 WindowSystem::GetScreenSize(screenWidth, screenHeight);
164 if(screenWidth > screenHeight)
166 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
170 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
173 mNativeWindowId = mWindowBase->GetNativeWindowId();
176 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
178 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
179 mEventHandler->AddObserver(*this);
181 // Add Window to bridge for ATSPI
182 auto bridge = Accessibility::Bridge::GetCurrentBridge();
185 auto rootLayer = mScene.GetRootLayer();
186 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
187 bridge->AddTopLevelWindow(accessible);
190 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
191 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
193 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
194 // The show must be called after the adaptor is initialized.
198 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
200 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
203 void Window::SetClass(std::string name, std::string className)
206 mClassName = className;
207 mWindowBase->SetClass(name, className);
210 std::string Window::GetClassName() const
217 mWindowBase->Raise();
219 mSurface->SetFullSwapNextFrame();
221 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
226 mWindowBase->Lower();
228 mSurface->SetFullSwapNextFrame();
230 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
233 void Window::Activate()
235 mWindowBase->Activate();
237 mSurface->SetFullSwapNextFrame();
239 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
242 void Window::Maximize(bool maximize)
244 mWindowBase->Maximize(maximize);
246 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
249 bool Window::IsMaximized() const
251 return mWindowBase->IsMaximized();
254 void Window::Minimize(bool minimize)
256 mWindowBase->Minimize(minimize);
258 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
261 bool Window::IsMinimized() const
263 return mWindowBase->IsMinimized();
266 uint32_t Window::GetLayerCount() const
268 return mScene.GetLayerCount();
271 Dali::Layer Window::GetLayer(uint32_t depth) const
273 return mScene.GetLayer(depth);
276 Dali::RenderTaskList Window::GetRenderTaskList() const
278 return mScene.GetRenderTaskList();
281 std::string Window::GetNativeResourceId() const
283 return mWindowBase->GetNativeWindowResourceId();
286 void Window::AddAvailableOrientation(WindowOrientation orientation)
288 if(IsOrientationAvailable(orientation) == false)
294 int convertedAngle = ConvertToAngle(orientation);
295 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
296 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
298 if(mAvailableAngles[i] == convertedAngle)
307 mAvailableAngles.push_back(convertedAngle);
308 SetAvailableAnlges(mAvailableAngles);
312 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
314 if(IsOrientationAvailable(orientation) == false)
319 int convertedAngle = ConvertToAngle(orientation);
320 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
321 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
322 iter != mAvailableAngles.end();
325 if(*iter == convertedAngle)
327 mAvailableAngles.erase(iter);
332 SetAvailableAnlges(mAvailableAngles);
335 void Window::SetPreferredOrientation(WindowOrientation orientation)
337 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
339 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
342 mPreferredAngle = ConvertToAngle(orientation);
343 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
344 mWindowBase->SetPreferredAngle(mPreferredAngle);
347 WindowOrientation Window::GetPreferredOrientation()
349 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
350 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
351 return preferredOrientation;
354 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
356 int angle = ConvertToAngle(orientation);
357 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
360 void Window::SetAvailableAnlges(const std::vector<int>& angles)
362 if(angles.size() > 4)
364 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
368 mWindowBase->SetAvailableAnlges(angles);
371 int Window::ConvertToAngle(WindowOrientation orientation)
373 int convertAngle = static_cast<int>(orientation);
374 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
378 case WindowOrientation::LANDSCAPE:
383 case WindowOrientation::PORTRAIT:
388 case WindowOrientation::LANDSCAPE_INVERSE:
393 case WindowOrientation::PORTRAIT_INVERSE:
398 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
408 WindowOrientation Window::ConvertToOrientation(int angle) const
410 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
411 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
417 orientation = WindowOrientation::LANDSCAPE;
422 orientation = WindowOrientation::PORTRAIT;
427 orientation = WindowOrientation::LANDSCAPE_INVERSE;
432 orientation = WindowOrientation::PORTRAIT_INVERSE;
437 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
445 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
447 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
449 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
455 Dali::Any Window::GetNativeHandle() const
457 return mWindowSurface->GetNativeWindow();
460 void Window::SetAcceptFocus(bool accept)
462 mIsFocusAcceptable = accept;
464 mWindowBase->SetAcceptFocus(accept);
467 bool Window::IsFocusAcceptable() const
469 return mIsFocusAcceptable;
480 Dali::Window handle(this);
481 mVisibilityChangedSignal.Emit(handle, true);
482 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
484 WindowVisibilityObserver* observer(mAdaptor);
485 observer->OnWindowShown();
488 mSurface->SetFullSwapNextFrame();
490 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
501 Dali::Window handle(this);
502 mVisibilityChangedSignal.Emit(handle, false);
503 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
505 WindowVisibilityObserver* observer(mAdaptor);
506 observer->OnWindowHidden();
509 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
512 bool Window::IsVisible() const
514 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
515 return mVisible && !mIconified;
518 unsigned int Window::GetSupportedAuxiliaryHintCount() const
520 return mWindowBase->GetSupportedAuxiliaryHintCount();
523 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
525 return mWindowBase->GetSupportedAuxiliaryHint(index);
528 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
530 return mWindowBase->AddAuxiliaryHint(hint, value);
533 bool Window::RemoveAuxiliaryHint(unsigned int id)
535 return mWindowBase->RemoveAuxiliaryHint(id);
538 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
540 return mWindowBase->SetAuxiliaryHintValue(id, value);
543 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
545 return mWindowBase->GetAuxiliaryHintValue(id);
548 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
550 return mWindowBase->GetAuxiliaryHintId(hint);
553 void Window::SetInputRegion(const Rect<int>& inputRegion)
555 Rect<int> convertRegion = RecalculateRect(inputRegion);
557 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);
559 mWindowBase->SetInputRegion(convertRegion);
562 void Window::SetType(WindowType type)
564 mWindowBase->SetType(type);
567 WindowType Window::GetType() const
569 return mWindowBase->GetType();
572 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
574 WindowType type = mWindowBase->GetType();
575 if(type != WindowType::NOTIFICATION)
577 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
578 return WindowOperationResult::INVALID_OPERATION;
581 return mWindowBase->SetNotificationLevel(level);
584 WindowNotificationLevel Window::GetNotificationLevel() const
586 WindowType type = mWindowBase->GetType();
587 if(type != WindowType::NOTIFICATION)
589 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
590 return WindowNotificationLevel::NONE;
593 return mWindowBase->GetNotificationLevel();
596 void Window::SetOpaqueState(bool opaque)
598 mOpaqueState = opaque;
600 mWindowBase->SetOpaqueState(opaque);
602 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
605 bool Window::IsOpaqueState() const
610 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
612 return mWindowBase->SetScreenOffMode(screenOffMode);
615 WindowScreenOffMode Window::GetScreenOffMode() const
617 return mWindowBase->GetScreenOffMode();
620 WindowOperationResult Window::SetBrightness(int brightness)
622 if(brightness < 0 || brightness > 100)
624 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
625 return WindowOperationResult::INVALID_OPERATION;
628 return mWindowBase->SetBrightness(brightness);
631 int Window::GetBrightness() const
633 return mWindowBase->GetBrightness();
636 void Window::SetSize(Dali::Window::WindowSize size)
638 PositionSize oldRect = mSurface->GetPositionSize();
640 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
642 PositionSize newRect = mSurface->GetPositionSize();
644 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
645 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
647 Uint16Pair newSize(newRect.width, newRect.height);
651 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
653 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
655 Dali::Window handle(this);
656 mResizeSignal.Emit(handle, newSize);
658 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
661 mSurface->SetFullSwapNextFrame();
663 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
666 Dali::Window::WindowSize Window::GetSize() const
668 PositionSize positionSize = mSurface->GetPositionSize();
670 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
673 void Window::SetPosition(Dali::Window::WindowPosition position)
675 PositionSize oldRect = mSurface->GetPositionSize();
677 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
679 mSurface->SetFullSwapNextFrame();
681 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
684 Dali::Window::WindowPosition Window::GetPosition() const
686 PositionSize positionSize = mSurface->GetPositionSize();
688 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
691 PositionSize Window::GetPositionSize() const
693 return mSurface->GetPositionSize();
696 void Window::SetPositionSize(PositionSize positionSize)
698 PositionSize oldRect = mSurface->GetPositionSize();
700 mWindowSurface->MoveResize(positionSize);
702 PositionSize newRect = mSurface->GetPositionSize();
704 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
705 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
707 Uint16Pair newSize(newRect.width, newRect.height);
711 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
713 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
714 Dali::Window handle(this);
715 mResizeSignal.Emit(handle, newSize);
716 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
719 mSurface->SetFullSwapNextFrame();
721 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
724 Dali::Layer Window::GetRootLayer() const
726 return mScene.GetRootLayer();
729 void Window::SetTransparency(bool transparent)
731 mWindowSurface->SetTransparency(transparent);
734 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
736 return mWindowBase->GrabKey(key, grabMode);
739 bool Window::UngrabKey(Dali::KEY key)
741 return mWindowBase->UngrabKey(key);
744 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
746 return mWindowBase->GrabKeyList(key, grabMode, result);
749 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
751 return mWindowBase->UngrabKeyList(key, result);
754 void Window::OnIconifyChanged(bool iconified)
762 Dali::Window handle(this);
763 mVisibilityChangedSignal.Emit(handle, false);
764 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
766 WindowVisibilityObserver* observer(mAdaptor);
767 observer->OnWindowHidden();
770 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
778 Dali::Window handle(this);
779 mVisibilityChangedSignal.Emit(handle, true);
780 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
782 WindowVisibilityObserver* observer(mAdaptor);
783 observer->OnWindowShown();
786 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
789 mSurface->SetFullSwapNextFrame();
792 void Window::OnFocusChanged(bool focusIn)
794 Dali::Window handle(this);
795 mFocusChangeSignal.Emit(handle, focusIn);
797 mSurface->SetFullSwapNextFrame();
799 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
803 bridge->WindowFocused(handle);
807 bridge->WindowUnfocused(handle);
813 void Window::OnOutputTransformed()
815 PositionSize positionSize = mSurface->GetPositionSize();
817 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
818 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
820 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
821 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
824 void Window::OnDeleteRequest()
826 mDeleteRequestSignal.Emit();
829 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
831 Dali::Window handle(this);
832 mTransitionEffectEventSignal.Emit(handle, state, type);
835 void Window::OnKeyboardRepeatSettingsChanged()
837 Dali::Window handle(this);
838 mKeyboardRepeatSettingsChangedSignal.Emit();
841 void Window::OnWindowRedrawRequest()
843 mAdaptor->RenderOnce();
846 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
848 PositionSize oldRect = mSurface->GetPositionSize();
850 mWindowSurface->UpdatePositionSize(positionSize);
852 PositionSize newRect = positionSize;
854 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
855 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
857 Uint16Pair newSize(newRect.width, newRect.height);
861 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
863 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
864 Dali::Window handle(this);
865 mResizeSignal.Emit(handle, newSize);
866 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
869 mSurface->SetFullSwapNextFrame();
871 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
874 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
876 FeedTouchPoint(point, timeStamp);
879 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
881 FeedWheelEvent(wheelEvent);
884 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
886 FeedKeyEvent(keyEvent);
889 void Window::OnRotation(const RotationEvent& rotation)
891 mRotationAngle = rotation.angle;
892 mWindowWidth = rotation.width;
893 mWindowHeight = rotation.height;
895 // Notify that the orientation is changed
896 mOrientation->OnOrientationChange(rotation);
898 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
900 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
901 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
903 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
905 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
907 Dali::Window handle(this);
908 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
910 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
913 void Window::OnPause()
917 mEventHandler->Pause();
921 void Window::OnResume()
925 mEventHandler->Resume();
928 mSurface->SetFullSwapNextFrame();
931 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
933 mAuxiliaryMessageSignal.Emit(key, value, options);
936 void Window::OnAccessibilityEnabled()
938 auto bridge = Accessibility::Bridge::GetCurrentBridge();
939 auto rootLayer = mScene.GetRootLayer();
940 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
941 bridge->AddTopLevelWindow(accessible);
945 Dali::Window handle(this);
946 bridge->WindowFocused(handle);
950 void Window::OnAccessibilityDisabled()
952 auto bridge = Accessibility::Bridge::GetCurrentBridge();
953 auto rootLayer = mScene.GetRootLayer();
954 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
955 bridge->RemoveTopLevelWindow(accessible);
958 void Window::RecalculateTouchPosition(Integration::Point& point)
960 Vector2 position = point.GetScreenPosition();
961 Vector2 convertedPosition;
963 switch(mRotationAngle)
967 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
968 convertedPosition.y = position.x;
973 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
974 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
979 convertedPosition.x = position.y;
980 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
985 convertedPosition = position;
990 point.SetScreenPosition(convertedPosition);
993 Dali::Window Window::Get(Dali::Actor actor)
995 Internal::Adaptor::Window* windowImpl = nullptr;
997 if(Internal::Adaptor::Adaptor::IsAvailable())
999 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1000 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1003 return Dali::Window(windowImpl);
1007 return Dali::Window();
1010 void Window::SetParent(Dali::Window& parent)
1012 if(DALI_UNLIKELY(parent))
1014 mParentWindow = parent;
1015 Dali::Window self = Dali::Window(this);
1016 // check circular parent window setting
1017 if(Dali::DevelWindow::GetParent(parent) == self)
1019 Dali::DevelWindow::Unparent(parent);
1021 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1025 void Window::SetParent(Dali::Window& parent, bool belowParent)
1027 if(DALI_UNLIKELY(parent))
1029 mParentWindow = parent;
1030 Dali::Window self = Dali::Window(this);
1031 // check circular parent window setting
1032 if(Dali::DevelWindow::GetParent(parent) == self)
1034 Dali::DevelWindow::Unparent(parent);
1036 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1040 void Window::Unparent()
1042 mWindowBase->SetParent(nullptr, false);
1043 mParentWindow.Reset();
1046 Dali::Window Window::GetParent()
1048 return mParentWindow;
1051 WindowOrientation Window::GetCurrentOrientation() const
1053 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1054 return ConvertToOrientation(mRotationAngle);
1057 int Window::GetPhysicalOrientation() const
1059 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1062 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1064 Dali::Vector<float>::SizeType count = orientations.Count();
1065 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1067 if(IsOrientationAvailable(orientations[index]) == false)
1069 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1074 int convertedAngle = ConvertToAngle(orientations[index]);
1076 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1078 if(mAvailableAngles[i] == convertedAngle)
1087 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1088 mAvailableAngles.push_back(convertedAngle);
1091 SetAvailableAnlges(mAvailableAngles);
1094 int32_t Window::GetNativeId() const
1096 return mWindowBase->GetNativeWindowId();
1099 void Window::RequestMoveToServer()
1101 mWindowBase->RequestMoveToServer();
1104 void Window::RequestResizeToServer(WindowResizeDirection direction)
1106 mWindowBase->RequestResizeToServer(direction);
1109 void Window::EnableFloatingMode(bool enable)
1111 mWindowBase->EnableFloatingMode(enable);
1114 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1117 int screenWidth, screenHeight;
1119 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1121 if(mRotationAngle == 90)
1124 newRect.y = screenHeight - (rect.x + rect.width);
1125 newRect.width = rect.height;
1126 newRect.height = rect.width;
1128 else if(mRotationAngle == 180)
1130 newRect.x = screenWidth - (rect.x + rect.width);
1131 newRect.y = screenHeight - (rect.y + rect.height);
1132 newRect.width = rect.width;
1133 newRect.height = rect.height;
1135 else if(mRotationAngle == 270)
1137 newRect.x = screenWidth - (rect.y + rect.height);
1139 newRect.width = rect.height;
1140 newRect.height = rect.width;
1146 newRect.width = rect.width;
1147 newRect.height = rect.height;
1152 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1154 Rect<int> convertRegion = RecalculateRect(inputRegion);
1156 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);
1157 mWindowBase->IncludeInputRegion(convertRegion);
1160 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1162 Rect<int> convertRegion = RecalculateRect(inputRegion);
1164 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);
1165 mWindowBase->ExcludeInputRegion(convertRegion);
1168 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1170 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1171 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1172 mWindowRotationAcknowledgement = needAcknowledgement;
1175 void Window::SendRotationCompletedAcknowledgement()
1177 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1178 if(mWindowRotationAcknowledgement)
1180 SetRotationCompletedAcknowledgement();
1184 } // namespace Adaptor
1186 } // namespace Internal