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