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