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