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