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::EmitAccessibilityHighlightSignal(bool highlight)
362 Dali::Window handle(this);
363 mAccessibilityHighlightSignal.Emit(handle, highlight);
366 void Window::SetAvailableAnlges(const std::vector<int>& angles)
368 if(angles.size() > 4)
370 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
374 mWindowBase->SetAvailableAnlges(angles);
377 int Window::ConvertToAngle(WindowOrientation orientation)
379 int convertAngle = static_cast<int>(orientation);
380 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
384 case WindowOrientation::LANDSCAPE:
389 case WindowOrientation::PORTRAIT:
394 case WindowOrientation::LANDSCAPE_INVERSE:
399 case WindowOrientation::PORTRAIT_INVERSE:
404 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
414 WindowOrientation Window::ConvertToOrientation(int angle) const
416 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
417 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
423 orientation = WindowOrientation::LANDSCAPE;
428 orientation = WindowOrientation::PORTRAIT;
433 orientation = WindowOrientation::LANDSCAPE_INVERSE;
438 orientation = WindowOrientation::PORTRAIT_INVERSE;
443 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
451 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
453 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
455 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
461 Dali::Any Window::GetNativeHandle() const
463 return mWindowSurface->GetNativeWindow();
466 void Window::SetAcceptFocus(bool accept)
468 mIsFocusAcceptable = accept;
470 mWindowBase->SetAcceptFocus(accept);
473 bool Window::IsFocusAcceptable() const
475 return mIsFocusAcceptable;
486 Dali::Window handle(this);
487 mVisibilityChangedSignal.Emit(handle, true);
488 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
490 WindowVisibilityObserver* observer(mAdaptor);
491 observer->OnWindowShown();
494 mSurface->SetFullSwapNextFrame();
496 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
507 Dali::Window handle(this);
508 mVisibilityChangedSignal.Emit(handle, false);
509 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
511 WindowVisibilityObserver* observer(mAdaptor);
512 observer->OnWindowHidden();
515 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
518 bool Window::IsVisible() const
520 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
521 return mVisible && !mIconified;
524 unsigned int Window::GetSupportedAuxiliaryHintCount() const
526 return mWindowBase->GetSupportedAuxiliaryHintCount();
529 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
531 return mWindowBase->GetSupportedAuxiliaryHint(index);
534 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
536 return mWindowBase->AddAuxiliaryHint(hint, value);
539 bool Window::RemoveAuxiliaryHint(unsigned int id)
541 return mWindowBase->RemoveAuxiliaryHint(id);
544 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
546 return mWindowBase->SetAuxiliaryHintValue(id, value);
549 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
551 return mWindowBase->GetAuxiliaryHintValue(id);
554 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
556 return mWindowBase->GetAuxiliaryHintId(hint);
559 void Window::SetInputRegion(const Rect<int>& inputRegion)
561 Rect<int> convertRegion = RecalculateRect(inputRegion);
563 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);
565 mWindowBase->SetInputRegion(convertRegion);
568 void Window::SetType(WindowType type)
570 mWindowBase->SetType(type);
573 WindowType Window::GetType() const
575 return mWindowBase->GetType();
578 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
580 WindowType type = mWindowBase->GetType();
581 if(type != WindowType::NOTIFICATION)
583 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
584 return WindowOperationResult::INVALID_OPERATION;
587 return mWindowBase->SetNotificationLevel(level);
590 WindowNotificationLevel Window::GetNotificationLevel() const
592 WindowType type = mWindowBase->GetType();
593 if(type != WindowType::NOTIFICATION)
595 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
596 return WindowNotificationLevel::NONE;
599 return mWindowBase->GetNotificationLevel();
602 void Window::SetOpaqueState(bool opaque)
604 mOpaqueState = opaque;
606 mWindowBase->SetOpaqueState(opaque);
608 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
611 bool Window::IsOpaqueState() const
616 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
618 return mWindowBase->SetScreenOffMode(screenOffMode);
621 WindowScreenOffMode Window::GetScreenOffMode() const
623 return mWindowBase->GetScreenOffMode();
626 WindowOperationResult Window::SetBrightness(int brightness)
628 if(brightness < 0 || brightness > 100)
630 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
631 return WindowOperationResult::INVALID_OPERATION;
634 return mWindowBase->SetBrightness(brightness);
637 int Window::GetBrightness() const
639 return mWindowBase->GetBrightness();
642 void Window::SetSize(Dali::Window::WindowSize size)
644 PositionSize oldRect = mSurface->GetPositionSize();
646 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
648 PositionSize newRect = mSurface->GetPositionSize();
650 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
651 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
653 Uint16Pair newSize(newRect.width, newRect.height);
655 mWindowWidth = newRect.width;
656 mWindowHeight = newRect.height;
660 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
662 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.width, newRect.height);
664 Dali::Window handle(this);
665 mResizeSignal.Emit(handle, newSize);
667 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
670 mSurface->SetFullSwapNextFrame();
672 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
675 Dali::Window::WindowSize Window::GetSize() const
677 PositionSize positionSize = mSurface->GetPositionSize();
679 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
682 void Window::SetPosition(Dali::Window::WindowPosition position)
684 PositionSize oldRect = mSurface->GetPositionSize();
686 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
688 mSurface->SetFullSwapNextFrame();
690 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
693 Dali::Window::WindowPosition Window::GetPosition() const
695 PositionSize positionSize = mSurface->GetPositionSize();
697 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
700 PositionSize Window::GetPositionSize() const
702 return mSurface->GetPositionSize();
705 void Window::SetPositionSize(PositionSize positionSize)
707 PositionSize oldRect = mSurface->GetPositionSize();
709 mWindowSurface->MoveResize(positionSize);
711 PositionSize newRect = mSurface->GetPositionSize();
713 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
714 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
716 Uint16Pair newSize(newRect.width, newRect.height);
718 mWindowWidth = newRect.width;
719 mWindowHeight = newRect.height;
723 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
725 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.width, newRect.height);
726 Dali::Window handle(this);
727 mResizeSignal.Emit(handle, newSize);
728 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
731 mSurface->SetFullSwapNextFrame();
733 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
736 Dali::Layer Window::GetRootLayer() const
738 return mScene.GetRootLayer();
741 void Window::SetTransparency(bool transparent)
743 mWindowSurface->SetTransparency(transparent);
746 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
748 return mWindowBase->GrabKey(key, grabMode);
751 bool Window::UngrabKey(Dali::KEY key)
753 return mWindowBase->UngrabKey(key);
756 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
758 return mWindowBase->GrabKeyList(key, grabMode, result);
761 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
763 return mWindowBase->UngrabKeyList(key, result);
766 void Window::OnIconifyChanged(bool iconified)
774 Dali::Window handle(this);
775 mVisibilityChangedSignal.Emit(handle, false);
776 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
778 WindowVisibilityObserver* observer(mAdaptor);
779 observer->OnWindowHidden();
782 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
790 Dali::Window handle(this);
791 mVisibilityChangedSignal.Emit(handle, true);
792 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
794 WindowVisibilityObserver* observer(mAdaptor);
795 observer->OnWindowShown();
798 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
801 mSurface->SetFullSwapNextFrame();
804 void Window::OnFocusChanged(bool focusIn)
806 Dali::Window handle(this);
807 mFocusChangeSignal.Emit(handle, focusIn);
809 mSurface->SetFullSwapNextFrame();
811 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
815 bridge->WindowFocused(handle);
819 bridge->WindowUnfocused(handle);
825 void Window::OnOutputTransformed()
827 PositionSize positionSize = mSurface->GetPositionSize();
829 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
830 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
832 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
833 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
836 void Window::OnDeleteRequest()
838 mDeleteRequestSignal.Emit();
841 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
843 Dali::Window handle(this);
844 mTransitionEffectEventSignal.Emit(handle, state, type);
847 void Window::OnKeyboardRepeatSettingsChanged()
849 Dali::Window handle(this);
850 mKeyboardRepeatSettingsChangedSignal.Emit();
853 void Window::OnWindowRedrawRequest()
855 mAdaptor->RenderOnce();
858 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
860 PositionSize oldRect = mSurface->GetPositionSize();
862 mWindowSurface->UpdatePositionSize(positionSize);
864 PositionSize newRect = positionSize;
866 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
867 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
869 Uint16Pair newSize(newRect.width, newRect.height);
873 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
875 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
876 Dali::Window handle(this);
877 mResizeSignal.Emit(handle, newSize);
878 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
881 mSurface->SetFullSwapNextFrame();
883 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
886 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
888 FeedTouchPoint(point, timeStamp);
891 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
893 FeedWheelEvent(wheelEvent);
896 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
898 FeedKeyEvent(keyEvent);
901 void Window::OnRotation(const RotationEvent& rotation)
903 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
905 mRotationAngle = rotation.angle;
906 mWindowWidth = rotation.width;
907 mWindowHeight = rotation.height;
909 // Notify that the orientation is changed
910 mOrientation->OnOrientationChange(rotation);
912 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
914 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
915 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
917 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
919 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): x[%d], y[%d], resize signal emit [%d x %d]\n", this, mNativeWindowId, newPositionSize.x, newPositionSize.y, mWindowWidth, mWindowHeight);
921 Dali::Window handle(this);
922 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
924 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
927 void Window::OnPause()
931 mEventHandler->Pause();
935 void Window::OnResume()
939 mEventHandler->Resume();
942 mSurface->SetFullSwapNextFrame();
945 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
947 mAuxiliaryMessageSignal.Emit(key, value, options);
950 void Window::OnAccessibilityEnabled()
952 auto bridge = Accessibility::Bridge::GetCurrentBridge();
953 auto rootLayer = mScene.GetRootLayer();
954 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
955 bridge->AddTopLevelWindow(accessible);
959 Dali::Window handle(this);
960 bridge->WindowFocused(handle);
964 void Window::OnAccessibilityDisabled()
966 auto bridge = Accessibility::Bridge::GetCurrentBridge();
967 auto rootLayer = mScene.GetRootLayer();
968 auto accessible = Accessibility::Accessible::Get(rootLayer, true);
969 bridge->RemoveTopLevelWindow(accessible);
972 void Window::RecalculateTouchPosition(Integration::Point& point)
974 Vector2 position = point.GetScreenPosition();
975 Vector2 convertedPosition;
977 switch(mRotationAngle)
981 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
982 convertedPosition.y = position.x;
987 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
988 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
993 convertedPosition.x = position.y;
994 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
999 convertedPosition = position;
1004 point.SetScreenPosition(convertedPosition);
1007 Dali::Window Window::Get(Dali::Actor actor)
1009 Internal::Adaptor::Window* windowImpl = nullptr;
1011 if(Internal::Adaptor::Adaptor::IsAvailable())
1013 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1014 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1017 return Dali::Window(windowImpl);
1021 return Dali::Window();
1024 void Window::SetParent(Dali::Window& parent)
1026 if(DALI_UNLIKELY(parent))
1028 mParentWindow = parent;
1029 Dali::Window self = Dali::Window(this);
1030 // check circular parent window setting
1031 if(Dali::DevelWindow::GetParent(parent) == self)
1033 Dali::DevelWindow::Unparent(parent);
1035 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1039 void Window::SetParent(Dali::Window& parent, bool belowParent)
1041 if(DALI_UNLIKELY(parent))
1043 mParentWindow = parent;
1044 Dali::Window self = Dali::Window(this);
1045 // check circular parent window setting
1046 if(Dali::DevelWindow::GetParent(parent) == self)
1048 Dali::DevelWindow::Unparent(parent);
1050 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1054 void Window::Unparent()
1056 mWindowBase->SetParent(nullptr, false);
1057 mParentWindow.Reset();
1060 Dali::Window Window::GetParent()
1062 return mParentWindow;
1065 WindowOrientation Window::GetCurrentOrientation() const
1067 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1068 return ConvertToOrientation(mRotationAngle);
1071 int Window::GetPhysicalOrientation() const
1073 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1076 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1078 Dali::Vector<float>::SizeType count = orientations.Count();
1079 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1081 if(IsOrientationAvailable(orientations[index]) == false)
1083 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1088 int convertedAngle = ConvertToAngle(orientations[index]);
1090 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1092 if(mAvailableAngles[i] == convertedAngle)
1101 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1102 mAvailableAngles.push_back(convertedAngle);
1105 SetAvailableAnlges(mAvailableAngles);
1108 int32_t Window::GetNativeId() const
1110 return mWindowBase->GetNativeWindowId();
1113 void Window::RequestMoveToServer()
1115 mWindowBase->RequestMoveToServer();
1118 void Window::RequestResizeToServer(WindowResizeDirection direction)
1120 mWindowBase->RequestResizeToServer(direction);
1123 void Window::EnableFloatingMode(bool enable)
1125 mWindowBase->EnableFloatingMode(enable);
1128 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1131 int screenWidth, screenHeight;
1133 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1135 if(mRotationAngle == 90)
1138 newRect.y = screenHeight - (rect.x + rect.width);
1139 newRect.width = rect.height;
1140 newRect.height = rect.width;
1142 else if(mRotationAngle == 180)
1144 newRect.x = screenWidth - (rect.x + rect.width);
1145 newRect.y = screenHeight - (rect.y + rect.height);
1146 newRect.width = rect.width;
1147 newRect.height = rect.height;
1149 else if(mRotationAngle == 270)
1151 newRect.x = screenWidth - (rect.y + rect.height);
1153 newRect.width = rect.height;
1154 newRect.height = rect.width;
1160 newRect.width = rect.width;
1161 newRect.height = rect.height;
1166 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1168 Rect<int> convertRegion = RecalculateRect(inputRegion);
1170 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);
1171 mWindowBase->IncludeInputRegion(convertRegion);
1174 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1176 Rect<int> convertRegion = RecalculateRect(inputRegion);
1178 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);
1179 mWindowBase->ExcludeInputRegion(convertRegion);
1182 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1184 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1185 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1186 mWindowRotationAcknowledgement = needAcknowledgement;
1189 void Window::SendRotationCompletedAcknowledgement()
1191 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1192 if(mWindowRotationAcknowledgement)
1194 SetRotationCompletedAcknowledgement();
1198 } // namespace Adaptor
1200 } // namespace Internal