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");
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(),
98 mIsTransparent(false),
99 mIsFocusAcceptable(true),
103 mWindowRotationAcknowledgement(false),
105 mIsWindowRotating(false)
113 auto bridge = Accessibility::Bridge::GetCurrentBridge();
114 auto rootLayer = mScene.GetRootLayer();
115 auto accessible = Accessibility::Accessible::Get(rootLayer);
116 bridge->RemoveTopLevelWindow(accessible);
117 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
118 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
123 mAdaptor->RemoveWindow(this);
128 mEventHandler->RemoveObserver(*this);
132 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
134 // Create a window render surface
135 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
136 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
137 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
140 mWindowBase = mWindowSurface->GetWindowBase();
143 mWindowBase->SetType(type);
145 // Initialize for Ime window type
146 if(type == WindowType::IME)
148 mWindowBase->InitializeIme();
149 mWindowSurface->InitializeImeSurface();
153 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
154 mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
155 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
156 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
157 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
158 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
159 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
160 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
161 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
163 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
164 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
166 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
168 SetClass(name, className);
170 mOrientation = Orientation::New(this);
172 // Get OrientationMode
173 int screenWidth, screenHeight;
174 WindowSystem::GetScreenSize(screenWidth, screenHeight);
175 if(screenWidth > screenHeight)
177 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
181 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
184 if(positionSize.width <= 0 || positionSize.height <= 0)
186 mWindowWidth = screenWidth;
187 mWindowHeight = screenHeight;
191 mWindowWidth = positionSize.width;
192 mWindowHeight = positionSize.height;
196 mNativeWindowId = mWindowBase->GetNativeWindowId();
199 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
201 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
202 mEventHandler->AddObserver(*this);
204 // Add Window to bridge for ATSPI
205 auto bridge = Accessibility::Bridge::GetCurrentBridge();
208 auto rootLayer = mScene.GetRootLayer();
209 auto accessible = Accessibility::Accessible::Get(rootLayer);
210 bridge->AddTopLevelWindow(accessible);
212 // Emit Window create event
213 // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
214 bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
217 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
218 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
220 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
221 // The show must be called after the adaptor is initialized.
225 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
227 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
230 void Window::SetClass(std::string name, std::string className)
233 mClassName = className;
234 mWindowBase->SetClass(name, className);
237 std::string Window::GetClassName() const
244 mWindowBase->Raise();
246 mSurface->SetFullSwapNextFrame();
248 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
253 mWindowBase->Lower();
255 mSurface->SetFullSwapNextFrame();
257 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
260 void Window::Activate()
262 mWindowBase->Activate();
264 mSurface->SetFullSwapNextFrame();
266 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
269 void Window::Maximize(bool maximize)
271 mWindowBase->Maximize(maximize);
273 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
276 bool Window::IsMaximized() const
278 return mWindowBase->IsMaximized();
281 void Window::SetMaximumSize(Dali::Window::WindowSize size)
283 mWindowBase->SetMaximumSize(size);
286 void Window::Minimize(bool minimize)
288 mWindowBase->Minimize(minimize);
290 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
293 bool Window::IsMinimized() const
295 return mWindowBase->IsMinimized();
298 void Window::SetMimimumSize(Dali::Window::WindowSize size)
300 mWindowBase->SetMimimumSize(size);
303 uint32_t Window::GetLayerCount() const
305 return mScene.GetLayerCount();
308 Dali::Layer Window::GetLayer(uint32_t depth) const
310 return mScene.GetLayer(depth);
313 Dali::RenderTaskList Window::GetRenderTaskList() const
315 return mScene.GetRenderTaskList();
318 std::string Window::GetNativeResourceId() const
320 return mWindowBase->GetNativeWindowResourceId();
323 void Window::AddAvailableOrientation(WindowOrientation orientation)
325 if(IsOrientationAvailable(orientation) == false)
331 int convertedAngle = ConvertToAngle(orientation);
332 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
333 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
335 if(mAvailableAngles[i] == convertedAngle)
344 mAvailableAngles.push_back(convertedAngle);
345 SetAvailableAnlges(mAvailableAngles);
349 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
351 if(IsOrientationAvailable(orientation) == false)
356 int convertedAngle = ConvertToAngle(orientation);
357 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
358 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
359 iter != mAvailableAngles.end();
362 if(*iter == convertedAngle)
364 mAvailableAngles.erase(iter);
369 SetAvailableAnlges(mAvailableAngles);
372 void Window::SetPreferredOrientation(WindowOrientation orientation)
374 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
376 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
379 mPreferredAngle = ConvertToAngle(orientation);
380 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
381 mWindowBase->SetPreferredAngle(mPreferredAngle);
384 WindowOrientation Window::GetPreferredOrientation()
386 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
387 return preferredOrientation;
390 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
392 int angle = ConvertToAngle(orientation);
393 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
396 void Window::EmitAccessibilityHighlightSignal(bool highlight)
398 Dali::Window handle(this);
399 mAccessibilityHighlightSignal.Emit(handle, highlight);
402 void Window::SetAvailableAnlges(const std::vector<int>& angles)
404 if(angles.size() > 4)
406 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
410 mWindowBase->SetAvailableAnlges(angles);
413 int Window::ConvertToAngle(WindowOrientation orientation)
415 int convertAngle = static_cast<int>(orientation);
416 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
420 case WindowOrientation::LANDSCAPE:
425 case WindowOrientation::PORTRAIT:
430 case WindowOrientation::LANDSCAPE_INVERSE:
435 case WindowOrientation::PORTRAIT_INVERSE:
440 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
450 WindowOrientation Window::ConvertToOrientation(int angle) const
452 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
453 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
459 orientation = WindowOrientation::LANDSCAPE;
464 orientation = WindowOrientation::PORTRAIT;
469 orientation = WindowOrientation::LANDSCAPE_INVERSE;
474 orientation = WindowOrientation::PORTRAIT_INVERSE;
479 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
487 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
489 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
491 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
497 Dali::Any Window::GetNativeHandle() const
499 return mWindowSurface->GetNativeWindow();
502 void Window::SetAcceptFocus(bool accept)
504 mIsFocusAcceptable = accept;
506 mWindowBase->SetAcceptFocus(accept);
509 bool Window::IsFocusAcceptable() const
511 return mIsFocusAcceptable;
522 Dali::Window handle(this);
523 mVisibilityChangedSignal.Emit(handle, true);
524 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
526 WindowVisibilityObserver* observer(mAdaptor);
527 observer->OnWindowShown();
530 mSurface->SetFullSwapNextFrame();
532 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
543 Dali::Window handle(this);
544 mVisibilityChangedSignal.Emit(handle, false);
545 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
547 WindowVisibilityObserver* observer(mAdaptor);
548 observer->OnWindowHidden();
551 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
554 bool Window::IsVisible() const
556 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
557 return mVisible && !mIconified;
560 unsigned int Window::GetSupportedAuxiliaryHintCount() const
562 return mWindowBase->GetSupportedAuxiliaryHintCount();
565 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
567 return mWindowBase->GetSupportedAuxiliaryHint(index);
570 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
572 return mWindowBase->AddAuxiliaryHint(hint, value);
575 bool Window::RemoveAuxiliaryHint(unsigned int id)
577 return mWindowBase->RemoveAuxiliaryHint(id);
580 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
582 return mWindowBase->SetAuxiliaryHintValue(id, value);
585 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
587 return mWindowBase->GetAuxiliaryHintValue(id);
590 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
592 return mWindowBase->GetAuxiliaryHintId(hint);
595 void Window::SetInputRegion(const Rect<int>& inputRegion)
597 Rect<int> convertRegion = RecalculateRect(inputRegion);
599 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);
601 mWindowBase->SetInputRegion(convertRegion);
604 void Window::SetType(WindowType type)
606 mWindowBase->SetType(type);
609 WindowType Window::GetType() const
611 return mWindowBase->GetType();
614 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
616 WindowType type = mWindowBase->GetType();
617 if(type != WindowType::NOTIFICATION)
619 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
620 return WindowOperationResult::INVALID_OPERATION;
623 return mWindowBase->SetNotificationLevel(level);
626 WindowNotificationLevel Window::GetNotificationLevel() const
628 WindowType type = mWindowBase->GetType();
629 if(type != WindowType::NOTIFICATION)
631 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
632 return WindowNotificationLevel::NONE;
635 return mWindowBase->GetNotificationLevel();
638 void Window::SetOpaqueState(bool opaque)
640 mOpaqueState = opaque;
642 mWindowBase->SetOpaqueState(opaque);
644 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
647 bool Window::IsOpaqueState() const
652 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
654 return mWindowBase->SetScreenOffMode(screenOffMode);
657 WindowScreenOffMode Window::GetScreenOffMode() const
659 return mWindowBase->GetScreenOffMode();
662 WindowOperationResult Window::SetBrightness(int brightness)
664 if(brightness < 0 || brightness > 100)
666 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
667 return WindowOperationResult::INVALID_OPERATION;
670 return mWindowBase->SetBrightness(brightness);
673 int Window::GetBrightness() const
675 return mWindowBase->GetBrightness();
678 void Window::SetSize(Dali::Window::WindowSize size)
680 PositionSize oldRect = GetPositionSize();
682 PositionSize newRect;
683 newRect.width = size.GetWidth();
684 newRect.height = size.GetHeight();
686 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
687 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
689 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
691 Uint16Pair newSize(newRect.width, newRect.height);
693 mWindowWidth = newRect.width;
694 mWindowHeight = newRect.height;
696 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);
698 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
700 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
702 Dali::Window handle(this);
703 mResizeSignal.Emit(handle, newSize);
705 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
708 mSurface->SetFullSwapNextFrame();
710 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
713 Dali::Window::WindowSize Window::GetSize() const
715 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
718 void Window::SetPosition(Dali::Window::WindowPosition position)
720 PositionSize oldRect = mSurface->GetPositionSize();
721 int32_t newX = position.GetX();
722 int32_t newY = position.GetY();
724 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
726 if((oldRect.x != newX) || (oldRect.y != newY))
728 Dali::Window handle(this);
729 Dali::Window::WindowPosition newPosition(newX, newY);
731 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
732 mMovedSignal.Emit(handle, newPosition);
735 mSurface->SetFullSwapNextFrame();
737 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
740 Dali::Window::WindowPosition Window::GetPosition() const
742 PositionSize positionSize = GetPositionSize();
743 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
746 PositionSize Window::GetPositionSize() const
748 PositionSize positionSize = mSurface->GetPositionSize();
749 positionSize.width = mWindowWidth;
750 positionSize.height = mWindowHeight;
754 void Window::SetPositionSize(PositionSize positionSize)
759 PositionSize oldRect = GetPositionSize();
760 Dali::Window handle(this);
762 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
767 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
774 mWindowSurface->MoveResize(positionSize);
777 // When window is moved, emit Moved Signal
780 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
781 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
782 mMovedSignal.Emit(handle, position);
785 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
788 Uint16Pair newSize(positionSize.width, positionSize.height);
790 mWindowWidth = positionSize.width;
791 mWindowHeight = positionSize.height;
793 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
795 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
797 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
799 mResizeSignal.Emit(handle, newSize);
800 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
803 mSurface->SetFullSwapNextFrame();
805 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
808 Dali::Layer Window::GetRootLayer() const
810 return mScene.GetRootLayer();
813 void Window::SetTransparency(bool transparent)
815 mWindowSurface->SetTransparency(transparent);
818 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
820 return mWindowBase->GrabKey(key, grabMode);
823 bool Window::UngrabKey(Dali::KEY key)
825 return mWindowBase->UngrabKey(key);
828 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
830 return mWindowBase->GrabKeyList(key, grabMode, result);
833 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
835 return mWindowBase->UngrabKeyList(key, result);
838 void Window::OnIconifyChanged(bool iconified)
840 const bool isActuallyChanged = (iconified != mIconified);
841 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
842 Dali::Window handle(this);
850 mVisibilityChangedSignal.Emit(handle, false);
851 bridge->WindowHidden(handle);
853 WindowVisibilityObserver* observer(mAdaptor);
854 observer->OnWindowHidden();
857 if(isActuallyChanged)
859 bridge->WindowMinimized(handle);
862 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
870 mVisibilityChangedSignal.Emit(handle, true);
871 bridge->WindowShown(handle);
873 WindowVisibilityObserver* observer(mAdaptor);
874 observer->OnWindowShown();
877 if(isActuallyChanged)
879 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
882 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
885 mSurface->SetFullSwapNextFrame();
888 void Window::OnMaximizeChanged(bool maximized)
890 const bool isActuallyChanged = (maximized != mMaximized);
892 if(isActuallyChanged)
894 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
895 Dali::Window handle(this);
900 bridge->WindowMaximized(handle);
905 bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
910 void Window::OnFocusChanged(bool focusIn)
912 Dali::Window handle(this);
913 mFocusChangeSignal.Emit(handle, focusIn);
915 mSurface->SetFullSwapNextFrame();
916 auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
920 bridge->WindowFocused(handle);
924 bridge->WindowUnfocused(handle);
930 void Window::OnOutputTransformed()
932 PositionSize positionSize = GetPositionSize();
934 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
936 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
937 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
940 void Window::OnDeleteRequest()
942 mDeleteRequestSignal.Emit();
945 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
947 Dali::Window handle(this);
948 mTransitionEffectEventSignal.Emit(handle, state, type);
951 void Window::OnKeyboardRepeatSettingsChanged()
953 Dali::Window handle(this);
954 mKeyboardRepeatSettingsChangedSignal.Emit();
957 void Window::OnWindowRedrawRequest()
959 mAdaptor->RenderOnce();
962 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
967 Dali::Window handle(this);
969 PositionSize oldRect = GetPositionSize();
970 PositionSize newRect = positionSize;
972 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
977 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
984 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);
985 mWindowSurface->UpdatePositionSize(positionSize);
988 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
990 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
991 Dali::Window::WindowPosition position(newRect.x, newRect.y);
992 mMovedSignal.Emit(handle, position);
995 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
996 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
998 Uint16Pair newSize(newRect.width, newRect.height);
1000 mWindowWidth = newRect.width;
1001 mWindowHeight = newRect.height;
1003 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1005 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1007 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1008 mResizeSignal.Emit(handle, newSize);
1009 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1012 mSurface->SetFullSwapNextFrame();
1014 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1017 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1019 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1020 FeedTouchPoint(point, timeStamp);
1023 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1025 FeedWheelEvent(wheelEvent);
1028 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1030 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);
1031 FeedKeyEvent(keyEvent);
1034 void Window::OnRotation(const RotationEvent& rotation)
1036 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1038 mRotationAngle = rotation.angle;
1039 mWindowWidth = rotation.width;
1040 mWindowHeight = rotation.height;
1042 mIsWindowRotating = true;
1043 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);
1045 // Notify that the orientation is changed
1046 mOrientation->OnOrientationChange(rotation);
1048 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1050 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1052 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1054 Dali::Window handle(this);
1055 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1056 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1058 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1061 void Window::OnRotationFinished()
1063 mIsWindowRotating = false;
1064 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1067 void Window::OnPause()
1071 mEventHandler->Pause();
1075 void Window::OnResume()
1079 mEventHandler->Resume();
1082 mSurface->SetFullSwapNextFrame();
1085 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1087 mAuxiliaryMessageSignal.Emit(key, value, options);
1090 void Window::OnAccessibilityEnabled()
1092 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1093 auto rootLayer = mScene.GetRootLayer();
1094 auto accessible = Accessibility::Accessible::Get(rootLayer);
1095 bridge->AddTopLevelWindow(accessible);
1097 if(!mVisible || mIconified)
1102 Dali::Window handle(this);
1103 bridge->WindowShown(handle);
1107 bridge->WindowFocused(handle);
1111 void Window::OnAccessibilityDisabled()
1113 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1114 auto rootLayer = mScene.GetRootLayer();
1115 auto accessible = Accessibility::Accessible::Get(rootLayer);
1116 bridge->RemoveTopLevelWindow(accessible);
1119 Vector2 Window::RecalculatePosition(const Vector2& position)
1121 Vector2 convertedPosition;
1123 switch(mRotationAngle)
1127 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1128 convertedPosition.y = position.x;
1133 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1134 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1139 convertedPosition.x = position.y;
1140 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1145 convertedPosition = position;
1149 return convertedPosition;
1152 Dali::Window Window::Get(Dali::Actor actor)
1154 Internal::Adaptor::Window* windowImpl = nullptr;
1156 if(Internal::Adaptor::Adaptor::IsAvailable())
1158 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1159 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1162 return Dali::Window(windowImpl);
1166 return Dali::Window();
1169 void Window::SetParent(Dali::Window& parent)
1171 if(DALI_UNLIKELY(parent))
1173 mParentWindow = parent;
1174 Dali::Window self = Dali::Window(this);
1175 // check circular parent window setting
1176 if(Dali::DevelWindow::GetParent(parent) == self)
1178 Dali::DevelWindow::Unparent(parent);
1180 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1184 void Window::SetParent(Dali::Window& parent, bool belowParent)
1186 if(DALI_UNLIKELY(parent))
1188 mParentWindow = parent;
1189 Dali::Window self = Dali::Window(this);
1190 // check circular parent window setting
1191 if(Dali::DevelWindow::GetParent(parent) == self)
1193 Dali::DevelWindow::Unparent(parent);
1195 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1199 void Window::Unparent()
1201 mWindowBase->SetParent(nullptr, false);
1202 mParentWindow.Reset();
1205 Dali::Window Window::GetParent()
1207 return mParentWindow;
1210 WindowOrientation Window::GetCurrentOrientation() const
1212 return ConvertToOrientation(mRotationAngle);
1215 int Window::GetPhysicalOrientation() const
1217 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1220 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1222 Dali::Vector<float>::SizeType count = orientations.Count();
1223 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1225 if(IsOrientationAvailable(orientations[index]) == false)
1227 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1232 int convertedAngle = ConvertToAngle(orientations[index]);
1234 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1236 if(mAvailableAngles[i] == convertedAngle)
1245 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1246 mAvailableAngles.push_back(convertedAngle);
1249 SetAvailableAnlges(mAvailableAngles);
1252 int32_t Window::GetNativeId() const
1254 return mWindowBase->GetNativeWindowId();
1257 void Window::RequestMoveToServer()
1259 mWindowBase->RequestMoveToServer();
1262 void Window::RequestResizeToServer(WindowResizeDirection direction)
1264 mWindowBase->RequestResizeToServer(direction);
1267 void Window::EnableFloatingMode(bool enable)
1269 mWindowBase->EnableFloatingMode(enable);
1272 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1275 int screenWidth, screenHeight;
1277 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1279 if(mRotationAngle == 90)
1282 newRect.y = screenHeight - (rect.x + rect.width);
1283 newRect.width = rect.height;
1284 newRect.height = rect.width;
1286 else if(mRotationAngle == 180)
1288 newRect.x = screenWidth - (rect.x + rect.width);
1289 newRect.y = screenHeight - (rect.y + rect.height);
1290 newRect.width = rect.width;
1291 newRect.height = rect.height;
1293 else if(mRotationAngle == 270)
1295 newRect.x = screenWidth - (rect.y + rect.height);
1297 newRect.width = rect.height;
1298 newRect.height = rect.width;
1304 newRect.width = rect.width;
1305 newRect.height = rect.height;
1310 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1312 Rect<int> convertRegion = RecalculateRect(inputRegion);
1314 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);
1315 mWindowBase->IncludeInputRegion(convertRegion);
1318 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1320 Rect<int> convertRegion = RecalculateRect(inputRegion);
1322 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);
1323 mWindowBase->ExcludeInputRegion(convertRegion);
1326 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1328 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1329 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1330 mWindowRotationAcknowledgement = needAcknowledgement;
1333 void Window::SendRotationCompletedAcknowledgement()
1335 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1336 if(mWindowRotationAcknowledgement)
1338 SetRotationCompletedAcknowledgement();
1342 bool Window::IsWindowRotating() const
1344 return mIsWindowRotating;
1347 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1349 return mLastKeyEvent;
1352 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1354 return mLastTouchEvent;
1357 } // namespace Adaptor
1359 } // namespace Internal