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");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
96 mOrientationChangedSignal(),
99 mIsTransparent(false),
100 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);
121 if(DALI_LIKELY(mAdaptor))
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->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
155 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
156 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
157 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
158 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
159 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
160 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
162 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
163 mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
165 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
167 SetClass(name, className);
169 mOrientation = Orientation::New(this);
171 // Get OrientationMode
172 int screenWidth, screenHeight;
173 WindowSystem::GetScreenSize(screenWidth, screenHeight);
174 if(screenWidth > screenHeight)
176 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
180 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
183 if(positionSize.width <= 0 || positionSize.height <= 0)
185 mWindowWidth = screenWidth;
186 mWindowHeight = screenHeight;
190 mWindowWidth = positionSize.width;
191 mWindowHeight = positionSize.height;
195 mNativeWindowId = mWindowBase->GetNativeWindowId();
198 void Window::SetRenderNotification(TriggerEventInterface *renderNotification)
205 mWindowSurface->SetRenderNotification(renderNotification);
208 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
210 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
211 mEventHandler->AddObserver(*this);
213 // Add Window to bridge for ATSPI
214 auto bridge = Accessibility::Bridge::GetCurrentBridge();
217 auto rootLayer = mScene.GetRootLayer();
218 auto accessible = Accessibility::Accessible::Get(rootLayer);
219 bridge->AddTopLevelWindow(accessible);
222 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
223 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
225 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
226 // The show must be called after the adaptor is initialized.
230 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
232 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
235 void Window::SetClass(std::string name, std::string className)
238 mClassName = className;
239 mWindowBase->SetClass(name, className);
242 std::string Window::GetClassName() const
249 mWindowBase->Raise();
251 mSurface->SetFullSwapNextFrame();
253 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
258 mWindowBase->Lower();
260 mSurface->SetFullSwapNextFrame();
262 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
265 void Window::Activate()
267 mWindowBase->Activate();
269 mSurface->SetFullSwapNextFrame();
271 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
274 void Window::Maximize(bool maximize)
276 mWindowBase->Maximize(maximize);
278 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
281 bool Window::IsMaximized() const
283 return mWindowBase->IsMaximized();
286 void Window::SetMaximumSize(Dali::Window::WindowSize size)
288 mWindowBase->SetMaximumSize(size);
291 void Window::Minimize(bool minimize)
293 mWindowBase->Minimize(minimize);
295 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
298 bool Window::IsMinimized() const
300 return mWindowBase->IsMinimized();
303 void Window::SetMimimumSize(Dali::Window::WindowSize size)
305 mWindowBase->SetMimimumSize(size);
308 uint32_t Window::GetLayerCount() const
310 return mScene.GetLayerCount();
313 Dali::Layer Window::GetLayer(uint32_t depth) const
315 return mScene.GetLayer(depth);
318 Dali::RenderTaskList Window::GetRenderTaskList() const
320 return mScene.GetRenderTaskList();
323 std::string Window::GetNativeResourceId() const
325 return mWindowBase->GetNativeWindowResourceId();
328 void Window::AddAvailableOrientation(WindowOrientation orientation)
330 if(IsOrientationAvailable(orientation) == false)
336 int convertedAngle = ConvertToAngle(orientation);
337 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
338 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
340 if(mAvailableAngles[i] == convertedAngle)
349 mAvailableAngles.push_back(convertedAngle);
350 SetAvailableAnlges(mAvailableAngles);
354 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
356 if(IsOrientationAvailable(orientation) == false)
361 int convertedAngle = ConvertToAngle(orientation);
362 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
363 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
364 iter != mAvailableAngles.end();
367 if(*iter == convertedAngle)
369 mAvailableAngles.erase(iter);
374 SetAvailableAnlges(mAvailableAngles);
377 void Window::SetPreferredOrientation(WindowOrientation orientation)
379 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
381 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
384 mPreferredAngle = ConvertToAngle(orientation);
385 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
386 mWindowBase->SetPreferredAngle(mPreferredAngle);
389 WindowOrientation Window::GetPreferredOrientation()
391 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
392 return preferredOrientation;
395 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
397 int angle = ConvertToAngle(orientation);
398 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
401 void Window::EmitAccessibilityHighlightSignal(bool highlight)
403 Dali::Window handle(this);
404 mAccessibilityHighlightSignal.Emit(handle, highlight);
407 void Window::SetAvailableAnlges(const std::vector<int>& angles)
409 if(angles.size() > 4)
411 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
415 mWindowBase->SetAvailableAnlges(angles);
418 int Window::ConvertToAngle(WindowOrientation orientation)
420 int convertAngle = static_cast<int>(orientation);
421 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
425 case WindowOrientation::LANDSCAPE:
430 case WindowOrientation::PORTRAIT:
435 case WindowOrientation::LANDSCAPE_INVERSE:
440 case WindowOrientation::PORTRAIT_INVERSE:
445 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
455 WindowOrientation Window::ConvertToOrientation(int angle) const
457 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
458 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
464 orientation = WindowOrientation::LANDSCAPE;
469 orientation = WindowOrientation::PORTRAIT;
474 orientation = WindowOrientation::LANDSCAPE_INVERSE;
479 orientation = WindowOrientation::PORTRAIT_INVERSE;
484 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
492 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
494 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
496 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
502 Dali::Any Window::GetNativeHandle() const
504 return mWindowSurface->GetNativeWindow();
507 void Window::SetAcceptFocus(bool accept)
509 mIsFocusAcceptable = accept;
511 mWindowBase->SetAcceptFocus(accept);
514 bool Window::IsFocusAcceptable() const
516 return mIsFocusAcceptable;
527 Dali::Window handle(this);
528 mVisibilityChangedSignal.Emit(handle, true);
529 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
531 WindowVisibilityObserver* observer(mAdaptor);
532 observer->OnWindowShown();
535 mSurface->SetFullSwapNextFrame();
537 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
548 Dali::Window handle(this);
549 mVisibilityChangedSignal.Emit(handle, false);
550 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
552 WindowVisibilityObserver* observer(mAdaptor);
553 observer->OnWindowHidden();
556 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
559 bool Window::IsVisible() const
561 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
562 return mVisible && !mIconified;
565 unsigned int Window::GetSupportedAuxiliaryHintCount() const
567 return mWindowBase->GetSupportedAuxiliaryHintCount();
570 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
572 return mWindowBase->GetSupportedAuxiliaryHint(index);
575 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
577 return mWindowBase->AddAuxiliaryHint(hint, value);
580 bool Window::RemoveAuxiliaryHint(unsigned int id)
582 return mWindowBase->RemoveAuxiliaryHint(id);
585 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
587 return mWindowBase->SetAuxiliaryHintValue(id, value);
590 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
592 return mWindowBase->GetAuxiliaryHintValue(id);
595 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
597 return mWindowBase->GetAuxiliaryHintId(hint);
600 void Window::SetInputRegion(const Rect<int>& inputRegion)
602 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);
603 mWindowBase->SetInputRegion(inputRegion);
606 void Window::SetType(WindowType type)
608 mWindowBase->SetType(type);
611 WindowType Window::GetType() const
613 return mWindowBase->GetType();
616 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
618 WindowType type = mWindowBase->GetType();
619 if(type != WindowType::NOTIFICATION)
621 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
622 return WindowOperationResult::INVALID_OPERATION;
625 return mWindowBase->SetNotificationLevel(level);
628 WindowNotificationLevel Window::GetNotificationLevel() const
630 WindowType type = mWindowBase->GetType();
631 if(type != WindowType::NOTIFICATION)
633 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
634 return WindowNotificationLevel::NONE;
637 return mWindowBase->GetNotificationLevel();
640 void Window::SetOpaqueState(bool opaque)
642 mOpaqueState = opaque;
644 mWindowBase->SetOpaqueState(opaque);
646 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
649 bool Window::IsOpaqueState() const
654 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
656 return mWindowBase->SetScreenOffMode(screenOffMode);
659 WindowScreenOffMode Window::GetScreenOffMode() const
661 return mWindowBase->GetScreenOffMode();
664 WindowOperationResult Window::SetBrightness(int brightness)
666 if(brightness < 0 || brightness > 100)
668 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
669 return WindowOperationResult::INVALID_OPERATION;
672 return mWindowBase->SetBrightness(brightness);
675 int Window::GetBrightness() const
677 return mWindowBase->GetBrightness();
680 void Window::SetSize(Dali::Window::WindowSize size)
682 PositionSize oldRect = GetPositionSize();
684 PositionSize newRect;
685 newRect.width = size.GetWidth();
686 newRect.height = size.GetHeight();
688 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
689 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
691 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
693 Uint16Pair newSize(newRect.width, newRect.height);
695 mWindowWidth = newRect.width;
696 mWindowHeight = newRect.height;
698 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);
700 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
702 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
704 Dali::Window handle(this);
705 mResizeSignal.Emit(handle, newSize);
707 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
710 mSurface->SetFullSwapNextFrame();
712 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
715 Dali::Window::WindowSize Window::GetSize() const
717 return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
720 void Window::SetPosition(Dali::Window::WindowPosition position)
722 PositionSize oldRect = mSurface->GetPositionSize();
723 int32_t newX = position.GetX();
724 int32_t newY = position.GetY();
726 mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
728 if((oldRect.x != newX) || (oldRect.y != newY))
730 Dali::Window handle(this);
731 Dali::Window::WindowPosition newPosition(newX, newY);
733 DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
734 mMovedSignal.Emit(handle, newPosition);
737 mSurface->SetFullSwapNextFrame();
739 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
742 Dali::Window::WindowPosition Window::GetPosition() const
744 PositionSize positionSize = GetPositionSize();
745 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
748 PositionSize Window::GetPositionSize() const
750 PositionSize positionSize = mSurface->GetPositionSize();
751 positionSize.width = mWindowWidth;
752 positionSize.height = mWindowHeight;
756 void Window::SetPositionSize(PositionSize positionSize)
761 PositionSize oldRect = GetPositionSize();
762 Dali::Window handle(this);
764 if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
769 if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
776 mWindowSurface->MoveResize(positionSize);
779 // When window is moved, emit Moved Signal
782 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
783 Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
784 mMovedSignal.Emit(handle, position);
787 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
790 Uint16Pair newSize(positionSize.width, positionSize.height);
792 mWindowWidth = positionSize.width;
793 mWindowHeight = positionSize.height;
795 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
797 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
799 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
801 mResizeSignal.Emit(handle, newSize);
802 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
805 mSurface->SetFullSwapNextFrame();
807 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
810 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
812 mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
815 Dali::Layer Window::GetRootLayer() const
817 return mScene.GetRootLayer();
820 void Window::SetTransparency(bool transparent)
822 mWindowSurface->SetTransparency(transparent);
825 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
827 return mWindowBase->GrabKey(key, grabMode);
830 bool Window::UngrabKey(Dali::KEY key)
832 return mWindowBase->UngrabKey(key);
835 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
837 return mWindowBase->GrabKeyList(key, grabMode, result);
840 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
842 return mWindowBase->UngrabKeyList(key, result);
845 void Window::OnIconifyChanged(bool iconified)
853 Dali::Window handle(this);
854 mVisibilityChangedSignal.Emit(handle, false);
855 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
857 if(DALI_LIKELY(mAdaptor))
859 WindowVisibilityObserver* observer(mAdaptor);
860 observer->OnWindowHidden();
864 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
872 Dali::Window handle(this);
873 mVisibilityChangedSignal.Emit(handle, true);
874 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
876 if(DALI_LIKELY(mAdaptor))
878 WindowVisibilityObserver* observer(mAdaptor);
879 observer->OnWindowShown();
883 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
886 mSurface->SetFullSwapNextFrame();
889 void Window::OnFocusChanged(bool focusIn)
891 Dali::Window handle(this);
892 mFocusChangeSignal.Emit(handle, focusIn);
894 mSurface->SetFullSwapNextFrame();
896 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
900 bridge->WindowFocused(handle);
904 bridge->WindowUnfocused(handle);
910 void Window::OnOutputTransformed()
912 PositionSize positionSize = GetPositionSize();
914 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
916 if(DALI_LIKELY(mAdaptor))
918 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
919 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
923 void Window::OnDeleteRequest()
925 mDeleteRequestSignal.Emit();
928 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
930 Dali::Window handle(this);
931 mTransitionEffectEventSignal.Emit(handle, state, type);
934 void Window::OnKeyboardRepeatSettingsChanged()
936 Dali::Window handle(this);
937 mKeyboardRepeatSettingsChangedSignal.Emit();
940 void Window::OnWindowRedrawRequest()
942 if(DALI_LIKELY(mAdaptor))
944 mAdaptor->RenderOnce();
948 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
953 Dali::Window handle(this);
955 PositionSize oldRect = GetPositionSize();
956 PositionSize newRect = positionSize;
958 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
963 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
970 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);
971 mWindowSurface->UpdatePositionSize(positionSize);
974 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
976 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
977 Dali::Window::WindowPosition position(newRect.x, newRect.y);
978 mMovedSignal.Emit(handle, position);
981 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
982 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
984 Uint16Pair newSize(newRect.width, newRect.height);
986 mWindowWidth = newRect.width;
987 mWindowHeight = newRect.height;
989 SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
991 if(DALI_LIKELY(mAdaptor))
993 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
996 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
997 mResizeSignal.Emit(handle, newSize);
998 if(DALI_LIKELY(mAdaptor))
1000 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1004 mSurface->SetFullSwapNextFrame();
1006 if(DALI_LIKELY(mScene))
1008 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1012 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1014 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1015 FeedTouchPoint(point, timeStamp);
1018 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1020 FeedWheelEvent(wheelEvent);
1023 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1025 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);
1026 FeedKeyEvent(keyEvent);
1029 void Window::OnRotation(const RotationEvent& rotation)
1031 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1033 mRotationAngle = rotation.angle;
1034 mWindowWidth = rotation.width;
1035 mWindowHeight = rotation.height;
1037 mIsWindowRotating = true;
1038 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);
1040 // Notify that the orientation is changed
1041 mOrientation->OnOrientationChange(rotation);
1043 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1045 SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1047 if(DALI_LIKELY(mAdaptor))
1049 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1052 Dali::Window handle(this);
1053 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1054 mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1056 if(DALI_LIKELY(mAdaptor))
1058 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1062 void Window::OnRotationFinished()
1064 mIsWindowRotating = false;
1065 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1068 void Window::OnPause()
1072 mEventHandler->Pause();
1076 void Window::OnResume()
1080 mEventHandler->Resume();
1083 mSurface->SetFullSwapNextFrame();
1086 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1088 mAuxiliaryMessageSignal.Emit(key, value, options);
1091 void Window::OnAccessibilityEnabled()
1093 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1094 auto rootLayer = mScene.GetRootLayer();
1095 auto accessible = Accessibility::Accessible::Get(rootLayer);
1096 bridge->AddTopLevelWindow(accessible);
1098 if(!mVisible || mIconified)
1103 Dali::Window handle(this);
1104 bridge->WindowShown(handle);
1108 bridge->WindowFocused(handle);
1112 void Window::OnAccessibilityDisabled()
1114 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1115 auto rootLayer = mScene.GetRootLayer();
1116 auto accessible = Accessibility::Accessible::Get(rootLayer);
1117 bridge->RemoveTopLevelWindow(accessible);
1120 Vector2 Window::RecalculatePosition(const Vector2& position)
1122 Vector2 convertedPosition;
1124 switch(mRotationAngle)
1128 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1129 convertedPosition.y = position.x;
1134 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1135 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1140 convertedPosition.x = position.y;
1141 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1146 convertedPosition = position;
1150 return convertedPosition;
1153 Dali::Window Window::Get(Dali::Actor actor)
1155 Internal::Adaptor::Window* windowImpl = nullptr;
1157 if(Internal::Adaptor::Adaptor::IsAvailable())
1159 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1160 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1163 return Dali::Window(windowImpl);
1167 return Dali::Window();
1170 void Window::SetParent(Dali::Window& parent)
1172 if(DALI_UNLIKELY(parent))
1174 mParentWindow = parent;
1175 Dali::Window self = Dali::Window(this);
1176 // check circular parent window setting
1177 if(Dali::DevelWindow::GetParent(parent) == self)
1179 Dali::DevelWindow::Unparent(parent);
1181 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1185 void Window::SetParent(Dali::Window& parent, bool belowParent)
1187 if(DALI_UNLIKELY(parent))
1189 mParentWindow = parent;
1190 Dali::Window self = Dali::Window(this);
1191 // check circular parent window setting
1192 if(Dali::DevelWindow::GetParent(parent) == self)
1194 Dali::DevelWindow::Unparent(parent);
1196 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1200 void Window::Unparent()
1202 mWindowBase->SetParent(nullptr, false);
1203 mParentWindow.Reset();
1206 Dali::Window Window::GetParent()
1208 return mParentWindow;
1211 WindowOrientation Window::GetCurrentOrientation() const
1213 return ConvertToOrientation(mRotationAngle);
1216 int Window::GetPhysicalOrientation() const
1218 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1221 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1223 Dali::Vector<float>::SizeType count = orientations.Count();
1224 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1226 if(IsOrientationAvailable(orientations[index]) == false)
1228 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1233 int convertedAngle = ConvertToAngle(orientations[index]);
1235 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1237 if(mAvailableAngles[i] == convertedAngle)
1246 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1247 mAvailableAngles.push_back(convertedAngle);
1250 SetAvailableAnlges(mAvailableAngles);
1253 int32_t Window::GetNativeId() const
1255 return mWindowBase->GetNativeWindowId();
1258 void Window::RequestMoveToServer()
1260 mWindowBase->RequestMoveToServer();
1263 void Window::RequestResizeToServer(WindowResizeDirection direction)
1265 mWindowBase->RequestResizeToServer(direction);
1268 void Window::EnableFloatingMode(bool enable)
1270 mWindowBase->EnableFloatingMode(enable);
1273 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1275 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);
1276 mWindowBase->IncludeInputRegion(inputRegion);
1279 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1281 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);
1282 mWindowBase->ExcludeInputRegion(inputRegion);
1285 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1287 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1288 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1289 mWindowRotationAcknowledgement = needAcknowledgement;
1292 void Window::SendRotationCompletedAcknowledgement()
1294 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1295 if(mWindowRotationAcknowledgement)
1297 SetRotationCompletedAcknowledgement();
1301 bool Window::IsWindowRotating() const
1303 return mIsWindowRotating;
1306 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1308 return mLastKeyEvent;
1311 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1313 return mLastTouchEvent;
1316 } // namespace Adaptor
1318 } // namespace Internal