[Tizen] Support Ecore-Wayland2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
1 /*
2  * Copyright (c) 2018 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 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
21
22 // CLASS HEADER
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
24
25 // INTERNAL HEADERS
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.h>
28 #include <dali/internal/input/common/key-impl.h>
29
30 // EXTERNAL_HEADERS
31 #include <dali/public-api/object/any.h>
32 #include <dali/integration-api/debug.h>
33
34 namespace Dali
35 {
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 namespace
44 {
45
46 #if defined(DEBUG_ENABLED)
47 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
48 #endif
49
50 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
51
52 /// Called when the window iconify state is changed.
53 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
54 {
55   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
56   if( windowBase )
57   {
58     return windowBase->OnIconifyStateChanged( data, type, event );
59   }
60
61   return ECORE_CALLBACK_PASS_ON;
62 }
63
64 /// Called when the window gains focus
65 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
66 {
67   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
68   if( windowBase )
69   {
70     return windowBase->OnFocusIn( data, type, event );
71   }
72
73   return ECORE_CALLBACK_PASS_ON;
74 }
75
76 /// Called when the window loses focus
77 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
78 {
79   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
80   if( windowBase )
81   {
82     return windowBase->OnFocusOut( data, type, event );
83   }
84
85   return ECORE_CALLBACK_PASS_ON;
86 }
87
88 /// Called when the output is transformed
89 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
90 {
91   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
92   if( windowBase )
93   {
94     return windowBase->OnOutputTransform( data, type, event );
95   }
96
97   return ECORE_CALLBACK_PASS_ON;
98 }
99
100 /// Called when the output transform should be ignored
101 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
102 {
103   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
104   if( windowBase )
105   {
106     return windowBase->OnIgnoreOutputTransform( data, type, event );
107   }
108
109   return ECORE_CALLBACK_PASS_ON;
110 }
111
112 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
113 {
114   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
115   if( windowBase )
116   {
117     windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
118   }
119 }
120
121 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
122 {
123   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
124   if( windowBase )
125   {
126     windowBase->RegistryGlobalCallbackRemove( data, registry, id );
127   }
128 }
129
130 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
131 {
132 }
133
134 static void TizenPolicyConformantArea( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h )
135 {
136 }
137
138 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
139 {
140   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
141   if( windowBase )
142   {
143     windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
144   }
145 }
146
147 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
148 {
149 }
150
151 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
152 {
153   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
154   if( windowBase )
155   {
156     windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
157   }
158 }
159
160 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
161 {
162 }
163
164 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
165 {
166 }
167
168 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
169 {
170 }
171
172 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
173 {
174 }
175
176 static void TizenPolicyConformantRegion( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial )
177 {
178 }
179
180 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
181 {
182   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
183   if( windowBase )
184   {
185     windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
186   }
187 }
188
189 const struct wl_registry_listener registryListener =
190 {
191    RegistryGlobalCallback,
192    RegistryGlobalCallbackRemove
193 };
194
195 const struct tizen_policy_listener tizenPolicyListener =
196 {
197    TizenPolicyConformant,
198    TizenPolicyConformantArea,
199    TizenPolicyNotificationChangeDone,
200    TizenPolicyTransientForDone,
201    TizenPolicyScreenModeChangeDone,
202    TizenPolicyIconifyStateChanged,
203    TizenPolicySupportedAuxiliaryHints,
204    TizenPolicyAllowedAuxiliaryHint,
205    TizenPolicyAuxiliaryMessage,
206    TizenPolicyConformantRegion
207 };
208
209 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
210 {
211   DisplayPolicyBrightnessChangeDone
212 };
213
214 } // unnamed namespace
215
216 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Window* window, WindowRenderSurface* windowRenderSurface )
217 : mEcoreEventHandler(),
218   mWindow( window ),
219   mWindowSurface( NULL ),
220   mEcoreWindow( NULL ),
221   mDisplay( NULL ),
222   mEventQueue( NULL ),
223   mTizenPolicy( NULL ),
224   mTizenDisplayPolicy( NULL ),
225   mSupportedAuxiliaryHints(),
226   mAuxiliaryHints(),
227   mNotificationLevel( -1 ),
228   mNotificationChangeState( 0 ),
229   mNotificationLevelChangeDone( true ),
230   mScreenOffMode( 0 ),
231   mScreenOffModeChangeState( 0 ),
232   mScreenOffModeChangeDone( true ),
233   mBrightness( 0 ),
234   mBrightnessChangeState( 0 ),
235   mBrightnessChangeDone( true )
236 {
237   mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWl2* >( windowRenderSurface );
238 }
239
240 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
241 {
242   for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
243   {
244     ecore_event_handler_del( *iter );
245   }
246   mEcoreEventHandler.Clear();
247
248   if( mEventQueue )
249   {
250     wl_event_queue_destroy( mEventQueue );
251   }
252
253   mSupportedAuxiliaryHints.clear();
254   mAuxiliaryHints.clear();
255 }
256
257 void WindowBaseEcoreWl2::Initialize()
258 {
259   if( !mWindowSurface )
260   {
261     DALI_ASSERT_ALWAYS( "Invalid window surface" );
262   }
263
264   mEcoreWindow = mWindowSurface->GetWlWindow();
265   DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWl window" );
266
267   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
268   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
269   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
270   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
271   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
272
273   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
274   mDisplay = ecore_wl2_display_get( display );
275
276   if( mDisplay )
277   {
278     wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
279     if( displayWrapper )
280     {
281       mEventQueue = wl_display_create_queue( mDisplay );
282       if( mEventQueue )
283       {
284         wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
285
286         wl_registry* registry = wl_display_get_registry( displayWrapper );
287         wl_registry_add_listener( registry, &registryListener, this );
288       }
289
290       wl_proxy_wrapper_destroy( displayWrapper );
291     }
292   }
293
294   // get auxiliary hint
295   Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
296   if( hints )
297   {
298     Eina_List* l = NULL;
299     char* hint = NULL;
300
301     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) ) ) )
302     {
303       mSupportedAuxiliaryHints.push_back( hint );
304
305       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
306     }
307   }
308 }
309
310 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
311 {
312   Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
313   Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
314
315   if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
316   {
317     if( iconifyChangedEvent->iconified == EINA_TRUE )
318     {
319       mWindow->OnIconifyChanged( true );
320     }
321     else
322     {
323       mWindow->OnIconifyChanged( false );
324     }
325     handled = ECORE_CALLBACK_DONE;
326   }
327
328   return handled;
329 }
330
331 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
332 {
333   Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
334
335   if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
336   {
337     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
338
339     mWindow->OnFocusChanged( true );
340   }
341
342   return ECORE_CALLBACK_PASS_ON;
343 }
344
345 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
346 {
347   Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
348
349   if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
350   {
351     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
352
353     mWindow->OnFocusChanged( false );
354   }
355
356   return ECORE_CALLBACK_PASS_ON;
357 }
358
359 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
360 {
361   Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
362
363   if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
364   {
365     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
366
367     mWindowSurface->OutputTransformed();
368
369     mWindow->OnOutputTransformed();
370   }
371
372   return ECORE_CALLBACK_PASS_ON;
373 }
374
375 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
376 {
377   Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
378
379   if( ignoreTransformEvent->win == mEcoreWindow )
380   {
381     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
382
383     mWindowSurface->OutputTransformed();
384
385     mWindow->OnOutputTransformed();
386   }
387
388   return ECORE_CALLBACK_PASS_ON;
389 }
390
391 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
392 {
393   if( strcmp( interface, tizen_policy_interface.name ) == 0 )
394   {
395     uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
396
397     mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
398     if( !mTizenPolicy )
399     {
400       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
401       return;
402     }
403
404     tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
405
406     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
407   }
408   else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
409   {
410     mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
411     if( !mTizenDisplayPolicy )
412     {
413       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
414       return;
415     }
416
417     tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
418
419     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
420   }
421 }
422
423 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
424 {
425   mTizenPolicy = NULL;
426   mTizenDisplayPolicy = NULL;
427 }
428
429 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
430 {
431   mNotificationLevel = level;
432   mNotificationChangeState = state;
433   mNotificationLevelChangeDone = true;
434
435   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
436 }
437
438 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
439 {
440   mScreenOffMode = mode;
441   mScreenOffModeChangeState = state;
442   mScreenOffModeChangeDone = true;
443
444   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
445 }
446
447 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
448 {
449   mBrightness = brightness;
450   mBrightnessChangeState = state;
451   mBrightnessChangeDone = true;
452
453   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
454 }
455
456 void WindowBaseEcoreWl2::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
457 {
458   DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
459
460   if( visibleMode == Dali::Window::VISIBLE )
461   {
462     // when the indicator is visible, set proper mode for indicator server according to bg mode
463     if( opacityMode == Dali::Window::OPAQUE )
464     {
465       ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE );
466     }
467     else if( opacityMode == Dali::Window::TRANSLUCENT )
468     {
469       ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSLUCENT );
470     }
471     else if( opacityMode == Dali::Window::TRANSPARENT )
472     {
473       ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE );
474     }
475   }
476   else
477   {
478     // when the indicator is not visible, set TRANSPARENT mode for indicator server
479     ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSPARENT); // it means hidden indicator
480   }
481 }
482
483 void WindowBaseEcoreWl2::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
484 {
485   if( isShow )
486   {
487     ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_ON );
488   }
489   else
490   {
491     ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_OFF );
492   }
493 }
494
495 void WindowBaseEcoreWl2::IndicatorTypeChanged( IndicatorInterface::Type type )
496 {
497 #if defined(DALI_PROFILE_MOBILE)
498   switch( type )
499   {
500     case IndicatorInterface::INDICATOR_TYPE_1:
501     {
502       ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN );
503       break;
504     }
505     case IndicatorInterface::INDICATOR_TYPE_2:
506     {
507       ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN );
508       break;
509     }
510     case IndicatorInterface::INDICATOR_TYPE_UNKNOWN:
511     default:
512     {
513       break;
514     }
515   }
516 #endif //MOBILE
517 }
518
519 void WindowBaseEcoreWl2::SetClass( std::string name, std::string className )
520 {
521   ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
522   ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
523 }
524
525 void WindowBaseEcoreWl2::Raise()
526 {
527   // Use ecore_wl2_window_activate to prevent the window shown without rendering
528   ecore_wl2_window_activate( mEcoreWindow );
529 }
530
531 void WindowBaseEcoreWl2::Lower()
532 {
533   ecore_wl2_window_lower( mEcoreWindow );
534 }
535
536 void WindowBaseEcoreWl2::Activate()
537 {
538   ecore_wl2_window_activate( mEcoreWindow );
539 }
540
541 void WindowBaseEcoreWl2::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
542 {
543   int rotations[4] = { 0 };
544   for( std::size_t i = 0; i < orientations.size(); ++i )
545   {
546     rotations[i] = static_cast< int >( orientations[i] );
547   }
548   ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
549 }
550
551 void WindowBaseEcoreWl2::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
552 {
553   ecore_wl2_window_preferred_rotation_set( mEcoreWindow, orientation );
554 }
555
556 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
557 {
558   ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
559 }
560
561 void WindowBaseEcoreWl2::Show()
562 {
563   ecore_wl2_window_show( mEcoreWindow );
564 }
565
566 void WindowBaseEcoreWl2::Hide()
567 {
568   ecore_wl2_window_hide( mEcoreWindow );
569 }
570
571 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
572 {
573   return mSupportedAuxiliaryHints.size();
574 }
575
576 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
577 {
578   if( index >= GetSupportedAuxiliaryHintCount() )
579   {
580     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
581   }
582
583   return mSupportedAuxiliaryHints[index];
584 }
585
586 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
587 {
588   bool supported = false;
589
590   // Check if the hint is suppported
591   for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
592   {
593     if( *iter == hint )
594     {
595       supported = true;
596       break;
597     }
598   }
599
600   if( !supported )
601   {
602     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
603     return 0;
604   }
605
606   // Check if the hint is already added
607   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
608   {
609     if( mAuxiliaryHints[i].first == hint )
610     {
611       // Just change the value
612       mAuxiliaryHints[i].second = value;
613
614       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
615
616       return i + 1;   // id is index + 1
617     }
618   }
619
620   // Add the hint
621   mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
622
623   unsigned int id = mAuxiliaryHints.size();
624
625   ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
626
627   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
628
629   return id;
630 }
631
632 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
633 {
634   if( id == 0 || id > mAuxiliaryHints.size() )
635   {
636     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
637     return false;
638   }
639
640   mAuxiliaryHints[id - 1].second = std::string();
641
642   ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
643
644   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
645
646   return true;
647 }
648
649 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
650 {
651   if( id == 0 || id > mAuxiliaryHints.size() )
652   {
653     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
654     return false;
655   }
656
657   mAuxiliaryHints[id - 1].second = value;
658
659   ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
660
661   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
662
663   return true;
664 }
665
666 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
667 {
668   if( id == 0 || id > mAuxiliaryHints.size() )
669   {
670     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
671     return std::string();
672   }
673
674   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
675
676   return mAuxiliaryHints[id - 1].second;
677 }
678
679 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
680 {
681   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
682   {
683     if( mAuxiliaryHints[i].first == hint )
684     {
685       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
686       return i + 1;
687     }
688   }
689
690   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
691
692   return 0;
693 }
694
695 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
696 {
697   ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
698 }
699
700 void WindowBaseEcoreWl2::SetType( Dali::Window::Type type )
701 {
702   Ecore_Wl2_Window_Type windowType;
703
704   switch( type )
705   {
706     case Dali::Window::NORMAL:
707     {
708       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
709       break;
710     }
711     case Dali::Window::NOTIFICATION:
712     {
713       windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
714       break;
715     }
716     case Dali::Window::UTILITY:
717     {
718       windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
719       break;
720     }
721     case Dali::Window::DIALOG:
722     {
723       windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
724       break;
725     }
726     default:
727     {
728       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
729       break;
730     }
731   }
732
733   ecore_wl2_window_type_set( mEcoreWindow, windowType );
734 }
735
736 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
737 {
738   while( !mTizenPolicy )
739   {
740     wl_display_dispatch_queue( mDisplay, mEventQueue );
741   }
742
743   int notificationLevel;
744
745   switch( level )
746   {
747     case Dali::Window::NotificationLevel::NONE:
748     {
749       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
750       break;
751     }
752     case Dali::Window::NotificationLevel::BASE:
753     {
754       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
755       break;
756     }
757     case Dali::Window::NotificationLevel::MEDIUM:
758     {
759       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
760       break;
761     }
762     case Dali::Window::NotificationLevel::HIGH:
763     {
764       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
765       break;
766     }
767     case Dali::Window::NotificationLevel::TOP:
768     {
769       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
770       break;
771     }
772     default:
773     {
774       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
775       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
776       break;
777     }
778   }
779
780   mNotificationLevelChangeDone = false;
781   mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
782
783   tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
784
785   int count = 0;
786
787   while( !mNotificationLevelChangeDone && count < 3 )
788   {
789     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
790     wl_display_dispatch_queue( mDisplay, mEventQueue );
791     count++;
792   }
793
794   if( !mNotificationLevelChangeDone )
795   {
796     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
797     return false;
798   }
799   else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
800   {
801     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
802     return false;
803   }
804
805   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
806
807   return true;
808 }
809
810 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const
811 {
812   while( !mTizenPolicy )
813   {
814     wl_display_dispatch_queue( mDisplay, mEventQueue );
815   }
816
817   int count = 0;
818
819   while( !mNotificationLevelChangeDone && count < 3 )
820   {
821     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
822     wl_display_dispatch_queue( mDisplay, mEventQueue );
823     count++;
824   }
825
826   if( !mNotificationLevelChangeDone )
827   {
828     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
829     return Dali::Window::NotificationLevel::NONE;
830   }
831
832   Dali::Window::NotificationLevel::Type level;
833
834   switch( mNotificationLevel )
835   {
836     case TIZEN_POLICY_LEVEL_NONE:
837     {
838       level = Dali::Window::NotificationLevel::NONE;
839       break;
840     }
841     case TIZEN_POLICY_LEVEL_DEFAULT:
842     {
843       level = Dali::Window::NotificationLevel::BASE;
844       break;
845     }
846     case TIZEN_POLICY_LEVEL_MEDIUM:
847     {
848       level = Dali::Window::NotificationLevel::MEDIUM;
849       break;
850     }
851     case TIZEN_POLICY_LEVEL_HIGH:
852     {
853       level = Dali::Window::NotificationLevel::HIGH;
854       break;
855     }
856     case TIZEN_POLICY_LEVEL_TOP:
857     {
858       level = Dali::Window::NotificationLevel::TOP;
859       break;
860     }
861     default:
862     {
863       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
864       level = Dali::Window::NotificationLevel::NONE;
865       break;
866     }
867   }
868
869   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
870
871   return level;
872 }
873
874 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
875 {
876   while( !mTizenPolicy )
877   {
878     wl_display_dispatch_queue( mDisplay, mEventQueue );
879   }
880
881   tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
882 }
883
884 bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
885 {
886   while( !mTizenPolicy )
887   {
888     wl_display_dispatch_queue( mDisplay, mEventQueue );
889   }
890
891   mScreenOffModeChangeDone = false;
892   mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
893
894   unsigned int mode = 0;
895
896   switch( screenOffMode )
897   {
898     case Dali::Window::ScreenOffMode::TIMEOUT:
899     {
900       mode = 0;
901       break;
902     }
903     case Dali::Window::ScreenOffMode::NEVER:
904     {
905       mode = 1;
906       break;
907     }
908   }
909
910   tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
911
912   int count = 0;
913
914   while( !mScreenOffModeChangeDone && count < 3 )
915   {
916     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
917     wl_display_dispatch_queue( mDisplay, mEventQueue );
918     count++;
919   }
920
921   if( !mScreenOffModeChangeDone )
922   {
923     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
924     return false;
925   }
926   else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
927   {
928     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
929     return false;
930   }
931
932   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
933
934   return true;
935 }
936
937 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const
938 {
939   while( !mTizenPolicy )
940   {
941     wl_display_dispatch_queue( mDisplay, mEventQueue );
942   }
943
944   int count = 0;
945
946   while( !mScreenOffModeChangeDone && count < 3 )
947   {
948     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
949     wl_display_dispatch_queue( mDisplay, mEventQueue );
950     count++;
951   }
952
953   if( !mScreenOffModeChangeDone )
954   {
955     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
956     return Dali::Window::ScreenOffMode::TIMEOUT;
957   }
958
959   Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
960
961   switch( mScreenOffMode )
962   {
963     case 0:
964     {
965       screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
966       break;
967     }
968     case 1:
969     {
970       screenMode = Dali::Window::ScreenOffMode::NEVER;
971       break;
972     }
973   }
974
975   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
976
977   return screenMode;
978 }
979
980 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
981 {
982   while( !mTizenDisplayPolicy )
983   {
984     wl_display_dispatch_queue( mDisplay, mEventQueue );
985   }
986
987   mBrightnessChangeDone = false;
988   mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
989
990   tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
991
992   int count = 0;
993
994   while( !mBrightnessChangeDone && count < 3 )
995   {
996     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
997     wl_display_dispatch_queue( mDisplay, mEventQueue );
998     count++;
999   }
1000
1001   if( !mBrightnessChangeDone )
1002   {
1003     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1004     return false;
1005   }
1006   else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1007   {
1008     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
1009     return false;
1010   }
1011
1012   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1013
1014   return true;
1015 }
1016
1017 int WindowBaseEcoreWl2::GetBrightness() const
1018 {
1019   while( !mTizenDisplayPolicy )
1020   {
1021     wl_display_dispatch_queue( mDisplay, mEventQueue );
1022   }
1023
1024   int count = 0;
1025
1026   while( !mBrightnessChangeDone && count < 3 )
1027   {
1028     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1029     wl_display_dispatch_queue( mDisplay, mEventQueue );
1030     count++;
1031   }
1032
1033   if( !mBrightnessChangeDone )
1034   {
1035     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1036     return 0;
1037   }
1038
1039   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
1040
1041   return mBrightness;
1042 }
1043
1044 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1045 {
1046   Ecore_Wl2_Window_Keygrab_Mode mode;
1047
1048   switch( grabMode )
1049   {
1050     case KeyGrab::TOPMOST:
1051     {
1052       mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
1053       break;
1054     }
1055     case KeyGrab::SHARED:
1056     {
1057       mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
1058       break;
1059     }
1060     case KeyGrab::OVERRIDE_EXCLUSIVE:
1061     {
1062       mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1063       break;
1064     }
1065     case KeyGrab::EXCLUSIVE:
1066     {
1067       mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
1068       break;
1069     }
1070     default:
1071     {
1072       return false;
1073     }
1074   }
1075
1076   return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1077 }
1078
1079 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
1080 {
1081   return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1082 }
1083
1084 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1085 {
1086   int keyCount = key.Count();
1087   int keyGrabModeCount = grabMode.Count();
1088
1089   if( keyCount != keyGrabModeCount || keyCount == 0 )
1090   {
1091     return false;
1092   }
1093
1094   eina_init();
1095
1096   Eina_List* keyList = NULL;
1097   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
1098
1099   for( int index = 0; index < keyCount; ++index )
1100   {
1101     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1102
1103     switch( grabMode[index] )
1104     {
1105       case KeyGrab::TOPMOST:
1106       {
1107         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
1108         break;
1109       }
1110       case KeyGrab::SHARED:
1111       {
1112         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
1113         break;
1114       }
1115       case KeyGrab::OVERRIDE_EXCLUSIVE:
1116       {
1117         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1118         break;
1119       }
1120       case KeyGrab::EXCLUSIVE:
1121       {
1122         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
1123         break;
1124       }
1125       default:
1126       {
1127         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
1128         break;
1129       }
1130     }
1131
1132     keyList = eina_list_append( keyList, &info );
1133   }
1134
1135   Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
1136
1137   result.Resize( keyCount, true );
1138
1139   Eina_List* l = NULL;
1140   Eina_List* m = NULL;
1141   void* listData = NULL;
1142   void* data = NULL;
1143   if( grabList != NULL )
1144   {
1145     EINA_LIST_FOREACH( grabList, m, data )
1146     {
1147       int index = 0;
1148       EINA_LIST_FOREACH( keyList, l, listData )
1149       {
1150         if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
1151         {
1152           DALI_LOG_ERROR( "input key list has null data!" );
1153           break;
1154         }
1155
1156         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
1157         {
1158           result[index] = false;
1159         }
1160         ++index;
1161       }
1162     }
1163   }
1164
1165   delete [] info;
1166
1167   eina_list_free( keyList );
1168   eina_list_free( grabList );
1169   eina_shutdown();
1170
1171   return true;
1172 }
1173
1174 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
1175 {
1176   int keyCount = key.Count();
1177   if( keyCount == 0 )
1178   {
1179     return false;
1180   }
1181
1182   eina_init();
1183
1184   Eina_List* keyList = NULL;
1185   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
1186
1187   for( int index = 0; index < keyCount; ++index )
1188   {
1189     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1190     keyList = eina_list_append( keyList, &info );
1191   }
1192
1193   Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
1194
1195   result.Resize( keyCount, true );
1196
1197   Eina_List* l = NULL;
1198   Eina_List* m = NULL;
1199   void *listData = NULL;
1200   void *data = NULL;
1201
1202   if( ungrabList != NULL )
1203   {
1204     EINA_LIST_FOREACH( ungrabList, m, data )
1205     {
1206       int index = 0;
1207       EINA_LIST_FOREACH( keyList, l, listData )
1208       {
1209         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
1210         {
1211           result[index] = false;
1212         }
1213         ++index;
1214       }
1215     }
1216   }
1217
1218   delete [] info;
1219
1220   eina_list_free( keyList );
1221   eina_list_free( ungrabList );
1222   eina_shutdown();
1223
1224   return true;
1225 }
1226
1227 } // namespace Adaptor
1228
1229 } // namespace Internal
1230
1231 } // namespace Dali
1232
1233 #pragma GCC diagnostic pop