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