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