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