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