2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/public-api/render-tasks/render-task-list.h>
32 #include <dali/public-api/render-tasks/render-task.h>
33 #include <dali/public-api/rendering/frame-buffer.h>
37 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
38 #include <dali/devel-api/atspi-interfaces/accessible.h>
39 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
40 #include <dali/internal/graphics/gles/egl-graphics.h>
41 #include <dali/internal/window-system/common/event-handler.h>
42 #include <dali/internal/window-system/common/orientation-impl.h>
43 #include <dali/internal/window-system/common/render-surface-factory.h>
44 #include <dali/internal/window-system/common/window-base.h>
45 #include <dali/internal/window-system/common/window-factory.h>
46 #include <dali/internal/window-system/common/window-render-surface.h>
47 #include <dali/internal/window-system/common/window-system.h>
48 #include <dali/internal/window-system/common/window-visibility-observer.h>
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
62 } // unnamed namespace
64 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
67 return Window::New(surface, positionSize, name, className, type, isTransparent);
70 Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
72 Window* window = new Window();
73 window->mIsTransparent = isTransparent;
74 window->Initialize(surface, positionSize, name, className, type);
79 : mWindowSurface(nullptr),
82 mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
87 mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
88 mDeleteRequestSignal(),
91 mVisibilityChangedSignal(),
92 mTransitionEffectEventSignal(),
93 mKeyboardRepeatSettingsChangedSignal(),
94 mAuxiliaryMessageSignal(),
98 mIsTransparent(false),
99 mIsFocusAcceptable(true),
102 mWindowRotationAcknowledgement(false),
111 auto bridge = Accessibility::Bridge::GetCurrentBridge();
112 auto rootLayer = mScene.GetRootLayer();
113 auto accessible = Accessibility::Accessible::Get(rootLayer);
114 bridge->RemoveTopLevelWindow(accessible);
115 // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
116 bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
121 mAdaptor->RemoveWindow(this);
126 mEventHandler->RemoveObserver(*this);
130 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
132 // Create a window render surface
133 auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
134 mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
135 mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
138 mWindowBase = mWindowSurface->GetWindowBase();
141 mWindowBase->SetType(type);
143 // Initialize for Ime window type
144 if(type == WindowType::IME)
146 mWindowBase->InitializeIme();
147 mWindowSurface->InitializeImeSurface();
151 mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
152 mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
153 mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
154 mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
155 mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
156 mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
157 mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
158 mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
160 mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
162 AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
164 SetClass(name, className);
166 mOrientation = Orientation::New(this);
168 // Get OrientationMode
169 int screenWidth, screenHeight;
170 WindowSystem::GetScreenSize(screenWidth, screenHeight);
171 if(screenWidth > screenHeight)
173 mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
177 mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
180 mNativeWindowId = mWindowBase->GetNativeWindowId();
183 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
185 mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
186 mEventHandler->AddObserver(*this);
188 // Add Window to bridge for ATSPI
189 auto bridge = Accessibility::Bridge::GetCurrentBridge();
192 auto rootLayer = mScene.GetRootLayer();
193 auto accessible = Accessibility::Accessible::Get(rootLayer);
194 bridge->AddTopLevelWindow(accessible);
197 bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
198 bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
200 // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
201 // The show must be called after the adaptor is initialized.
205 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
207 mWindowSurface = static_cast<WindowRenderSurface*>(surface);
210 void Window::SetClass(std::string name, std::string className)
213 mClassName = className;
214 mWindowBase->SetClass(name, className);
217 std::string Window::GetClassName() const
224 mWindowBase->Raise();
226 mSurface->SetFullSwapNextFrame();
228 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
233 mWindowBase->Lower();
235 mSurface->SetFullSwapNextFrame();
237 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
240 void Window::Activate()
242 mWindowBase->Activate();
244 mSurface->SetFullSwapNextFrame();
246 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
249 void Window::Maximize(bool maximize)
251 mWindowBase->Maximize(maximize);
253 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
256 bool Window::IsMaximized() const
258 return mWindowBase->IsMaximized();
261 void Window::SetMaximumSize(Dali::Window::WindowSize size)
263 mWindowBase->SetMaximumSize(size);
266 void Window::Minimize(bool minimize)
268 mWindowBase->Minimize(minimize);
270 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
273 bool Window::IsMinimized() const
275 return mWindowBase->IsMinimized();
278 void Window::SetMimimumSize(Dali::Window::WindowSize size)
280 mWindowBase->SetMimimumSize(size);
283 uint32_t Window::GetLayerCount() const
285 return mScene.GetLayerCount();
288 Dali::Layer Window::GetLayer(uint32_t depth) const
290 return mScene.GetLayer(depth);
293 Dali::RenderTaskList Window::GetRenderTaskList() const
295 return mScene.GetRenderTaskList();
298 std::string Window::GetNativeResourceId() const
300 return mWindowBase->GetNativeWindowResourceId();
303 void Window::AddAvailableOrientation(WindowOrientation orientation)
305 if(IsOrientationAvailable(orientation) == false)
311 int convertedAngle = ConvertToAngle(orientation);
312 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
313 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
315 if(mAvailableAngles[i] == convertedAngle)
324 mAvailableAngles.push_back(convertedAngle);
325 SetAvailableAnlges(mAvailableAngles);
329 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
331 if(IsOrientationAvailable(orientation) == false)
336 int convertedAngle = ConvertToAngle(orientation);
337 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
338 for(std::vector<int>::iterator iter = mAvailableAngles.begin();
339 iter != mAvailableAngles.end();
342 if(*iter == convertedAngle)
344 mAvailableAngles.erase(iter);
349 SetAvailableAnlges(mAvailableAngles);
352 void Window::SetPreferredOrientation(WindowOrientation orientation)
354 if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
356 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
359 mPreferredAngle = ConvertToAngle(orientation);
360 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
361 mWindowBase->SetPreferredAngle(mPreferredAngle);
364 WindowOrientation Window::GetPreferredOrientation()
366 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
367 WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
368 return preferredOrientation;
371 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
373 int angle = ConvertToAngle(orientation);
374 mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
377 void Window::EmitAccessibilityHighlightSignal(bool highlight)
379 Dali::Window handle(this);
380 mAccessibilityHighlightSignal.Emit(handle, highlight);
383 void Window::SetAvailableAnlges(const std::vector<int>& angles)
385 if(angles.size() > 4)
387 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
391 mWindowBase->SetAvailableAnlges(angles);
394 int Window::ConvertToAngle(WindowOrientation orientation)
396 int convertAngle = static_cast<int>(orientation);
397 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
401 case WindowOrientation::LANDSCAPE:
406 case WindowOrientation::PORTRAIT:
411 case WindowOrientation::LANDSCAPE_INVERSE:
416 case WindowOrientation::PORTRAIT_INVERSE:
421 case WindowOrientation::NO_ORIENTATION_PREFERENCE:
431 WindowOrientation Window::ConvertToOrientation(int angle) const
433 WindowOrientation orientation = static_cast<WindowOrientation>(angle);
434 if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
440 orientation = WindowOrientation::LANDSCAPE;
445 orientation = WindowOrientation::PORTRAIT;
450 orientation = WindowOrientation::LANDSCAPE_INVERSE;
455 orientation = WindowOrientation::PORTRAIT_INVERSE;
460 orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
468 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
470 if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
472 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
478 Dali::Any Window::GetNativeHandle() const
480 return mWindowSurface->GetNativeWindow();
483 void Window::SetAcceptFocus(bool accept)
485 mIsFocusAcceptable = accept;
487 mWindowBase->SetAcceptFocus(accept);
490 bool Window::IsFocusAcceptable() const
492 return mIsFocusAcceptable;
503 Dali::Window handle(this);
504 mVisibilityChangedSignal.Emit(handle, true);
505 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
507 WindowVisibilityObserver* observer(mAdaptor);
508 observer->OnWindowShown();
511 mSurface->SetFullSwapNextFrame();
513 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
524 Dali::Window handle(this);
525 mVisibilityChangedSignal.Emit(handle, false);
526 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
528 WindowVisibilityObserver* observer(mAdaptor);
529 observer->OnWindowHidden();
532 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
535 bool Window::IsVisible() const
537 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
538 return mVisible && !mIconified;
541 unsigned int Window::GetSupportedAuxiliaryHintCount() const
543 return mWindowBase->GetSupportedAuxiliaryHintCount();
546 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
548 return mWindowBase->GetSupportedAuxiliaryHint(index);
551 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
553 return mWindowBase->AddAuxiliaryHint(hint, value);
556 bool Window::RemoveAuxiliaryHint(unsigned int id)
558 return mWindowBase->RemoveAuxiliaryHint(id);
561 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
563 return mWindowBase->SetAuxiliaryHintValue(id, value);
566 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
568 return mWindowBase->GetAuxiliaryHintValue(id);
571 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
573 return mWindowBase->GetAuxiliaryHintId(hint);
576 void Window::SetInputRegion(const Rect<int>& inputRegion)
578 Rect<int> convertRegion = RecalculateRect(inputRegion);
580 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);
582 mWindowBase->SetInputRegion(convertRegion);
585 void Window::SetType(WindowType type)
587 mWindowBase->SetType(type);
590 WindowType Window::GetType() const
592 return mWindowBase->GetType();
595 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
597 WindowType type = mWindowBase->GetType();
598 if(type != WindowType::NOTIFICATION)
600 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
601 return WindowOperationResult::INVALID_OPERATION;
604 return mWindowBase->SetNotificationLevel(level);
607 WindowNotificationLevel Window::GetNotificationLevel() const
609 WindowType type = mWindowBase->GetType();
610 if(type != WindowType::NOTIFICATION)
612 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
613 return WindowNotificationLevel::NONE;
616 return mWindowBase->GetNotificationLevel();
619 void Window::SetOpaqueState(bool opaque)
621 mOpaqueState = opaque;
623 mWindowBase->SetOpaqueState(opaque);
625 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
628 bool Window::IsOpaqueState() const
633 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
635 return mWindowBase->SetScreenOffMode(screenOffMode);
638 WindowScreenOffMode Window::GetScreenOffMode() const
640 return mWindowBase->GetScreenOffMode();
643 WindowOperationResult Window::SetBrightness(int brightness)
645 if(brightness < 0 || brightness > 100)
647 DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
648 return WindowOperationResult::INVALID_OPERATION;
651 return mWindowBase->SetBrightness(brightness);
654 int Window::GetBrightness() const
656 return mWindowBase->GetBrightness();
659 void Window::SetSize(Dali::Window::WindowSize size)
661 PositionSize oldRect = mSurface->GetPositionSize();
663 mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
665 PositionSize newRect = mSurface->GetPositionSize();
667 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
668 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
670 Uint16Pair newSize(newRect.width, newRect.height);
672 mWindowWidth = newRect.width;
673 mWindowHeight = newRect.height;
677 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
679 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.width, newRect.height);
681 Dali::Window handle(this);
682 mResizeSignal.Emit(handle, newSize);
684 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
687 mSurface->SetFullSwapNextFrame();
689 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
692 Dali::Window::WindowSize Window::GetSize() const
694 PositionSize positionSize = mSurface->GetPositionSize();
696 return Dali::Window::WindowSize(positionSize.width, positionSize.height);
699 void Window::SetPosition(Dali::Window::WindowPosition position)
701 PositionSize oldRect = mSurface->GetPositionSize();
703 mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
705 mSurface->SetFullSwapNextFrame();
707 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
710 Dali::Window::WindowPosition Window::GetPosition() const
712 PositionSize positionSize = mSurface->GetPositionSize();
714 return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
717 PositionSize Window::GetPositionSize() const
719 return mSurface->GetPositionSize();
722 void Window::SetPositionSize(PositionSize positionSize)
724 PositionSize oldRect = mSurface->GetPositionSize();
725 Dali::Window handle(this);
727 mWindowSurface->MoveResize(positionSize);
729 PositionSize newRect = mSurface->GetPositionSize();
731 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
733 Dali::Window::WindowPosition position(newRect.x, newRect.y);
734 mMovedSignal.Emit(handle, position);
737 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
738 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
740 Uint16Pair newSize(newRect.width, newRect.height);
742 mWindowWidth = newRect.width;
743 mWindowHeight = newRect.height;
747 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
749 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.width, newRect.height);
750 mResizeSignal.Emit(handle, newSize);
751 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
754 mSurface->SetFullSwapNextFrame();
756 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
759 Dali::Layer Window::GetRootLayer() const
761 return mScene.GetRootLayer();
764 void Window::SetTransparency(bool transparent)
766 mWindowSurface->SetTransparency(transparent);
769 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
771 return mWindowBase->GrabKey(key, grabMode);
774 bool Window::UngrabKey(Dali::KEY key)
776 return mWindowBase->UngrabKey(key);
779 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
781 return mWindowBase->GrabKeyList(key, grabMode, result);
784 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
786 return mWindowBase->UngrabKeyList(key, result);
789 void Window::OnIconifyChanged(bool iconified)
797 Dali::Window handle(this);
798 mVisibilityChangedSignal.Emit(handle, false);
799 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
801 WindowVisibilityObserver* observer(mAdaptor);
802 observer->OnWindowHidden();
805 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
813 Dali::Window handle(this);
814 mVisibilityChangedSignal.Emit(handle, true);
815 Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
817 WindowVisibilityObserver* observer(mAdaptor);
818 observer->OnWindowShown();
821 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
824 mSurface->SetFullSwapNextFrame();
827 void Window::OnFocusChanged(bool focusIn)
829 Dali::Window handle(this);
830 mFocusChangeSignal.Emit(handle, focusIn);
832 mSurface->SetFullSwapNextFrame();
834 if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
838 bridge->WindowFocused(handle);
842 bridge->WindowUnfocused(handle);
848 void Window::OnOutputTransformed()
850 PositionSize positionSize = mSurface->GetPositionSize();
852 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
853 SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), orientation);
855 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
856 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
859 void Window::OnDeleteRequest()
861 mDeleteRequestSignal.Emit();
864 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
866 Dali::Window handle(this);
867 mTransitionEffectEventSignal.Emit(handle, state, type);
870 void Window::OnKeyboardRepeatSettingsChanged()
872 Dali::Window handle(this);
873 mKeyboardRepeatSettingsChangedSignal.Emit();
876 void Window::OnWindowRedrawRequest()
878 mAdaptor->RenderOnce();
881 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
883 bool resized = false;
885 Dali::Window handle(this);
886 PositionSize oldRect = mSurface->GetPositionSize();
888 mWindowSurface->UpdatePositionSize(positionSize);
890 PositionSize newRect = positionSize;
892 if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
897 if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
904 Dali::Window::WindowPosition position(newRect.x, newRect.y);
905 mMovedSignal.Emit(handle, position);
908 // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
911 Uint16Pair newSize(newRect.width, newRect.height);
913 mWindowWidth = newRect.width;
914 mWindowHeight = newRect.height;
918 mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
920 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
921 mResizeSignal.Emit(handle, newSize);
922 mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
925 mSurface->SetFullSwapNextFrame();
927 Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
930 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
932 mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
933 FeedTouchPoint(point, timeStamp);
936 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
938 FeedWheelEvent(wheelEvent);
941 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
943 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);
944 FeedKeyEvent(keyEvent);
947 void Window::OnRotation(const RotationEvent& rotation)
949 PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
951 mRotationAngle = rotation.angle;
952 mWindowWidth = rotation.width;
953 mWindowHeight = rotation.height;
955 // Notify that the orientation is changed
956 mOrientation->OnOrientationChange(rotation);
958 mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
960 int orientation = (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
961 SurfaceRotated(mWindowWidth, mWindowHeight, orientation);
963 mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
965 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): x[%d], y[%d], resize signal emit [%d x %d]\n", this, mNativeWindowId, newPositionSize.x, newPositionSize.y, mWindowWidth, mWindowHeight);
967 Dali::Window handle(this);
968 mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
970 mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
973 void Window::OnPause()
977 mEventHandler->Pause();
981 void Window::OnResume()
985 mEventHandler->Resume();
988 mSurface->SetFullSwapNextFrame();
991 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
993 mAuxiliaryMessageSignal.Emit(key, value, options);
996 void Window::OnAccessibilityEnabled()
998 auto bridge = Accessibility::Bridge::GetCurrentBridge();
999 auto rootLayer = mScene.GetRootLayer();
1000 auto accessible = Accessibility::Accessible::Get(rootLayer);
1001 bridge->AddTopLevelWindow(accessible);
1003 if(!mVisible || mIconified)
1008 Dali::Window handle(this);
1009 bridge->WindowShown(handle);
1013 bridge->WindowFocused(handle);
1017 void Window::OnAccessibilityDisabled()
1019 auto bridge = Accessibility::Bridge::GetCurrentBridge();
1020 auto rootLayer = mScene.GetRootLayer();
1021 auto accessible = Accessibility::Accessible::Get(rootLayer);
1022 bridge->RemoveTopLevelWindow(accessible);
1025 void Window::RecalculateTouchPosition(Integration::Point& point)
1027 Vector2 position = point.GetScreenPosition();
1028 Vector2 convertedPosition;
1030 switch(mRotationAngle)
1034 convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1035 convertedPosition.y = position.x;
1040 convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1041 convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1046 convertedPosition.x = position.y;
1047 convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1052 convertedPosition = position;
1057 point.SetScreenPosition(convertedPosition);
1060 Dali::Window Window::Get(Dali::Actor actor)
1062 Internal::Adaptor::Window* windowImpl = nullptr;
1064 if(Internal::Adaptor::Adaptor::IsAvailable())
1066 Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1067 windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1070 return Dali::Window(windowImpl);
1074 return Dali::Window();
1077 void Window::SetParent(Dali::Window& parent)
1079 if(DALI_UNLIKELY(parent))
1081 mParentWindow = parent;
1082 Dali::Window self = Dali::Window(this);
1083 // check circular parent window setting
1084 if(Dali::DevelWindow::GetParent(parent) == self)
1086 Dali::DevelWindow::Unparent(parent);
1088 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1092 void Window::SetParent(Dali::Window& parent, bool belowParent)
1094 if(DALI_UNLIKELY(parent))
1096 mParentWindow = parent;
1097 Dali::Window self = Dali::Window(this);
1098 // check circular parent window setting
1099 if(Dali::DevelWindow::GetParent(parent) == self)
1101 Dali::DevelWindow::Unparent(parent);
1103 mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1107 void Window::Unparent()
1109 mWindowBase->SetParent(nullptr, false);
1110 mParentWindow.Reset();
1113 Dali::Window Window::GetParent()
1115 return mParentWindow;
1118 WindowOrientation Window::GetCurrentOrientation() const
1120 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
1121 return ConvertToOrientation(mRotationAngle);
1124 int Window::GetPhysicalOrientation() const
1126 return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1129 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1131 Dali::Vector<float>::SizeType count = orientations.Count();
1132 for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1134 if(IsOrientationAvailable(orientations[index]) == false)
1136 DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1141 int convertedAngle = ConvertToAngle(orientations[index]);
1143 for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1145 if(mAvailableAngles[i] == convertedAngle)
1154 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1155 mAvailableAngles.push_back(convertedAngle);
1158 SetAvailableAnlges(mAvailableAngles);
1161 int32_t Window::GetNativeId() const
1163 return mWindowBase->GetNativeWindowId();
1166 void Window::RequestMoveToServer()
1168 mWindowBase->RequestMoveToServer();
1171 void Window::RequestResizeToServer(WindowResizeDirection direction)
1173 mWindowBase->RequestResizeToServer(direction);
1176 void Window::EnableFloatingMode(bool enable)
1178 mWindowBase->EnableFloatingMode(enable);
1181 Rect<int> Window::RecalculateRect(const Rect<int>& rect)
1184 int screenWidth, screenHeight;
1186 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1188 if(mRotationAngle == 90)
1191 newRect.y = screenHeight - (rect.x + rect.width);
1192 newRect.width = rect.height;
1193 newRect.height = rect.width;
1195 else if(mRotationAngle == 180)
1197 newRect.x = screenWidth - (rect.x + rect.width);
1198 newRect.y = screenHeight - (rect.y + rect.height);
1199 newRect.width = rect.width;
1200 newRect.height = rect.height;
1202 else if(mRotationAngle == 270)
1204 newRect.x = screenWidth - (rect.y + rect.height);
1206 newRect.width = rect.height;
1207 newRect.height = rect.width;
1213 newRect.width = rect.width;
1214 newRect.height = rect.height;
1219 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1221 Rect<int> convertRegion = RecalculateRect(inputRegion);
1223 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);
1224 mWindowBase->IncludeInputRegion(convertRegion);
1227 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1229 Rect<int> convertRegion = RecalculateRect(inputRegion);
1231 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);
1232 mWindowBase->ExcludeInputRegion(convertRegion);
1235 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1237 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1238 mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1239 mWindowRotationAcknowledgement = needAcknowledgement;
1242 void Window::SendRotationCompletedAcknowledgement()
1244 DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1245 if(mWindowRotationAcknowledgement)
1247 SetRotationCompletedAcknowledgement();
1251 bool Window::IsWindowRotating() const
1253 return mWindowSurface->IsWindowRotating();
1256 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1258 return mLastKeyEvent;
1261 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1263 return mLastTouchEvent;
1266 } // namespace Adaptor
1268 } // namespace Internal