2 * Copyright (c) 2023 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/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),
80 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
85 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
86 mDeleteRequestSignal(),
89 mVisibilityChangedSignal(),
90 mTransitionEffectEventSignal(),
91 mKeyboardRepeatSettingsChangedSignal(),
92 mAuxiliaryMessageSignal(),
94 mOrientationChangedSignal(),
95 mMouseInOutEventSignal(),
96 mMoveCompletedSignal(),
97 mResizeCompletedSignal(),
98 mInsetsChangedSignal(),
101 mIsTransparent(false),
102 mIsFocusAcceptable(true),
105 mWindowRotationAcknowledgement(false),
107 mIsWindowRotating(false)
115 auto bridge = Accessibility::Bridge::GetCurrentBridge();
116 auto rootLayer = mScene.GetRootLayer();
117 auto accessible = Accessibility::Accessible::Get(rootLayer);
118 bridge->RemoveTopLevelWindow(accessible);
119 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
120 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
123 if(DALI_LIKELY(mAdaptor))
125 mAdaptor->RemoveWindow(this);
130 mEventHandler->RemoveObserver(*this);
134 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
136 // Create a window render surface
137 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
138 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
139 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
142 mWindowBase = mWindowSurface->GetWindowBase();
145 mWindowBase->SetType(type);
147 // Initialize for Ime window type
148 if(type == WindowType::IME)
150 mWindowBase->InitializeIme();
151 mWindowSurface->InitializeImeSurface();
155 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
156 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
157 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
158 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
159 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
160 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
161 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
162 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
163 mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
164 mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
165 mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
167 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
168 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
170 mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
172 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
174 SetClass(name, className);
176 mOrientation = Orientation::New(this);
178 // Get OrientationMode
179 int screenWidth, screenHeight;
180 WindowSystem::GetScreenSize(screenWidth, screenHeight);
181 if(screenWidth > screenHeight)
183 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
187 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
190 if(positionSize.width <= 0 || positionSize.height <= 0)
192 mWindowWidth = screenWidth;
193 mWindowHeight = screenHeight;
197 mWindowWidth = positionSize.width;
198 mWindowHeight = positionSize.height;
202 mNativeWindowId = mWindowBase->GetNativeWindowId();
205 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
212 mWindowSurface->SetRenderNotification(renderNotification);
215 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
217 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
218 mEventHandler->AddObserver(*this);
220 // Add Window to bridge for ATSPI
221 auto bridge = Accessibility::Bridge::GetCurrentBridge();
224 auto rootLayer = mScene.GetRootLayer();
225 auto accessible = Accessibility::Accessible::Get(rootLayer);
226 bridge->AddTopLevelWindow(accessible);
229 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
230 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
232 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
233 // The show must be called after the adaptor is initialized.
237 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
239 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
242 void Window::SetClass(std::string name, std::string className)
245 mClassName = className;
246 mWindowBase->SetClass(name, className);
249 std::string Window::GetClassName() const
256 mWindowBase->Raise();
258 mSurface->SetFullSwapNextFrame();
260 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
265 mWindowBase->Lower();
267 mSurface->SetFullSwapNextFrame();
269 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
272 void Window::Activate()
274 mWindowBase->Activate();
276 mSurface->SetFullSwapNextFrame();
278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
281 void Window::Maximize(bool maximize)
283 mWindowBase->Maximize(maximize);
285 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
288 bool Window::IsMaximized() const
290 return mWindowBase->IsMaximized();
293 void Window::SetMaximumSize(Dali::Window::WindowSize size)
295 mWindowBase->SetMaximumSize(size);
298 void Window::Minimize(bool minimize)
300 mWindowBase->Minimize(minimize);
302 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
305 bool Window::IsMinimized() const
307 return mWindowBase->IsMinimized();
310 void Window::SetMimimumSize(Dali::Window::WindowSize size)
312 mWindowBase->SetMimimumSize(size);
315 uint32_t Window::GetLayerCount() const
317 return mScene.GetLayerCount();
320 Dali::Layer Window::GetLayer(uint32_t depth) const
322 return mScene.GetLayer(depth);
325 std::string Window::GetNativeResourceId() const
327 return mWindowBase->GetNativeWindowResourceId();
330 void Window::AddAvailableOrientation(WindowOrientation orientation)
332 if(IsOrientationAvailable(orientation) == false)
338 int convertedAngle = ConvertToAngle(orientation);
339 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
340 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
342 if(mAvailableAngles[i] == convertedAngle)
351 mAvailableAngles.push_back(convertedAngle);
352 SetAvailableAnlges(mAvailableAngles);
356 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
358 if(IsOrientationAvailable(orientation) == false)
363 int convertedAngle = ConvertToAngle(orientation);
364 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
365 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
366 iter != mAvailableAngles.end();
369 if(*iter == convertedAngle)
371 mAvailableAngles.erase(iter);
376 SetAvailableAnlges(mAvailableAngles);
379 void Window::SetPreferredOrientation(WindowOrientation orientation)
381 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
383 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
386 mPreferredAngle = ConvertToAngle(orientation);
387 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
388 mWindowBase->SetPreferredAngle(mPreferredAngle);
391 WindowOrientation Window::GetPreferredOrientation()
393 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
394 return preferredOrientation;
397 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
399 int angle = ConvertToAngle(orientation);
400 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
403 void Window::EmitAccessibilityHighlightSignal(bool highlight)
405 Dali::Window handle(this);
406 mAccessibilityHighlightSignal.Emit(handle, highlight);
409 void Window::SetAvailableAnlges(const std::vector<int>& angles)
411 if(angles.size() > 4)
413 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
417 mWindowBase->SetAvailableAnlges(angles);
420 int Window::ConvertToAngle(WindowOrientation orientation)
422 int convertAngle = static_cast<int>(orientation);
423 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
427 case WindowOrientation::LANDSCAPE:
432 case WindowOrientation::PORTRAIT:
437 case WindowOrientation::LANDSCAPE_INVERSE:
442 case WindowOrientation::PORTRAIT_INVERSE:
447 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
457 WindowOrientation Window::ConvertToOrientation(int angle) const
459 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
460 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
466 orientation = WindowOrientation::LANDSCAPE;
471 orientation = WindowOrientation::PORTRAIT;
476 orientation = WindowOrientation::LANDSCAPE_INVERSE;
481 orientation = WindowOrientation::PORTRAIT_INVERSE;
486 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
494 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
496 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
498 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
504 Dali::Any Window::GetNativeHandle() const
506 return mWindowSurface->GetNativeWindow();
509 void Window::SetAcceptFocus(bool accept)
511 mIsFocusAcceptable = accept;
513 mWindowBase->SetAcceptFocus(accept);
516 bool Window::IsFocusAcceptable() const
518 return mIsFocusAcceptable;
529 Dali::Window handle(this);
530 mVisibilityChangedSignal.Emit(handle, true);
531 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
533 WindowVisibilityObserver* observer(mAdaptor);
534 observer->OnWindowShown();
537 mSurface->SetFullSwapNextFrame();
539 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
550 Dali::Window handle(this);
551 mVisibilityChangedSignal.Emit(handle, false);
552 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
554 WindowVisibilityObserver* observer(mAdaptor);
555 observer->OnWindowHidden();
558 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
561 bool Window::IsVisible() const
563 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
564 return mVisible && !mIconified;
567 unsigned int Window::GetSupportedAuxiliaryHintCount() const
569 return mWindowBase->GetSupportedAuxiliaryHintCount();
572 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
574 return mWindowBase->GetSupportedAuxiliaryHint(index);
577 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
579 return mWindowBase->AddAuxiliaryHint(hint, value);
582 bool Window::RemoveAuxiliaryHint(unsigned int id)
584 return mWindowBase->RemoveAuxiliaryHint(id);
587 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
589 return mWindowBase->SetAuxiliaryHintValue(id, value);
592 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
594 return mWindowBase->GetAuxiliaryHintValue(id);
597 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
599 return mWindowBase->GetAuxiliaryHintId(hint);
602 void Window::SetInputRegion(const Rect<int>& inputRegion)
604 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
605 mWindowBase->SetInputRegion(inputRegion);
608 void Window::SetType(WindowType type)
610 mWindowBase->SetType(type);
613 WindowType Window::GetType() const
615 return mWindowBase->GetType();
618 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
620 WindowType type = mWindowBase->GetType();
621 if(type != WindowType::NOTIFICATION)
623 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
624 return WindowOperationResult::INVALID_OPERATION;
627 return mWindowBase->SetNotificationLevel(level);
630 WindowNotificationLevel Window::GetNotificationLevel() const
632 WindowType type = mWindowBase->GetType();
633 if(type != WindowType::NOTIFICATION)
635 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
636 return WindowNotificationLevel::NONE;
639 return mWindowBase->GetNotificationLevel();
642 void Window::SetOpaqueState(bool opaque)
644 mOpaqueState = opaque;
646 mWindowBase->SetOpaqueState(opaque);
648 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
651 bool Window::IsOpaqueState() const
656 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
658 return mWindowBase->SetScreenOffMode(screenOffMode);
661 WindowScreenOffMode Window::GetScreenOffMode() const
663 return mWindowBase->GetScreenOffMode();
666 WindowOperationResult Window::SetBrightness(int brightness)
668 if(brightness < 0 || brightness > 100)
670 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
671 return WindowOperationResult::INVALID_OPERATION;
674 return mWindowBase->SetBrightness(brightness);
677 int Window::GetBrightness() const
679 return mWindowBase->GetBrightness();
682 void Window::SetSize(Dali::Window::WindowSize size)
684 PositionSize oldRect = GetPositionSize();
686 PositionSize newRect;
687 newRect.width = size.GetWidth();
688 newRect.height = size.GetHeight();
690 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
691 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
693 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
695 Uint16Pair newSize(newRect.width, newRect.height);
697 mWindowWidth = newRect.width;
698 mWindowHeight = newRect.height;
700 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetSize(): (%d, %d), [%d x %d]\n", this, mNativeWindowId, mRotationAngle, oldRect.x, oldRect.y, newRect.width, newRect.height);
702 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
704 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
706 Dali::Window handle(this);
707 mResizeSignal.Emit(handle, newSize);
709 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
712 mSurface->SetFullSwapNextFrame();
714 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
717 Dali::Window::WindowSize Window::GetSize() const
719 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
722 void Window::SetPosition(Dali::Window::WindowPosition position)
724 PositionSize oldRect = mSurface->GetPositionSize();
725 int32_t newX = position.GetX();
726 int32_t newY = position.GetY();
728 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
730 if((oldRect.x != newX) || (oldRect.y != newY))
732 Dali::Window handle(this);
733 Dali::Window::WindowPosition newPosition(newX, newY);
735 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
736 mMovedSignal.Emit(handle, newPosition);
739 mSurface->SetFullSwapNextFrame();
741 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
744 Dali::Window::WindowPosition Window::GetPosition() const
746 PositionSize positionSize = GetPositionSize();
747 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
750 PositionSize Window::GetPositionSize() const
752 PositionSize positionSize = mSurface->GetPositionSize();
753 positionSize.width = mWindowWidth;
754 positionSize.height = mWindowHeight;
758 void Window::SetPositionSize(PositionSize positionSize)
763 PositionSize oldRect = GetPositionSize();
764 Dali::Window handle(this);
766 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
771 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
778 mWindowSurface->MoveResize(positionSize);
781 // When window is moved, emit Moved Signal
784 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
785 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
786 mMovedSignal.Emit(handle, position);
789 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
792 Uint16Pair newSize(positionSize.width, positionSize.height);
794 mWindowWidth = positionSize.width;
795 mWindowHeight = positionSize.height;
797 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
799 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
801 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
803 mResizeSignal.Emit(handle, newSize);
804 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
807 mSurface->SetFullSwapNextFrame();
809 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
812 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
814 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
817 Dali::Layer Window::GetRootLayer() const
819 return mScene.GetRootLayer();
822 void Window::SetTransparency(bool transparent)
824 mWindowSurface->SetTransparency(transparent);
827 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
829 return mWindowBase->GrabKey(key, grabMode);
832 bool Window::UngrabKey(Dali::KEY key)
834 return mWindowBase->UngrabKey(key);
837 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
839 return mWindowBase->GrabKeyList(key, grabMode, result);
842 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
844 return mWindowBase->UngrabKeyList(key, result);
847 void Window::OnIconifyChanged(bool iconified)
855 Dali::Window handle(this);
856 mVisibilityChangedSignal.Emit(handle, false);
857 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
859 if(DALI_LIKELY(mAdaptor))
861 WindowVisibilityObserver* observer(mAdaptor);
862 observer->OnWindowHidden();
866 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
874 Dali::Window handle(this);
875 mVisibilityChangedSignal.Emit(handle, true);
876 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
878 if(DALI_LIKELY(mAdaptor))
880 WindowVisibilityObserver* observer(mAdaptor);
881 observer->OnWindowShown();
885 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
888 mSurface->SetFullSwapNextFrame();
891 void Window::OnFocusChanged(bool focusIn)
893 Dali::Window handle(this);
894 mFocusChangeSignal.Emit(handle, focusIn);
896 mSurface->SetFullSwapNextFrame();
898 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
902 bridge->WindowFocused(handle);
906 bridge->WindowUnfocused(handle);
912 void Window::OnOutputTransformed()
914 PositionSize positionSize = GetPositionSize();
916 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
918 if(DALI_LIKELY(mAdaptor))
920 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
921 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
925 void Window::OnDeleteRequest()
927 mDeleteRequestSignal.Emit();
930 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
932 Dali::Window handle(this);
933 mTransitionEffectEventSignal.Emit(handle, state, type);
936 void Window::OnKeyboardRepeatSettingsChanged()
938 Dali::Window handle(this);
939 mKeyboardRepeatSettingsChangedSignal.Emit();
942 void Window::OnWindowRedrawRequest()
944 if(DALI_LIKELY(mAdaptor))
946 mAdaptor->RenderOnce();
950 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
955 Dali::Window handle(this);
957 PositionSize oldRect = GetPositionSize();
958 PositionSize newRect = positionSize;
960 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
965 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
972 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), position or size is updated by server , (%d, %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.x, newRect.y, newRect.width, newRect.height);
973 mWindowSurface->UpdatePositionSize(positionSize);
976 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
978 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
979 Dali::Window::WindowPosition position(newRect.x, newRect.y);
980 mMovedSignal.Emit(handle, position);
983 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
984 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
986 Uint16Pair newSize(newRect.width, newRect.height);
988 mWindowWidth = newRect.width;
989 mWindowHeight = newRect.height;
991 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
993 if(DALI_LIKELY(mAdaptor))
995 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
998 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
999 mResizeSignal.Emit(handle, newSize);
1000 if(DALI_LIKELY(mAdaptor))
1002 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1006 mSurface->SetFullSwapNextFrame();
1008 if(DALI_LIKELY(mScene))
1010 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1014 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1016 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1017 FeedTouchPoint(point, timeStamp);
1020 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1022 FeedWheelEvent(wheelEvent);
1025 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1027 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);
1028 FeedKeyEvent(keyEvent);
1031 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1033 Dali::Window handle(this);
1035 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1038 void Window::OnRotation(const RotationEvent& rotation)
1040 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1042 mRotationAngle = rotation.angle;
1043 mWindowWidth = rotation.width;
1044 mWindowHeight = rotation.height;
1046 mIsWindowRotating = true;
1047 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), angle(%d), Window Rotation (%d , %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newPositionSize.x, newPositionSize.y, mWindowWidth, mWindowHeight);
1049 // Notify that the orientation is changed
1050 mOrientation->OnOrientationChange(rotation);
1052 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1054 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1056 if(DALI_LIKELY(mAdaptor))
1058 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1061 Dali::Window handle(this);
1062 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1063 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1065 if(DALI_LIKELY(mAdaptor))
1067 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1071 void Window::OnRotationFinished()
1073 mIsWindowRotating = false;
1074 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1077 void Window::OnPause()
1081 mEventHandler->Pause();
1085 void Window::OnResume()
1089 mEventHandler->Resume();
1092 mSurface->SetFullSwapNextFrame();
1095 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1097 mAuxiliaryMessageSignal.Emit(key, value, options);
1100 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1102 mInsetsChangedSignal.Emit(partType, partState, insets);
1105 void Window::OnAccessibilityEnabled()
1107 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1108 auto rootLayer = mScene.GetRootLayer();
1109 auto accessible = Accessibility::Accessible::Get(rootLayer);
1110 bridge->AddTopLevelWindow(accessible);
1112 if(!mVisible || mIconified)
1117 Dali::Window handle(this);
1118 bridge->WindowShown(handle);
1122 bridge->WindowFocused(handle);
1126 void Window::OnAccessibilityDisabled()
1128 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1129 auto rootLayer = mScene.GetRootLayer();
1130 auto accessible = Accessibility::Accessible::Get(rootLayer);
1131 bridge->RemoveTopLevelWindow(accessible);
1134 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1136 Dali::Window handle(this);
1137 mMoveCompletedSignal.Emit(handle, position);
1140 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1142 Dali::Window handle(this);
1143 mResizeCompletedSignal.Emit(handle, size);
1146 Vector2 Window::RecalculatePosition(const Vector2& position)
1148 Vector2 convertedPosition;
1150 switch(mRotationAngle)
1154 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1155 convertedPosition.y = position.x;
1160 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1161 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1166 convertedPosition.x = position.y;
1167 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1172 convertedPosition = position;
1176 return convertedPosition;
1179 Dali::Window Window::Get(Dali::Actor actor)
1181 Internal::Adaptor::Window* windowImpl = nullptr;
1183 if(Internal::Adaptor::Adaptor::IsAvailable())
1185 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1186 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1189 return Dali::Window(windowImpl);
1193 return Dali::Window();
1196 void Window::SetParent(Dali::Window& parent)
1198 if(DALI_UNLIKELY(parent))
1200 mParentWindow = parent;
1201 Dali::Window self = Dali::Window(this);
1202 // check circular parent window setting
1203 if(Dali::DevelWindow::GetParent(parent) == self)
1205 Dali::DevelWindow::Unparent(parent);
1207 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1211 void Window::SetParent(Dali::Window& parent, bool belowParent)
1213 if(DALI_UNLIKELY(parent))
1215 mParentWindow = parent;
1216 Dali::Window self = Dali::Window(this);
1217 // check circular parent window setting
1218 if(Dali::DevelWindow::GetParent(parent) == self)
1220 Dali::DevelWindow::Unparent(parent);
1222 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1226 void Window::Unparent()
1228 mWindowBase->SetParent(nullptr, false);
1229 mParentWindow.Reset();
1232 Dali::Window Window::GetParent()
1234 return mParentWindow;
1237 WindowOrientation Window::GetCurrentOrientation() const
1239 return ConvertToOrientation(mRotationAngle);
1242 int Window::GetPhysicalOrientation() const
1244 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1247 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1249 Dali::Vector<float>::SizeType count = orientations.Count();
1250 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1252 if(IsOrientationAvailable(orientations[index]) == false)
1254 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1259 int convertedAngle = ConvertToAngle(orientations[index]);
1261 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1263 if(mAvailableAngles[i] == convertedAngle)
1272 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1273 mAvailableAngles.push_back(convertedAngle);
1276 SetAvailableAnlges(mAvailableAngles);
1279 int32_t Window::GetNativeId() const
1281 return mWindowBase->GetNativeWindowId();
1284 void Window::RequestMoveToServer()
1286 mWindowBase->RequestMoveToServer();
1289 void Window::RequestResizeToServer(WindowResizeDirection direction)
1291 mWindowBase->RequestResizeToServer(direction);
1294 void Window::EnableFloatingMode(bool enable)
1296 mWindowBase->EnableFloatingMode(enable);
1299 bool Window::IsFloatingModeEnabled()
1301 return mWindowBase->IsFloatingModeEnabled();
1304 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1306 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1307 mWindowBase->IncludeInputRegion(inputRegion);
1310 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1312 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1313 mWindowBase->ExcludeInputRegion(inputRegion);
1316 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1318 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1319 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1320 mWindowRotationAcknowledgement = needAcknowledgement;
1323 void Window::SendRotationCompletedAcknowledgement()
1325 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1326 if(mWindowRotationAcknowledgement)
1328 SetRotationCompletedAcknowledgement();
1332 bool Window::IsWindowRotating() const
1334 return mIsWindowRotating;
1337 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1339 return mLastKeyEvent;
1342 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1344 return mLastTouchEvent;
1347 } // namespace Adaptor
1349 } // namespace Internal