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/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");
61 } // unnamed namespace
63 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
66 return Window::New(surface, positionSize, name, className, type, isTransparent);
69 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
71 Window* window = new Window();
72 window->mIsTransparent = isTransparent;
73 window->Initialize(surface, positionSize, name, className, type);
78 : mWindowSurface(nullptr),
81 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
86 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
87 mDeleteRequestSignal(),
90 mVisibilityChangedSignal(),
91 mTransitionEffectEventSignal(),
92 mKeyboardRepeatSettingsChangedSignal(),
93 mAuxiliaryMessageSignal(),
95 mOrientationChangedSignal(),
96 mMouseInOutEventSignal(),
99 mIsTransparent(false),
100 mIsFocusAcceptable(true),
104 mWindowRotationAcknowledgement(false),
106 mIsWindowRotating(false)
114 auto bridge = Accessibility::Bridge::GetCurrentBridge();
115 auto rootLayer = mScene.GetRootLayer();
116 auto accessible = Accessibility::Accessible::Get(rootLayer);
117 bridge->RemoveTopLevelWindow(accessible);
118 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
119 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
124 mAdaptor->RemoveWindow(this);
129 mEventHandler->RemoveObserver(*this);
133 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
135 // Create a window render surface
136 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
137 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
138 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
141 mWindowBase = mWindowSurface->GetWindowBase();
144 mWindowBase->SetType(type);
146 // Initialize for Ime window type
147 if(type == WindowType::IME)
149 mWindowBase->InitializeIme();
150 mWindowSurface->InitializeImeSurface();
154 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
155 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
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);
165 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
166 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
168 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
170 SetClass(name, className);
172 mOrientation = Orientation::New(this);
174 // Get OrientationMode
175 int screenWidth, screenHeight;
176 WindowSystem::GetScreenSize(screenWidth, screenHeight);
177 if(screenWidth > screenHeight)
179 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
183 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
186 if(positionSize.width <= 0 || positionSize.height <= 0)
188 mWindowWidth = screenWidth;
189 mWindowHeight = screenHeight;
193 mWindowWidth = positionSize.width;
194 mWindowHeight = positionSize.height;
198 mNativeWindowId = mWindowBase->GetNativeWindowId();
201 void Window::SetRenderNotification(TriggerEventInterface *renderNotification)
208 mWindowSurface->SetRenderNotification(renderNotification);
211 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
213 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
214 mEventHandler->AddObserver(*this);
216 // Add Window to bridge for ATSPI
217 auto bridge = Accessibility::Bridge::GetCurrentBridge();
220 auto rootLayer = mScene.GetRootLayer();
221 auto accessible = Accessibility::Accessible::Get(rootLayer);
222 bridge->AddTopLevelWindow(accessible);
224 // Emit Window create event
225 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
226 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
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 Dali::RenderTaskList Window::GetRenderTaskList() const
327 return mScene.GetRenderTaskList();
330 std::string Window::GetNativeResourceId() const
332 return mWindowBase->GetNativeWindowResourceId();
335 void Window::AddAvailableOrientation(WindowOrientation orientation)
337 if(IsOrientationAvailable(orientation) == false)
343 int convertedAngle = ConvertToAngle(orientation);
344 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
345 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
347 if(mAvailableAngles[i] == convertedAngle)
356 mAvailableAngles.push_back(convertedAngle);
357 SetAvailableAnlges(mAvailableAngles);
361 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
363 if(IsOrientationAvailable(orientation) == false)
368 int convertedAngle = ConvertToAngle(orientation);
369 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
370 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
371 iter != mAvailableAngles.end();
374 if(*iter == convertedAngle)
376 mAvailableAngles.erase(iter);
381 SetAvailableAnlges(mAvailableAngles);
384 void Window::SetPreferredOrientation(WindowOrientation orientation)
386 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
388 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
391 mPreferredAngle = ConvertToAngle(orientation);
392 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
393 mWindowBase->SetPreferredAngle(mPreferredAngle);
396 WindowOrientation Window::GetPreferredOrientation()
398 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
399 return preferredOrientation;
402 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
404 int angle = ConvertToAngle(orientation);
405 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
408 void Window::EmitAccessibilityHighlightSignal(bool highlight)
410 Dali::Window handle(this);
411 mAccessibilityHighlightSignal.Emit(handle, highlight);
414 void Window::SetAvailableAnlges(const std::vector<int>& angles)
416 if(angles.size() > 4)
418 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
422 mWindowBase->SetAvailableAnlges(angles);
425 int Window::ConvertToAngle(WindowOrientation orientation)
427 int convertAngle = static_cast<int>(orientation);
428 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
432 case WindowOrientation::LANDSCAPE:
437 case WindowOrientation::PORTRAIT:
442 case WindowOrientation::LANDSCAPE_INVERSE:
447 case WindowOrientation::PORTRAIT_INVERSE:
452 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
462 WindowOrientation Window::ConvertToOrientation(int angle) const
464 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
465 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
471 orientation = WindowOrientation::LANDSCAPE;
476 orientation = WindowOrientation::PORTRAIT;
481 orientation = WindowOrientation::LANDSCAPE_INVERSE;
486 orientation = WindowOrientation::PORTRAIT_INVERSE;
491 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
499 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
501 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
503 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
509 Dali::Any Window::GetNativeHandle() const
511 return mWindowSurface->GetNativeWindow();
514 void Window::SetAcceptFocus(bool accept)
516 mIsFocusAcceptable = accept;
518 mWindowBase->SetAcceptFocus(accept);
521 bool Window::IsFocusAcceptable() const
523 return mIsFocusAcceptable;
534 Dali::Window handle(this);
535 mVisibilityChangedSignal.Emit(handle, true);
536 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
538 WindowVisibilityObserver* observer(mAdaptor);
539 observer->OnWindowShown();
542 mSurface->SetFullSwapNextFrame();
544 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
555 Dali::Window handle(this);
556 mVisibilityChangedSignal.Emit(handle, false);
557 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
559 WindowVisibilityObserver* observer(mAdaptor);
560 observer->OnWindowHidden();
563 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
566 bool Window::IsVisible() const
568 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
569 return mVisible && !mIconified;
572 unsigned int Window::GetSupportedAuxiliaryHintCount() const
574 return mWindowBase->GetSupportedAuxiliaryHintCount();
577 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
579 return mWindowBase->GetSupportedAuxiliaryHint(index);
582 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
584 return mWindowBase->AddAuxiliaryHint(hint, value);
587 bool Window::RemoveAuxiliaryHint(unsigned int id)
589 return mWindowBase->RemoveAuxiliaryHint(id);
592 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
594 return mWindowBase->SetAuxiliaryHintValue(id, value);
597 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
599 return mWindowBase->GetAuxiliaryHintValue(id);
602 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
604 return mWindowBase->GetAuxiliaryHintId(hint);
607 void Window::SetInputRegion(const Rect<int>& inputRegion)
609 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);
610 mWindowBase->SetInputRegion(inputRegion);
613 void Window::SetType(WindowType type)
615 mWindowBase->SetType(type);
618 WindowType Window::GetType() const
620 return mWindowBase->GetType();
623 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
625 WindowType type = mWindowBase->GetType();
626 if(type != WindowType::NOTIFICATION)
628 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
629 return WindowOperationResult::INVALID_OPERATION;
632 return mWindowBase->SetNotificationLevel(level);
635 WindowNotificationLevel Window::GetNotificationLevel() const
637 WindowType type = mWindowBase->GetType();
638 if(type != WindowType::NOTIFICATION)
640 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
641 return WindowNotificationLevel::NONE;
644 return mWindowBase->GetNotificationLevel();
647 void Window::SetOpaqueState(bool opaque)
649 mOpaqueState = opaque;
651 mWindowBase->SetOpaqueState(opaque);
653 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
656 bool Window::IsOpaqueState() const
661 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
663 return mWindowBase->SetScreenOffMode(screenOffMode);
666 WindowScreenOffMode Window::GetScreenOffMode() const
668 return mWindowBase->GetScreenOffMode();
671 WindowOperationResult Window::SetBrightness(int brightness)
673 if(brightness < 0 || brightness > 100)
675 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
676 return WindowOperationResult::INVALID_OPERATION;
679 return mWindowBase->SetBrightness(brightness);
682 int Window::GetBrightness() const
684 return mWindowBase->GetBrightness();
687 void Window::SetSize(Dali::Window::WindowSize size)
689 PositionSize oldRect = GetPositionSize();
691 PositionSize newRect;
692 newRect.width = size.GetWidth();
693 newRect.height = size.GetHeight();
695 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
696 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
698 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
700 Uint16Pair newSize(newRect.width, newRect.height);
702 mWindowWidth = newRect.width;
703 mWindowHeight = newRect.height;
705 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);
707 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
709 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
711 Dali::Window handle(this);
712 mResizeSignal.Emit(handle, newSize);
714 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
717 mSurface->SetFullSwapNextFrame();
719 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
722 Dali::Window::WindowSize Window::GetSize() const
724 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
727 void Window::SetPosition(Dali::Window::WindowPosition position)
729 PositionSize oldRect = mSurface->GetPositionSize();
730 int32_t newX = position.GetX();
731 int32_t newY = position.GetY();
733 mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
735 if((oldRect.x != newX) || (oldRect.y != newY))
737 Dali::Window handle(this);
738 Dali::Window::WindowPosition newPosition(newX, newY);
740 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
741 mMovedSignal.Emit(handle, newPosition);
744 mSurface->SetFullSwapNextFrame();
746 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
749 Dali::Window::WindowPosition Window::GetPosition() const
751 PositionSize positionSize = GetPositionSize();
752 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
755 PositionSize Window::GetPositionSize() const
757 PositionSize positionSize = mSurface->GetPositionSize();
758 positionSize.width = mWindowWidth;
759 positionSize.height = mWindowHeight;
763 void Window::SetPositionSize(PositionSize positionSize)
768 PositionSize oldRect = GetPositionSize();
769 Dali::Window handle(this);
771 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
776 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
783 mWindowSurface->MoveResize(positionSize);
786 // When window is moved, emit Moved Signal
789 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
790 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
791 mMovedSignal.Emit(handle, position);
794 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
797 Uint16Pair newSize(positionSize.width, positionSize.height);
799 mWindowWidth = positionSize.width;
800 mWindowHeight = positionSize.height;
802 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
804 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
806 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
808 mResizeSignal.Emit(handle, newSize);
809 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
812 mSurface->SetFullSwapNextFrame();
814 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
817 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
819 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
822 Dali::Layer Window::GetRootLayer() const
824 return mScene.GetRootLayer();
827 void Window::SetTransparency(bool transparent)
829 mWindowSurface->SetTransparency(transparent);
832 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
834 return mWindowBase->GrabKey(key, grabMode);
837 bool Window::UngrabKey(Dali::KEY key)
839 return mWindowBase->UngrabKey(key);
842 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
844 return mWindowBase->GrabKeyList(key, grabMode, result);
847 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
849 return mWindowBase->UngrabKeyList(key, result);
852 void Window::OnIconifyChanged(bool iconified)
854 const bool isActuallyChanged = (iconified != mIconified);
855 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
856 Dali::Window handle(this);
864 mVisibilityChangedSignal.Emit(handle, false);
865 bridge->WindowHidden(handle);
867 WindowVisibilityObserver* observer(mAdaptor);
868 observer->OnWindowHidden();
871 if(isActuallyChanged)
873 bridge->WindowMinimized(handle);
876 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
884 mVisibilityChangedSignal.Emit(handle, true);
885 bridge->WindowShown(handle);
887 WindowVisibilityObserver* observer(mAdaptor);
888 observer->OnWindowShown();
891 if(isActuallyChanged)
893 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
896 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
899 mSurface->SetFullSwapNextFrame();
902 void Window::OnMaximizeChanged(bool maximized)
904 const bool isActuallyChanged = (maximized != mMaximized);
906 if(isActuallyChanged)
908 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
909 Dali::Window handle(this);
914 bridge->WindowMaximized(handle);
919 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
924 void Window::OnFocusChanged(bool focusIn)
926 Dali::Window handle(this);
927 mFocusChangeSignal.Emit(handle, focusIn);
929 mSurface->SetFullSwapNextFrame();
930 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
934 bridge->WindowFocused(handle);
938 bridge->WindowUnfocused(handle);
944 void Window::OnOutputTransformed()
946 PositionSize positionSize = GetPositionSize();
948 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
950 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
951 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
954 void Window::OnDeleteRequest()
956 mDeleteRequestSignal.Emit();
959 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
961 Dali::Window handle(this);
962 mTransitionEffectEventSignal.Emit(handle, state, type);
965 void Window::OnKeyboardRepeatSettingsChanged()
967 Dali::Window handle(this);
968 mKeyboardRepeatSettingsChangedSignal.Emit();
971 void Window::OnWindowRedrawRequest()
973 mAdaptor->RenderOnce();
976 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
981 Dali::Window handle(this);
983 PositionSize oldRect = GetPositionSize();
984 PositionSize newRect = positionSize;
986 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
991 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
998 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);
999 mWindowSurface->UpdatePositionSize(positionSize);
1002 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1004 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1005 Dali::Window::WindowPosition position(newRect.x, newRect.y);
1006 mMovedSignal.Emit(handle, position);
1009 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1010 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1012 Uint16Pair newSize(newRect.width, newRect.height);
1014 mWindowWidth = newRect.width;
1015 mWindowHeight = newRect.height;
1017 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1019 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1021 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1022 mResizeSignal.Emit(handle, newSize);
1023 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1026 mSurface->SetFullSwapNextFrame();
1028 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1031 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1033 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1034 FeedTouchPoint(point, timeStamp);
1037 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1039 FeedWheelEvent(wheelEvent);
1042 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1044 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);
1045 FeedKeyEvent(keyEvent);
1048 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1050 Dali::Window handle(this);
1052 mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1055 void Window::OnRotation(const RotationEvent& rotation)
1057 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1059 mRotationAngle = rotation.angle;
1060 mWindowWidth = rotation.width;
1061 mWindowHeight = rotation.height;
1063 mIsWindowRotating = true;
1064 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);
1066 // Notify that the orientation is changed
1067 mOrientation->OnOrientationChange(rotation);
1069 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1071 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1073 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1075 Dali::Window handle(this);
1076 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1077 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1079 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1082 void Window::OnRotationFinished()
1084 mIsWindowRotating = false;
1085 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1088 void Window::OnPause()
1092 mEventHandler->Pause();
1096 void Window::OnResume()
1100 mEventHandler->Resume();
1103 mSurface->SetFullSwapNextFrame();
1106 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1108 mAuxiliaryMessageSignal.Emit(key, value, options);
1111 void Window::OnAccessibilityEnabled()
1113 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1114 auto rootLayer = mScene.GetRootLayer();
1115 auto accessible = Accessibility::Accessible::Get(rootLayer);
1116 bridge->AddTopLevelWindow(accessible);
1118 if(!mVisible || mIconified)
1123 Dali::Window handle(this);
1124 bridge->WindowShown(handle);
1128 bridge->WindowFocused(handle);
1132 void Window::OnAccessibilityDisabled()
1134 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1135 auto rootLayer = mScene.GetRootLayer();
1136 auto accessible = Accessibility::Accessible::Get(rootLayer);
1137 bridge->RemoveTopLevelWindow(accessible);
1140 Vector2 Window::RecalculatePosition(const Vector2& position)
1142 Vector2 convertedPosition;
1144 switch(mRotationAngle)
1148 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1149 convertedPosition.y = position.x;
1154 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1155 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1160 convertedPosition.x = position.y;
1161 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1166 convertedPosition = position;
1170 return convertedPosition;
1173 Dali::Window Window::Get(Dali::Actor actor)
1175 Internal::Adaptor::Window* windowImpl = nullptr;
1177 if(Internal::Adaptor::Adaptor::IsAvailable())
1179 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1180 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1183 return Dali::Window(windowImpl);
1187 return Dali::Window();
1190 void Window::SetParent(Dali::Window& parent)
1192 if(DALI_UNLIKELY(parent))
1194 mParentWindow = parent;
1195 Dali::Window self = Dali::Window(this);
1196 // check circular parent window setting
1197 if(Dali::DevelWindow::GetParent(parent) == self)
1199 Dali::DevelWindow::Unparent(parent);
1201 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1205 void Window::SetParent(Dali::Window& parent, bool belowParent)
1207 if(DALI_UNLIKELY(parent))
1209 mParentWindow = parent;
1210 Dali::Window self = Dali::Window(this);
1211 // check circular parent window setting
1212 if(Dali::DevelWindow::GetParent(parent) == self)
1214 Dali::DevelWindow::Unparent(parent);
1216 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1220 void Window::Unparent()
1222 mWindowBase->SetParent(nullptr, false);
1223 mParentWindow.Reset();
1226 Dali::Window Window::GetParent()
1228 return mParentWindow;
1231 WindowOrientation Window::GetCurrentOrientation() const
1233 return ConvertToOrientation(mRotationAngle);
1236 int Window::GetPhysicalOrientation() const
1238 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1241 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1243 Dali::Vector<float>::SizeType count = orientations.Count();
1244 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1246 if(IsOrientationAvailable(orientations[index]) == false)
1248 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1253 int convertedAngle = ConvertToAngle(orientations[index]);
1255 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1257 if(mAvailableAngles[i] == convertedAngle)
1266 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1267 mAvailableAngles.push_back(convertedAngle);
1270 SetAvailableAnlges(mAvailableAngles);
1273 int32_t Window::GetNativeId() const
1275 return mWindowBase->GetNativeWindowId();
1278 void Window::RequestMoveToServer()
1280 mWindowBase->RequestMoveToServer();
1283 void Window::RequestResizeToServer(WindowResizeDirection direction)
1285 mWindowBase->RequestResizeToServer(direction);
1288 void Window::EnableFloatingMode(bool enable)
1290 mWindowBase->EnableFloatingMode(enable);
1293 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1295 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);
1296 mWindowBase->IncludeInputRegion(inputRegion);
1299 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1301 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);
1302 mWindowBase->ExcludeInputRegion(inputRegion);
1305 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1307 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1308 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1309 mWindowRotationAcknowledgement = needAcknowledgement;
1312 void Window::SendRotationCompletedAcknowledgement()
1314 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1315 if(mWindowRotationAcknowledgement)
1317 SetRotationCompletedAcknowledgement();
1321 bool Window::IsWindowRotating() const
1323 return mIsWindowRotating;
1326 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1328 return mLastKeyEvent;
1331 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1333 return mLastTouchEvent;
1336 } // namespace Adaptor
1338 } // namespace Internal