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