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