ad286f4b7c651888c18f5bd2e60692ff3174f4c9
[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
25 #include <dali/integration-api/core.h>
26 #include <dali/integration-api/system-overlay.h>
27 #include <dali/public-api/render-tasks/render-task.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
29 #include <orientation.h>
30
31 // INTERNAL HEADERS
32 #include <window-render-surface.h>
33 #include <drag-and-drop-detector-impl.h>
34 #include <ecore-indicator-impl.h>
35 #include <window-visibility-observer.h>
36 #include <orientation-impl.h>
37
38 namespace
39 {
40 const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
41 const float INDICATOR_SHOW_Y_POSITION( 0.0f );
42 const float INDICATOR_HIDE_Y_POSITION( -52.0f );
43 }
44
45 namespace Dali
46 {
47 namespace Internal
48 {
49 namespace Adaptor
50 {
51 #if defined(DEBUG_ENABLED)
52 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
53 #endif
54
55 /**
56  * TODO: Abstract Window class out and move this into a window implementation for Ecore
57  */
58 struct Window::EventHandler
59 {
60   /**
61    * Constructor
62    * @param[in]  window  A pointer to the window class.
63    */
64   EventHandler( Window* window )
65   : mWindow( window ),
66     mWindowPropertyHandler( NULL ),
67     mWindowIconifyStateHandler( NULL ),
68     mWindowFocusInHandler( NULL ),
69     mWindowFocusOutHandler( NULL ),
70     mEcoreWindow( 0 )
71   {
72     // store ecore window handle
73     ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
74     if( wlWindow )
75     {
76       mEcoreWindow = wlWindow->GetWlWindow();
77     }
78     DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore Wl window");
79
80     if( mWindow->mEcoreEventHander )
81     {
82       mWindowIconifyStateHandler = ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this );
83       mWindowFocusInHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this );
84       mWindowFocusOutHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this );
85     }
86   }
87
88   /**
89    * Destructor
90    */
91   ~EventHandler()
92   {
93     if ( mWindowPropertyHandler )
94     {
95       ecore_event_handler_del( mWindowPropertyHandler );
96     }
97     if ( mWindowIconifyStateHandler )
98     {
99       ecore_event_handler_del( mWindowIconifyStateHandler );
100     }
101     if( mWindowFocusInHandler )
102     {
103       ecore_event_handler_del( mWindowFocusInHandler );
104     }
105     if( mWindowFocusOutHandler )
106     {
107       ecore_event_handler_del( mWindowFocusOutHandler );
108     }
109   }
110
111   // Static methods
112
113   /// Called when the window properties are changed.
114   static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
115   {
116     return EINA_FALSE;
117   }
118
119   /// Called when the window iconify state is changed.
120   static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
121   {
122     Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
123     EventHandler* handler( static_cast< EventHandler* >( data ) );
124     Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
125
126     if ( handler && handler->mWindow )
127     {
128       WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
129       if ( observer && ( iconifyChangedEvent->win == static_cast< unsigned int> ( ecore_wl_window_id_get( handler->mEcoreWindow ) ) ) )
130       {
131         if( iconifyChangedEvent->iconified == EINA_TRUE )
132         {
133           observer->OnWindowHidden();
134           DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
135         }
136         else
137         {
138           observer->OnWindowShown();
139           DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
140         }
141         handled = ECORE_CALLBACK_DONE;
142       }
143     }
144
145     return handled;
146   }
147
148   /// Called when the window gains focus
149   static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
150   {
151     Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
152     EventHandler* handler( static_cast< EventHandler* >( data ) );
153
154     if ( handler && handler->mWindow && focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
155     {
156       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
157
158       handler->mWindow->mFocusChangedSignal.Emit( true );
159     }
160
161     return ECORE_CALLBACK_PASS_ON;
162   }
163
164   /// Called when the window loses focus
165   static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
166   {
167     Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
168     EventHandler* handler( static_cast< EventHandler* >( data ) );
169
170     if ( handler && handler->mWindow && focusOutEvent->win == static_cast< unsigned int >(ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
171     {
172       DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
173
174       handler->mWindow->mFocusChangedSignal.Emit( false );
175     }
176
177     return ECORE_CALLBACK_PASS_ON;
178   }
179
180   // Data
181   Window* mWindow;
182   Ecore_Event_Handler* mWindowPropertyHandler;
183   Ecore_Event_Handler* mWindowIconifyStateHandler;
184   Ecore_Event_Handler* mWindowFocusInHandler;
185   Ecore_Event_Handler* mWindowFocusOutHandler;
186   Ecore_Wl_Window* mEcoreWindow;
187 };
188
189 Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
190 {
191   Window* window = new Window();
192   window->mIsTransparent = isTransparent;
193   window->Initialize(posSize, name, className);
194   return window;
195 }
196
197 void Window::SetAdaptor(Dali::Adaptor& adaptor)
198 {
199   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
200   mStarted = true;
201
202   // Only create one overlay per window
203   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
204   Integration::Core& core = adaptorImpl.GetCore();
205   mOverlay = &core.GetSystemOverlay();
206
207   Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
208   taskList.CreateTask();
209
210   mAdaptor = &adaptorImpl;
211   mAdaptor->AddObserver( *this );
212
213   // Can only create the detector when we know the Core has been instantiated.
214   mDragAndDropDetector = DragAndDropDetector::New();
215   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
216
217   if( mOrientation )
218   {
219     mOrientation->SetAdaptor(adaptor);
220   }
221
222   if( mIndicator != NULL )
223   {
224     mIndicator->SetAdaptor(mAdaptor);
225   }
226 }
227
228 RenderSurface* Window::GetSurface()
229 {
230   return mSurface;
231 }
232
233 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
234 {
235   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
236   DALI_ASSERT_DEBUG(mOverlay);
237
238   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
239   DALI_ASSERT_DEBUG(wlSurface);
240
241   if( wlSurface )
242   {
243     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
244
245     mIndicatorVisible = visibleMode;
246
247     if ( mIndicatorVisible == Dali::Window::VISIBLE )
248     {
249       // when the indicator is visible, set proper mode for indicator server according to bg mode
250       if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
251       {
252         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
253       }
254       else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
255       {
256         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSLUCENT);
257       }
258       else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
259       {
260         ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
261       }
262     }
263     else
264     {
265       // when the indicator is not visible, set TRANSPARENT mode for indicator server
266       ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator
267     }
268   }
269
270   DoShowIndicator( mIndicatorOrientation );
271 }
272
273 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
274 {
275   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
276
277   DoRotateIndicator( orientation );
278 }
279
280 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
281 {
282   mIndicatorOpacityMode = opacityMode;
283
284   if( mIndicator != NULL )
285   {
286     mIndicator->SetOpacityMode( opacityMode );
287   }
288 }
289
290 void Window::SetClass(std::string name, std::string klass)
291 {
292   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
293
294   if( wlSurface )
295   {
296     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
297     ecore_wl_window_title_set( wlWindow, name.c_str() );
298     ecore_wl_window_class_name_set( wlWindow, klass.c_str() );
299   }
300   else
301   {
302     DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window has no surface\n" );
303   }
304 }
305
306 Window::Window()
307 : mSurface( NULL ),
308   mIndicatorVisible( Dali::Window::VISIBLE ),
309   mIndicatorIsShown( false ),
310   mShowRotatedIndicatorOnClose( false ),
311   mStarted( false ),
312   mIsTransparent( false ),
313   mWMRotationAppSet( false ),
314   mEcoreEventHander( true ),
315   mIsFocusAcceptable( true ),
316   mVisible( true ),
317   mIndicator( NULL ),
318   mIndicatorOrientation( Dali::Window::PORTRAIT ),
319   mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
320   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
321   mOverlay( NULL ),
322   mAdaptor( NULL ),
323   mEventHandler( NULL ),
324   mPreferredOrientation( Dali::Window::PORTRAIT ),
325   mSupportedAuxiliaryHints(),
326   mAuxiliaryHints()
327 {
328 }
329
330 Window::~Window()
331 {
332   delete mEventHandler;
333
334   if( mIndicator )
335   {
336     mIndicator->Close();
337     delete mIndicator;
338   }
339
340   if ( mAdaptor )
341   {
342     mAdaptor->RemoveObserver( *this );
343     mAdaptor->SetDragAndDropDetector( NULL );
344     mAdaptor = NULL;
345   }
346
347   delete mSurface;
348
349   mSupportedAuxiliaryHints.clear();
350   mAuxiliaryHints.clear();
351 }
352
353 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
354 {
355   // create an Wayland window by default
356   Any surface;
357   ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
358
359   mSurface = windowSurface;
360   SetClass( name, className );
361   windowSurface->Map();
362
363   mOrientation = Orientation::New(this);
364
365   // create event handler for Wayland window
366   mEventHandler = new EventHandler( this );
367
368   // get auxiliary hint
369   Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEventHandler->mEcoreWindow );
370   if( hints )
371   {
372     Eina_List* l = NULL;
373     char* hint = NULL;
374
375     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) ) ) )
376     {
377       mSupportedAuxiliaryHints.push_back( hint );
378
379       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
380     }
381   }
382 }
383
384 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
385 {
386   if( mIndicator == NULL )
387   {
388     if( mIndicatorVisible != Dali::Window::INVISIBLE )
389     {
390       mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
391       mIndicator->SetOpacityMode( mIndicatorOpacityMode );
392       Dali::Actor actor = mIndicator->GetActor();
393       SetIndicatorActorRotation();
394       mOverlay->Add(actor);
395     }
396     // else don't create a hidden indicator
397   }
398   else // Already have indicator
399   {
400     if( mIndicatorVisible == Dali::Window::VISIBLE )
401     {
402       // If we are resuming, and rotation has changed,
403       if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
404       {
405         // then close current indicator and open new one
406         mShowRotatedIndicatorOnClose = true;
407         mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
408         // Don't show actor - will contain indicator for old orientation.
409       }
410     }
411   }
412
413   // set indicator visible mode
414   if( mIndicator != NULL )
415   {
416     mIndicator->SetVisible( mIndicatorVisible );
417   }
418
419   bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
420   SetIndicatorProperties( show, lastOrientation );
421   mIndicatorIsShown = show;
422 }
423
424 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
425 {
426   if( mIndicatorIsShown )
427   {
428     mShowRotatedIndicatorOnClose = true;
429     mNextIndicatorOrientation = orientation;
430     mIndicator->Close(); // May synchronously call IndicatorClosed() callback
431   }
432   else
433   {
434     // Save orientation for when the indicator is next shown
435     mShowRotatedIndicatorOnClose = false;
436     mNextIndicatorOrientation = orientation;
437   }
438 }
439
440 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
441 {
442   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
443
444   if( wlSurface )
445   {
446     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
447     if ( isShow )
448     {
449       ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_ON);
450     }
451     else
452     {
453       ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_OFF);
454     }
455   }
456 }
457
458 void Window::IndicatorTypeChanged(Indicator::Type type)
459 {
460 #if defined(DALI_PROFILE_MOBILE)
461   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
462
463   if( wlSurface )
464   {
465     Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
466     switch(type)
467     {
468       case Indicator::INDICATOR_TYPE_1:
469         ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
470         break;
471
472       case Indicator::INDICATOR_TYPE_2:
473         ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN);
474         break;
475
476       case Indicator::INDICATOR_TYPE_UNKNOWN:
477       default:
478         break;
479     }
480   }
481 #endif //MOBILE
482 }
483
484 void Window::IndicatorClosed( IndicatorInterface* indicator )
485 {
486   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
487
488   if( mShowRotatedIndicatorOnClose )
489   {
490     Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
491     mIndicator->Open(mNextIndicatorOrientation);
492     mIndicatorOrientation = mNextIndicatorOrientation;
493     SetIndicatorActorRotation();
494     DoShowIndicator(currentOrientation);
495   }
496 }
497
498 void Window::IndicatorVisibilityChanged(bool isVisible)
499 {
500   mIndicatorVisibilityChangedSignal.Emit(isVisible);
501 }
502
503 void Window::SetIndicatorActorRotation()
504 {
505   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
506   DALI_ASSERT_DEBUG( mIndicator != NULL );
507
508   Dali::Actor actor = mIndicator->GetActor();
509   switch( mIndicatorOrientation )
510   {
511     case Dali::Window::PORTRAIT:
512       actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
513       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
514       actor.SetOrientation( Degree(0), Vector3::ZAXIS );
515       break;
516     case Dali::Window::PORTRAIT_INVERSE:
517       actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
518       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
519       actor.SetOrientation( Degree(180), Vector3::ZAXIS );
520       break;
521     case Dali::Window::LANDSCAPE:
522       actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
523       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
524       actor.SetOrientation( Degree(270), Vector3::ZAXIS );
525       break;
526     case Dali::Window::LANDSCAPE_INVERSE:
527       actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
528       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
529       actor.SetOrientation( Degree(90), Vector3::ZAXIS );
530       break;
531   }
532 }
533
534 void Window::Raise()
535 {
536   ecore_wl_window_raise( mEventHandler->mEcoreWindow );
537 }
538
539 void Window::Lower()
540 {
541   ecore_wl_window_lower( mEventHandler->mEcoreWindow );
542 }
543
544 void Window::Activate()
545 {
546   ecore_wl_window_activate( mEventHandler->mEcoreWindow );
547 }
548
549 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
550 {
551   return mDragAndDropDetector;
552 }
553
554 Dali::Any Window::GetNativeHandle() const
555 {
556   if(mEventHandler)
557   {
558     return mEventHandler->mEcoreWindow;
559   }
560   else
561   {
562     return Dali::Any();
563   }
564 }
565
566 void Window::OnStart()
567 {
568   DoShowIndicator( mIndicatorOrientation );
569 }
570
571 void Window::OnPause()
572 {
573 }
574
575 void Window::OnResume()
576 {
577   // resume indicator status
578   if( mIndicator != NULL )
579   {
580     // Restore own indicator opacity
581     // Send opacity mode to indicator service when app resumed
582     mIndicator->SetOpacityMode( mIndicatorOpacityMode );
583   }
584 }
585
586 void Window::OnStop()
587 {
588   if( mIndicator )
589   {
590     mIndicator->Close();
591   }
592
593   delete mIndicator;
594   mIndicator = NULL;
595 }
596
597 void Window::OnDestroy()
598 {
599   mAdaptor = NULL;
600 }
601
602 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
603 {
604   bool found = false;
605
606   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
607   {
608     if(mAvailableOrientations[i] == orientation)
609     {
610       found = true;
611       break;
612     }
613   }
614
615   if( ! found )
616   {
617     mAvailableOrientations.push_back(orientation);
618     SetAvailableOrientations( mAvailableOrientations );
619   }
620 }
621
622 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
623 {
624   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
625        iter != mAvailableOrientations.end(); ++iter )
626   {
627     if( *iter == orientation )
628     {
629       mAvailableOrientations.erase( iter );
630       break;
631     }
632   }
633   SetAvailableOrientations( mAvailableOrientations );
634 }
635
636 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
637 {
638   int rotations[4];
639   for( std::size_t i = 0; i < mAvailableOrientations.size(); ++i )
640   {
641     rotations[i] = static_cast< int >( mAvailableOrientations[i] );
642   }
643   ecore_wl_window_rotation_available_rotations_set( mEventHandler->mEcoreWindow, rotations, mAvailableOrientations.size() );
644 }
645
646 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
647 {
648   return mAvailableOrientations;
649 }
650
651 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
652 {
653   mPreferredOrientation = orientation;
654
655   ecore_wl_window_rotation_preferred_rotation_set( mEventHandler->mEcoreWindow, orientation );
656 }
657
658 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
659 {
660   return mPreferredOrientation;
661 }
662
663 void Window::SetAcceptFocus( bool accept )
664 {
665   mIsFocusAcceptable = accept;
666
667   ecore_wl_window_focus_skip_set( mEventHandler->mEcoreWindow, !accept );
668 }
669
670 bool Window::IsFocusAcceptable()
671 {
672   return mIsFocusAcceptable;
673 }
674
675 void Window::Show()
676 {
677   mVisible = true;
678   ecore_wl_window_show( mEventHandler->mEcoreWindow );
679
680   // Need an update request
681   if( mAdaptor )
682   {
683     mAdaptor->RequestUpdateOnce();
684   }
685 }
686
687 void Window::Hide()
688 {
689   mVisible = false;
690   ecore_wl_window_hide( mEventHandler->mEcoreWindow );
691 }
692
693 bool Window::IsVisible() const
694 {
695   return mVisible;
696 }
697
698 void Window::RotationDone( int orientation, int width, int height )
699 {
700   ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
701 }
702
703 unsigned int Window::GetSupportedAuxiliaryHintCount()
704 {
705   return mSupportedAuxiliaryHints.size();
706 }
707
708 std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
709 {
710   if( index >= GetSupportedAuxiliaryHintCount() )
711   {
712     DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
713   }
714
715   return mSupportedAuxiliaryHints[index];
716 }
717
718 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
719 {
720   bool supported = false;
721
722   // Check if the hint is suppported
723   for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
724   {
725     if( *iter == hint )
726     {
727       supported = true;
728       break;
729     }
730   }
731
732   if( !supported )
733   {
734     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
735     return 0;
736   }
737
738   // Check if the hint is already added
739   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
740   {
741     if( mAuxiliaryHints[i].first == hint )
742     {
743       // Just change the value
744       mAuxiliaryHints[i].second = value;
745
746       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
747
748       return i + 1;   // id is index + 1
749     }
750   }
751
752   // Add the hint
753   mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
754
755   unsigned int id = mAuxiliaryHints.size();
756
757   ecore_wl_window_aux_hint_add( mEventHandler->mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
758
759   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
760
761   return id;
762 }
763
764 bool Window::RemoveAuxiliaryHint( unsigned int id )
765 {
766   if( id == 0 || id > mAuxiliaryHints.size() )
767   {
768     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
769     return false;
770   }
771
772   mAuxiliaryHints[id - 1].second = std::string();
773
774   ecore_wl_window_aux_hint_del( mEventHandler->mEcoreWindow, static_cast< int >( id ) );
775
776   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
777
778   return true;
779 }
780
781 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
782 {
783   if( id == 0 || id > mAuxiliaryHints.size() )
784   {
785     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
786     return false;
787   }
788
789   mAuxiliaryHints[id - 1].second = value;
790
791   ecore_wl_window_aux_hint_change( mEventHandler->mEcoreWindow, static_cast< int >( id ), value.c_str() );
792
793   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() );
794
795   return true;
796 }
797
798 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
799 {
800   if( id == 0 || id > mAuxiliaryHints.size() )
801   {
802     DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
803     return std::string();
804   }
805
806   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() );
807
808   return mAuxiliaryHints[id - 1].second;
809 }
810
811 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
812 {
813   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
814   {
815     if( mAuxiliaryHints[i].first == hint )
816     {
817       DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
818       return i + 1;
819     }
820   }
821
822   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
823
824   return 0;
825 }
826
827 void Window::SetInputRegion( const Rect< int >& inputRegion )
828 {
829   ecore_wl_window_input_region_set( mEventHandler->mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
830
831   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 );
832 }
833
834 } // Adaptor
835 } // Internal
836 } // Dali