2 * Copyright (c) 2021 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 void Window::AddAvailableOrientation(WindowOrientation orientation)
283 if(IsOrientationAvailable(orientation) == false)
289 int convertedAngle = ConvertToAngle(orientation);
290 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
291 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
293 if(mAvailableAngles[i] == convertedAngle)
302 mAvailableAngles.push_back(convertedAngle);
303 SetAvailableAnlges(mAvailableAngles);
307 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
309 if(IsOrientationAvailable(orientation) == false)
314 int convertedAngle = ConvertToAngle(orientation);
315 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
316 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
317 iter != mAvailableAngles.end();
320 if(*iter == convertedAngle)
322 mAvailableAngles.erase(iter);
327 SetAvailableAnlges(mAvailableAngles);
330 void Window::SetPreferredOrientation(WindowOrientation orientation)
332 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
334 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
337 mPreferredAngle = ConvertToAngle(orientation);
338 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
339 mWindowBase->SetPreferredAngle(mPreferredAngle);
342 WindowOrientation Window::GetPreferredOrientation()
344 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
345 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
346 return preferredOrientation;
349 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
351 int angle = ConvertToAngle(orientation);
352 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
355 void Window::SetAvailableAnlges(const std::vector<int>& angles)
357 if(angles.size() > 4)
359 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
363 mWindowBase->SetAvailableAnlges(angles);
366 int Window::ConvertToAngle(WindowOrientation orientation)
368 int convertAngle = static_cast<int>(orientation);
369 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
373 case WindowOrientation::LANDSCAPE:
378 case WindowOrientation::PORTRAIT:
383 case WindowOrientation::LANDSCAPE_INVERSE:
388 case WindowOrientation::PORTRAIT_INVERSE:
393 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
403 WindowOrientation Window::ConvertToOrientation(int angle) const
405 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
406 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
412 orientation = WindowOrientation::LANDSCAPE;
417 orientation = WindowOrientation::PORTRAIT;
422 orientation = WindowOrientation::LANDSCAPE_INVERSE;
427 orientation = WindowOrientation::PORTRAIT_INVERSE;
432 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
440 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
442 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
444 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
450 Dali::Any Window::GetNativeHandle() const
452 return mWindowSurface->GetNativeWindow();
455 void Window::SetAcceptFocus(bool accept)
457 mIsFocusAcceptable = accept;
459 mWindowBase->SetAcceptFocus(accept);
462 bool Window::IsFocusAcceptable() const
464 return mIsFocusAcceptable;
475 Dali::Window handle(this);
476 mVisibilityChangedSignal.Emit(handle, true);
477 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
479 WindowVisibilityObserver* observer(mAdaptor);
480 observer->OnWindowShown();
483 mSurface->SetFullSwapNextFrame();
485 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
496 Dali::Window handle(this);
497 mVisibilityChangedSignal.Emit(handle, false);
498 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
500 WindowVisibilityObserver* observer(mAdaptor);
501 observer->OnWindowHidden();
504 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
507 bool Window::IsVisible() const
509 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
510 return mVisible && !mIconified;
513 unsigned int Window::GetSupportedAuxiliaryHintCount() const
515 return mWindowBase->GetSupportedAuxiliaryHintCount();
518 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
520 return mWindowBase->GetSupportedAuxiliaryHint(index);
523 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
525 return mWindowBase->AddAuxiliaryHint(hint, value);
528 bool Window::RemoveAuxiliaryHint(unsigned int id)
530 return mWindowBase->RemoveAuxiliaryHint(id);
533 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
535 return mWindowBase->SetAuxiliaryHintValue(id, value);
538 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
540 return mWindowBase->GetAuxiliaryHintValue(id);
543 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
545 return mWindowBase->GetAuxiliaryHintId(hint);
548 void Window::SetInputRegion(const Rect<int>& inputRegion)
550 Rect<int> convertRegion = RecalculateRect(inputRegion);
552 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);
554 mWindowBase->SetInputRegion(convertRegion);
557 void Window::SetType(WindowType type)
559 mWindowBase->SetType(type);
562 WindowType Window::GetType() const
564 return mWindowBase->GetType();
567 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
569 WindowType type = mWindowBase->GetType();
570 if(type != WindowType::NOTIFICATION)
572 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
573 return WindowOperationResult::INVALID_OPERATION;
576 return mWindowBase->SetNotificationLevel(level);
579 WindowNotificationLevel Window::GetNotificationLevel() const
581 WindowType type = mWindowBase->GetType();
582 if(type != WindowType::NOTIFICATION)
584 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
585 return WindowNotificationLevel::NONE;
588 return mWindowBase->GetNotificationLevel();
591 void Window::SetOpaqueState(bool opaque)
593 mOpaqueState = opaque;
595 mWindowBase->SetOpaqueState(opaque);
597 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
600 bool Window::IsOpaqueState() const
605 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
607 return mWindowBase->SetScreenOffMode(screenOffMode);
610 WindowScreenOffMode Window::GetScreenOffMode() const
612 return mWindowBase->GetScreenOffMode();
615 WindowOperationResult Window::SetBrightness(int brightness)
617 if(brightness < 0 || brightness > 100)
619 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
620 return WindowOperationResult::INVALID_OPERATION;
623 return mWindowBase->SetBrightness(brightness);
626 int Window::GetBrightness() const
628 return mWindowBase->GetBrightness();
631 void Window::SetSize(Dali::Window::WindowSize size)
633 PositionSize oldRect = mSurface->GetPositionSize();
635 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
637 PositionSize newRect = mSurface->GetPositionSize();
639 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
640 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
642 Uint16Pair newSize(newRect.width, newRect.height);
646 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
648 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
650 Dali::Window handle(this);
651 mResizeSignal.Emit(handle, newSize);
653 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
656 mSurface->SetFullSwapNextFrame();
658 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
661 Dali::Window::WindowSize Window::GetSize() const
663 PositionSize positionSize = mSurface->GetPositionSize();
665 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
668 void Window::SetPosition(Dali::Window::WindowPosition position)
670 PositionSize oldRect = mSurface->GetPositionSize();
672 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
674 mSurface->SetFullSwapNextFrame();
676 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
679 Dali::Window::WindowPosition Window::GetPosition() const
681 PositionSize positionSize = mSurface->GetPositionSize();
683 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
686 PositionSize Window::GetPositionSize() const
688 return mSurface->GetPositionSize();
691 void Window::SetPositionSize(PositionSize positionSize)
693 PositionSize oldRect = mSurface->GetPositionSize();
695 mWindowSurface->MoveResize(positionSize);
697 PositionSize newRect = mSurface->GetPositionSize();
699 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
700 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
702 Uint16Pair newSize(newRect.width, newRect.height);
706 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
708 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
709 Dali::Window handle(this);
710 mResizeSignal.Emit(handle, newSize);
711 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
714 mSurface->SetFullSwapNextFrame();
716 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
719 Dali::Layer Window::GetRootLayer() const
721 return mScene.GetRootLayer();
724 void Window::SetTransparency(bool transparent)
726 mWindowSurface->SetTransparency(transparent);
729 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
731 return mWindowBase->GrabKey(key, grabMode);
734 bool Window::UngrabKey(Dali::KEY key)
736 return mWindowBase->UngrabKey(key);
739 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
741 return mWindowBase->GrabKeyList(key, grabMode, result);
744 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
746 return mWindowBase->UngrabKeyList(key, result);
749 void Window::OnIconifyChanged(bool iconified)
757 Dali::Window handle(this);
758 mVisibilityChangedSignal.Emit(handle, false);
759 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
761 WindowVisibilityObserver* observer(mAdaptor);
762 observer->OnWindowHidden();
765 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
773 Dali::Window handle(this);
774 mVisibilityChangedSignal.Emit(handle, true);
775 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
777 WindowVisibilityObserver* observer(mAdaptor);
778 observer->OnWindowShown();
781 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
784 mSurface->SetFullSwapNextFrame();
787 void Window::OnFocusChanged(bool focusIn)
789 Dali::Window handle(this);
790 mFocusChangeSignal.Emit(handle, focusIn);
792 mSurface->SetFullSwapNextFrame();
794 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
798 bridge->WindowFocused(handle);
802 bridge->WindowUnfocused(handle);
808 void Window::OnOutputTransformed()
810 PositionSize positionSize = mSurface->GetPositionSize();
812 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
813 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
815 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
816 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
819 void Window::OnDeleteRequest()
821 mDeleteRequestSignal.Emit();
824 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
826 Dali::Window handle(this);
827 mTransitionEffectEventSignal.Emit(handle, state, type);
830 void Window::OnKeyboardRepeatSettingsChanged()
832 Dali::Window handle(this);
833 mKeyboardRepeatSettingsChangedSignal.Emit();
836 void Window::OnWindowRedrawRequest()
838 mAdaptor->RenderOnce();
841 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
843 PositionSize oldRect = mSurface->GetPositionSize();
845 mWindowSurface->UpdatePositionSize(positionSize);
847 PositionSize newRect = positionSize;
849 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
850 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
852 Uint16Pair newSize(newRect.width, newRect.height);
856 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
858 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
859 Dali::Window handle(this);
860 mResizeSignal.Emit(handle, newSize);
861 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
864 mSurface->SetFullSwapNextFrame();
866 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
869 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
871 FeedTouchPoint(point, timeStamp);
874 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
876 FeedWheelEvent(wheelEvent);
879 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
881 FeedKeyEvent(keyEvent);
884 void Window::OnRotation(const RotationEvent& rotation)
886 mRotationAngle = rotation.angle;
887 mWindowWidth = rotation.width;
888 mWindowHeight = rotation.height;
890 // Notify that the orientation is changed
891 mOrientation->OnOrientationChange(rotation);
893 mWindowSurface->RequestRotation(mRotationAngle, mWindowWidth, mWindowHeight);
895 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
896 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
898 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
900 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
902 Dali::Window handle(this);
903 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
905 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
908 void Window::OnPause()
912 mEventHandler->Pause();
916 void Window::OnResume()
920 mEventHandler->Resume();
923 mSurface->SetFullSwapNextFrame();
926 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
928 mAuxiliaryMessageSignal.Emit(key, value, options);
931 void Window::OnAccessibilityEnabled()
933 auto bridge = Accessibility::Bridge::GetCurrentBridge();
934 auto rootLayer = mScene.GetRootLayer();
935 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
936 bridge->AddTopLevelWindow(accessible);
940 Dali::Window handle(this);
941 bridge->WindowFocused(handle);
945 void Window::OnAccessibilityDisabled()
947 auto bridge = Accessibility::Bridge::GetCurrentBridge();
948 auto rootLayer = mScene.GetRootLayer();
949 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
950 bridge->RemoveTopLevelWindow(accessible);
953 void Window::RecalculateTouchPosition(Integration::Point& point)
955 Vector2 position = point.GetScreenPosition();
956 Vector2 convertedPosition;
958 switch(mRotationAngle)
962 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
963 convertedPosition.y = position.x;
968 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
969 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
974 convertedPosition.x = position.y;
975 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
980 convertedPosition = position;
985 point.SetScreenPosition(convertedPosition);
988 Dali::Window Window::Get(Dali::Actor actor)
990 Internal::Adaptor::Window* windowImpl = nullptr;
992 if(Internal::Adaptor::Adaptor::IsAvailable())
994 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
995 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
998 return Dali::Window(windowImpl);
1002 return Dali::Window();
1005 void Window::SetParent(Dali::Window& parent)
1007 if(DALI_UNLIKELY(parent))
1009 mParentWindow = parent;
1010 Dali::Window self = Dali::Window(this);
1011 // check circular parent window setting
1012 if(Dali::DevelWindow::GetParent(parent) == self)
1014 Dali::DevelWindow::Unparent(parent);
1016 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1020 void Window::SetParent(Dali::Window& parent, bool belowParent)
1022 if(DALI_UNLIKELY(parent))
1024 mParentWindow = parent;
1025 Dali::Window self = Dali::Window(this);
1026 // check circular parent window setting
1027 if(Dali::DevelWindow::GetParent(parent) == self)
1029 Dali::DevelWindow::Unparent(parent);
1031 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1035 void Window::Unparent()
1037 mWindowBase->SetParent(nullptr, false);
1038 mParentWindow.Reset();
1041 Dali::Window Window::GetParent()
1043 return mParentWindow;
1046 WindowOrientation Window::GetCurrentOrientation() const
1048 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1049 return ConvertToOrientation(mRotationAngle);
1052 int Window::GetPhysicalOrientation() const
1054 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1057 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1059 Dali::Vector<float>::SizeType count = orientations.Count();
1060 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1062 if(IsOrientationAvailable(orientations[index]) == false)
1064 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1069 int convertedAngle = ConvertToAngle(orientations[index]);
1071 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1073 if(mAvailableAngles[i] == convertedAngle)
1082 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1083 mAvailableAngles.push_back(convertedAngle);
1086 SetAvailableAnlges(mAvailableAngles);
1089 int32_t Window::GetNativeId() const
1091 return mWindowBase->GetNativeWindowId();
1094 void Window::RequestMoveToServer()
1096 mWindowBase->RequestMoveToServer();
1099 void Window::RequestResizeToServer(WindowResizeDirection direction)
1101 mWindowBase->RequestResizeToServer(direction);
1104 void Window::EnableFloatingMode(bool enable)
1106 mWindowBase->EnableFloatingMode(enable);
1109 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1112 int screenWidth, screenHeight;
1114 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1116 if(mRotationAngle == 90)
1119 newRect.y = screenHeight - (rect.x + rect.width);
1120 newRect.width = rect.height;
1121 newRect.height = rect.width;
1123 else if(mRotationAngle == 180)
1125 newRect.x = screenWidth - (rect.x + rect.width);
1126 newRect.y = screenHeight - (rect.y + rect.height);
1127 newRect.width = rect.width;
1128 newRect.height = rect.height;
1130 else if(mRotationAngle == 270)
1132 newRect.x = screenWidth - (rect.y + rect.height);
1134 newRect.width = rect.height;
1135 newRect.height = rect.width;
1141 newRect.width = rect.width;
1142 newRect.height = rect.height;
1147 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1149 Rect<int> convertRegion = RecalculateRect(inputRegion);
1151 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);
1152 mWindowBase->IncludeInputRegion(convertRegion);
1155 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1157 Rect<int> convertRegion = RecalculateRect(inputRegion);
1159 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);
1160 mWindowBase->ExcludeInputRegion(convertRegion);
1163 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1165 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1166 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1167 mWindowRotationAcknowledgement = needAcknowledgement;
1170 void Window::SendRotationCompletedAcknowledgement()
1172 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1173 if(mWindowRotationAcknowledgement)
1175 SetRotationCompletedAcknowledgement();
1179 } // namespace Adaptor
1181 } // namespace Internal