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