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