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