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