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