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