Merge "Revert "[Tizen] Added 'make clean' on each profile build."" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / window-impl-ecore-wl.cpp
1 /*
2 * Copyright (c) 2017 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 <window-impl.h>
20
21 // EXTERNAL HEADERS
22 #include <Ecore.h>
23 #include <Ecore_Wayland.h>
24 #include <tizen-extension-client-protocol.h>
25
26 #include <dali/integration-api/core.h>
27 #include <dali/integration-api/system-overlay.h>
28 #include <dali/public-api/render-tasks/render-task.h>
29 #include <dali/public-api/render-tasks/render-task-list.h>
30 #include <orientation.h>
31
32 // INTERNAL HEADERS
33 #include <window-render-surface.h>
34 #include <drag-and-drop-detector-impl.h>
35 #include <ecore-indicator-impl.h>
36 #include <window-visibility-observer.h>
37 #include <orientation-impl.h>
38
39 namespace
40 {
41 const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
42 const float INDICATOR_SHOW_Y_POSITION( 0.0f );
43 const float INDICATOR_HIDE_Y_POSITION( -52.0f );
44 }
45
46 namespace Dali
47 {
48 namespace Internal
49 {
50 namespace Adaptor
51 {
52
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
55 #endif
56
57 /**
58  * TODO: Abstract Window class out and move this into a window implementation for Ecore
59  */
60 struct Window::EventHandler
61 {
62   /**
63    * Constructor
64    * @param[in]  window  A pointer to the window class.
65    */
66   EventHandler( Window* window )
67   : mWindow( window ),
68     mWindowPropertyHandler( NULL ),
69     mWindowIconifyStateHandler( NULL ),
70     mWindowFocusInHandler( NULL ),
71     mWindowFocusOutHandler( NULL ),
72     mEcoreWindow( 0 ),
73     mDisplay( NULL ),
74     mEventQueue( NULL ),
75     mTizenPolicy( NULL ),
76     mTizenDisplayPolicy( NULL ),
77     mNotificationLevel( -1 ),
78     mNotificationChangeState( 0 ),
79     mNotificationLevelChangeDone( true ),
80     mScreenMode( 0 ),
81     mScreenModeChangeState( 0 ),
82     mScreenModeChangeDone( true )
83   {
84     // store ecore window handle
85     ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
86     if( wlWindow )
87     {
88       mEcoreWindow = wlWindow->GetWlWindow();
89     }
90     DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore Wl window");
91
92     if( mWindow->mEcoreEventHander )
93     {
94       mWindowIconifyStateHandler = ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this );
95       mWindowFocusInHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this );
96       mWindowFocusOutHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this );
97     }
98
99     mDisplay = ecore_wl_display_get();
100
101     if( mDisplay )
102     {
103       wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
104       if( displayWrapper )
105       {
106         mEventQueue = wl_display_create_queue( mDisplay );
107         if( mEventQueue )
108         {
109           wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
110
111           wl_registry* registry = wl_display_get_registry( displayWrapper );
112           wl_registry_add_listener( registry, &mRegistryListener, this );
113         }
114
115         wl_proxy_wrapper_destroy( displayWrapper );
116       }
117     }
118   }
119
120   /**
121    * Destructor
122    */
123   ~EventHandler()
124   {
125     if ( mWindowPropertyHandler )
126     {
127       ecore_event_handler_del( mWindowPropertyHandler );
128     }
129     if ( mWindowIconifyStateHandler )
130     {
131       ecore_event_handler_del( mWindowIconifyStateHandler );
132     }
133     if( mWindowFocusInHandler )
134     {
135       ecore_event_handler_del( mWindowFocusInHandler );
136     }
137     if( mWindowFocusOutHandler )
138     {
139       ecore_event_handler_del( mWindowFocusOutHandler );
140     }
141     if( mEventQueue )
142     {
143       wl_event_queue_destroy( mEventQueue );
144     }
145   }
146
147   // Static methods
148
149   /// Called when the window properties are changed.
150   static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
151   {
152     return EINA_FALSE;
153   }
154
155   /// Called when the window iconify state is changed.
156   static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
157   {
158     Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
159     EventHandler* handler( static_cast< EventHandler* >( data ) );
160     Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
161
162     if ( handler && handler->mWindow )
163     {
164       WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
165       if ( observer && ( iconifyChangedEvent->win == static_cast< unsigned int> ( ecore_wl_window_id_get( handler->mEcoreWindow ) ) ) )
166       {
167         if( iconifyChangedEvent->iconified == EINA_TRUE )
168         {
169           observer->OnWindowHidden();
170           DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
171         }
172         else
173         {
174           observer->OnWindowShown();
175           DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
176         }
177         handled = ECORE_CALLBACK_DONE;
178       }
179     }
180
181     return handled;
182   }
183
184   /// Called when the window gains focus
185   static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
186   {
187     Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
188     EventHandler* handler( static_cast< EventHandler* >( data ) );
189
190     if ( handler && handler->mWindow && focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
191     {
192       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
193
194       handler->mWindow->mFocusChangedSignal.Emit( true );
195     }
196
197     return ECORE_CALLBACK_PASS_ON;
198   }
199
200   /// Called when the window loses focus
201   static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
202   {
203     Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
204     EventHandler* handler( static_cast< EventHandler* >( data ) );
205
206     if ( handler && handler->mWindow && focusOutEvent->win == static_cast< unsigned int >(ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
207     {
208       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
209
210       handler->mWindow->mFocusChangedSignal.Emit( false );
211     }
212
213     return ECORE_CALLBACK_PASS_ON;
214   }
215
216   static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
217   {
218     Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
219
220     if( strcmp( interface, tizen_policy_interface.name ) == 0 )
221     {
222       eventHandler->mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, version ) );
223       if( !eventHandler->mTizenPolicy )
224       {
225         DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
226         return;
227       }
228
229       tizen_policy_add_listener( eventHandler->mTizenPolicy, &eventHandler->mTizenPolicyListener, data );
230
231       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
232     }
233     else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
234     {
235       eventHandler->mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
236       if( !eventHandler->mTizenDisplayPolicy )
237       {
238         DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
239         return;
240       }
241
242       tizen_display_policy_add_listener( eventHandler->mTizenDisplayPolicy, &eventHandler->mTizenDisplayPolicyListener, data );
243
244       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
245     }
246   }
247
248   static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
249   {
250     Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
251     eventHandler->mTizenPolicy = NULL;
252     eventHandler->mTizenDisplayPolicy = NULL;
253   }
254
255   static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
256   {
257     Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
258
259     eventHandler->mNotificationLevel = level;
260     eventHandler->mNotificationChangeState = state;
261     eventHandler->mNotificationLevelChangeDone = true;
262
263     DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
264   }
265
266   static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
267   {
268     Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
269
270     eventHandler->mScreenMode = mode;
271     eventHandler->mScreenModeChangeState = state;
272     eventHandler->mScreenModeChangeDone = true;
273
274     DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
275   }
276
277   static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
278   {
279     Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
280
281     eventHandler->mBrightness = brightness;
282     eventHandler->mBrightnessChangeState = state;
283     eventHandler->mBrightnessChangeDone = true;
284
285     DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
286   }
287
288   const struct wl_registry_listener mRegistryListener =
289   {
290      RegistryGlobalCallback,
291      RegistryGlobalCallbackRemove
292   };
293
294   const struct tizen_policy_listener mTizenPolicyListener =
295   {
296      NULL,
297      NULL,
298      TizenPolicyNotificationChangeDone,
299      NULL,
300      TizenPolicyScreenModeChangeDone,
301      NULL,
302      NULL,
303      NULL,
304      NULL
305   };
306
307   const struct tizen_display_policy_listener mTizenDisplayPolicyListener =
308   {
309     DisplayPolicyBrightnessChangeDone
310   };
311
312   // Data
313   Window* mWindow;
314   Ecore_Event_Handler* mWindowPropertyHandler;
315   Ecore_Event_Handler* mWindowIconifyStateHandler;
316   Ecore_Event_Handler* mWindowFocusInHandler;
317   Ecore_Event_Handler* mWindowFocusOutHandler;
318   Ecore_Wl_Window* mEcoreWindow;
319
320   wl_display* mDisplay;
321   wl_event_queue* mEventQueue;
322   tizen_policy* mTizenPolicy;
323   tizen_display_policy* mTizenDisplayPolicy;
324
325   int mNotificationLevel;
326   uint32_t mNotificationChangeState;
327   bool mNotificationLevelChangeDone;
328
329   int mScreenMode;
330   uint32_t mScreenModeChangeState;
331   bool mScreenModeChangeDone;
332
333   int mBrightness;
334   uint32_t mBrightnessChangeState;
335   bool mBrightnessChangeDone;
336 };
337
338 Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
339 {
340   Window* window = new Window();
341   window->mIsTransparent = isTransparent;
342   window->Initialize(posSize, name, className);
343   return window;
344 }
345
346 void Window::SetAdaptor(Dali::Adaptor& adaptor)
347 {
348   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
349   mStarted = true;
350
351   // Only create one overlay per window
352   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
353   Integration::Core& core = adaptorImpl.GetCore();
354   mOverlay = &core.GetSystemOverlay();
355
356   Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
357   taskList.CreateTask();
358
359   mAdaptor = &adaptorImpl;
360   mAdaptor->AddObserver( *this );
361
362   // Can only create the detector when we know the Core has been instantiated.
363   mDragAndDropDetector = DragAndDropDetector::New();
364   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
365
366   if( mOrientation )
367   {
368     mOrientation->SetAdaptor(adaptor);
369   }
370
371   if( mIndicator != NULL )
372   {
373     mIndicator->SetAdaptor(mAdaptor);
374   }
375 }
376
377 RenderSurface* Window::GetSurface()
378 {
379   return mSurface;
380 }
381
382 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
383 {
384   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
385   DALI_ASSERT_DEBUG(mOverlay);
386
387   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
388   DALI_ASSERT_DEBUG(wlSurface);
389
390   if( wlSurface )
391   {
392     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
393
394     mIndicatorVisible = visibleMode;
395
396     if ( mIndicatorVisible == Dali::Window::VISIBLE )
397     {
398       // when the indicator is visible, set proper mode for indicator server according to bg mode
399       if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
400       {
401         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
402       }
403       else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
404       {
405         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSLUCENT);
406       }
407       else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
408       {
409         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
410       }
411     }
412     else
413     {
414       // when the indicator is not visible, set TRANSPARENT mode for indicator server
415       ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator
416     }
417   }
418
419   DoShowIndicator( mIndicatorOrientation );
420 }
421
422 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
423 {
424   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
425
426   DoRotateIndicator( orientation );
427 }
428
429 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
430 {
431   mIndicatorOpacityMode = opacityMode;
432
433   if( mIndicator != NULL )
434   {
435     mIndicator->SetOpacityMode( opacityMode );
436   }
437 }
438
439 void Window::SetClass(std::string name, std::string klass)
440 {
441   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
442
443   if( wlSurface )
444   {
445     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
446     ecore_wl_window_title_set( wlWindow, name.c_str() );
447     ecore_wl_window_class_name_set( wlWindow, klass.c_str() );
448   }
449   else
450   {
451     DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window has no surface\n" );
452   }
453 }
454
455 Window::Window()
456 : mSurface( NULL ),
457   mIndicatorVisible( Dali::Window::VISIBLE ),
458   mIndicatorIsShown( false ),
459   mShowRotatedIndicatorOnClose( false ),
460   mStarted( false ),
461   mIsTransparent( false ),
462   mWMRotationAppSet( false ),
463   mEcoreEventHander( true ),
464   mIsFocusAcceptable( true ),
465   mVisible( true ),
466   mOpaqueState( false ),
467   mIndicator( NULL ),
468   mIndicatorOrientation( Dali::Window::PORTRAIT ),
469   mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
470   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
471   mOverlay( NULL ),
472   mAdaptor( NULL ),
473   mType( Dali::DevelWindow::NORMAL ),
474   mEventHandler( NULL ),
475   mPreferredOrientation( Dali::Window::PORTRAIT ),
476   mSupportedAuxiliaryHints(),
477   mAuxiliaryHints()
478 {
479 }
480
481 Window::~Window()
482 {
483   delete mEventHandler;
484
485   if( mIndicator )
486   {
487     mIndicator->Close();
488     delete mIndicator;
489   }
490
491   if ( mAdaptor )
492   {
493     mAdaptor->RemoveObserver( *this );
494     mAdaptor->SetDragAndDropDetector( NULL );
495     mAdaptor = NULL;
496   }
497
498   delete mSurface;
499
500   mSupportedAuxiliaryHints.clear();
501   mAuxiliaryHints.clear();
502 }
503
504 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
505 {
506   // create an Wayland window by default
507   Any surface;
508   ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
509
510   mSurface = windowSurface;
511   SetClass( name, className );
512   windowSurface->Map();
513
514   mOrientation = Orientation::New(this);
515
516   // create event handler for Wayland window
517   mEventHandler = new EventHandler( this );
518
519   // get auxiliary hint
520   Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEventHandler->mEcoreWindow );
521   if( hints )
522   {
523     Eina_List* l = NULL;
524     char* hint = NULL;
525
526     for( l = hints, ( hint =  static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
527     {
528       mSupportedAuxiliaryHints.push_back( hint );
529
530       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
531     }
532   }
533 }
534
535 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
536 {
537   if( mIndicator == NULL )
538   {
539     if( mIndicatorVisible != Dali::Window::INVISIBLE )
540     {
541       mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
542       mIndicator->SetOpacityMode( mIndicatorOpacityMode );
543       Dali::Actor actor = mIndicator->GetActor();
544       SetIndicatorActorRotation();
545       mOverlay->Add(actor);
546     }
547     // else don't create a hidden indicator
548   }
549   else // Already have indicator
550   {
551     if( mIndicatorVisible == Dali::Window::VISIBLE )
552     {
553       // If we are resuming, and rotation has changed,
554       if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
555       {
556         // then close current indicator and open new one
557         mShowRotatedIndicatorOnClose = true;
558         mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
559         // Don't show actor - will contain indicator for old orientation.
560       }
561     }
562   }
563
564   // set indicator visible mode
565   if( mIndicator != NULL )
566   {
567     mIndicator->SetVisible( mIndicatorVisible );
568   }
569
570   bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
571   SetIndicatorProperties( show, lastOrientation );
572   mIndicatorIsShown = show;
573 }
574
575 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
576 {
577   if( mIndicatorIsShown )
578   {
579     mShowRotatedIndicatorOnClose = true;
580     mNextIndicatorOrientation = orientation;
581     mIndicator->Close(); // May synchronously call IndicatorClosed() callback
582   }
583   else
584   {
585     // Save orientation for when the indicator is next shown
586     mShowRotatedIndicatorOnClose = false;
587     mNextIndicatorOrientation = orientation;
588   }
589 }
590
591 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
592 {
593   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
594
595   if( wlSurface )
596   {
597     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
598     if ( isShow )
599     {
600       ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_ON);
601     }
602     else
603     {
604       ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_OFF);
605     }
606   }
607 }
608
609 void Window::IndicatorTypeChanged(Indicator::Type type)
610 {
611 #if defined(DALI_PROFILE_MOBILE)
612   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
613
614   if( wlSurface )
615   {
616     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
617     switch(type)
618     {
619       case Indicator::INDICATOR_TYPE_1:
620         ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
621         break;
622
623       case Indicator::INDICATOR_TYPE_2:
624         ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN);
625         break;
626
627       case Indicator::INDICATOR_TYPE_UNKNOWN:
628       default:
629         break;
630     }
631   }
632 #endif //MOBILE
633 }
634
635 void Window::IndicatorClosed( IndicatorInterface* indicator )
636 {
637   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
638
639   if( mShowRotatedIndicatorOnClose )
640   {
641     Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
642     mIndicator->Open(mNextIndicatorOrientation);
643     mIndicatorOrientation = mNextIndicatorOrientation;
644     SetIndicatorActorRotation();
645     DoShowIndicator(currentOrientation);
646   }
647 }
648
649 void Window::IndicatorVisibilityChanged(bool isVisible)
650 {
651   mIndicatorVisibilityChangedSignal.Emit(isVisible);
652 }
653
654 void Window::SetIndicatorActorRotation()
655 {
656   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
657   DALI_ASSERT_DEBUG( mIndicator != NULL );
658
659   Dali::Actor actor = mIndicator->GetActor();
660   switch( mIndicatorOrientation )
661   {
662     case Dali::Window::PORTRAIT:
663       actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
664       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
665       actor.SetOrientation( Degree(0), Vector3::ZAXIS );
666       break;
667     case Dali::Window::PORTRAIT_INVERSE:
668       actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
669       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
670       actor.SetOrientation( Degree(180), Vector3::ZAXIS );
671       break;
672     case Dali::Window::LANDSCAPE:
673       actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
674       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
675       actor.SetOrientation( Degree(270), Vector3::ZAXIS );
676       break;
677     case Dali::Window::LANDSCAPE_INVERSE:
678       actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
679       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
680       actor.SetOrientation( Degree(90), Vector3::ZAXIS );
681       break;
682   }
683 }
684
685 void Window::Raise()
686 {
687   ecore_wl_window_raise( mEventHandler->mEcoreWindow );
688 }
689
690 void Window::Lower()
691 {
692   ecore_wl_window_lower( mEventHandler->mEcoreWindow );
693 }
694
695 void Window::Activate()
696 {
697   ecore_wl_window_activate( mEventHandler->mEcoreWindow );
698 }
699
700 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
701 {
702   return mDragAndDropDetector;
703 }
704
705 Dali::Any Window::GetNativeHandle() const
706 {
707   if(mEventHandler)
708   {
709     return mEventHandler->mEcoreWindow;
710   }
711   else
712   {
713     return Dali::Any();
714   }
715 }
716
717 void Window::OnStart()
718 {
719   DoShowIndicator( mIndicatorOrientation );
720 }
721
722 void Window::OnPause()
723 {
724 }
725
726 void Window::OnResume()
727 {
728   // resume indicator status
729   if( mIndicator != NULL )
730   {
731     // Restore own indicator opacity
732     // Send opacity mode to indicator service when app resumed
733     mIndicator->SetOpacityMode( mIndicatorOpacityMode );
734   }
735 }
736
737 void Window::OnStop()
738 {
739   if( mIndicator )
740   {
741     mIndicator->Close();
742   }
743
744   delete mIndicator;
745   mIndicator = NULL;
746 }
747
748 void Window::OnDestroy()
749 {
750   mAdaptor = NULL;
751 }
752
753 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
754 {
755   bool found = false;
756
757   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
758   {
759     if(mAvailableOrientations[i] == orientation)
760     {
761       found = true;
762       break;
763     }
764   }
765
766   if( ! found )
767   {
768     mAvailableOrientations.push_back(orientation);
769     SetAvailableOrientations( mAvailableOrientations );
770   }
771 }
772
773 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
774 {
775   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
776        iter != mAvailableOrientations.end(); ++iter )
777   {
778     if( *iter == orientation )
779     {
780       mAvailableOrientations.erase( iter );
781       break;
782     }
783   }
784   SetAvailableOrientations( mAvailableOrientations );
785 }
786
787 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
788 {
789   int rotations[4];
790   for( std::size_t i = 0; i < mAvailableOrientations.size(); ++i )
791   {
792     rotations[i] = static_cast< int >( mAvailableOrientations[i] );
793   }
794   ecore_wl_window_rotation_available_rotations_set( mEventHandler->mEcoreWindow, rotations, mAvailableOrientations.size() );
795 }
796
797 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
798 {
799   return mAvailableOrientations;
800 }
801
802 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
803 {
804   mPreferredOrientation = orientation;
805
806   ecore_wl_window_rotation_preferred_rotation_set( mEventHandler->mEcoreWindow, orientation );
807 }
808
809 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
810 {
811   return mPreferredOrientation;
812 }
813
814 void Window::SetAcceptFocus( bool accept )
815 {
816   mIsFocusAcceptable = accept;
817
818   ecore_wl_window_focus_skip_set( mEventHandler->mEcoreWindow, !accept );
819 }
820
821 bool Window::IsFocusAcceptable()
822 {
823   return mIsFocusAcceptable;
824 }
825
826 void Window::Show()
827 {
828   mVisible = true;
829   ecore_wl_window_show( mEventHandler->mEcoreWindow );
830
831   // Need an update request
832   if( mAdaptor )
833   {
834     mAdaptor->RequestUpdateOnce();
835   }
836 }
837
838 void Window::Hide()
839 {
840   mVisible = false;
841   ecore_wl_window_hide( mEventHandler->mEcoreWindow );
842 }
843
844 bool Window::IsVisible() const
845 {
846   return mVisible;
847 }
848
849 void Window::RotationDone( int orientation, int width, int height )
850 {
851   ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
852 }
853
854 unsigned int Window::GetSupportedAuxiliaryHintCount()
855 {
856   return mSupportedAuxiliaryHints.size();
857 }
858
859 std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
860 {
861   if( index >= GetSupportedAuxiliaryHintCount() )
862   {
863     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
864   }
865
866   return mSupportedAuxiliaryHints[index];
867 }
868
869 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
870 {
871   bool supported = false;
872
873   // Check if the hint is suppported
874   for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
875   {
876     if( *iter == hint )
877     {
878       supported = true;
879       break;
880     }
881   }
882
883   if( !supported )
884   {
885     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
886     return 0;
887   }
888
889   // Check if the hint is already added
890   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
891   {
892     if( mAuxiliaryHints[i].first == hint )
893     {
894       // Just change the value
895       mAuxiliaryHints[i].second = value;
896
897       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
898
899       return i + 1;   // id is index + 1
900     }
901   }
902
903   // Add the hint
904   mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
905
906   unsigned int id = mAuxiliaryHints.size();
907
908   ecore_wl_window_aux_hint_add( mEventHandler->mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
909
910   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
911
912   return id;
913 }
914
915 bool Window::RemoveAuxiliaryHint( unsigned int id )
916 {
917   if( id == 0 || id > mAuxiliaryHints.size() )
918   {
919     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
920     return false;
921   }
922
923   mAuxiliaryHints[id - 1].second = std::string();
924
925   ecore_wl_window_aux_hint_del( mEventHandler->mEcoreWindow, static_cast< int >( id ) );
926
927   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
928
929   return true;
930 }
931
932 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
933 {
934   if( id == 0 || id > mAuxiliaryHints.size() )
935   {
936     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
937     return false;
938   }
939
940   mAuxiliaryHints[id - 1].second = value;
941
942   ecore_wl_window_aux_hint_change( mEventHandler->mEcoreWindow, static_cast< int >( id ), value.c_str() );
943
944   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
945
946   return true;
947 }
948
949 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
950 {
951   if( id == 0 || id > mAuxiliaryHints.size() )
952   {
953     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
954     return std::string();
955   }
956
957   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
958
959   return mAuxiliaryHints[id - 1].second;
960 }
961
962 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
963 {
964   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
965   {
966     if( mAuxiliaryHints[i].first == hint )
967     {
968       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
969       return i + 1;
970     }
971   }
972
973   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
974
975   return 0;
976 }
977
978 void Window::SetInputRegion( const Rect< int >& inputRegion )
979 {
980   ecore_wl_window_input_region_set( mEventHandler->mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
981
982   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
983 }
984
985 void Window::SetType( Dali::DevelWindow::Type type )
986 {
987   Ecore_Wl_Window_Type windowType;
988
989   if( type != mType )
990   {
991     switch( type )
992     {
993       case Dali::DevelWindow::NORMAL:
994       {
995         windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
996         break;
997       }
998       case Dali::DevelWindow::NOTIFICATION:
999       {
1000         windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1001         break;
1002       }
1003       case Dali::DevelWindow::UTILITY:
1004       {
1005         windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1006         break;
1007       }
1008       case Dali::DevelWindow::DIALOG:
1009       {
1010         windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1011         break;
1012       }
1013       default:
1014       {
1015         windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1016         break;
1017       }
1018     }
1019
1020     ecore_wl_window_type_set( mEventHandler->mEcoreWindow, windowType );
1021   }
1022
1023   mType = type;
1024 }
1025
1026 Dali::DevelWindow::Type Window::GetType() const
1027 {
1028   return mType;
1029 }
1030
1031 bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
1032 {
1033   if( mType != Dali::DevelWindow::NOTIFICATION )
1034   {
1035     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
1036     return false;
1037   }
1038
1039   while( !mEventHandler->mTizenPolicy )
1040   {
1041     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1042   }
1043
1044   int notificationLevel;
1045
1046   switch( level )
1047   {
1048     case Dali::DevelWindow::NotificationLevel::NONE:
1049     {
1050       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1051       break;
1052     }
1053     case Dali::DevelWindow::NotificationLevel::BASE:
1054     {
1055       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1056       break;
1057     }
1058     case Dali::DevelWindow::NotificationLevel::MEDIUM:
1059     {
1060       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1061       break;
1062     }
1063     case Dali::DevelWindow::NotificationLevel::HIGH:
1064     {
1065       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1066       break;
1067     }
1068     case Dali::DevelWindow::NotificationLevel::TOP:
1069     {
1070       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1071       break;
1072     }
1073     default:
1074     {
1075       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: invalid level [%d]\n", level );
1076       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1077       break;
1078     }
1079   }
1080
1081   mEventHandler->mNotificationLevelChangeDone = false;
1082   mEventHandler->mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1083
1084   tizen_policy_set_notification_level( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), notificationLevel );
1085
1086   int count = 0;
1087
1088   while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1089   {
1090     ecore_wl_flush();
1091     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1092     count++;
1093   }
1094
1095   if( !mEventHandler->mNotificationLevelChangeDone )
1096   {
1097     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mEventHandler->mNotificationChangeState );
1098     return false;
1099   }
1100   else if( mEventHandler->mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1101   {
1102     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Permission denied! [%d]\n", level );
1103     return false;
1104   }
1105
1106   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level is changed [%d]\n", mEventHandler->mNotificationLevel );
1107
1108   return true;
1109 }
1110
1111 Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
1112 {
1113   if( mType != Dali::DevelWindow::NOTIFICATION )
1114   {
1115     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
1116     return Dali::DevelWindow::NotificationLevel::NONE;
1117   }
1118
1119   while( !mEventHandler->mTizenPolicy )
1120   {
1121     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1122   }
1123
1124   int count = 0;
1125
1126   while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1127   {
1128     ecore_wl_flush();
1129     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1130     count++;
1131   }
1132
1133   if( !mEventHandler->mNotificationLevelChangeDone )
1134   {
1135     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Error! [%d]\n", mEventHandler->mNotificationChangeState );
1136     return Dali::DevelWindow::NotificationLevel::NONE;
1137   }
1138
1139   Dali::DevelWindow::NotificationLevel::Type level;
1140
1141   switch( mEventHandler->mNotificationLevel )
1142   {
1143     case TIZEN_POLICY_LEVEL_NONE:
1144     {
1145       level = Dali::DevelWindow::NotificationLevel::NONE;
1146       break;
1147     }
1148     case TIZEN_POLICY_LEVEL_DEFAULT:
1149     {
1150       level = Dali::DevelWindow::NotificationLevel::BASE;
1151       break;
1152     }
1153     case TIZEN_POLICY_LEVEL_MEDIUM:
1154     {
1155       level = Dali::DevelWindow::NotificationLevel::MEDIUM;
1156       break;
1157     }
1158     case TIZEN_POLICY_LEVEL_HIGH:
1159     {
1160       level = Dali::DevelWindow::NotificationLevel::HIGH;
1161       break;
1162     }
1163     case TIZEN_POLICY_LEVEL_TOP:
1164     {
1165       level = Dali::DevelWindow::NotificationLevel::TOP;
1166       break;
1167     }
1168     default:
1169     {
1170       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: invalid level [%d]\n", mEventHandler->mNotificationLevel );
1171       level = Dali::DevelWindow::NotificationLevel::NONE;
1172       break;
1173     }
1174   }
1175
1176   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: level [%d]\n", mEventHandler->mNotificationLevel );
1177
1178   return level;
1179 }
1180
1181 void Window::SetOpaqueState( bool opaque )
1182 {
1183   while( !mEventHandler->mTizenPolicy )
1184   {
1185     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1186   }
1187
1188   tizen_policy_set_opaque_state( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), ( opaque ? 1 : 0 ) );
1189
1190   mOpaqueState = opaque;
1191
1192   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
1193 }
1194
1195 bool Window::IsOpaqueState()
1196 {
1197   return mOpaqueState;
1198 }
1199
1200 bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
1201 {
1202   while( !mEventHandler->mTizenPolicy )
1203   {
1204     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1205   }
1206
1207   mEventHandler->mScreenModeChangeDone = false;
1208   mEventHandler->mScreenModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1209
1210   unsigned int mode = 0;
1211
1212   switch( screenMode )
1213   {
1214     case Dali::DevelWindow::ScreenMode::DEFAULT:
1215     {
1216       mode = 0;
1217       break;
1218     }
1219     case Dali::DevelWindow::ScreenMode::ALWAYS_ON:
1220     {
1221       mode = 1;
1222       break;
1223     }
1224   }
1225
1226   tizen_policy_set_window_screen_mode( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), mode );
1227
1228   int count = 0;
1229
1230   while( !mEventHandler->mScreenModeChangeDone && count < 3 )
1231   {
1232     ecore_wl_flush();
1233     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1234     count++;
1235   }
1236
1237   if( !mEventHandler->mScreenModeChangeDone )
1238   {
1239     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Screen mode change is failed [%d, %d]\n", screenMode, mEventHandler->mScreenModeChangeState );
1240     return false;
1241   }
1242   else if( mEventHandler->mScreenModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1243   {
1244     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Permission denied! [%d]\n", screenMode );
1245     return false;
1246   }
1247
1248   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Screen mode is changed [%d]\n", mEventHandler->mScreenMode );
1249
1250   return true;
1251 }
1252
1253 Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
1254 {
1255   while( !mEventHandler->mTizenPolicy )
1256   {
1257     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1258   }
1259
1260   int count = 0;
1261
1262   while( !mEventHandler->mScreenModeChangeDone && count < 3 )
1263   {
1264     ecore_wl_flush();
1265     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1266     count++;
1267   }
1268
1269   if( !mEventHandler->mScreenModeChangeDone )
1270   {
1271     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenMode: Error! [%d]\n", mEventHandler->mScreenModeChangeState );
1272     return Dali::DevelWindow::ScreenMode::DEFAULT;
1273   }
1274
1275   Dali::DevelWindow::ScreenMode::Type screenMode = Dali::DevelWindow::ScreenMode::DEFAULT;
1276
1277   switch( mEventHandler->mScreenMode )
1278   {
1279     case 0:
1280     {
1281       screenMode = Dali::DevelWindow::ScreenMode::DEFAULT;
1282       break;
1283     }
1284     case 1:
1285     {
1286       screenMode = Dali::DevelWindow::ScreenMode::ALWAYS_ON;
1287       break;
1288     }
1289   }
1290
1291   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenMode: screen mode [%d]\n", mEventHandler->mScreenMode );
1292
1293   return screenMode;
1294 }
1295
1296 bool Window::SetBrightness( int brightness )
1297 {
1298   if( brightness < 0 || brightness > 100 )
1299   {
1300     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
1301     return false;
1302   }
1303
1304   while( !mEventHandler->mTizenDisplayPolicy )
1305   {
1306     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1307   }
1308
1309   mEventHandler->mBrightnessChangeDone = false;
1310   mEventHandler->mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1311
1312   tizen_display_policy_set_window_brightness( mEventHandler->mTizenDisplayPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), brightness );
1313
1314   int count = 0;
1315
1316   while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1317   {
1318     ecore_wl_flush();
1319     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1320     count++;
1321   }
1322
1323   if( !mEventHandler->mBrightnessChangeDone )
1324   {
1325     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mEventHandler->mBrightnessChangeState );
1326     return false;
1327   }
1328   else if( mEventHandler->mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1329   {
1330     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Permission denied! [%d]\n", brightness );
1331     return false;
1332   }
1333
1334   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness is changed [%d]\n", mEventHandler->mBrightness );
1335
1336   return true;
1337 }
1338
1339 int Window::GetBrightness()
1340 {
1341   while( !mEventHandler->mTizenDisplayPolicy )
1342   {
1343     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1344   }
1345
1346   int count = 0;
1347
1348   while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1349   {
1350     ecore_wl_flush();
1351     wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1352     count++;
1353   }
1354
1355   if( !mEventHandler->mBrightnessChangeDone )
1356   {
1357     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Error! [%d]\n", mEventHandler->mBrightnessChangeState );
1358     return 0;
1359   }
1360
1361   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Brightness [%d]\n", mEventHandler->mBrightness );
1362
1363   return mEventHandler->mBrightness;
1364 }
1365
1366 void* Window::GetNativeWindowHandler()
1367 {
1368   return mEventHandler->mEcoreWindow;
1369 }
1370
1371 } // Adaptor
1372 } // Internal
1373 } // Dali