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