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