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