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