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