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