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