[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
1 /*
2  * Copyright (c) 2019 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/common/window-system.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/input/common/key-impl.h>
30
31 // EXTERNAL_HEADERS
32 #include <dali/public-api/object/any.h>
33 #include <dali/public-api/events/mouse-button.h>
34 #include <dali/public-api/adaptor-framework/window-enumerations.h>
35 #include <dali/integration-api/debug.h>
36 #include <Ecore_Input.h>
37 #include <vconf.h>
38 #include <vconf-keys.h>
39 #include <wayland-egl-tizen.h>
40
41 namespace Dali
42 {
43
44 namespace Internal
45 {
46
47 namespace Adaptor
48 {
49
50 namespace
51 {
52
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
55 #endif
56
57 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
58 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
59
60 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name";  // It will be update at vconf-key.h and replaced.
61
62 // DBUS accessibility
63 const char* BUS = "org.enlightenment.wm-screen-reader";
64 const char* INTERFACE = "org.tizen.GestureNavigation";
65 const char* PATH = "/org/tizen/GestureNavigation";
66
67 struct KeyCodeMap
68 {
69   xkb_keysym_t keySym;
70   xkb_keycode_t keyCode;
71   bool isKeyCode;
72 };
73
74 /**
75  * Get the device name from the provided ecore key event
76  */
77 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
78 {
79   const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
80
81   if( ecoreDeviceName )
82   {
83     result = ecoreDeviceName;
84   }
85 }
86
87 /**
88  * Get the device class from the provided ecore event
89  */
90 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
91 {
92   switch( ecoreDeviceClass )
93   {
94     case ECORE_DEVICE_CLASS_SEAT:
95     {
96       deviceClass = Device::Class::USER;
97       break;
98     }
99     case ECORE_DEVICE_CLASS_KEYBOARD:
100     {
101       deviceClass = Device::Class::KEYBOARD;
102       break;
103     }
104     case ECORE_DEVICE_CLASS_MOUSE:
105     {
106       deviceClass = Device::Class::MOUSE;
107       break;
108     }
109     case ECORE_DEVICE_CLASS_TOUCH:
110     {
111       deviceClass = Device::Class::TOUCH;
112       break;
113     }
114     case ECORE_DEVICE_CLASS_PEN:
115     {
116       deviceClass = Device::Class::PEN;
117       break;
118     }
119     case ECORE_DEVICE_CLASS_POINTER:
120     {
121       deviceClass = Device::Class::POINTER;
122       break;
123     }
124     case ECORE_DEVICE_CLASS_GAMEPAD:
125     {
126       deviceClass = Device::Class::GAMEPAD;
127       break;
128     }
129     default:
130     {
131       deviceClass = Device::Class::NONE;
132       break;
133     }
134   }
135 }
136
137 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
138 {
139   switch( ecoreDeviceSubclass )
140   {
141     case ECORE_DEVICE_SUBCLASS_FINGER:
142     {
143       deviceSubclass = Device::Subclass::FINGER;
144       break;
145     }
146     case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
147     {
148       deviceSubclass = Device::Subclass::FINGERNAIL;
149       break;
150     }
151     case ECORE_DEVICE_SUBCLASS_KNUCKLE:
152     {
153       deviceSubclass = Device::Subclass::KNUCKLE;
154       break;
155     }
156     case ECORE_DEVICE_SUBCLASS_PALM:
157     {
158       deviceSubclass = Device::Subclass::PALM;
159       break;
160     }
161     case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
162     {
163       deviceSubclass = Device::Subclass::HAND_SIDE;
164       break;
165     }
166     case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
167     {
168       deviceSubclass = Device::Subclass::HAND_FLAT;
169       break;
170     }
171     case ECORE_DEVICE_SUBCLASS_PEN_TIP:
172     {
173       deviceSubclass = Device::Subclass::PEN_TIP;
174       break;
175     }
176     case ECORE_DEVICE_SUBCLASS_TRACKPAD:
177     {
178       deviceSubclass = Device::Subclass::TRACKPAD;
179       break;
180     }
181     case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
182     {
183       deviceSubclass = Device::Subclass::TRACKPOINT;
184       break;
185     }
186     case ECORE_DEVICE_SUBCLASS_TRACKBALL:
187     {
188       deviceSubclass = Device::Subclass::TRACKBALL;
189       break;
190     }
191     case ECORE_DEVICE_SUBCLASS_REMOCON:
192     {
193       deviceSubclass = Device::Subclass::REMOCON;
194       break;
195     }
196     case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
197     {
198       deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
199       break;
200     }
201     default:
202     {
203       deviceSubclass = Device::Subclass::NONE;
204       break;
205     }
206   }
207 }
208
209
210 void FindKeyCode( struct xkb_keymap* keyMap, xkb_keycode_t key, void* data )
211 {
212   KeyCodeMap* foundKeyCode = static_cast< KeyCodeMap* >( data );
213   if( foundKeyCode->isKeyCode )
214   {
215     return;
216   }
217
218   xkb_keysym_t keySym = foundKeyCode->keySym;
219   int nsyms = 0;
220   const xkb_keysym_t* symsOut = NULL;
221
222   nsyms = xkb_keymap_key_get_syms_by_level( keyMap, key, 0, 0, &symsOut );
223
224   if( nsyms && symsOut )
225   {
226     if( *symsOut == keySym )
227     {
228       foundKeyCode->keyCode = key;
229       foundKeyCode->isKeyCode = true;
230     }
231   }
232 }
233
234 /////////////////////////////////////////////////////////////////////////////////////////////////
235 // Window Callbacks
236 /////////////////////////////////////////////////////////////////////////////////////////////////
237
238 /// Called when the window iconify state is changed.
239 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
240 {
241   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
242   if( windowBase )
243   {
244     return windowBase->OnIconifyStateChanged( data, type, event );
245   }
246
247   return ECORE_CALLBACK_PASS_ON;
248 }
249
250 /// Called when the window gains focus
251 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
252 {
253   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
254   if( windowBase )
255   {
256     return windowBase->OnFocusIn( data, type, event );
257   }
258
259   return ECORE_CALLBACK_PASS_ON;
260 }
261
262 /// Called when the window loses focus
263 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
264 {
265   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
266   if( windowBase )
267   {
268     return windowBase->OnFocusOut( data, type, event );
269   }
270
271   return ECORE_CALLBACK_PASS_ON;
272 }
273
274 /// Called when the output is transformed
275 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
276 {
277   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
278   if( windowBase )
279   {
280     return windowBase->OnOutputTransform( data, type, event );
281   }
282
283   return ECORE_CALLBACK_PASS_ON;
284 }
285
286 /// Called when the output transform should be ignored
287 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
288 {
289   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
290   if( windowBase )
291   {
292     return windowBase->OnIgnoreOutputTransform( data, type, event );
293   }
294
295   return ECORE_CALLBACK_PASS_ON;
296 }
297
298 /**
299  * Called when rotate event is recevied.
300  */
301 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
302 {
303   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
304   if( windowBase )
305   {
306     DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::EcoreEventRotate\n" );
307     windowBase->OnRotation( data, type, event );
308   }
309   return ECORE_CALLBACK_PASS_ON;
310 }
311
312 /**
313  * Called when configure event is recevied.
314  */
315 static Eina_Bool EcoreEventConfigure( void* data, int type, void* event )
316 {
317   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
318   if( windowBase )
319   {
320     windowBase->OnConfiguration( data, type, event );
321   }
322   return ECORE_CALLBACK_PASS_ON;
323 }
324
325 /////////////////////////////////////////////////////////////////////////////////////////////////
326 // Touch Callbacks
327 /////////////////////////////////////////////////////////////////////////////////////////////////
328
329 /**
330  * Called when a touch down is received.
331  */
332 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
333 {
334   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
335   if( windowBase )
336   {
337     windowBase->OnMouseButtonDown( data, type, event );
338   }
339   return ECORE_CALLBACK_PASS_ON;
340 }
341
342 /**
343  * Called when a touch up is received.
344  */
345 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
346 {
347   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
348   if( windowBase )
349   {
350     windowBase->OnMouseButtonUp( data, type, event );
351   }
352   return ECORE_CALLBACK_PASS_ON;
353 }
354
355 /**
356  * Called when a touch motion is received.
357  */
358 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
359 {
360   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
361   if( windowBase )
362   {
363     windowBase->OnMouseButtonMove( data, type, event );
364   }
365   return ECORE_CALLBACK_PASS_ON;
366 }
367
368 /**
369  * Called when a touch is canceled.
370  */
371 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
372 {
373   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
374   if( windowBase )
375   {
376     windowBase->OnMouseButtonCancel( data, type, event );
377   }
378   return ECORE_CALLBACK_PASS_ON;
379 }
380
381 /**
382  * Called when a mouse wheel is received.
383  */
384 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
385 {
386   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
387   if( windowBase )
388   {
389     windowBase->OnMouseWheel( data, type, event );
390   }
391   return ECORE_CALLBACK_PASS_ON;
392 }
393
394 /**
395  * Called when a detent rotation event is recevied.
396  */
397 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
398 {
399   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
400   if( windowBase )
401   {
402     windowBase->OnDetentRotation( data, type, event );
403   }
404   return ECORE_CALLBACK_PASS_ON;
405 }
406
407 /////////////////////////////////////////////////////////////////////////////////////////////////
408 // Key Callbacks
409 /////////////////////////////////////////////////////////////////////////////////////////////////
410
411 /**
412  * Called when a key down is received.
413  */
414 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
415 {
416   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
417   if( windowBase )
418   {
419     windowBase->OnKeyDown( data, type, event );
420   }
421   return ECORE_CALLBACK_PASS_ON;
422 }
423
424 /**
425  * Called when a key up is received.
426  */
427 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
428 {
429   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
430   if( windowBase )
431   {
432     windowBase->OnKeyUp( data, type, event );
433   }
434   return ECORE_CALLBACK_PASS_ON;
435 }
436
437 /////////////////////////////////////////////////////////////////////////////////////////////////
438 // Selection Callbacks
439 /////////////////////////////////////////////////////////////////////////////////////////////////
440
441 /**
442  * Called when the source window notifies us the content in clipboard is selected.
443  */
444 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
445 {
446   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
447   if( windowBase )
448   {
449     windowBase->OnDataSend( data, type, event );
450   }
451   return ECORE_CALLBACK_PASS_ON;
452 }
453
454 /**
455 * Called when the source window sends us about the selected content.
456 * For example, when item is selected in the clipboard.
457 */
458 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
459 {
460   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
461   if( windowBase )
462   {
463     windowBase->OnDataReceive( data, type, event );
464   }
465   return ECORE_CALLBACK_PASS_ON;
466 }
467
468 /////////////////////////////////////////////////////////////////////////////////////////////////
469 // Effect Start/End Callbacks
470 /////////////////////////////////////////////////////////////////////////////////////////////////
471
472 /**
473  * Called when transition animation of the window's shown/hidden is started by window manager.
474  */
475 static Eina_Bool EcoreEventEffectStart(void *data, int type, void *event)
476 {
477   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
478   Ecore_Wl2_Event_Effect_Start *effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
479   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type );
480   if( windowBase )
481   {
482     if( effectStart->type < 3 ) // only under restack
483     {
484       windowBase->OnTransitionEffectEvent( WindowEffectState::START, static_cast<WindowEffectType>( effectStart->type ) );
485     }
486   }
487   return ECORE_CALLBACK_PASS_ON;
488 }
489
490 /**
491  * Called when transition animation of the window's shown/hidden is ended by window manager.
492  */
493 static Eina_Bool EcoreEventEffectEnd(void *data, int type, void *event)
494 {
495   Ecore_Wl2_Event_Effect_Start *effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
496   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
497   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type );
498   if( windowBase )
499   {
500     if( effectEnd->type < 3 ) // only under restack
501     {
502       windowBase->OnTransitionEffectEvent( WindowEffectState::END, static_cast<WindowEffectType>( effectEnd->type ) );
503     }
504   }
505   return ECORE_CALLBACK_PASS_ON;
506 }
507
508 /////////////////////////////////////////////////////////////////////////////////////////////////
509 // Keyboard Repeat Settings Changed Callbacks
510 /////////////////////////////////////////////////////////////////////////////////////////////////
511
512 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void *data, int type, void *event)
513 {
514    Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed *keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>( event );
515    WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
516    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id );
517    if( windowBase )
518    {
519      windowBase->OnKeyboardRepeatSettingsChanged();
520    }
521
522   return ECORE_CALLBACK_RENEW;
523 }
524
525 /////////////////////////////////////////////////////////////////////////////////////////////////
526 // Keymap Changed Callbacks
527 /////////////////////////////////////////////////////////////////////////////////////////////////
528
529 static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
530 {
531   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
532   if( windowBase )
533   {
534     windowBase->KeymapChanged( data, type, event );
535   }
536
537   return ECORE_CALLBACK_RENEW;
538 }
539
540 /////////////////////////////////////////////////////////////////////////////////////////////////
541 // Font Callbacks
542 /////////////////////////////////////////////////////////////////////////////////////////////////
543
544 /**
545  * Called when a font name is changed.
546  */
547 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
548 {
549   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
550   if( windowBase )
551   {
552     windowBase->OnFontNameChanged();
553   }
554 }
555
556 /**
557  * Called when a font size is changed.
558  */
559 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
560 {
561   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
562   if( windowBase )
563   {
564     windowBase->OnFontSizeChanged();
565   }
566 }
567
568 /////////////////////////////////////////////////////////////////////////////////////////////////
569 // Window Redraw Request Event Callbacks
570 /////////////////////////////////////////////////////////////////////////////////////////////////
571
572 static Eina_Bool EcoreEventWindowRedrawRequest(void *data, int type, void *event)
573 {
574   Ecore_Wl2_Event_Window_Redraw_Request *windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request *>(event);
575   WindowBaseEcoreWl2 *windowBase = static_cast<WindowBaseEcoreWl2 *>(data);
576   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win );
577   if ( windowBase )
578   {
579     windowBase->OnEcoreEventWindowRedrawRequest();
580   }
581
582   return ECORE_CALLBACK_RENEW;
583 }
584
585 /////////////////////////////////////////////////////////////////////////////////////////////////
586 // ElDBus Accessibility Callbacks
587 /////////////////////////////////////////////////////////////////////////////////////////////////
588
589 #ifdef DALI_ELDBUS_AVAILABLE
590 // Callback for Ecore ElDBus accessibility events.
591 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
592 {
593   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
594   if( windowBase )
595   {
596     windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
597   }
598 }
599 #endif // DALI_ELDBUS_AVAILABLE
600
601 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
602 {
603   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
604   if( windowBase )
605   {
606     windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
607   }
608 }
609
610 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
611 {
612   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
613   if( windowBase )
614   {
615     windowBase->RegistryGlobalCallbackRemove( data, registry, id );
616   }
617 }
618
619 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
620 {
621 }
622
623 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 )
624 {
625 }
626
627 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
628 {
629   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
630   if( windowBase )
631   {
632     windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
633   }
634 }
635
636 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
637 {
638 }
639
640 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
641 {
642   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
643   if( windowBase )
644   {
645     windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
646   }
647 }
648
649 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
650 {
651 }
652
653 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
654 {
655 }
656
657 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
658 {
659 }
660
661 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
662 {
663 }
664
665 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 )
666 {
667 }
668
669 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
670 {
671   WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
672   if( windowBase )
673   {
674     windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
675   }
676 }
677
678 const struct wl_registry_listener registryListener =
679 {
680    RegistryGlobalCallback,
681    RegistryGlobalCallbackRemove
682 };
683
684 const struct tizen_policy_listener tizenPolicyListener =
685 {
686    TizenPolicyConformant,
687    TizenPolicyConformantArea,
688    TizenPolicyNotificationChangeDone,
689    TizenPolicyTransientForDone,
690    TizenPolicyScreenModeChangeDone,
691    TizenPolicyIconifyStateChanged,
692    TizenPolicySupportedAuxiliaryHints,
693    TizenPolicyAllowedAuxiliaryHint,
694    TizenPolicyAuxiliaryMessage,
695    TizenPolicyConformantRegion
696 };
697
698 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
699 {
700   DisplayPolicyBrightnessChangeDone
701 };
702
703 } // unnamed namespace
704
705 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent )
706 : mEcoreEventHandler(),
707   mEcoreWindow( NULL ),
708   mWlSurface( NULL ),
709   mEglWindow( NULL ),
710   mDisplay( NULL ),
711   mEventQueue( NULL ),
712   mTizenPolicy( NULL ),
713   mTizenDisplayPolicy( NULL ),
714   mKeyMap( NULL ),
715   mSupportedAuxiliaryHints(),
716   mAuxiliaryHints(),
717   mNotificationLevel( -1 ),
718   mNotificationChangeState( 0 ),
719   mNotificationLevelChangeDone( true ),
720   mScreenOffMode( 0 ),
721   mScreenOffModeChangeState( 0 ),
722   mScreenOffModeChangeDone( true ),
723   mBrightness( 0 ),
724   mBrightnessChangeState( 0 ),
725   mBrightnessChangeDone( true ),
726   mVisible( true ),
727   mWindowPositionSize( positionSize ),
728   mOwnSurface( false ),
729   mMoveResizeSerial( 0 ),
730   mLastSubmittedMoveResizeSerial( 0 ),
731   mWindowRotationAngle( 0 ),
732   mScreenRotationAngle( 0 ),
733   mSupportedPreProtation( 0 )
734 #ifdef DALI_ELDBUS_AVAILABLE
735   , mSystemConnection( NULL )
736 #endif
737 {
738   Initialize( positionSize, surface, isTransparent );
739 }
740
741 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
742 {
743 #ifdef DALI_ELDBUS_AVAILABLE
744     // Close down ElDBus connections.
745     if( mSystemConnection )
746     {
747       eldbus_connection_unref( mSystemConnection );
748     }
749 #endif // DALI_ELDBUS_AVAILABLE
750
751   vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
752   vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
753
754   for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
755   {
756     ecore_event_handler_del( *iter );
757   }
758   mEcoreEventHandler.Clear();
759
760   if( mEventQueue )
761   {
762     wl_event_queue_destroy( mEventQueue );
763   }
764
765   mSupportedAuxiliaryHints.clear();
766   mAuxiliaryHints.clear();
767
768   if( mEglWindow != NULL )
769   {
770     wl_egl_window_destroy( mEglWindow );
771     mEglWindow = NULL;
772   }
773
774   if( mOwnSurface )
775   {
776     ecore_wl2_window_free( mEcoreWindow );
777
778     WindowSystem::Shutdown();
779   }
780 }
781
782 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
783 {
784   if( surface.Empty() == false )
785   {
786     // check we have a valid type
787     DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
788
789     mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
790   }
791   else
792   {
793     // we own the surface about to created
794     WindowSystem::Initialize();
795
796     mOwnSurface = true;
797     CreateWindow( positionSize );
798   }
799
800   mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
801
802   SetTransparency( isTransparent );
803
804   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE,  EcoreEventWindowIconifyStateChanged, this ) );
805   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN,                     EcoreEventWindowFocusIn,             this ) );
806   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT,                    EcoreEventWindowFocusOut,            this ) );
807   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM,             EcoreEventOutputTransform,           this ) );
808   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM,      EcoreEventIgnoreOutputTransform,     this ) );
809
810   // Register Rotate event
811   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE,                EcoreEventRotate,                    this ) );
812
813   // Register Configure event
814   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE,             EcoreEventConfigure,                 this ) );
815
816   // Register Touch events
817   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN,                EcoreEventMouseButtonDown,           this ) );
818   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP,                  EcoreEventMouseButtonUp,             this ) );
819   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE,                       EcoreEventMouseButtonMove,           this ) );
820   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL,              EcoreEventMouseButtonCancel,         this ) );
821
822   // Register Mouse wheel events
823   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL,                      EcoreEventMouseWheel,                this ) );
824
825   // Register Detent event
826   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE,                    EcoreEventDetentRotation,            this ) );
827
828   // Register Key events
829   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN,                         EcoreEventKeyDown,                   this ) );
830   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP,                           EcoreEventKeyUp,                     this ) );
831
832   // Register Selection event - clipboard selection
833   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND,             EcoreEventDataSend,                  this ) );
834   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY,         EcoreEventDataReceive,               this ) );
835
836   // Register Effect Start/End event
837   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START,                 EcoreEventEffectStart,               this ) );
838   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END,                   EcoreEventEffectEnd,                 this ) );
839
840   // Register Keyboard repeat event
841   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
842
843   // Register Window redraw request event
844   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST,        EcoreEventWindowRedrawRequest,       this ) );
845
846   // Register Vconf notify - font name and size
847   vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
848   vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
849
850   InitializeEcoreElDBus();
851
852   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
853   mDisplay = ecore_wl2_display_get( display );
854
855   if( mDisplay )
856   {
857     wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
858     if( displayWrapper )
859     {
860       mEventQueue = wl_display_create_queue( mDisplay );
861       if( mEventQueue )
862       {
863         wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
864
865         wl_registry* registry = wl_display_get_registry( displayWrapper );
866         wl_registry_add_listener( registry, &registryListener, this );
867       }
868
869       wl_proxy_wrapper_destroy( displayWrapper );
870     }
871   }
872
873   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
874
875   if( ecoreWlInput )
876   {
877     mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
878
879     mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
880   }
881
882   // get auxiliary hint
883   Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
884   if( hints )
885   {
886     Eina_List* l = NULL;
887     char* hint = NULL;
888
889     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) ) ) )
890     {
891       mSupportedAuxiliaryHints.push_back( hint );
892
893       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
894     }
895   }
896 }
897
898 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
899 {
900   Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
901   Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
902
903   if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
904   {
905     if( iconifyChangedEvent->iconified == EINA_TRUE )
906     {
907       mIconifyChangedSignal.Emit( true );
908     }
909     else
910     {
911       mIconifyChangedSignal.Emit( false );
912     }
913     handled = ECORE_CALLBACK_DONE;
914   }
915
916   return handled;
917 }
918
919 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
920 {
921   Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
922
923   if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
924   {
925     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
926
927     mFocusChangedSignal.Emit( true );
928   }
929
930   return ECORE_CALLBACK_PASS_ON;
931 }
932
933 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
934 {
935   Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
936
937   if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
938   {
939     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
940
941     mFocusChangedSignal.Emit( false );
942   }
943
944   return ECORE_CALLBACK_PASS_ON;
945 }
946
947 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
948 {
949   Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
950
951   if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
952   {
953     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
954
955     mOutputTransformedSignal.Emit();
956   }
957
958   return ECORE_CALLBACK_PASS_ON;
959 }
960
961 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
962 {
963   Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
964
965   if( ignoreTransformEvent->win == mEcoreWindow )
966   {
967     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
968
969     mOutputTransformedSignal.Emit();
970   }
971
972   return ECORE_CALLBACK_PASS_ON;
973 }
974
975 void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
976 {
977   Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
978
979   if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
980   {
981     DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
982
983     RotationEvent rotationEvent;
984     rotationEvent.angle = ev->angle;
985     rotationEvent.winResize = 0;
986
987     if( ev->angle == 0 || ev->angle == 180 )
988     {
989       rotationEvent.width = ev->w;
990       rotationEvent.height = ev->h;
991     }
992     else
993     {
994       rotationEvent.width = ev->h;
995       rotationEvent.height = ev->w;
996     }
997
998     mWindowPositionSize.width = rotationEvent.width;
999     mWindowPositionSize.height = rotationEvent.height;
1000
1001     mRotationSignal.Emit( rotationEvent );
1002   }
1003 }
1004
1005 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
1006 {
1007   Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
1008
1009   if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1010   {
1011     // Note: To comply with the wayland protocol, Dali should make an ack_configure
1012     // by calling ecore_wl2_window_commit
1013     ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1014   }
1015 }
1016
1017 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
1018 {
1019   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1020
1021   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1022   {
1023     Device::Class::Type deviceClass;
1024     Device::Subclass::Type deviceSubclass;
1025
1026     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1027     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1028
1029     PointState::Type state ( PointState::DOWN );
1030
1031     if( deviceClass != Device::Class::Type::MOUSE )
1032     {
1033       // Check if the buttons field is set and ensure it's the primary touch button.
1034       // If this event was triggered by buttons other than the primary button (used for touch), then
1035       // just send an interrupted event to Core.
1036       if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1037       {
1038         state = PointState::INTERRUPTED;
1039       }
1040     }
1041
1042     Integration::Point point;
1043     point.SetDeviceId( touchEvent->multi.device );
1044     point.SetState( state );
1045     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1046     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1047     point.SetPressure( touchEvent->multi.pressure );
1048     point.SetAngle( Degree( touchEvent->multi.angle ) );
1049     point.SetDeviceClass( deviceClass );
1050     point.SetDeviceSubclass( deviceSubclass );
1051     point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1052
1053     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1054   }
1055 }
1056
1057 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1058 {
1059   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1060
1061   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1062   {
1063     Device::Class::Type deviceClass;
1064     Device::Subclass::Type deviceSubclass;
1065
1066     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1067     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1068
1069     Integration::Point point;
1070     point.SetDeviceId( touchEvent->multi.device );
1071     point.SetState( PointState::UP );
1072     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1073     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1074     point.SetPressure( touchEvent->multi.pressure );
1075     point.SetAngle( Degree( touchEvent->multi.angle ) );
1076     point.SetDeviceClass( deviceClass );
1077     point.SetDeviceSubclass( deviceSubclass );
1078     point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1079
1080     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1081   }
1082 }
1083
1084 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1085 {
1086   Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1087
1088   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1089   {
1090     Device::Class::Type deviceClass;
1091     Device::Subclass::Type deviceSubclass;
1092
1093     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1094     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1095
1096     Integration::Point point;
1097     point.SetDeviceId( touchEvent->multi.device );
1098     point.SetState( PointState::MOTION );
1099     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1100     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1101     point.SetPressure( touchEvent->multi.pressure );
1102     point.SetAngle( Degree( touchEvent->multi.angle ) );
1103     point.SetDeviceClass( deviceClass );
1104     point.SetDeviceSubclass( deviceSubclass );
1105
1106     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1107   }
1108 }
1109
1110 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1111 {
1112   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1113
1114   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1115   {
1116     Integration::Point point;
1117     point.SetDeviceId( touchEvent->multi.device );
1118     point.SetState( PointState::INTERRUPTED );
1119     point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1120
1121     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1122
1123     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
1124   }
1125 }
1126
1127 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1128 {
1129   Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1130
1131   if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1132   {
1133     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
1134
1135     Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1136
1137     mWheelEventSignal.Emit( wheelEvent );
1138   }
1139 }
1140
1141 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1142 {
1143   Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1144
1145   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
1146
1147   int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1148   int timeStamp = detentEvent->timestamp;
1149
1150   Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1151
1152   mWheelEventSignal.Emit( wheelEvent );
1153 }
1154
1155 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1156 {
1157   Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1158
1159   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1160   {
1161     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
1162
1163     std::string keyName( keyEvent->keyname );
1164     std::string logicalKey( "" );
1165     std::string keyString( "" );
1166     std::string compose( "" );
1167
1168     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1169     if( keyEvent->compose )
1170     {
1171       compose = keyEvent->compose;
1172     }
1173
1174     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1175     if( keyEvent->key )
1176     {
1177       logicalKey = keyEvent->key;
1178     }
1179
1180     int keyCode = 0;
1181     GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1182
1183     if( keyCode == 0 )
1184     {
1185       // Get a specific key code from dali key look up table.
1186       keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1187     }
1188
1189     keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1190     int modifier( keyEvent->modifiers );
1191     unsigned long time = keyEvent->timestamp;
1192     if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1193     {
1194       keyCode = atoi( keyEvent->keyname + 8 );
1195     }
1196
1197     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1198     if( keyEvent->string )
1199     {
1200       keyString = keyEvent->string;
1201     }
1202
1203     std::string deviceName;
1204     Device::Class::Type deviceClass;
1205     Device::Subclass::Type deviceSubclass;
1206
1207     GetDeviceName( keyEvent, deviceName );
1208     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1209     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1210
1211     Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
1212
1213      mKeyEventSignal.Emit( keyEvent );
1214   }
1215 }
1216
1217 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1218 {
1219   Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1220
1221   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1222   {
1223     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
1224
1225 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1226     // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1227     if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
1228     {
1229       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n" );
1230       return;
1231     }
1232 #endif // Since ecore 1.23 version
1233
1234     std::string keyName( keyEvent->keyname );
1235     std::string logicalKey( "" );
1236     std::string keyString( "" );
1237     std::string compose( "" );
1238
1239     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1240     if( keyEvent->compose )
1241     {
1242       compose = keyEvent->compose;
1243     }
1244
1245     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1246     if( keyEvent->key )
1247     {
1248       logicalKey = keyEvent->key;
1249     }
1250
1251     int keyCode = 0;
1252     GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1253
1254     if( keyCode == 0 )
1255     {
1256       // Get a specific key code from dali key look up table.
1257       keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1258     }
1259
1260     keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1261     int modifier( keyEvent->modifiers );
1262     unsigned long time = keyEvent->timestamp;
1263     if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1264     {
1265       keyCode = atoi( keyEvent->keyname + 8 );
1266     }
1267
1268     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1269     if( keyEvent->string )
1270     {
1271       keyString = keyEvent->string;
1272     }
1273
1274     std::string deviceName;
1275     Device::Class::Type deviceClass;
1276     Device::Subclass::Type deviceSubclass;
1277
1278     GetDeviceName( keyEvent, deviceName );
1279     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1280     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1281
1282     Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
1283
1284      mKeyEventSignal.Emit( keyEvent );
1285   }
1286 }
1287
1288 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1289 {
1290   mSelectionDataSendSignal.Emit( event );
1291 }
1292
1293 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1294 {
1295   mSelectionDataReceivedSignal.Emit( event  );
1296 }
1297
1298 void WindowBaseEcoreWl2::OnFontNameChanged()
1299 {
1300   mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1301 }
1302
1303 void WindowBaseEcoreWl2::OnFontSizeChanged()
1304 {
1305   mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1306 }
1307
1308 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1309 {
1310 #ifdef DALI_ELDBUS_AVAILABLE
1311   AccessibilityInfo info;
1312
1313   // The string defines the arg-list's respective types.
1314   if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1315   {
1316     DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1317   }
1318
1319   mAccessibilitySignal.Emit( info );
1320 #endif
1321 }
1322
1323 void WindowBaseEcoreWl2::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
1324 {
1325   mTransitionEffectEventSignal.Emit( state, type );
1326 }
1327
1328 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1329 {
1330   mKeyboardRepeatSettingsChangedSignal.Emit();
1331 }
1332
1333 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1334 {
1335   mWindowRedrawRequestSignal.Emit();
1336 }
1337
1338 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1339 {
1340   Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1341   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1342   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1343   if( ecoreWlInput )
1344   {
1345     mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1346   }
1347 }
1348
1349 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1350 {
1351   if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1352   {
1353     uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1354
1355     mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1356     if( !mTizenPolicy )
1357     {
1358       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1359       return;
1360     }
1361
1362     tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1363
1364     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1365   }
1366   else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1367   {
1368     mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1369     if( !mTizenDisplayPolicy )
1370     {
1371       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1372       return;
1373     }
1374
1375     tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1376
1377     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1378   }
1379 }
1380
1381 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1382 {
1383   mTizenPolicy = NULL;
1384   mTizenDisplayPolicy = NULL;
1385 }
1386
1387 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1388 {
1389   mNotificationLevel = level;
1390   mNotificationChangeState = state;
1391   mNotificationLevelChangeDone = true;
1392
1393   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1394 }
1395
1396 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1397 {
1398   mScreenOffMode = mode;
1399   mScreenOffModeChangeState = state;
1400   mScreenOffModeChangeDone = true;
1401
1402   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1403 }
1404
1405 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1406 {
1407   mBrightness = brightness;
1408   mBrightnessChangeState = state;
1409   mBrightnessChangeDone = true;
1410
1411   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1412 }
1413
1414 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1415 {
1416   xkb_keysym_t sym = XKB_KEY_NoSymbol;
1417   KeyCodeMap foundKeyCode;
1418
1419   sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1420   if( sym == XKB_KEY_NoSymbol )
1421   {
1422     DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1423     return;
1424   }
1425
1426   foundKeyCode.keySym = sym;
1427   foundKeyCode.isKeyCode = false;
1428   xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1429   keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1430 }
1431
1432 Any WindowBaseEcoreWl2::GetNativeWindow()
1433 {
1434   return mEcoreWindow;
1435 }
1436
1437 int WindowBaseEcoreWl2::GetNativeWindowId()
1438 {
1439   return ecore_wl2_window_id_get( mEcoreWindow );
1440 }
1441
1442 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height )
1443 {
1444   int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1445   if( totalAngle == 90 || totalAngle == 270 )
1446   {
1447     mEglWindow = wl_egl_window_create( mWlSurface, height, width );
1448   }
1449   else
1450   {
1451     mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1452   }
1453
1454   return static_cast< EGLNativeWindowType >( mEglWindow );
1455 }
1456
1457 void WindowBaseEcoreWl2::DestroyEglWindow()
1458 {
1459   if( mEglWindow != NULL )
1460   {
1461     wl_egl_window_destroy( mEglWindow );
1462     mEglWindow = NULL;
1463   }
1464 }
1465
1466 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1467 {
1468   wl_egl_window_tizen_rotation rotation;
1469
1470   switch( angle )
1471   {
1472     case 0:
1473     {
1474       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1475       break;
1476     }
1477     case 90:
1478     {
1479       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1480       break;
1481     }
1482     case 180:
1483     {
1484       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1485       break;
1486     }
1487     case 270:
1488     {
1489       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1490       break;
1491     }
1492     default:
1493     {
1494       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1495       break;
1496     }
1497   }
1498
1499   wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1500 }
1501
1502 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1503 {
1504   wl_output_transform bufferTransform;
1505
1506   switch( angle )
1507   {
1508     case 0:
1509     {
1510       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1511       break;
1512     }
1513     case 90:
1514     {
1515       bufferTransform = WL_OUTPUT_TRANSFORM_90;
1516       break;
1517     }
1518     case 180:
1519     {
1520       bufferTransform = WL_OUTPUT_TRANSFORM_180;
1521       break;
1522     }
1523     case 270:
1524     {
1525       bufferTransform = WL_OUTPUT_TRANSFORM_270;
1526       break;
1527     }
1528     default:
1529     {
1530       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1531       break;
1532     }
1533   }
1534
1535   wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1536 }
1537
1538 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1539 {
1540   wl_output_transform windowTransform;
1541
1542   switch( angle )
1543   {
1544     case 0:
1545     {
1546       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1547       break;
1548     }
1549     case 90:
1550     {
1551       windowTransform = WL_OUTPUT_TRANSFORM_90;
1552       break;
1553     }
1554     case 180:
1555     {
1556       windowTransform = WL_OUTPUT_TRANSFORM_180;
1557       break;
1558     }
1559     case 270:
1560     {
1561       windowTransform = WL_OUTPUT_TRANSFORM_270;
1562       break;
1563     }
1564     default:
1565     {
1566       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1567       break;
1568     }
1569   }
1570
1571   wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1572 }
1573
1574 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1575 {
1576   wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1577
1578   // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1579   if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1580   {
1581     wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1582     mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1583   }
1584 }
1585
1586 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1587 {
1588   // Check capability
1589   wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
1590   if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
1591   {
1592     mSupportedPreProtation = true;
1593     return true;
1594   }
1595   mSupportedPreProtation = false;
1596   return false;
1597 }
1598
1599 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1600 {
1601   mWindowPositionSize = positionSize;
1602   ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1603 }
1604
1605 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1606 {
1607   mWindowPositionSize = positionSize;
1608   ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1609 }
1610
1611 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1612 {
1613   mWindowPositionSize = positionSize;
1614   ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1615 }
1616
1617 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1618 {
1619   ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1620   ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1621 }
1622
1623 void WindowBaseEcoreWl2::Raise()
1624 {
1625   // Use ecore_wl2_window_activate to prevent the window shown without rendering
1626   ecore_wl2_window_activate( mEcoreWindow );
1627 }
1628
1629 void WindowBaseEcoreWl2::Lower()
1630 {
1631   ecore_wl2_window_lower( mEcoreWindow );
1632 }
1633
1634 void WindowBaseEcoreWl2::Activate()
1635 {
1636   ecore_wl2_window_activate( mEcoreWindow );
1637 }
1638
1639 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
1640 {
1641   int rotations[4] = { 0 };
1642   DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
1643   for( std::size_t i = 0; i < angles.size(); ++i )
1644   {
1645     rotations[i] = static_cast< int >( angles[i] );
1646     DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1647   }
1648   ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1649 }
1650
1651 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1652 {
1653   DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle );
1654   ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1655 }
1656
1657 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1658 {
1659   ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1660 }
1661
1662 void WindowBaseEcoreWl2::Show()
1663 {
1664   if( !mVisible )
1665   {
1666     ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1667   }
1668   mVisible = true;
1669
1670   ecore_wl2_window_show( mEcoreWindow );
1671 }
1672
1673 void WindowBaseEcoreWl2::Hide()
1674 {
1675   mVisible = false;
1676   ecore_wl2_window_hide( mEcoreWindow );
1677 }
1678
1679 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1680 {
1681   return mSupportedAuxiliaryHints.size();
1682 }
1683
1684 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1685 {
1686   if( index >= GetSupportedAuxiliaryHintCount() )
1687   {
1688     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1689   }
1690
1691   return mSupportedAuxiliaryHints[index];
1692 }
1693
1694 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1695 {
1696   bool supported = false;
1697
1698   // Check if the hint is suppported
1699   for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1700   {
1701     if( *iter == hint )
1702     {
1703       supported = true;
1704       break;
1705     }
1706   }
1707
1708   if( !supported )
1709   {
1710     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1711     return 0;
1712   }
1713
1714   // Check if the hint is already added
1715   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1716   {
1717     if( mAuxiliaryHints[i].first == hint )
1718     {
1719       // Just change the value
1720       mAuxiliaryHints[i].second = value;
1721
1722       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1723
1724       return i + 1;   // id is index + 1
1725     }
1726   }
1727
1728   // Add the hint
1729   mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1730
1731   unsigned int id = mAuxiliaryHints.size();
1732
1733   ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1734
1735   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1736
1737   return id;
1738 }
1739
1740 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1741 {
1742   if( id == 0 || id > mAuxiliaryHints.size() )
1743   {
1744     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1745     return false;
1746   }
1747
1748   mAuxiliaryHints[id - 1].second = std::string();
1749
1750   ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1751
1752   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1753
1754   return true;
1755 }
1756
1757 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1758 {
1759   if( id == 0 || id > mAuxiliaryHints.size() )
1760   {
1761     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1762     return false;
1763   }
1764
1765   mAuxiliaryHints[id - 1].second = value;
1766
1767   ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1768
1769   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() );
1770
1771   return true;
1772 }
1773
1774 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1775 {
1776   if( id == 0 || id > mAuxiliaryHints.size() )
1777   {
1778     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1779     return std::string();
1780   }
1781
1782   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() );
1783
1784   return mAuxiliaryHints[id - 1].second;
1785 }
1786
1787 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1788 {
1789   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1790   {
1791     if( mAuxiliaryHints[i].first == hint )
1792     {
1793       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1794       return i + 1;
1795     }
1796   }
1797
1798   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1799
1800   return 0;
1801 }
1802
1803 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1804 {
1805   ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1806 }
1807
1808 void WindowBaseEcoreWl2::SetType( Dali::WindowType type )
1809 {
1810   Ecore_Wl2_Window_Type windowType;
1811
1812   switch( type )
1813   {
1814     case Dali::WindowType::NORMAL:
1815     {
1816       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1817       break;
1818     }
1819     case Dali::WindowType::NOTIFICATION:
1820     {
1821       windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1822       break;
1823     }
1824     case Dali::WindowType::UTILITY:
1825     {
1826       windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1827       break;
1828     }
1829     case Dali::WindowType::DIALOG:
1830     {
1831       windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1832       break;
1833     }
1834     default:
1835     {
1836       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1837       break;
1838     }
1839   }
1840
1841   ecore_wl2_window_type_set( mEcoreWindow, windowType );
1842 }
1843
1844 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::WindowNotificationLevel level )
1845 {
1846   while( !mTizenPolicy )
1847   {
1848     wl_display_dispatch_queue( mDisplay, mEventQueue );
1849   }
1850
1851   int notificationLevel;
1852
1853   switch( level )
1854   {
1855     case Dali::WindowNotificationLevel::NONE:
1856     {
1857       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1858       break;
1859     }
1860     case Dali::WindowNotificationLevel::BASE:
1861     {
1862       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1863       break;
1864     }
1865     case Dali::WindowNotificationLevel::MEDIUM:
1866     {
1867       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1868       break;
1869     }
1870     case Dali::WindowNotificationLevel::HIGH:
1871     {
1872       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1873       break;
1874     }
1875     case Dali::WindowNotificationLevel::TOP:
1876     {
1877       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1878       break;
1879     }
1880     default:
1881     {
1882       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1883       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1884       break;
1885     }
1886   }
1887
1888   mNotificationLevelChangeDone = false;
1889   mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1890
1891   tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1892
1893   int count = 0;
1894
1895   while( !mNotificationLevelChangeDone && count < 3 )
1896   {
1897     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1898     wl_display_dispatch_queue( mDisplay, mEventQueue );
1899     count++;
1900   }
1901
1902   if( !mNotificationLevelChangeDone )
1903   {
1904     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1905     return false;
1906   }
1907   else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1908   {
1909     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1910     return false;
1911   }
1912
1913   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1914
1915   return true;
1916 }
1917
1918 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
1919 {
1920   while( !mTizenPolicy )
1921   {
1922     wl_display_dispatch_queue( mDisplay, mEventQueue );
1923   }
1924
1925   int count = 0;
1926
1927   while( !mNotificationLevelChangeDone && count < 3 )
1928   {
1929     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1930     wl_display_dispatch_queue( mDisplay, mEventQueue );
1931     count++;
1932   }
1933
1934   if( !mNotificationLevelChangeDone )
1935   {
1936     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1937     return Dali::WindowNotificationLevel::NONE;
1938   }
1939
1940   Dali::WindowNotificationLevel level;
1941
1942   switch( mNotificationLevel )
1943   {
1944     case TIZEN_POLICY_LEVEL_NONE:
1945     {
1946       level = Dali::WindowNotificationLevel::NONE;
1947       break;
1948     }
1949     case TIZEN_POLICY_LEVEL_DEFAULT:
1950     {
1951       level = Dali::WindowNotificationLevel::BASE;
1952       break;
1953     }
1954     case TIZEN_POLICY_LEVEL_MEDIUM:
1955     {
1956       level = Dali::WindowNotificationLevel::MEDIUM;
1957       break;
1958     }
1959     case TIZEN_POLICY_LEVEL_HIGH:
1960     {
1961       level = Dali::WindowNotificationLevel::HIGH;
1962       break;
1963     }
1964     case TIZEN_POLICY_LEVEL_TOP:
1965     {
1966       level = Dali::WindowNotificationLevel::TOP;
1967       break;
1968     }
1969     default:
1970     {
1971       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1972       level = Dali::WindowNotificationLevel::NONE;
1973       break;
1974     }
1975   }
1976
1977   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1978
1979   return level;
1980 }
1981
1982 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
1983 {
1984   while( !mTizenPolicy )
1985   {
1986     wl_display_dispatch_queue( mDisplay, mEventQueue );
1987   }
1988
1989   tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1990 }
1991
1992 bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1993 {
1994   while( !mTizenPolicy )
1995   {
1996     wl_display_dispatch_queue( mDisplay, mEventQueue );
1997   }
1998
1999   mScreenOffModeChangeDone = false;
2000   mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2001
2002   unsigned int mode = 0;
2003
2004   switch( screenOffMode )
2005   {
2006     case WindowScreenOffMode::TIMEOUT:
2007     {
2008       mode = 0;
2009       break;
2010     }
2011     case WindowScreenOffMode::NEVER:
2012     {
2013       mode = 1;
2014       break;
2015     }
2016   }
2017
2018   tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
2019
2020   int count = 0;
2021
2022   while( !mScreenOffModeChangeDone && count < 3 )
2023   {
2024     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2025     wl_display_dispatch_queue( mDisplay, mEventQueue );
2026     count++;
2027   }
2028
2029   if( !mScreenOffModeChangeDone )
2030   {
2031     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
2032     return false;
2033   }
2034   else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2035   {
2036     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
2037     return false;
2038   }
2039
2040   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
2041
2042   return true;
2043 }
2044
2045 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2046 {
2047   while( !mTizenPolicy )
2048   {
2049     wl_display_dispatch_queue( mDisplay, mEventQueue );
2050   }
2051
2052   int count = 0;
2053
2054   while( !mScreenOffModeChangeDone && count < 3 )
2055   {
2056     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2057     wl_display_dispatch_queue( mDisplay, mEventQueue );
2058     count++;
2059   }
2060
2061   if( !mScreenOffModeChangeDone )
2062   {
2063     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2064     return WindowScreenOffMode::TIMEOUT;
2065   }
2066
2067   WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2068
2069   switch( mScreenOffMode )
2070   {
2071     case 0:
2072     {
2073       screenMode = WindowScreenOffMode::TIMEOUT;
2074       break;
2075     }
2076     case 1:
2077     {
2078       screenMode = WindowScreenOffMode::NEVER;
2079       break;
2080     }
2081   }
2082
2083   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2084
2085   return screenMode;
2086 }
2087
2088 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2089 {
2090   while( !mTizenDisplayPolicy )
2091   {
2092     wl_display_dispatch_queue( mDisplay, mEventQueue );
2093   }
2094
2095   mBrightnessChangeDone = false;
2096   mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2097
2098   tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2099
2100   int count = 0;
2101
2102   while( !mBrightnessChangeDone && count < 3 )
2103   {
2104     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2105     wl_display_dispatch_queue( mDisplay, mEventQueue );
2106     count++;
2107   }
2108
2109   if( !mBrightnessChangeDone )
2110   {
2111     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2112     return false;
2113   }
2114   else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2115   {
2116     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2117     return false;
2118   }
2119
2120   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2121
2122   return true;
2123 }
2124
2125 int WindowBaseEcoreWl2::GetBrightness() const
2126 {
2127   while( !mTizenDisplayPolicy )
2128   {
2129     wl_display_dispatch_queue( mDisplay, mEventQueue );
2130   }
2131
2132   int count = 0;
2133
2134   while( !mBrightnessChangeDone && count < 3 )
2135   {
2136     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2137     wl_display_dispatch_queue( mDisplay, mEventQueue );
2138     count++;
2139   }
2140
2141   if( !mBrightnessChangeDone )
2142   {
2143     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2144     return 0;
2145   }
2146
2147   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2148
2149   return mBrightness;
2150 }
2151
2152 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2153 {
2154   Ecore_Wl2_Window_Keygrab_Mode mode;
2155
2156   switch( grabMode )
2157   {
2158     case KeyGrab::TOPMOST:
2159     {
2160       mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2161       break;
2162     }
2163     case KeyGrab::SHARED:
2164     {
2165       mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2166       break;
2167     }
2168     case KeyGrab::OVERRIDE_EXCLUSIVE:
2169     {
2170       mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2171       break;
2172     }
2173     case KeyGrab::EXCLUSIVE:
2174     {
2175       mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2176       break;
2177     }
2178     default:
2179     {
2180       return false;
2181     }
2182   }
2183
2184   return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2185 }
2186
2187 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2188 {
2189   return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2190 }
2191
2192 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2193 {
2194   int keyCount = key.Count();
2195   int keyGrabModeCount = grabMode.Count();
2196
2197   if( keyCount != keyGrabModeCount || keyCount == 0 )
2198   {
2199     return false;
2200   }
2201
2202   eina_init();
2203
2204   Eina_List* keyList = NULL;
2205   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2206
2207   for( int index = 0; index < keyCount; ++index )
2208   {
2209     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2210
2211     switch( grabMode[index] )
2212     {
2213       case KeyGrab::TOPMOST:
2214       {
2215         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2216         break;
2217       }
2218       case KeyGrab::SHARED:
2219       {
2220         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2221         break;
2222       }
2223       case KeyGrab::OVERRIDE_EXCLUSIVE:
2224       {
2225         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2226         break;
2227       }
2228       case KeyGrab::EXCLUSIVE:
2229       {
2230         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2231         break;
2232       }
2233       default:
2234       {
2235         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2236         break;
2237       }
2238     }
2239
2240     keyList = eina_list_append( keyList, &info );
2241   }
2242
2243   Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2244
2245   result.Resize( keyCount, true );
2246
2247   Eina_List* l = NULL;
2248   Eina_List* m = NULL;
2249   void* listData = NULL;
2250   void* data = NULL;
2251   if( grabList != NULL )
2252   {
2253     EINA_LIST_FOREACH( grabList, m, data )
2254     {
2255       int index = 0;
2256       EINA_LIST_FOREACH( keyList, l, listData )
2257       {
2258         if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2259         {
2260           DALI_LOG_ERROR( "input key list has null data!" );
2261           break;
2262         }
2263
2264         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2265         {
2266           result[index] = false;
2267         }
2268         ++index;
2269       }
2270     }
2271   }
2272
2273   delete [] info;
2274
2275   eina_list_free( keyList );
2276   eina_list_free( grabList );
2277   eina_shutdown();
2278
2279   return true;
2280 }
2281
2282 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2283 {
2284   int keyCount = key.Count();
2285   if( keyCount == 0 )
2286   {
2287     return false;
2288   }
2289
2290   eina_init();
2291
2292   Eina_List* keyList = NULL;
2293   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2294
2295   for( int index = 0; index < keyCount; ++index )
2296   {
2297     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2298     keyList = eina_list_append( keyList, &info );
2299   }
2300
2301   Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2302
2303   result.Resize( keyCount, true );
2304
2305   Eina_List* l = NULL;
2306   Eina_List* m = NULL;
2307   void *listData = NULL;
2308   void *data = NULL;
2309
2310   if( ungrabList != NULL )
2311   {
2312     EINA_LIST_FOREACH( ungrabList, m, data )
2313     {
2314       int index = 0;
2315       EINA_LIST_FOREACH( keyList, l, listData )
2316       {
2317         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2318         {
2319           result[index] = false;
2320         }
2321         ++index;
2322       }
2323     }
2324   }
2325
2326   delete [] info;
2327
2328   eina_list_free( keyList );
2329   eina_list_free( ungrabList );
2330   eina_shutdown();
2331
2332   return true;
2333 }
2334
2335 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2336 {
2337   // calculate DPI
2338   float xres, yres;
2339
2340   Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2341
2342   // 1 inch = 25.4 millimeters
2343   xres = ecore_wl2_output_dpi_get( output );
2344   yres = ecore_wl2_output_dpi_get( output );
2345
2346   dpiHorizontal = int( xres + 0.5f );  // rounding
2347   dpiVertical   = int( yres + 0.5f );
2348 }
2349
2350 int WindowBaseEcoreWl2::GetOrientation() const
2351 {
2352   int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2353   if( mSupportedPreProtation )
2354   {
2355     orientation = 0;
2356   }
2357   return orientation;
2358 }
2359
2360 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2361 {
2362   int transform = 0;
2363
2364   if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) )
2365   {
2366     transform = 0;
2367   }
2368   else
2369   {
2370     transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
2371   }
2372   mScreenRotationAngle = transform * 90;
2373   return mScreenRotationAngle;
2374 }
2375
2376 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
2377 {
2378   mWindowRotationAngle = degree;
2379   ecore_wl2_window_rotation_set( mEcoreWindow, degree );
2380 }
2381
2382 int WindowBaseEcoreWl2::GetWindowRotationAngle()
2383 {
2384   return mWindowRotationAngle;
2385 }
2386
2387 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
2388 {
2389   ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );
2390 }
2391
2392 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2393 {
2394   ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2395 }
2396
2397 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2398 {
2399 #ifdef DALI_ELDBUS_AVAILABLE
2400   Eldbus_Object* object;
2401   Eldbus_Proxy* manager;
2402
2403   if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2404   {
2405     DALI_LOG_ERROR( "Unable to get system bus\n" );
2406   }
2407
2408   object = eldbus_object_get( mSystemConnection, BUS, PATH );
2409   if( !object )
2410   {
2411     DALI_LOG_ERROR( "Getting object failed\n" );
2412     return;
2413   }
2414
2415   manager = eldbus_proxy_get( object, INTERFACE );
2416   if( !manager )
2417   {
2418     DALI_LOG_ERROR( "Getting proxy failed\n" );
2419     return;
2420   }
2421
2422   if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2423   {
2424     DALI_LOG_ERROR( "No signal handler returned\n" );
2425   }
2426 #endif
2427 }
2428
2429 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2430 {
2431   Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2432   if( !display )
2433   {
2434     DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2435   }
2436
2437   ecore_wl2_display_sync( display );
2438
2439   mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2440
2441   if ( mEcoreWindow == 0 )
2442   {
2443     DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2444   }
2445
2446   // Set default type
2447   ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2448 }
2449
2450 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2451 {
2452   Ecore_Wl2_Window* ecoreParent = NULL;
2453   if( parentWinBase )
2454   {
2455     WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2456     ecoreParent = winBaseEcore2->mEcoreWindow;
2457   }
2458   ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2459 }
2460
2461 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2462 {
2463   return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
2464 }
2465
2466 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2467 {
2468   return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
2469 }
2470
2471 } // namespace Adaptor
2472
2473 } // namespace Internal
2474
2475 } // namespace Dali
2476
2477 #pragma GCC diagnostic pop