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