Fix the failure to emit Accessibility::WindowEvent::CREATE event.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/window-system/common/window-impl.h>
20
21 // EXTERNAL HEADERS
22 #include <dali/devel-api/adaptor-framework/orientation.h>
23 #include <dali/devel-api/events/key-event-devel.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/touch-integ.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/camera-actor.h>
29 #include <dali/public-api/actors/layer.h>
30 #include <dali/public-api/adaptor-framework/window-enumerations.h>
31 #include <dali/public-api/rendering/frame-buffer.h>
32 #include <thread>
33
34 // INTERNAL HEADERS
35 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
36 #include <dali/devel-api/atspi-interfaces/accessible.h>
37 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
38 #include <dali/internal/graphics/gles/egl-graphics.h>
39 #include <dali/internal/window-system/common/event-handler.h>
40 #include <dali/internal/window-system/common/orientation-impl.h>
41 #include <dali/internal/window-system/common/render-surface-factory.h>
42 #include <dali/internal/window-system/common/window-base.h>
43 #include <dali/internal/window-system/common/window-factory.h>
44 #include <dali/internal/window-system/common/window-render-surface.h>
45 #include <dali/internal/window-system/common/window-system.h>
46 #include <dali/internal/window-system/common/window-visibility-observer.h>
47
48 namespace Dali
49 {
50 namespace Internal
51 {
52 namespace Adaptor
53 {
54 namespace
55 {
56 #if defined(DEBUG_ENABLED)
57 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
58 #endif
59 } // unnamed namespace
60
61 Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
62 {
63   Any surface;
64   return Window::New(surface, name, className, windowData);
65 }
66
67 Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
68 {
69   Window* window         = new Window();
70   window->mIsTransparent = windowData.GetTransparency();
71   window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
72   return window;
73 }
74
75 Window::Window()
76 : mWindowSurface(nullptr),
77   mWindowBase(),
78   mParentWindow(NULL),
79   mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
80   mRotationAngle(0),
81   mWindowWidth(0),
82   mWindowHeight(0),
83   mNativeWindowId(-1),
84   mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
85   mDeleteRequestSignal(),
86   mFocusChangeSignal(),
87   mResizeSignal(),
88   mVisibilityChangedSignal(),
89   mTransitionEffectEventSignal(),
90   mKeyboardRepeatSettingsChangedSignal(),
91   mAuxiliaryMessageSignal(),
92   mMovedSignal(),
93   mOrientationChangedSignal(),
94   mMouseInOutEventSignal(),
95   mMouseRelativeEventSignal(),
96   mMoveCompletedSignal(),
97   mResizeCompletedSignal(),
98   mInsetsChangedSignal(),
99   mPointerConstraintsSignal(),
100   mLastKeyEvent(),
101   mLastTouchEvent(),
102   mIsTransparent(false),
103   mIsFocusAcceptable(true),
104   mIconified(false),
105   mMaximized(false),
106   mOpaqueState(false),
107   mWindowRotationAcknowledgement(false),
108   mFocused(false),
109   mIsWindowRotating(false),
110   mIsEnabledUserGeometry(false),
111   mIsEmittedWindowCreatedEvent(false)
112 {
113 }
114
115 Window::~Window()
116 {
117   if(mScene)
118   {
119     auto bridge     = Accessibility::Bridge::GetCurrentBridge();
120     auto rootLayer  = mScene.GetRootLayer();
121     auto accessible = Accessibility::Accessible::Get(rootLayer);
122     bridge->RemoveTopLevelWindow(accessible);
123     // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
124     bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
125   }
126
127   if(mAdaptor)
128   {
129     mAdaptor->RemoveWindow(this);
130   }
131
132   if(mEventHandler)
133   {
134     mEventHandler->RemoveObserver(*this);
135   }
136 }
137
138 void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type)
139 {
140   // Create a window render surface
141   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
142   mSurface                  = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
143   mWindowSurface            = static_cast<WindowRenderSurface*>(mSurface.get());
144
145   // Get a window base
146   mWindowBase = mWindowSurface->GetWindowBase();
147
148   // Set Window Type
149   mWindowBase->SetType(type);
150
151   // Initialize for Ime window type
152   if(type == WindowType::IME)
153   {
154     mWindowBase->InitializeIme();
155     mWindowSurface->InitializeImeSurface();
156   }
157
158   // Connect signals
159   mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
160   mWindowBase->MaximizeChangedSignal().Connect(this, &Window::OnMaximizeChanged);
161   mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
162   mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
163   mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
164   mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
165   mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
166   mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
167   mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
168   mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
169   mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
170   mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
171   mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
172   mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
173
174   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
175   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
176
177   mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
178
179   SetClass(name, className);
180
181   mOrientation = Orientation::New(this);
182
183   // Get OrientationMode
184   int screenWidth, screenHeight;
185   WindowSystem::GetScreenSize(screenWidth, screenHeight);
186   if(screenWidth > screenHeight)
187   {
188     mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
189   }
190   else
191   {
192     mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
193   }
194
195   mWindowWidth  = positionSize.width;
196   mWindowHeight = positionSize.height;
197
198   bool isSetWithScreenSize = false;
199   if(mWindowWidth <= 0 || mWindowHeight <= 0)
200   {
201     mWindowWidth        = screenWidth;
202     mWindowHeight       = screenHeight;
203     isSetWithScreenSize = true;
204     DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
205   }
206
207   if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
208   {
209     SetUserGeometryPolicy();
210   }
211
212   // For Debugging
213   mNativeWindowId = mWindowBase->GetNativeWindowId();
214 }
215
216 void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
217 {
218   if(!mWindowSurface)
219   {
220     return;
221   }
222
223   mWindowSurface->SetRenderNotification(renderNotification);
224 }
225
226 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
227 {
228   mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
229   mEventHandler->AddObserver(*this);
230
231   // Add Window to bridge for ATSPI
232   auto bridge = Accessibility::Bridge::GetCurrentBridge();
233
234   bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
235   bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
236
237   if(bridge->IsUp())
238   {
239     OnAccessibilityEnabled();
240   }
241   else
242   {
243     OnAccessibilityDisabled();
244   }
245
246   // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
247   // The show must be called after the adaptor is initialized.
248   Show();
249 }
250
251 void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
252 {
253   mWindowSurface = static_cast<WindowRenderSurface*>(surface);
254 }
255
256 void Window::SetClass(std::string name, std::string className)
257 {
258   mName      = name;
259   mClassName = className;
260   mWindowBase->SetClass(name, className);
261 }
262
263 std::string Window::GetClassName() const
264 {
265   return mClassName;
266 }
267
268 void Window::Raise()
269 {
270   mWindowBase->Raise();
271
272   mSurface->SetFullSwapNextFrame();
273
274   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
275 }
276
277 void Window::Lower()
278 {
279   mWindowBase->Lower();
280
281   mSurface->SetFullSwapNextFrame();
282
283   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
284 }
285
286 void Window::Activate()
287 {
288   mWindowBase->Activate();
289
290   mSurface->SetFullSwapNextFrame();
291
292   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
293 }
294
295 void Window::Maximize(bool maximize)
296 {
297   mWindowBase->Maximize(maximize);
298
299   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
300 }
301
302 bool Window::IsMaximized() const
303 {
304   return mWindowBase->IsMaximized();
305 }
306
307 void Window::SetMaximumSize(Dali::Window::WindowSize size)
308 {
309   mWindowBase->SetMaximumSize(size);
310 }
311
312 void Window::Minimize(bool minimize)
313 {
314   mWindowBase->Minimize(minimize);
315
316   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
317 }
318
319 bool Window::IsMinimized() const
320 {
321   return mWindowBase->IsMinimized();
322 }
323
324 void Window::SetMimimumSize(Dali::Window::WindowSize size)
325 {
326   mWindowBase->SetMimimumSize(size);
327 }
328
329 uint32_t Window::GetLayerCount() const
330 {
331   return mScene.GetLayerCount();
332 }
333
334 Dali::Layer Window::GetLayer(uint32_t depth) const
335 {
336   return mScene.GetLayer(depth);
337 }
338
339 void Window::KeepRendering(float durationSeconds)
340 {
341   mScene.KeepRendering(durationSeconds);
342 }
343
344 void Window::SetPartialUpdateEnabled(bool enabled)
345 {
346   mScene.SetPartialUpdateEnabled(enabled);
347 }
348
349 bool Window::IsPartialUpdateEnabled() const
350 {
351   return mScene.IsPartialUpdateEnabled();
352 }
353
354 std::string Window::GetNativeResourceId() const
355 {
356   return mWindowBase->GetNativeWindowResourceId();
357 }
358
359 void Window::AddAvailableOrientation(WindowOrientation orientation)
360 {
361   if(IsOrientationAvailable(orientation) == false)
362   {
363     return;
364   }
365
366   bool found          = false;
367   int  convertedAngle = ConvertToAngle(orientation);
368   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
369   for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
370   {
371     if(mAvailableAngles[i] == convertedAngle)
372     {
373       found = true;
374       break;
375     }
376   }
377
378   if(!found)
379   {
380     mAvailableAngles.push_back(convertedAngle);
381     SetAvailableAnlges(mAvailableAngles);
382   }
383 }
384
385 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
386 {
387   if(IsOrientationAvailable(orientation) == false)
388   {
389     return;
390   }
391
392   int convertedAngle = ConvertToAngle(orientation);
393   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
394   for(std::vector<int>::iterator iter = mAvailableAngles.begin();
395       iter != mAvailableAngles.end();
396       ++iter)
397   {
398     if(*iter == convertedAngle)
399     {
400       mAvailableAngles.erase(iter);
401       break;
402     }
403   }
404
405   SetAvailableAnlges(mAvailableAngles);
406 }
407
408 void Window::SetPreferredOrientation(WindowOrientation orientation)
409 {
410   if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
411   {
412     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
413     return;
414   }
415   mPreferredAngle = ConvertToAngle(orientation);
416   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
417   mWindowBase->SetPreferredAngle(mPreferredAngle);
418 }
419
420 WindowOrientation Window::GetPreferredOrientation()
421 {
422   WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
423   return preferredOrientation;
424 }
425
426 void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation)
427 {
428   int angle = ConvertToAngle(orientation);
429   mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
430 }
431
432 void Window::EmitAccessibilityHighlightSignal(bool highlight)
433 {
434   Dali::Window handle(this);
435   mAccessibilityHighlightSignal.Emit(handle, highlight);
436 }
437
438 void Window::SetAvailableAnlges(const std::vector<int>& angles)
439 {
440   if(angles.size() > 4)
441   {
442     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
443     return;
444   }
445
446   mWindowBase->SetAvailableAnlges(angles);
447 }
448
449 int Window::ConvertToAngle(WindowOrientation orientation)
450 {
451   int convertAngle = static_cast<int>(orientation);
452   if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
453   {
454     switch(orientation)
455     {
456       case WindowOrientation::LANDSCAPE:
457       {
458         convertAngle = 0;
459         break;
460       }
461       case WindowOrientation::PORTRAIT:
462       {
463         convertAngle = 90;
464         break;
465       }
466       case WindowOrientation::LANDSCAPE_INVERSE:
467       {
468         convertAngle = 180;
469         break;
470       }
471       case WindowOrientation::PORTRAIT_INVERSE:
472       {
473         convertAngle = 270;
474         break;
475       }
476       case WindowOrientation::NO_ORIENTATION_PREFERENCE:
477       {
478         convertAngle = -1;
479         break;
480       }
481     }
482   }
483   return convertAngle;
484 }
485
486 WindowOrientation Window::ConvertToOrientation(int angle) const
487 {
488   WindowOrientation orientation = static_cast<WindowOrientation>(angle);
489   if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
490   {
491     switch(angle)
492     {
493       case 0:
494       {
495         orientation = WindowOrientation::LANDSCAPE;
496         break;
497       }
498       case 90:
499       {
500         orientation = WindowOrientation::PORTRAIT;
501         break;
502       }
503       case 180:
504       {
505         orientation = WindowOrientation::LANDSCAPE_INVERSE;
506         break;
507       }
508       case 270:
509       {
510         orientation = WindowOrientation::PORTRAIT_INVERSE;
511         break;
512       }
513       case -1:
514       {
515         orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
516         break;
517       }
518     }
519   }
520   return orientation;
521 }
522
523 bool Window::IsOrientationAvailable(WindowOrientation orientation) const
524 {
525   if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
526   {
527     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
528     return false;
529   }
530   return true;
531 }
532
533 Dali::Any Window::GetNativeHandle() const
534 {
535   return mWindowSurface->GetNativeWindow();
536 }
537
538 void Window::SetAcceptFocus(bool accept)
539 {
540   mIsFocusAcceptable = accept;
541
542   mWindowBase->SetAcceptFocus(accept);
543 }
544
545 bool Window::IsFocusAcceptable() const
546 {
547   return mIsFocusAcceptable;
548 }
549
550 void Window::Show()
551 {
552   mVisible = true;
553
554   mWindowBase->Show();
555
556   if(!mIconified)
557   {
558     Dali::Window handle(this);
559     mVisibilityChangedSignal.Emit(handle, true);
560     Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
561
562     WindowVisibilityObserver* observer(mAdaptor);
563     observer->OnWindowShown();
564   }
565
566   mSurface->SetFullSwapNextFrame();
567
568   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
569 }
570
571 void Window::Hide()
572 {
573   mVisible = false;
574
575   mWindowBase->Hide();
576
577   if(!mIconified)
578   {
579     Dali::Window handle(this);
580     mVisibilityChangedSignal.Emit(handle, false);
581     Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
582
583     WindowVisibilityObserver* observer(mAdaptor);
584     observer->OnWindowHidden();
585   }
586
587   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
588 }
589
590 bool Window::IsVisible() const
591 {
592   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
593   return mVisible && !mIconified;
594 }
595
596 unsigned int Window::GetSupportedAuxiliaryHintCount() const
597 {
598   return mWindowBase->GetSupportedAuxiliaryHintCount();
599 }
600
601 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
602 {
603   return mWindowBase->GetSupportedAuxiliaryHint(index);
604 }
605
606 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
607 {
608   return mWindowBase->AddAuxiliaryHint(hint, value);
609 }
610
611 bool Window::RemoveAuxiliaryHint(unsigned int id)
612 {
613   return mWindowBase->RemoveAuxiliaryHint(id);
614 }
615
616 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
617 {
618   return mWindowBase->SetAuxiliaryHintValue(id, value);
619 }
620
621 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
622 {
623   return mWindowBase->GetAuxiliaryHintValue(id);
624 }
625
626 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
627 {
628   return mWindowBase->GetAuxiliaryHintId(hint);
629 }
630
631 void Window::SetInputRegion(const Rect<int>& inputRegion)
632 {
633   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);
634   mWindowBase->SetInputRegion(inputRegion);
635 }
636
637 void Window::SetType(WindowType type)
638 {
639   mWindowBase->SetType(type);
640 }
641
642 WindowType Window::GetType() const
643 {
644   return mWindowBase->GetType();
645 }
646
647 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
648 {
649   WindowType type = mWindowBase->GetType();
650   if(type != WindowType::NOTIFICATION)
651   {
652     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", type);
653     return WindowOperationResult::INVALID_OPERATION;
654   }
655
656   return mWindowBase->SetNotificationLevel(level);
657 }
658
659 WindowNotificationLevel Window::GetNotificationLevel() const
660 {
661   WindowType type = mWindowBase->GetType();
662   if(type != WindowType::NOTIFICATION)
663   {
664     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", type);
665     return WindowNotificationLevel::NONE;
666   }
667
668   return mWindowBase->GetNotificationLevel();
669 }
670
671 void Window::SetOpaqueState(bool opaque)
672 {
673   mOpaqueState = opaque;
674
675   mWindowBase->SetOpaqueState(opaque);
676
677   DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
678 }
679
680 bool Window::IsOpaqueState() const
681 {
682   return mOpaqueState;
683 }
684
685 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
686 {
687   return mWindowBase->SetScreenOffMode(screenOffMode);
688 }
689
690 WindowScreenOffMode Window::GetScreenOffMode() const
691 {
692   return mWindowBase->GetScreenOffMode();
693 }
694
695 WindowOperationResult Window::SetBrightness(int brightness)
696 {
697   if(brightness < 0 || brightness > 100)
698   {
699     DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
700     return WindowOperationResult::INVALID_OPERATION;
701   }
702
703   return mWindowBase->SetBrightness(brightness);
704 }
705
706 int Window::GetBrightness() const
707 {
708   return mWindowBase->GetBrightness();
709 }
710
711 void Window::SetSize(Dali::Window::WindowSize size)
712 {
713   PositionSize oldRect = GetPositionSize();
714
715   PositionSize newRect;
716   newRect.width  = size.GetWidth();
717   newRect.height = size.GetHeight();
718
719   SetUserGeometryPolicy();
720
721   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
722   if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
723   {
724     mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, newRect.width, newRect.height));
725
726     Uint16Pair newSize(newRect.width, newRect.height);
727
728     mWindowWidth  = newRect.width;
729     mWindowHeight = newRect.height;
730
731     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);
732
733     SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
734
735     mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
736
737     Dali::Window handle(this);
738     mResizeSignal.Emit(handle, newSize);
739
740     mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
741   }
742
743   mSurface->SetFullSwapNextFrame();
744
745   Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
746 }
747
748 Dali::Window::WindowSize Window::GetSize() const
749 {
750   return Dali::Window::WindowSize(mWindowWidth, mWindowHeight);
751 }
752
753 void Window::SetPosition(Dali::Window::WindowPosition position)
754 {
755   PositionSize oldRect = mSurface->GetPositionSize();
756   int32_t      newX    = position.GetX();
757   int32_t      newY    = position.GetY();
758
759   SetUserGeometryPolicy();
760
761   mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
762
763   if((oldRect.x != newX) || (oldRect.y != newY))
764   {
765     Dali::Window                 handle(this);
766     Dali::Window::WindowPosition newPosition(newX, newY);
767
768     DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
769     mMovedSignal.Emit(handle, newPosition);
770   }
771
772   mSurface->SetFullSwapNextFrame();
773
774   Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
775 }
776
777 Dali::Window::WindowPosition Window::GetPosition() const
778 {
779   PositionSize positionSize = GetPositionSize();
780   return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
781 }
782
783 PositionSize Window::GetPositionSize() const
784 {
785   PositionSize positionSize = mSurface->GetPositionSize();
786   positionSize.width        = mWindowWidth;
787   positionSize.height       = mWindowHeight;
788   return positionSize;
789 }
790
791 void Window::SetPositionSize(PositionSize positionSize)
792 {
793   bool moved  = false;
794   bool resize = false;
795
796   PositionSize oldRect = GetPositionSize();
797   Dali::Window handle(this);
798
799   SetUserGeometryPolicy();
800
801   if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
802   {
803     moved = true;
804   }
805
806   if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
807   {
808     resize = true;
809   }
810
811   if(moved || resize)
812   {
813     mWindowSurface->MoveResize(positionSize);
814   }
815
816   // When window is moved, emit Moved Signal
817   if(moved)
818   {
819     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
820     Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
821     mMovedSignal.Emit(handle, position);
822   }
823
824   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
825   if(resize)
826   {
827     Uint16Pair newSize(positionSize.width, positionSize.height);
828
829     mWindowWidth  = positionSize.width;
830     mWindowHeight = positionSize.height;
831
832     SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
833
834     mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
835
836     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
837
838     mResizeSignal.Emit(handle, newSize);
839     mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
840   }
841
842   mSurface->SetFullSwapNextFrame();
843
844   Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
845 }
846
847 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
848 {
849   SetUserGeometryPolicy();
850   mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
851 }
852
853 Dali::Layer Window::GetRootLayer() const
854 {
855   return mScene.GetRootLayer();
856 }
857
858 void Window::SetTransparency(bool transparent)
859 {
860   mWindowSurface->SetTransparency(transparent);
861 }
862
863 bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
864 {
865   return mWindowBase->GrabKey(key, grabMode);
866 }
867
868 bool Window::UngrabKey(Dali::KEY key)
869 {
870   return mWindowBase->UngrabKey(key);
871 }
872
873 bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
874 {
875   return mWindowBase->GrabKeyList(key, grabMode, result);
876 }
877
878 bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
879 {
880   return mWindowBase->UngrabKeyList(key, result);
881 }
882
883 void Window::OnIconifyChanged(bool iconified)
884 {
885   const bool   isActuallyChanged = (iconified != mIconified);
886   auto         bridge            = Dali::Accessibility::Bridge::GetCurrentBridge();
887   Dali::Window handle(this);
888
889   if(iconified)
890   {
891     mIconified = true;
892
893     if(mVisible)
894     {
895       mVisibilityChangedSignal.Emit(handle, false);
896       bridge->WindowHidden(handle);
897
898       WindowVisibilityObserver* observer(mAdaptor);
899       observer->OnWindowHidden();
900     }
901
902     if(isActuallyChanged)
903     {
904       bridge->WindowMinimized(handle);
905     }
906
907     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
908   }
909   else
910   {
911     mIconified = false;
912
913     if(mVisible)
914     {
915       mVisibilityChangedSignal.Emit(handle, true);
916       bridge->WindowShown(handle);
917
918       WindowVisibilityObserver* observer(mAdaptor);
919       observer->OnWindowShown();
920     }
921
922     if(isActuallyChanged)
923     {
924       bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_ICONIFY);
925     }
926
927     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
928   }
929
930   mSurface->SetFullSwapNextFrame();
931 }
932
933 void Window::OnMaximizeChanged(bool maximized)
934 {
935   const bool isActuallyChanged = (maximized != mMaximized);
936
937   if(isActuallyChanged)
938   {
939     auto         bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
940     Dali::Window handle(this);
941
942     if(maximized)
943     {
944       mMaximized = true;
945       bridge->WindowMaximized(handle);
946     }
947     else
948     {
949       mMaximized = false;
950       bridge->WindowRestored(handle, Dali::Accessibility::WindowRestoreType::RESTORE_FROM_MAXIMIZE);
951     }
952   }
953 }
954
955 void Window::OnFocusChanged(bool focusIn)
956 {
957   Dali::Window handle(this);
958   mFocusChangeSignal.Emit(handle, focusIn);
959
960   mSurface->SetFullSwapNextFrame();
961   auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
962
963   if(focusIn)
964   {
965     bridge->WindowFocused(handle);
966   }
967   else
968   {
969     bridge->WindowUnfocused(handle);
970   }
971
972   mFocused = focusIn;
973 }
974
975 void Window::OnOutputTransformed()
976 {
977   PositionSize positionSize = GetPositionSize();
978
979   SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
980
981   mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
982   mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
983 }
984
985 void Window::OnDeleteRequest()
986 {
987   mDeleteRequestSignal.Emit();
988 }
989
990 void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
991 {
992   Dali::Window handle(this);
993   mTransitionEffectEventSignal.Emit(handle, state, type);
994 }
995
996 void Window::OnKeyboardRepeatSettingsChanged()
997 {
998   Dali::Window handle(this);
999   mKeyboardRepeatSettingsChangedSignal.Emit();
1000 }
1001
1002 void Window::OnWindowRedrawRequest()
1003 {
1004   mAdaptor->RenderOnce();
1005 }
1006
1007 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
1008 {
1009   bool moved  = false;
1010   bool resize = false;
1011
1012   Dali::Window handle(this);
1013
1014   PositionSize oldRect = GetPositionSize();
1015   PositionSize newRect = positionSize;
1016
1017   if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1018   {
1019     moved = true;
1020   }
1021
1022   if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1023   {
1024     resize = true;
1025   }
1026
1027   if(moved || resize)
1028   {
1029     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);
1030     mWindowSurface->UpdatePositionSize(positionSize);
1031   }
1032
1033   if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
1034   {
1035     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
1036     Dali::Window::WindowPosition position(newRect.x, newRect.y);
1037     mMovedSignal.Emit(handle, position);
1038   }
1039
1040   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
1041   if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
1042   {
1043     Uint16Pair newSize(newRect.width, newRect.height);
1044
1045     mWindowWidth  = newRect.width;
1046     mWindowHeight = newRect.height;
1047
1048     SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
1049
1050     mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
1051
1052     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
1053     mResizeSignal.Emit(handle, newSize);
1054     mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
1055   }
1056
1057   mSurface->SetFullSwapNextFrame();
1058
1059   Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
1060 }
1061
1062 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
1063 {
1064   mLastTouchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
1065   FeedTouchPoint(point, timeStamp);
1066 }
1067
1068 void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
1069 {
1070   FeedWheelEvent(wheelEvent);
1071 }
1072
1073 void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
1074 {
1075   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);
1076   FeedKeyEvent(keyEvent);
1077 }
1078
1079 void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
1080 {
1081   Dali::Window handle(this);
1082
1083   mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
1084 }
1085
1086 void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
1087 {
1088   Dali::Window handle(this);
1089
1090   mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
1091 }
1092
1093 void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
1094 {
1095   Dali::Window handle(this);
1096
1097   Vector2                                    newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
1098   Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
1099
1100   mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
1101 }
1102
1103 void Window::OnRotation(const RotationEvent& rotation)
1104 {
1105   PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
1106
1107   mRotationAngle = rotation.angle;
1108   mWindowWidth   = rotation.width;
1109   mWindowHeight  = rotation.height;
1110
1111   mIsWindowRotating = true;
1112   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);
1113
1114   // Notify that the orientation is changed
1115   mOrientation->OnOrientationChange(rotation);
1116
1117   mWindowSurface->RequestRotation(mRotationAngle, newPositionSize);
1118
1119   SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
1120
1121   mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1122
1123   Dali::Window handle(this);
1124   mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
1125   mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
1126
1127   mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
1128 }
1129
1130 void Window::OnRotationFinished()
1131 {
1132   mIsWindowRotating = false;
1133   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window rotation is finised\n", this, mNativeWindowId);
1134 }
1135
1136 void Window::OnPause()
1137 {
1138   if(mEventHandler)
1139   {
1140     mEventHandler->Pause();
1141   }
1142 }
1143
1144 void Window::OnResume()
1145 {
1146   if(mEventHandler)
1147   {
1148     mEventHandler->Resume();
1149   }
1150
1151   mSurface->SetFullSwapNextFrame();
1152 }
1153
1154 void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
1155 {
1156   mAuxiliaryMessageSignal.Emit(key, value, options);
1157 }
1158
1159 void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
1160 {
1161   mInsetsChangedSignal.Emit(partType, partState, insets);
1162 }
1163
1164 void Window::OnAccessibilityEnabled()
1165 {
1166   auto bridge     = Accessibility::Bridge::GetCurrentBridge();
1167   auto rootLayer  = mScene.GetRootLayer();
1168   auto accessible = Accessibility::Accessible::Get(rootLayer);
1169   bridge->AddTopLevelWindow(accessible);
1170
1171   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
1172
1173   Dali::Window handle(this);
1174   if(!mIsEmittedWindowCreatedEvent)
1175   {
1176     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
1177     bridge->WindowCreated(handle);
1178     mIsEmittedWindowCreatedEvent = true;
1179   }
1180
1181   if(!mVisible || mIconified)
1182   {
1183     return;
1184   }
1185
1186   bridge->WindowShown(handle);
1187
1188   if(mFocused)
1189   {
1190     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
1191     bridge->WindowFocused(handle);
1192   }
1193 }
1194
1195 void Window::OnAccessibilityDisabled()
1196 {
1197   auto bridge     = Accessibility::Bridge::GetCurrentBridge();
1198   auto rootLayer  = mScene.GetRootLayer();
1199   auto accessible = Accessibility::Accessible::Get(rootLayer);
1200   bridge->RemoveTopLevelWindow(accessible);
1201   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
1202 }
1203
1204 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
1205 {
1206   Dali::Window handle(this);
1207   mMoveCompletedSignal.Emit(handle, position);
1208 }
1209
1210 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
1211 {
1212   Dali::Window handle(this);
1213   mResizeCompletedSignal.Emit(handle, size);
1214 }
1215
1216 Vector2 Window::RecalculatePosition(const Vector2& position)
1217 {
1218   Vector2 convertedPosition;
1219
1220   switch(mRotationAngle)
1221   {
1222     case 90:
1223     {
1224       convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
1225       convertedPosition.y = position.x;
1226       break;
1227     }
1228     case 180:
1229     {
1230       convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
1231       convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
1232       break;
1233     }
1234     case 270:
1235     {
1236       convertedPosition.x = position.y;
1237       convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
1238       break;
1239     }
1240     default:
1241     {
1242       convertedPosition = position;
1243       break;
1244     }
1245   }
1246   return convertedPosition;
1247 }
1248
1249 Dali::Window Window::Get(Dali::Actor actor)
1250 {
1251   Internal::Adaptor::Window* windowImpl = nullptr;
1252
1253   if(Internal::Adaptor::Adaptor::IsAvailable())
1254   {
1255     Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
1256     windowImpl                                = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
1257     if(windowImpl)
1258     {
1259       return Dali::Window(windowImpl);
1260     }
1261   }
1262
1263   return Dali::Window();
1264 }
1265
1266 void Window::SetParent(Dali::Window& parent)
1267 {
1268   if(DALI_UNLIKELY(parent))
1269   {
1270     mParentWindow     = parent;
1271     Dali::Window self = Dali::Window(this);
1272     // check circular parent window setting
1273     if(Dali::DevelWindow::GetParent(parent) == self)
1274     {
1275       Dali::DevelWindow::Unparent(parent);
1276     }
1277     mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
1278   }
1279 }
1280
1281 void Window::SetParent(Dali::Window& parent, bool belowParent)
1282 {
1283   if(DALI_UNLIKELY(parent))
1284   {
1285     mParentWindow     = parent;
1286     Dali::Window self = Dali::Window(this);
1287     // check circular parent window setting
1288     if(Dali::DevelWindow::GetParent(parent) == self)
1289     {
1290       Dali::DevelWindow::Unparent(parent);
1291     }
1292     mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
1293   }
1294 }
1295
1296 void Window::Unparent()
1297 {
1298   mWindowBase->SetParent(nullptr, false);
1299   mParentWindow.Reset();
1300 }
1301
1302 Dali::Window Window::GetParent()
1303 {
1304   return mParentWindow;
1305 }
1306
1307 WindowOrientation Window::GetCurrentOrientation() const
1308 {
1309   return ConvertToOrientation(mRotationAngle);
1310 }
1311
1312 int Window::GetPhysicalOrientation() const
1313 {
1314   return (mRotationAngle + mWindowBase->GetScreenRotationAngle()) % 360;
1315 }
1316
1317 void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
1318 {
1319   Dali::Vector<float>::SizeType count = orientations.Count();
1320   for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
1321   {
1322     if(IsOrientationAvailable(orientations[index]) == false)
1323     {
1324       DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
1325       continue;
1326     }
1327
1328     bool found          = false;
1329     int  convertedAngle = ConvertToAngle(orientations[index]);
1330
1331     for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
1332     {
1333       if(mAvailableAngles[i] == convertedAngle)
1334       {
1335         found = true;
1336         break;
1337       }
1338     }
1339
1340     if(!found)
1341     {
1342       DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
1343       mAvailableAngles.push_back(convertedAngle);
1344     }
1345   }
1346   SetAvailableAnlges(mAvailableAngles);
1347 }
1348
1349 int32_t Window::GetNativeId() const
1350 {
1351   return mWindowBase->GetNativeWindowId();
1352 }
1353
1354 void Window::RequestMoveToServer()
1355 {
1356   SetUserGeometryPolicy();
1357   mWindowBase->RequestMoveToServer();
1358 }
1359
1360 void Window::RequestResizeToServer(WindowResizeDirection direction)
1361 {
1362   SetUserGeometryPolicy();
1363   mWindowBase->RequestResizeToServer(direction);
1364 }
1365
1366 void Window::EnableFloatingMode(bool enable)
1367 {
1368   mWindowBase->EnableFloatingMode(enable);
1369 }
1370
1371 bool Window::IsFloatingModeEnabled()
1372 {
1373   return mWindowBase->IsFloatingModeEnabled();
1374 }
1375
1376 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
1377 {
1378   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);
1379   mWindowBase->IncludeInputRegion(inputRegion);
1380 }
1381
1382 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
1383 {
1384   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);
1385   mWindowBase->ExcludeInputRegion(inputRegion);
1386 }
1387
1388 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1389 {
1390   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
1391   mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
1392   mWindowRotationAcknowledgement = needAcknowledgement;
1393 }
1394
1395 void Window::SendRotationCompletedAcknowledgement()
1396 {
1397   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
1398   if(mWindowRotationAcknowledgement)
1399   {
1400     SetRotationCompletedAcknowledgement();
1401   }
1402 }
1403
1404 bool Window::IsWindowRotating() const
1405 {
1406   return mIsWindowRotating;
1407 }
1408
1409 const Dali::KeyEvent& Window::GetLastKeyEvent() const
1410 {
1411   return mLastKeyEvent;
1412 }
1413
1414 const Dali::TouchEvent& Window::GetLastTouchEvent() const
1415 {
1416   return mLastTouchEvent;
1417 }
1418
1419 void Window::SetUserGeometryPolicy()
1420 {
1421   if(mIsEnabledUserGeometry == true)
1422   {
1423     return;
1424   }
1425
1426   mIsEnabledUserGeometry = true;
1427   AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
1428   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
1429 }
1430
1431 bool Window::PointerConstraintsLock()
1432 {
1433   return mWindowBase->PointerConstraintsLock();
1434 }
1435
1436 bool Window::PointerConstraintsUnlock()
1437 {
1438   return mWindowBase->PointerConstraintsUnlock();
1439 }
1440
1441 void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
1442 {
1443   mWindowBase->LockedPointerRegionSet(x, y, width, height);
1444 }
1445
1446 void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
1447 {
1448   mWindowBase->LockedPointerCursorPositionHintSet(x, y);
1449 }
1450
1451 bool Window::PointerWarp(int32_t x, int32_t y)
1452 {
1453   return mWindowBase->PointerWarp(x, y);
1454 }
1455
1456 void Window::CursorVisibleSet(bool visible)
1457 {
1458   mWindowBase->CursorVisibleSet(visible);
1459 }
1460
1461 bool Window::KeyboardGrab(Device::Subclass::Type deviceSubclass)
1462 {
1463   return mWindowBase->KeyboardGrab(deviceSubclass);
1464 }
1465
1466 bool Window::KeyboardUnGrab()
1467 {
1468   return mWindowBase->KeyboardUnGrab();
1469 }
1470
1471 } // namespace Adaptor
1472
1473 } // namespace Internal
1474
1475 } // namespace Dali