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