2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/public-api/render-tasks/render-task-list.h>
32 #include <dali/public-api/render-tasks/render-task.h>
33 #include <dali/public-api/rendering/frame-buffer.h>
37 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
38 #include <dali/devel-api/atspi-interfaces/accessible.h>
39 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
40 #include <dali/internal/graphics/gles/egl-graphics.h>
41 #include <dali/internal/window-system/common/event-handler.h>
42 #include <dali/internal/window-system/common/orientation-impl.h>
43 #include <dali/internal/window-system/common/render-surface-factory.h>
44 #include <dali/internal/window-system/common/window-base.h>
45 #include <dali/internal/window-system/common/window-factory.h>
46 #include <dali/internal/window-system/common/window-render-surface.h>
47 #include <dali/internal/window-system/common/window-system.h>
48 #include <dali/internal/window-system/common/window-visibility-observer.h>
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
97 mIsTransparent(false),
98 mIsFocusAcceptable(true),
101 mWindowRotationAcknowledgement(false),
110 auto bridge = Accessibility::Bridge::GetCurrentBridge();
111 auto rootLayer = mScene.GetRootLayer();
112 auto accessible = Accessibility::Accessible::Get(rootLayer);
113 bridge->RemoveTopLevelWindow(accessible);
114 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
115 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
120 mAdaptor->RemoveWindow(this);
125 mEventHandler->RemoveObserver(*this);
129 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
131 // Create a window render surface
132 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
133 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
134 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
137 mWindowBase = mWindowSurface->GetWindowBase();
140 mWindowBase->SetType(type);
142 // Initialize for Ime window type
143 if(type == WindowType::IME)
145 mWindowBase->InitializeIme();
146 mWindowSurface->InitializeImeSurface();
150 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
151 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
152 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
153 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
154 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
155 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
156 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
157 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
159 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
161 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
163 SetClass(name, className);
165 mOrientation = Orientation::New(this);
167 // Get OrientationMode
168 int screenWidth, screenHeight;
169 WindowSystem::GetScreenSize(screenWidth, screenHeight);
170 if(screenWidth > screenHeight)
172 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
176 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
179 mNativeWindowId = mWindowBase->GetNativeWindowId();
182 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
184 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
185 mEventHandler->AddObserver(*this);
187 // Add Window to bridge for ATSPI
188 auto bridge = Accessibility::Bridge::GetCurrentBridge();
191 auto rootLayer = mScene.GetRootLayer();
192 auto accessible = Accessibility::Accessible::Get(rootLayer);
193 bridge->AddTopLevelWindow(accessible);
196 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
197 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
199 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
200 // The show must be called after the adaptor is initialized.
204 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
206 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
209 void Window::SetClass(std::string name, std::string className)
212 mClassName = className;
213 mWindowBase->SetClass(name, className);
216 std::string Window::GetClassName() const
223 mWindowBase->Raise();
225 mSurface->SetFullSwapNextFrame();
227 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
232 mWindowBase->Lower();
234 mSurface->SetFullSwapNextFrame();
236 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
239 void Window::Activate()
241 mWindowBase->Activate();
243 mSurface->SetFullSwapNextFrame();
245 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
248 void Window::Maximize(bool maximize)
250 mWindowBase->Maximize(maximize);
252 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
255 bool Window::IsMaximized() const
257 return mWindowBase->IsMaximized();
260 void Window::SetMaximumSize(Dali::Window::WindowSize size)
262 mWindowBase->SetMaximumSize(size);
265 void Window::Minimize(bool minimize)
267 mWindowBase->Minimize(minimize);
269 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
272 bool Window::IsMinimized() const
274 return mWindowBase->IsMinimized();
277 void Window::SetMimimumSize(Dali::Window::WindowSize size)
279 mWindowBase->SetMimimumSize(size);
282 uint32_t Window::GetLayerCount() const
284 return mScene.GetLayerCount();
287 Dali::Layer Window::GetLayer(uint32_t depth) const
289 return mScene.GetLayer(depth);
292 Dali::RenderTaskList Window::GetRenderTaskList() const
294 return mScene.GetRenderTaskList();
297 std::string Window::GetNativeResourceId() const
299 return mWindowBase->GetNativeWindowResourceId();
302 void Window::AddAvailableOrientation(WindowOrientation orientation)
304 if(IsOrientationAvailable(orientation) == false)
310 int convertedAngle = ConvertToAngle(orientation);
311 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
312 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
314 if(mAvailableAngles[i] == convertedAngle)
323 mAvailableAngles.push_back(convertedAngle);
324 SetAvailableAnlges(mAvailableAngles);
328 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
330 if(IsOrientationAvailable(orientation) == false)
335 int convertedAngle = ConvertToAngle(orientation);
336 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
337 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
338 iter != mAvailableAngles.end();
341 if(*iter == convertedAngle)
343 mAvailableAngles.erase(iter);
348 SetAvailableAnlges(mAvailableAngles);
351 void Window::SetPreferredOrientation(WindowOrientation orientation)
353 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
355 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
358 mPreferredAngle = ConvertToAngle(orientation);
359 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
360 mWindowBase->SetPreferredAngle(mPreferredAngle);
363 WindowOrientation Window::GetPreferredOrientation()
365 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
366 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
367 return preferredOrientation;
370 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
372 int angle = ConvertToAngle(orientation);
373 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
376 void Window::EmitAccessibilityHighlightSignal(bool highlight)
378 Dali::Window handle(this);
379 mAccessibilityHighlightSignal.Emit(handle, highlight);
382 void Window::SetAvailableAnlges(const std::vector<int>& angles)
384 if(angles.size() > 4)
386 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
390 mWindowBase->SetAvailableAnlges(angles);
393 int Window::ConvertToAngle(WindowOrientation orientation)
395 int convertAngle = static_cast<int>(orientation);
396 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
400 case WindowOrientation::LANDSCAPE:
405 case WindowOrientation::PORTRAIT:
410 case WindowOrientation::LANDSCAPE_INVERSE:
415 case WindowOrientation::PORTRAIT_INVERSE:
420 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
430 WindowOrientation Window::ConvertToOrientation(int angle) const
432 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
433 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
439 orientation = WindowOrientation::LANDSCAPE;
444 orientation = WindowOrientation::PORTRAIT;
449 orientation = WindowOrientation::LANDSCAPE_INVERSE;
454 orientation = WindowOrientation::PORTRAIT_INVERSE;
459 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
467 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
469 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
471 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
477 Dali::Any Window::GetNativeHandle() const
479 return mWindowSurface->GetNativeWindow();
482 void Window::SetAcceptFocus(bool accept)
484 mIsFocusAcceptable = accept;
486 mWindowBase->SetAcceptFocus(accept);
489 bool Window::IsFocusAcceptable() const
491 return mIsFocusAcceptable;
502 Dali::Window handle(this);
503 mVisibilityChangedSignal.Emit(handle, true);
504 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
506 WindowVisibilityObserver* observer(mAdaptor);
507 observer->OnWindowShown();
510 mSurface->SetFullSwapNextFrame();
512 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
523 Dali::Window handle(this);
524 mVisibilityChangedSignal.Emit(handle, false);
525 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
527 WindowVisibilityObserver* observer(mAdaptor);
528 observer->OnWindowHidden();
531 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
534 bool Window::IsVisible() const
536 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
537 return mVisible && !mIconified;
540 unsigned int Window::GetSupportedAuxiliaryHintCount() const
542 return mWindowBase->GetSupportedAuxiliaryHintCount();
545 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
547 return mWindowBase->GetSupportedAuxiliaryHint(index);
550 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
552 return mWindowBase->AddAuxiliaryHint(hint, value);
555 bool Window::RemoveAuxiliaryHint(unsigned int id)
557 return mWindowBase->RemoveAuxiliaryHint(id);
560 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
562 return mWindowBase->SetAuxiliaryHintValue(id, value);
565 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
567 return mWindowBase->GetAuxiliaryHintValue(id);
570 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
572 return mWindowBase->GetAuxiliaryHintId(hint);
575 void Window::SetInputRegion(const Rect<int>& inputRegion)
577 Rect<int> convertRegion = RecalculateRect(inputRegion);
579 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);
581 mWindowBase->SetInputRegion(convertRegion);
584 void Window::SetType(WindowType type)
586 mWindowBase->SetType(type);
589 WindowType Window::GetType() const
591 return mWindowBase->GetType();
594 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
596 WindowType type = mWindowBase->GetType();
597 if(type != WindowType::NOTIFICATION)
599 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
600 return WindowOperationResult::INVALID_OPERATION;
603 return mWindowBase->SetNotificationLevel(level);
606 WindowNotificationLevel Window::GetNotificationLevel() const
608 WindowType type = mWindowBase->GetType();
609 if(type != WindowType::NOTIFICATION)
611 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
612 return WindowNotificationLevel::NONE;
615 return mWindowBase->GetNotificationLevel();
618 void Window::SetOpaqueState(bool opaque)
620 mOpaqueState = opaque;
622 mWindowBase->SetOpaqueState(opaque);
624 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
627 bool Window::IsOpaqueState() const
632 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
634 return mWindowBase->SetScreenOffMode(screenOffMode);
637 WindowScreenOffMode Window::GetScreenOffMode() const
639 return mWindowBase->GetScreenOffMode();
642 WindowOperationResult Window::SetBrightness(int brightness)
644 if(brightness < 0 || brightness > 100)
646 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
647 return WindowOperationResult::INVALID_OPERATION;
650 return mWindowBase->SetBrightness(brightness);
653 int Window::GetBrightness() const
655 return mWindowBase->GetBrightness();
658 void Window::SetSize(Dali::Window::WindowSize size)
660 PositionSize oldRect = mSurface->GetPositionSize();
662 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
664 PositionSize newRect = mSurface->GetPositionSize();
666 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
667 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
669 Uint16Pair newSize(newRect.width, newRect.height);
671 mWindowWidth = newRect.width;
672 mWindowHeight = newRect.height;
676 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
678 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);
680 Dali::Window handle(this);
681 mResizeSignal.Emit(handle, newSize);
683 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
686 mSurface->SetFullSwapNextFrame();
688 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
691 Dali::Window::WindowSize Window::GetSize() const
693 PositionSize positionSize = mSurface->GetPositionSize();
695 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
698 void Window::SetPosition(Dali::Window::WindowPosition position)
700 PositionSize oldRect = mSurface->GetPositionSize();
702 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
704 mSurface->SetFullSwapNextFrame();
706 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
709 Dali::Window::WindowPosition Window::GetPosition() const
711 PositionSize positionSize = mSurface->GetPositionSize();
713 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
716 PositionSize Window::GetPositionSize() const
718 return mSurface->GetPositionSize();
721 void Window::SetPositionSize(PositionSize positionSize)
723 PositionSize oldRect = mSurface->GetPositionSize();
725 mWindowSurface->MoveResize(positionSize);
727 PositionSize newRect = mSurface->GetPositionSize();
729 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
730 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
732 Uint16Pair newSize(newRect.width, newRect.height);
734 mWindowWidth = newRect.width;
735 mWindowHeight = newRect.height;
739 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
741 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);
742 Dali::Window handle(this);
743 mResizeSignal.Emit(handle, newSize);
744 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
747 mSurface->SetFullSwapNextFrame();
749 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
752 Dali::Layer Window::GetRootLayer() const
754 return mScene.GetRootLayer();
757 void Window::SetTransparency(bool transparent)
759 mWindowSurface->SetTransparency(transparent);
762 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
764 return mWindowBase->GrabKey(key, grabMode);
767 bool Window::UngrabKey(Dali::KEY key)
769 return mWindowBase->UngrabKey(key);
772 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
774 return mWindowBase->GrabKeyList(key, grabMode, result);
777 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
779 return mWindowBase->UngrabKeyList(key, result);
782 void Window::OnIconifyChanged(bool iconified)
790 Dali::Window handle(this);
791 mVisibilityChangedSignal.Emit(handle, false);
792 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
794 WindowVisibilityObserver* observer(mAdaptor);
795 observer->OnWindowHidden();
798 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
806 Dali::Window handle(this);
807 mVisibilityChangedSignal.Emit(handle, true);
808 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
810 WindowVisibilityObserver* observer(mAdaptor);
811 observer->OnWindowShown();
814 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
817 mSurface->SetFullSwapNextFrame();
820 void Window::OnFocusChanged(bool focusIn)
822 Dali::Window handle(this);
823 mFocusChangeSignal.Emit(handle, focusIn);
825 mSurface->SetFullSwapNextFrame();
827 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
831 bridge->WindowFocused(handle);
835 bridge->WindowUnfocused(handle);
841 void Window::OnOutputTransformed()
843 PositionSize positionSize = mSurface->GetPositionSize();
845 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
846 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
848 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
849 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
852 void Window::OnDeleteRequest()
854 mDeleteRequestSignal.Emit();
857 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
859 Dali::Window handle(this);
860 mTransitionEffectEventSignal.Emit(handle, state, type);
863 void Window::OnKeyboardRepeatSettingsChanged()
865 Dali::Window handle(this);
866 mKeyboardRepeatSettingsChangedSignal.Emit();
869 void Window::OnWindowRedrawRequest()
871 mAdaptor->RenderOnce();
874 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
876 PositionSize oldRect = mSurface->GetPositionSize();
878 mWindowSurface->UpdatePositionSize(positionSize);
880 PositionSize newRect = positionSize;
882 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
883 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
885 Uint16Pair newSize(newRect.width, newRect.height);
887 mWindowWidth = newRect.width;
888 mWindowHeight = newRect.height;
892 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
894 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
895 Dali::Window handle(this);
896 mResizeSignal.Emit(handle, newSize);
897 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
900 mSurface->SetFullSwapNextFrame();
902 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
905 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
907 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
908 FeedTouchPoint(point, timeStamp);
911 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
913 FeedWheelEvent(wheelEvent);
916 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
918 mLastKeyEvent = Dali::DevelKeyEvent::New(keyEvent.keyName, keyEvent.logicalKey, keyEvent.keyString, keyEvent.keyCode, keyEvent.keyModifier, keyEvent.time, static_cast<Dali::KeyEvent::State>(keyEvent.state), keyEvent.compose, keyEvent.deviceName, keyEvent.deviceClass, keyEvent.deviceSubclass);
919 FeedKeyEvent(keyEvent);
922 void Window::OnRotation(const RotationEvent& rotation)
924 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
926 mRotationAngle = rotation.angle;
927 mWindowWidth = rotation.width;
928 mWindowHeight = rotation.height;
930 // Notify that the orientation is changed
931 mOrientation->OnOrientationChange(rotation);
933 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
935 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
936 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
938 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
940 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);
942 Dali::Window handle(this);
943 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
945 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
948 void Window::OnPause()
952 mEventHandler->Pause();
956 void Window::OnResume()
960 mEventHandler->Resume();
963 mSurface->SetFullSwapNextFrame();
966 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
968 mAuxiliaryMessageSignal.Emit(key, value, options);
971 void Window::OnAccessibilityEnabled()
973 auto bridge = Accessibility::Bridge::GetCurrentBridge();
974 auto rootLayer = mScene.GetRootLayer();
975 auto accessible = Accessibility::Accessible::Get(rootLayer);
976 bridge->AddTopLevelWindow(accessible);
978 if(!mVisible || mIconified)
983 Dali::Window handle(this);
984 bridge->WindowShown(handle);
988 bridge->WindowFocused(handle);
992 void Window::OnAccessibilityDisabled()
994 auto bridge = Accessibility::Bridge::GetCurrentBridge();
995 auto rootLayer = mScene.GetRootLayer();
996 auto accessible = Accessibility::Accessible::Get(rootLayer);
997 bridge->RemoveTopLevelWindow(accessible);
1000 void Window::RecalculateTouchPosition(Integration::Point& point)
1002 Vector2 position = point.GetScreenPosition();
1003 Vector2 convertedPosition;
1005 switch(mRotationAngle)
1009 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1010 convertedPosition.y = position.x;
1015 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1016 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1021 convertedPosition.x = position.y;
1022 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1027 convertedPosition = position;
1032 point.SetScreenPosition(convertedPosition);
1035 Dali::Window Window::Get(Dali::Actor actor)
1037 Internal::Adaptor::Window* windowImpl = nullptr;
1039 if(Internal::Adaptor::Adaptor::IsAvailable())
1041 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1042 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1045 return Dali::Window(windowImpl);
1049 return Dali::Window();
1052 void Window::SetParent(Dali::Window& parent)
1054 if(DALI_UNLIKELY(parent))
1056 mParentWindow = parent;
1057 Dali::Window self = Dali::Window(this);
1058 // check circular parent window setting
1059 if(Dali::DevelWindow::GetParent(parent) == self)
1061 Dali::DevelWindow::Unparent(parent);
1063 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1067 void Window::SetParent(Dali::Window& parent, bool belowParent)
1069 if(DALI_UNLIKELY(parent))
1071 mParentWindow = parent;
1072 Dali::Window self = Dali::Window(this);
1073 // check circular parent window setting
1074 if(Dali::DevelWindow::GetParent(parent) == self)
1076 Dali::DevelWindow::Unparent(parent);
1078 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1082 void Window::Unparent()
1084 mWindowBase->SetParent(nullptr, false);
1085 mParentWindow.Reset();
1088 Dali::Window Window::GetParent()
1090 return mParentWindow;
1093 WindowOrientation Window::GetCurrentOrientation() const
1095 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1096 return ConvertToOrientation(mRotationAngle);
1099 int Window::GetPhysicalOrientation() const
1101 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1104 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1106 Dali::Vector<float>::SizeType count = orientations.Count();
1107 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1109 if(IsOrientationAvailable(orientations[index]) == false)
1111 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1116 int convertedAngle = ConvertToAngle(orientations[index]);
1118 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1120 if(mAvailableAngles[i] == convertedAngle)
1129 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1130 mAvailableAngles.push_back(convertedAngle);
1133 SetAvailableAnlges(mAvailableAngles);
1136 int32_t Window::GetNativeId() const
1138 return mWindowBase->GetNativeWindowId();
1141 void Window::RequestMoveToServer()
1143 mWindowBase->RequestMoveToServer();
1146 void Window::RequestResizeToServer(WindowResizeDirection direction)
1148 mWindowBase->RequestResizeToServer(direction);
1151 void Window::EnableFloatingMode(bool enable)
1153 mWindowBase->EnableFloatingMode(enable);
1156 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1159 int screenWidth, screenHeight;
1161 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1163 if(mRotationAngle == 90)
1166 newRect.y = screenHeight - (rect.x + rect.width);
1167 newRect.width = rect.height;
1168 newRect.height = rect.width;
1170 else if(mRotationAngle == 180)
1172 newRect.x = screenWidth - (rect.x + rect.width);
1173 newRect.y = screenHeight - (rect.y + rect.height);
1174 newRect.width = rect.width;
1175 newRect.height = rect.height;
1177 else if(mRotationAngle == 270)
1179 newRect.x = screenWidth - (rect.y + rect.height);
1181 newRect.width = rect.height;
1182 newRect.height = rect.width;
1188 newRect.width = rect.width;
1189 newRect.height = rect.height;
1194 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1196 Rect<int> convertRegion = RecalculateRect(inputRegion);
1198 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);
1199 mWindowBase->IncludeInputRegion(convertRegion);
1202 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1204 Rect<int> convertRegion = RecalculateRect(inputRegion);
1206 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);
1207 mWindowBase->ExcludeInputRegion(convertRegion);
1210 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1212 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1213 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1214 mWindowRotationAcknowledgement = needAcknowledgement;
1217 void Window::SendRotationCompletedAcknowledgement()
1219 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1220 if(mWindowRotationAcknowledgement)
1222 SetRotationCompletedAcknowledgement();
1226 bool Window::IsWindowRotating() const
1228 return mWindowSurface->IsWindowRotating();
1231 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1233 return mLastKeyEvent;
1236 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1238 return mLastTouchEvent;
1241 } // namespace Adaptor
1243 } // namespace Internal