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