856a8deebbf13d044d38fb5ef52099d33d621821
[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(nullptr),
708   mWlSurface(nullptr),
709   mEglWindow(nullptr),
710   mDisplay(nullptr),
711   mEventQueue(nullptr),
712   mTizenPolicy(nullptr),
713   mTizenDisplayPolicy(nullptr),
714   mKeyMap(nullptr),
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   ,
736   mSystemConnection(NULL)
737 #endif
738 {
739   Initialize(positionSize, surface, isTransparent);
740 }
741
742 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
743 {
744 #ifdef DALI_ELDBUS_AVAILABLE
745     // Close down ElDBus connections.
746     if( mSystemConnection )
747     {
748       eldbus_connection_unref( mSystemConnection );
749     }
750 #endif // DALI_ELDBUS_AVAILABLE
751
752   vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
753   vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
754
755   for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
756   {
757     ecore_event_handler_del( *iter );
758   }
759   mEcoreEventHandler.Clear();
760
761   if( mEventQueue )
762   {
763     wl_event_queue_destroy( mEventQueue );
764   }
765
766   mSupportedAuxiliaryHints.clear();
767   mAuxiliaryHints.clear();
768
769   if( mEglWindow != NULL )
770   {
771     wl_egl_window_destroy( mEglWindow );
772     mEglWindow = NULL;
773   }
774
775   if( mOwnSurface )
776   {
777     ecore_wl2_window_free( mEcoreWindow );
778
779     WindowSystem::Shutdown();
780   }
781 }
782
783 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
784 {
785   if( surface.Empty() == false )
786   {
787     // check we have a valid type
788     DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
789
790     mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
791   }
792   else
793   {
794     // we own the surface about to created
795     WindowSystem::Initialize();
796
797     mOwnSurface = true;
798     CreateWindow( positionSize );
799   }
800
801   mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
802
803   SetTransparency( isTransparent );
804
805   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE,  EcoreEventWindowIconifyStateChanged, this ) );
806   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN,                     EcoreEventWindowFocusIn,             this ) );
807   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT,                    EcoreEventWindowFocusOut,            this ) );
808   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM,             EcoreEventOutputTransform,           this ) );
809   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM,      EcoreEventIgnoreOutputTransform,     this ) );
810
811   // Register Rotate event
812   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE,                EcoreEventRotate,                    this ) );
813
814   // Register Configure event
815   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE,             EcoreEventConfigure,                 this ) );
816
817   // Register Touch events
818   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN,                EcoreEventMouseButtonDown,           this ) );
819   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP,                  EcoreEventMouseButtonUp,             this ) );
820   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE,                       EcoreEventMouseButtonMove,           this ) );
821   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL,              EcoreEventMouseButtonCancel,         this ) );
822
823   // Register Mouse wheel events
824   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL,                      EcoreEventMouseWheel,                this ) );
825
826   // Register Detent event
827   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE,                    EcoreEventDetentRotation,            this ) );
828
829   // Register Key events
830   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN,                         EcoreEventKeyDown,                   this ) );
831   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP,                           EcoreEventKeyUp,                     this ) );
832
833   // Register Selection event - clipboard selection
834   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND,             EcoreEventDataSend,                  this ) );
835   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY,         EcoreEventDataReceive,               this ) );
836
837   // Register Effect Start/End event
838   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START,                 EcoreEventEffectStart,               this ) );
839   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END,                   EcoreEventEffectEnd,                 this ) );
840
841   // Register Keyboard repeat event
842   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
843
844   // Register Window redraw request event
845   mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST,        EcoreEventWindowRedrawRequest,       this ) );
846
847   // Register Vconf notify - font name and size
848   vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
849   vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
850
851   InitializeEcoreElDBus();
852
853   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
854   mDisplay = ecore_wl2_display_get( display );
855
856   if( mDisplay )
857   {
858     wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
859     if( displayWrapper )
860     {
861       mEventQueue = wl_display_create_queue( mDisplay );
862       if( mEventQueue )
863       {
864         wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
865
866         wl_registry* registry = wl_display_get_registry( displayWrapper );
867         wl_registry_add_listener( registry, &registryListener, this );
868       }
869
870       wl_proxy_wrapper_destroy( displayWrapper );
871     }
872   }
873
874   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
875
876   if( ecoreWlInput )
877   {
878     mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
879
880     mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
881   }
882
883   // get auxiliary hint
884   Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
885   if( hints )
886   {
887     Eina_List* l = NULL;
888     char* hint = NULL;
889
890     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) ) ) )
891     {
892       mSupportedAuxiliaryHints.push_back( hint );
893
894       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
895     }
896   }
897 }
898
899 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
900 {
901   Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
902   Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
903
904   if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
905   {
906     if( iconifyChangedEvent->iconified == EINA_TRUE )
907     {
908       mIconifyChangedSignal.Emit( true );
909     }
910     else
911     {
912       mIconifyChangedSignal.Emit( false );
913     }
914     handled = ECORE_CALLBACK_DONE;
915   }
916
917   return handled;
918 }
919
920 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
921 {
922   Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
923
924   if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
925   {
926     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
927
928     mFocusChangedSignal.Emit( true );
929   }
930
931   return ECORE_CALLBACK_PASS_ON;
932 }
933
934 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
935 {
936   Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
937
938   if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
939   {
940     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
941
942     mFocusChangedSignal.Emit( false );
943   }
944
945   return ECORE_CALLBACK_PASS_ON;
946 }
947
948 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
949 {
950   Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
951
952   if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
953   {
954     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
955
956     mScreenRotationAngle = GetScreenRotationAngle();
957
958     mOutputTransformedSignal.Emit();
959   }
960
961   return ECORE_CALLBACK_PASS_ON;
962 }
963
964 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
965 {
966   Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
967
968   if( ignoreTransformEvent->win == mEcoreWindow )
969   {
970     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
971
972     mScreenRotationAngle = GetScreenRotationAngle();
973
974     mOutputTransformedSignal.Emit();
975   }
976
977   return ECORE_CALLBACK_PASS_ON;
978 }
979
980 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
981 {
982   Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
983
984   if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
985   {
986     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
987
988     RotationEvent rotationEvent;
989     rotationEvent.angle     = ev->angle;
990     rotationEvent.winResize = 0;
991     mWindowRotationAngle    = ev->angle;
992
993     if(ev->angle == 0 || ev->angle == 180)
994     {
995       rotationEvent.width  = ev->w;
996       rotationEvent.height = ev->h;
997     }
998     else
999     {
1000       rotationEvent.width  = ev->h;
1001       rotationEvent.height = ev->w;
1002     }
1003
1004     mWindowPositionSize.width  = rotationEvent.width;
1005     mWindowPositionSize.height = rotationEvent.height;
1006
1007     mRotationSignal.Emit(rotationEvent);
1008   }
1009 }
1010
1011 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
1012 {
1013   Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
1014
1015   if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1016   {
1017     // Note: To comply with the wayland protocol, Dali should make an ack_configure
1018     // by calling ecore_wl2_window_commit
1019     ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1020   }
1021 }
1022
1023 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
1024 {
1025   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1026
1027   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1028   {
1029     Device::Class::Type deviceClass;
1030     Device::Subclass::Type deviceSubclass;
1031
1032     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1033     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1034
1035     PointState::Type state ( PointState::DOWN );
1036
1037     if( deviceClass != Device::Class::Type::MOUSE )
1038     {
1039       // Check if the buttons field is set and ensure it's the primary touch button.
1040       // If this event was triggered by buttons other than the primary button (used for touch), then
1041       // just send an interrupted event to Core.
1042       if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1043       {
1044         state = PointState::INTERRUPTED;
1045       }
1046     }
1047
1048     Integration::Point point;
1049     point.SetDeviceId( touchEvent->multi.device );
1050     point.SetState( state );
1051     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1052     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1053     point.SetPressure( touchEvent->multi.pressure );
1054     point.SetAngle( Degree( touchEvent->multi.angle ) );
1055     point.SetDeviceClass( deviceClass );
1056     point.SetDeviceSubclass( deviceSubclass );
1057     point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1058
1059     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1060   }
1061 }
1062
1063 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1064 {
1065   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1066
1067   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1068   {
1069     Device::Class::Type deviceClass;
1070     Device::Subclass::Type deviceSubclass;
1071
1072     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1073     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1074
1075     Integration::Point point;
1076     point.SetDeviceId( touchEvent->multi.device );
1077     point.SetState( PointState::UP );
1078     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1079     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1080     point.SetPressure( touchEvent->multi.pressure );
1081     point.SetAngle( Degree( touchEvent->multi.angle ) );
1082     point.SetDeviceClass( deviceClass );
1083     point.SetDeviceSubclass( deviceSubclass );
1084     point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1085
1086     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1087   }
1088 }
1089
1090 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1091 {
1092   Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1093
1094   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1095   {
1096     Device::Class::Type deviceClass;
1097     Device::Subclass::Type deviceSubclass;
1098
1099     GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1100     GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1101
1102     Integration::Point point;
1103     point.SetDeviceId( touchEvent->multi.device );
1104     point.SetState( PointState::MOTION );
1105     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1106     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1107     point.SetPressure( touchEvent->multi.pressure );
1108     point.SetAngle( Degree( touchEvent->multi.angle ) );
1109     point.SetDeviceClass( deviceClass );
1110     point.SetDeviceSubclass( deviceSubclass );
1111
1112     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1113   }
1114 }
1115
1116 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1117 {
1118   Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1119
1120   if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1121   {
1122     Integration::Point point;
1123     point.SetDeviceId( touchEvent->multi.device );
1124     point.SetState( PointState::INTERRUPTED );
1125     point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1126
1127     mTouchEventSignal.Emit( point, touchEvent->timestamp );
1128
1129     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
1130   }
1131 }
1132
1133 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1134 {
1135   Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1136
1137   if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1138   {
1139     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 );
1140
1141     Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1142
1143     mWheelEventSignal.Emit( wheelEvent );
1144   }
1145 }
1146
1147 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1148 {
1149   Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1150
1151   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
1152
1153   int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1154   int timeStamp = detentEvent->timestamp;
1155
1156   Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1157
1158   mWheelEventSignal.Emit( wheelEvent );
1159 }
1160
1161 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1162 {
1163   Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1164
1165   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1166   {
1167     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
1168
1169     std::string keyName( keyEvent->keyname );
1170     std::string logicalKey( "" );
1171     std::string keyString( "" );
1172     std::string compose( "" );
1173
1174     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1175     if( keyEvent->compose )
1176     {
1177       compose = keyEvent->compose;
1178     }
1179
1180     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1181     if( keyEvent->key )
1182     {
1183       logicalKey = keyEvent->key;
1184     }
1185
1186     int keyCode = 0;
1187     GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1188
1189     if( keyCode == 0 )
1190     {
1191       // Get a specific key code from dali key look up table.
1192       keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1193     }
1194
1195     keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1196     int modifier( keyEvent->modifiers );
1197     unsigned long time = keyEvent->timestamp;
1198     if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1199     {
1200       keyCode = atoi( keyEvent->keyname + 8 );
1201     }
1202
1203     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1204     if( keyEvent->string )
1205     {
1206       keyString = keyEvent->string;
1207     }
1208
1209     std::string deviceName;
1210     Device::Class::Type deviceClass;
1211     Device::Subclass::Type deviceSubclass;
1212
1213     GetDeviceName( keyEvent, deviceName );
1214     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1215     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1216
1217     Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
1218
1219      mKeyEventSignal.Emit( keyEvent );
1220   }
1221 }
1222
1223 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1224 {
1225   Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1226
1227   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1228   {
1229     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
1230
1231 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1232     // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1233     if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
1234     {
1235       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n" );
1236       return;
1237     }
1238 #endif // Since ecore 1.23 version
1239
1240     std::string keyName( keyEvent->keyname );
1241     std::string logicalKey( "" );
1242     std::string keyString( "" );
1243     std::string compose( "" );
1244
1245     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1246     if( keyEvent->compose )
1247     {
1248       compose = keyEvent->compose;
1249     }
1250
1251     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1252     if( keyEvent->key )
1253     {
1254       logicalKey = keyEvent->key;
1255     }
1256
1257     int keyCode = 0;
1258     GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1259
1260     if( keyCode == 0 )
1261     {
1262       // Get a specific key code from dali key look up table.
1263       keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1264     }
1265
1266     keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1267     int modifier( keyEvent->modifiers );
1268     unsigned long time = keyEvent->timestamp;
1269     if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1270     {
1271       keyCode = atoi( keyEvent->keyname + 8 );
1272     }
1273
1274     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1275     if( keyEvent->string )
1276     {
1277       keyString = keyEvent->string;
1278     }
1279
1280     std::string deviceName;
1281     Device::Class::Type deviceClass;
1282     Device::Subclass::Type deviceSubclass;
1283
1284     GetDeviceName( keyEvent, deviceName );
1285     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1286     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1287
1288     Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
1289
1290      mKeyEventSignal.Emit( keyEvent );
1291   }
1292 }
1293
1294 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1295 {
1296   mSelectionDataSendSignal.Emit( event );
1297 }
1298
1299 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1300 {
1301   mSelectionDataReceivedSignal.Emit( event  );
1302 }
1303
1304 void WindowBaseEcoreWl2::OnFontNameChanged()
1305 {
1306   mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1307 }
1308
1309 void WindowBaseEcoreWl2::OnFontSizeChanged()
1310 {
1311   mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1312 }
1313
1314 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1315 {
1316 #ifdef DALI_ELDBUS_AVAILABLE
1317   AccessibilityInfo info;
1318
1319   // The string defines the arg-list's respective types.
1320   if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1321   {
1322     DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1323   }
1324
1325   mAccessibilitySignal.Emit( info );
1326 #endif
1327 }
1328
1329 void WindowBaseEcoreWl2::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
1330 {
1331   mTransitionEffectEventSignal.Emit( state, type );
1332 }
1333
1334 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1335 {
1336   mKeyboardRepeatSettingsChangedSignal.Emit();
1337 }
1338
1339 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1340 {
1341   mWindowRedrawRequestSignal.Emit();
1342 }
1343
1344 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1345 {
1346   Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1347   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1348   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1349   if( ecoreWlInput )
1350   {
1351     mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1352   }
1353 }
1354
1355 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1356 {
1357   if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1358   {
1359     uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1360
1361     mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1362     if( !mTizenPolicy )
1363     {
1364       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1365       return;
1366     }
1367
1368     tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1369
1370     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1371   }
1372   else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1373   {
1374     mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1375     if( !mTizenDisplayPolicy )
1376     {
1377       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1378       return;
1379     }
1380
1381     tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1382
1383     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1384   }
1385 }
1386
1387 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1388 {
1389   mTizenPolicy = NULL;
1390   mTizenDisplayPolicy = NULL;
1391 }
1392
1393 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1394 {
1395   mNotificationLevel = level;
1396   mNotificationChangeState = state;
1397   mNotificationLevelChangeDone = true;
1398
1399   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1400 }
1401
1402 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1403 {
1404   mScreenOffMode = mode;
1405   mScreenOffModeChangeState = state;
1406   mScreenOffModeChangeDone = true;
1407
1408   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1409 }
1410
1411 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1412 {
1413   mBrightness = brightness;
1414   mBrightnessChangeState = state;
1415   mBrightnessChangeDone = true;
1416
1417   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1418 }
1419
1420 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1421 {
1422   xkb_keysym_t sym = XKB_KEY_NoSymbol;
1423   KeyCodeMap foundKeyCode;
1424
1425   sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1426   if( sym == XKB_KEY_NoSymbol )
1427   {
1428     DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1429     return;
1430   }
1431
1432   foundKeyCode.keySym = sym;
1433   foundKeyCode.isKeyCode = false;
1434   xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1435   keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1436 }
1437
1438 Any WindowBaseEcoreWl2::GetNativeWindow()
1439 {
1440   return mEcoreWindow;
1441 }
1442
1443 int WindowBaseEcoreWl2::GetNativeWindowId()
1444 {
1445   return ecore_wl2_window_id_get( mEcoreWindow );
1446 }
1447
1448 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1449 {
1450   int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1451   if(totalAngle == 90 || totalAngle == 270)
1452   {
1453     mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1454   }
1455   else
1456   {
1457     mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1458   }
1459
1460   return static_cast<EGLNativeWindowType>(mEglWindow);
1461 }
1462
1463 void WindowBaseEcoreWl2::DestroyEglWindow()
1464 {
1465   if( mEglWindow != NULL )
1466   {
1467     wl_egl_window_destroy( mEglWindow );
1468     mEglWindow = NULL;
1469   }
1470 }
1471
1472 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1473 {
1474   wl_egl_window_tizen_rotation rotation;
1475
1476   switch( angle )
1477   {
1478     case 0:
1479     {
1480       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1481       break;
1482     }
1483     case 90:
1484     {
1485       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1486       break;
1487     }
1488     case 180:
1489     {
1490       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1491       break;
1492     }
1493     case 270:
1494     {
1495       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1496       break;
1497     }
1498     default:
1499     {
1500       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1501       break;
1502     }
1503   }
1504
1505   wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1506 }
1507
1508 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1509 {
1510   wl_output_transform bufferTransform;
1511
1512   switch( angle )
1513   {
1514     case 0:
1515     {
1516       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1517       break;
1518     }
1519     case 90:
1520     {
1521       bufferTransform = WL_OUTPUT_TRANSFORM_90;
1522       break;
1523     }
1524     case 180:
1525     {
1526       bufferTransform = WL_OUTPUT_TRANSFORM_180;
1527       break;
1528     }
1529     case 270:
1530     {
1531       bufferTransform = WL_OUTPUT_TRANSFORM_270;
1532       break;
1533     }
1534     default:
1535     {
1536       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1537       break;
1538     }
1539   }
1540
1541   wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1542 }
1543
1544 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1545 {
1546   wl_output_transform windowTransform;
1547
1548   switch( angle )
1549   {
1550     case 0:
1551     {
1552       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1553       break;
1554     }
1555     case 90:
1556     {
1557       windowTransform = WL_OUTPUT_TRANSFORM_90;
1558       break;
1559     }
1560     case 180:
1561     {
1562       windowTransform = WL_OUTPUT_TRANSFORM_180;
1563       break;
1564     }
1565     case 270:
1566     {
1567       windowTransform = WL_OUTPUT_TRANSFORM_270;
1568       break;
1569     }
1570     default:
1571     {
1572       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1573       break;
1574     }
1575   }
1576
1577   wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1578 }
1579
1580 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1581 {
1582   wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1583
1584   // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1585   if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1586   {
1587     wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1588     mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1589   }
1590 }
1591
1592 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1593 {
1594   // Check capability
1595   wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1596   if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1597   {
1598     mSupportedPreProtation = true;
1599     return true;
1600   }
1601   mSupportedPreProtation = false;
1602   return false;
1603 }
1604
1605 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1606 {
1607   mWindowPositionSize = positionSize;
1608   ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1609 }
1610
1611 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1612 {
1613   mWindowPositionSize = positionSize;
1614   ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1615 }
1616
1617 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1618 {
1619   mWindowPositionSize = positionSize;
1620   ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1621 }
1622
1623 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1624 {
1625   ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1626   ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1627 }
1628
1629 void WindowBaseEcoreWl2::Raise()
1630 {
1631   // Use ecore_wl2_window_activate to prevent the window shown without rendering
1632   ecore_wl2_window_activate( mEcoreWindow );
1633 }
1634
1635 void WindowBaseEcoreWl2::Lower()
1636 {
1637   ecore_wl2_window_lower( mEcoreWindow );
1638 }
1639
1640 void WindowBaseEcoreWl2::Activate()
1641 {
1642   ecore_wl2_window_activate( mEcoreWindow );
1643 }
1644
1645 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1646 {
1647   int rotations[4] = {0};
1648   DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1649   for(std::size_t i = 0; i < angles.size(); ++i)
1650   {
1651     rotations[i] = static_cast<int>(angles[i]);
1652     DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1653   }
1654   ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1655 }
1656
1657 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1658 {
1659   DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle );
1660   ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1661 }
1662
1663 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1664 {
1665   ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1666 }
1667
1668 void WindowBaseEcoreWl2::Show()
1669 {
1670   if( !mVisible )
1671   {
1672     ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1673   }
1674   mVisible = true;
1675
1676   ecore_wl2_window_show( mEcoreWindow );
1677 }
1678
1679 void WindowBaseEcoreWl2::Hide()
1680 {
1681   mVisible = false;
1682   ecore_wl2_window_hide( mEcoreWindow );
1683 }
1684
1685 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1686 {
1687   return mSupportedAuxiliaryHints.size();
1688 }
1689
1690 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1691 {
1692   if( index >= GetSupportedAuxiliaryHintCount() )
1693   {
1694     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1695   }
1696
1697   return mSupportedAuxiliaryHints[index];
1698 }
1699
1700 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1701 {
1702   bool supported = false;
1703
1704   // Check if the hint is suppported
1705   for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1706   {
1707     if( *iter == hint )
1708     {
1709       supported = true;
1710       break;
1711     }
1712   }
1713
1714   if( !supported )
1715   {
1716     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1717     return 0;
1718   }
1719
1720   // Check if the hint is already added
1721   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1722   {
1723     if( mAuxiliaryHints[i].first == hint )
1724     {
1725       // Just change the value
1726       mAuxiliaryHints[i].second = value;
1727
1728       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1729
1730       return i + 1;   // id is index + 1
1731     }
1732   }
1733
1734   // Add the hint
1735   mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1736
1737   unsigned int id = mAuxiliaryHints.size();
1738
1739   ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1740
1741   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1742
1743   return id;
1744 }
1745
1746 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1747 {
1748   if( id == 0 || id > mAuxiliaryHints.size() )
1749   {
1750     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1751     return false;
1752   }
1753
1754   mAuxiliaryHints[id - 1].second = std::string();
1755
1756   ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1757
1758   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1759
1760   return true;
1761 }
1762
1763 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1764 {
1765   if( id == 0 || id > mAuxiliaryHints.size() )
1766   {
1767     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1768     return false;
1769   }
1770
1771   mAuxiliaryHints[id - 1].second = value;
1772
1773   ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1774
1775   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() );
1776
1777   return true;
1778 }
1779
1780 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1781 {
1782   if( id == 0 || id > mAuxiliaryHints.size() )
1783   {
1784     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1785     return std::string();
1786   }
1787
1788   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() );
1789
1790   return mAuxiliaryHints[id - 1].second;
1791 }
1792
1793 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1794 {
1795   for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1796   {
1797     if( mAuxiliaryHints[i].first == hint )
1798     {
1799       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1800       return i + 1;
1801     }
1802   }
1803
1804   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1805
1806   return 0;
1807 }
1808
1809 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1810 {
1811   ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1812 }
1813
1814 void WindowBaseEcoreWl2::SetType( Dali::WindowType type )
1815 {
1816   Ecore_Wl2_Window_Type windowType;
1817
1818   switch( type )
1819   {
1820     case Dali::WindowType::NORMAL:
1821     {
1822       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1823       break;
1824     }
1825     case Dali::WindowType::NOTIFICATION:
1826     {
1827       windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1828       break;
1829     }
1830     case Dali::WindowType::UTILITY:
1831     {
1832       windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1833       break;
1834     }
1835     case Dali::WindowType::DIALOG:
1836     {
1837       windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1838       break;
1839     }
1840     default:
1841     {
1842       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1843       break;
1844     }
1845   }
1846
1847   ecore_wl2_window_type_set( mEcoreWindow, windowType );
1848 }
1849
1850 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::WindowNotificationLevel level )
1851 {
1852   while( !mTizenPolicy )
1853   {
1854     wl_display_dispatch_queue( mDisplay, mEventQueue );
1855   }
1856
1857   int notificationLevel;
1858
1859   switch( level )
1860   {
1861     case Dali::WindowNotificationLevel::NONE:
1862     {
1863       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1864       break;
1865     }
1866     case Dali::WindowNotificationLevel::BASE:
1867     {
1868       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1869       break;
1870     }
1871     case Dali::WindowNotificationLevel::MEDIUM:
1872     {
1873       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1874       break;
1875     }
1876     case Dali::WindowNotificationLevel::HIGH:
1877     {
1878       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1879       break;
1880     }
1881     case Dali::WindowNotificationLevel::TOP:
1882     {
1883       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1884       break;
1885     }
1886     default:
1887     {
1888       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1889       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1890       break;
1891     }
1892   }
1893
1894   mNotificationLevelChangeDone = false;
1895   mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1896
1897   tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1898
1899   int count = 0;
1900
1901   while( !mNotificationLevelChangeDone && count < 3 )
1902   {
1903     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1904     wl_display_dispatch_queue( mDisplay, mEventQueue );
1905     count++;
1906   }
1907
1908   if( !mNotificationLevelChangeDone )
1909   {
1910     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1911     return false;
1912   }
1913   else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1914   {
1915     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1916     return false;
1917   }
1918
1919   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1920
1921   return true;
1922 }
1923
1924 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
1925 {
1926   while( !mTizenPolicy )
1927   {
1928     wl_display_dispatch_queue( mDisplay, mEventQueue );
1929   }
1930
1931   int count = 0;
1932
1933   while( !mNotificationLevelChangeDone && count < 3 )
1934   {
1935     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1936     wl_display_dispatch_queue( mDisplay, mEventQueue );
1937     count++;
1938   }
1939
1940   if( !mNotificationLevelChangeDone )
1941   {
1942     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1943     return Dali::WindowNotificationLevel::NONE;
1944   }
1945
1946   Dali::WindowNotificationLevel level;
1947
1948   switch( mNotificationLevel )
1949   {
1950     case TIZEN_POLICY_LEVEL_NONE:
1951     {
1952       level = Dali::WindowNotificationLevel::NONE;
1953       break;
1954     }
1955     case TIZEN_POLICY_LEVEL_DEFAULT:
1956     {
1957       level = Dali::WindowNotificationLevel::BASE;
1958       break;
1959     }
1960     case TIZEN_POLICY_LEVEL_MEDIUM:
1961     {
1962       level = Dali::WindowNotificationLevel::MEDIUM;
1963       break;
1964     }
1965     case TIZEN_POLICY_LEVEL_HIGH:
1966     {
1967       level = Dali::WindowNotificationLevel::HIGH;
1968       break;
1969     }
1970     case TIZEN_POLICY_LEVEL_TOP:
1971     {
1972       level = Dali::WindowNotificationLevel::TOP;
1973       break;
1974     }
1975     default:
1976     {
1977       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1978       level = Dali::WindowNotificationLevel::NONE;
1979       break;
1980     }
1981   }
1982
1983   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1984
1985   return level;
1986 }
1987
1988 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
1989 {
1990   while( !mTizenPolicy )
1991   {
1992     wl_display_dispatch_queue( mDisplay, mEventQueue );
1993   }
1994
1995   tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1996 }
1997
1998 bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1999 {
2000   while( !mTizenPolicy )
2001   {
2002     wl_display_dispatch_queue( mDisplay, mEventQueue );
2003   }
2004
2005   mScreenOffModeChangeDone = false;
2006   mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2007
2008   unsigned int mode = 0;
2009
2010   switch( screenOffMode )
2011   {
2012     case WindowScreenOffMode::TIMEOUT:
2013     {
2014       mode = 0;
2015       break;
2016     }
2017     case WindowScreenOffMode::NEVER:
2018     {
2019       mode = 1;
2020       break;
2021     }
2022   }
2023
2024   tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
2025
2026   int count = 0;
2027
2028   while( !mScreenOffModeChangeDone && count < 3 )
2029   {
2030     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2031     wl_display_dispatch_queue( mDisplay, mEventQueue );
2032     count++;
2033   }
2034
2035   if( !mScreenOffModeChangeDone )
2036   {
2037     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
2038     return false;
2039   }
2040   else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2041   {
2042     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
2043     return false;
2044   }
2045
2046   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
2047
2048   return true;
2049 }
2050
2051 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2052 {
2053   while( !mTizenPolicy )
2054   {
2055     wl_display_dispatch_queue( mDisplay, mEventQueue );
2056   }
2057
2058   int count = 0;
2059
2060   while( !mScreenOffModeChangeDone && count < 3 )
2061   {
2062     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2063     wl_display_dispatch_queue( mDisplay, mEventQueue );
2064     count++;
2065   }
2066
2067   if( !mScreenOffModeChangeDone )
2068   {
2069     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2070     return WindowScreenOffMode::TIMEOUT;
2071   }
2072
2073   WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2074
2075   switch( mScreenOffMode )
2076   {
2077     case 0:
2078     {
2079       screenMode = WindowScreenOffMode::TIMEOUT;
2080       break;
2081     }
2082     case 1:
2083     {
2084       screenMode = WindowScreenOffMode::NEVER;
2085       break;
2086     }
2087   }
2088
2089   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2090
2091   return screenMode;
2092 }
2093
2094 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2095 {
2096   while( !mTizenDisplayPolicy )
2097   {
2098     wl_display_dispatch_queue( mDisplay, mEventQueue );
2099   }
2100
2101   mBrightnessChangeDone = false;
2102   mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2103
2104   tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2105
2106   int count = 0;
2107
2108   while( !mBrightnessChangeDone && count < 3 )
2109   {
2110     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2111     wl_display_dispatch_queue( mDisplay, mEventQueue );
2112     count++;
2113   }
2114
2115   if( !mBrightnessChangeDone )
2116   {
2117     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2118     return false;
2119   }
2120   else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2121   {
2122     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2123     return false;
2124   }
2125
2126   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2127
2128   return true;
2129 }
2130
2131 int WindowBaseEcoreWl2::GetBrightness() const
2132 {
2133   while( !mTizenDisplayPolicy )
2134   {
2135     wl_display_dispatch_queue( mDisplay, mEventQueue );
2136   }
2137
2138   int count = 0;
2139
2140   while( !mBrightnessChangeDone && count < 3 )
2141   {
2142     ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2143     wl_display_dispatch_queue( mDisplay, mEventQueue );
2144     count++;
2145   }
2146
2147   if( !mBrightnessChangeDone )
2148   {
2149     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2150     return 0;
2151   }
2152
2153   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2154
2155   return mBrightness;
2156 }
2157
2158 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2159 {
2160   Ecore_Wl2_Window_Keygrab_Mode mode;
2161
2162   switch( grabMode )
2163   {
2164     case KeyGrab::TOPMOST:
2165     {
2166       mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2167       break;
2168     }
2169     case KeyGrab::SHARED:
2170     {
2171       mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2172       break;
2173     }
2174     case KeyGrab::OVERRIDE_EXCLUSIVE:
2175     {
2176       mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2177       break;
2178     }
2179     case KeyGrab::EXCLUSIVE:
2180     {
2181       mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2182       break;
2183     }
2184     default:
2185     {
2186       return false;
2187     }
2188   }
2189
2190   return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2191 }
2192
2193 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2194 {
2195   return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2196 }
2197
2198 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2199 {
2200   int keyCount = key.Count();
2201   int keyGrabModeCount = grabMode.Count();
2202
2203   if( keyCount != keyGrabModeCount || keyCount == 0 )
2204   {
2205     return false;
2206   }
2207
2208   eina_init();
2209
2210   Eina_List* keyList = NULL;
2211   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2212
2213   for( int index = 0; index < keyCount; ++index )
2214   {
2215     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2216
2217     switch( grabMode[index] )
2218     {
2219       case KeyGrab::TOPMOST:
2220       {
2221         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2222         break;
2223       }
2224       case KeyGrab::SHARED:
2225       {
2226         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2227         break;
2228       }
2229       case KeyGrab::OVERRIDE_EXCLUSIVE:
2230       {
2231         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2232         break;
2233       }
2234       case KeyGrab::EXCLUSIVE:
2235       {
2236         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2237         break;
2238       }
2239       default:
2240       {
2241         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2242         break;
2243       }
2244     }
2245
2246     keyList = eina_list_append( keyList, &info );
2247   }
2248
2249   Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2250
2251   result.Resize( keyCount, true );
2252
2253   Eina_List* l = NULL;
2254   Eina_List* m = NULL;
2255   void* listData = NULL;
2256   void* data = NULL;
2257   if( grabList != NULL )
2258   {
2259     EINA_LIST_FOREACH( grabList, m, data )
2260     {
2261       int index = 0;
2262       EINA_LIST_FOREACH( keyList, l, listData )
2263       {
2264         if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2265         {
2266           DALI_LOG_ERROR( "input key list has null data!" );
2267           break;
2268         }
2269
2270         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2271         {
2272           result[index] = false;
2273         }
2274         ++index;
2275       }
2276     }
2277   }
2278
2279   delete [] info;
2280
2281   eina_list_free( keyList );
2282   eina_list_free( grabList );
2283   eina_shutdown();
2284
2285   return true;
2286 }
2287
2288 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2289 {
2290   int keyCount = key.Count();
2291   if( keyCount == 0 )
2292   {
2293     return false;
2294   }
2295
2296   eina_init();
2297
2298   Eina_List* keyList = NULL;
2299   Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2300
2301   for( int index = 0; index < keyCount; ++index )
2302   {
2303     info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2304     keyList = eina_list_append( keyList, &info );
2305   }
2306
2307   Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2308
2309   result.Resize( keyCount, true );
2310
2311   Eina_List* l = NULL;
2312   Eina_List* m = NULL;
2313   void *listData = NULL;
2314   void *data = NULL;
2315
2316   if( ungrabList != NULL )
2317   {
2318     EINA_LIST_FOREACH( ungrabList, m, data )
2319     {
2320       int index = 0;
2321       EINA_LIST_FOREACH( keyList, l, listData )
2322       {
2323         if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2324         {
2325           result[index] = false;
2326         }
2327         ++index;
2328       }
2329     }
2330   }
2331
2332   delete [] info;
2333
2334   eina_list_free( keyList );
2335   eina_list_free( ungrabList );
2336   eina_shutdown();
2337
2338   return true;
2339 }
2340
2341 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2342 {
2343   // calculate DPI
2344   float xres, yres;
2345
2346   Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2347
2348   // 1 inch = 25.4 millimeters
2349   xres = ecore_wl2_output_dpi_get( output );
2350   yres = ecore_wl2_output_dpi_get( output );
2351
2352   dpiHorizontal = int( xres + 0.5f );  // rounding
2353   dpiVertical   = int( yres + 0.5f );
2354 }
2355
2356 int WindowBaseEcoreWl2::GetOrientation() const
2357 {
2358   int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2359   if(mSupportedPreProtation)
2360   {
2361     orientation = 0;
2362   }
2363   return orientation;
2364 }
2365
2366 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2367 {
2368   int transform = 0;
2369
2370   if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2371   {
2372     transform = 0;
2373   }
2374   else
2375   {
2376     transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2377   }
2378   mScreenRotationAngle = transform * 90;
2379   return mScreenRotationAngle;
2380 }
2381
2382 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2383 {
2384   mWindowRotationAngle = degree;
2385   ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2386 }
2387
2388 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2389 {
2390   ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2391 }
2392
2393 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2394 {
2395   ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2396 }
2397
2398 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2399 {
2400 #ifdef DALI_ELDBUS_AVAILABLE
2401   Eldbus_Object* object;
2402   Eldbus_Proxy* manager;
2403
2404   if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2405   {
2406     DALI_LOG_ERROR( "Unable to get system bus\n" );
2407   }
2408
2409   object = eldbus_object_get( mSystemConnection, BUS, PATH );
2410   if( !object )
2411   {
2412     DALI_LOG_ERROR( "Getting object failed\n" );
2413     return;
2414   }
2415
2416   manager = eldbus_proxy_get( object, INTERFACE );
2417   if( !manager )
2418   {
2419     DALI_LOG_ERROR( "Getting proxy failed\n" );
2420     return;
2421   }
2422
2423   if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2424   {
2425     DALI_LOG_ERROR( "No signal handler returned\n" );
2426   }
2427 #endif
2428 }
2429
2430 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2431 {
2432   Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2433   if( !display )
2434   {
2435     DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2436   }
2437
2438   ecore_wl2_display_sync( display );
2439
2440   mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2441
2442   if ( mEcoreWindow == 0 )
2443   {
2444     DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2445   }
2446
2447   // Set default type
2448   ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2449 }
2450
2451 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2452 {
2453   Ecore_Wl2_Window* ecoreParent = NULL;
2454   if( parentWinBase )
2455   {
2456     WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2457     ecoreParent = winBaseEcore2->mEcoreWindow;
2458   }
2459   ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2460 }
2461
2462 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2463 {
2464   return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
2465 }
2466
2467 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2468 {
2469   return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
2470 }
2471
2472 } // namespace Adaptor
2473
2474 } // namespace Internal
2475
2476 } // namespace Dali
2477
2478 #pragma GCC diagnostic pop