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