Merge "Add UI thread feature on Tizen" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl / window-base-ecore-wl.cpp
1 /*
2  * Copyright (c) 2022 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-wl/window-base-ecore-wl.h>
24
25 // INTERNAL HEADERS
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/window-system/common/window-impl.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/window-system/common/window-system.h>
30
31 // EXTERNAL_HEADERS
32 #include <Ecore_Input.h>
33 #include <dali/integration-api/debug.h>
34 #include <dali/public-api/object/any.h>
35 #include <vconf-keys.h>
36 #include <vconf.h>
37
38 namespace Dali
39 {
40 namespace Internal
41 {
42 namespace Adaptor
43 {
44 namespace
45 {
46 #if defined(DEBUG_ENABLED)
47 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
48 #endif
49
50 const uint32_t     MAX_TIZEN_CLIENT_VERSION = 7;
51 const unsigned int PRIMARY_TOUCH_BUTTON_ID  = 1;
52
53 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
54
55 // DBUS accessibility
56 const char* BUS       = "org.enlightenment.wm-screen-reader";
57 const char* INTERFACE = "org.tizen.GestureNavigation";
58 const char* PATH      = "/org/tizen/GestureNavigation";
59
60 /**
61  * Get the device name from the provided ecore key event
62  */
63 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
64 {
65   const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
66
67   if(ecoreDeviceName)
68   {
69     result = ecoreDeviceName;
70   }
71 }
72
73 /**
74  * Get the device class from the provided ecore event
75  */
76 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
77 {
78   switch(ecoreDeviceClass)
79   {
80     case ECORE_DEVICE_CLASS_SEAT:
81     {
82       deviceClass = Device::Class::USER;
83       break;
84     }
85     case ECORE_DEVICE_CLASS_KEYBOARD:
86     {
87       deviceClass = Device::Class::KEYBOARD;
88       break;
89     }
90     case ECORE_DEVICE_CLASS_MOUSE:
91     {
92       deviceClass = Device::Class::MOUSE;
93       break;
94     }
95     case ECORE_DEVICE_CLASS_TOUCH:
96     {
97       deviceClass = Device::Class::TOUCH;
98       break;
99     }
100     case ECORE_DEVICE_CLASS_PEN:
101     {
102       deviceClass = Device::Class::PEN;
103       break;
104     }
105     case ECORE_DEVICE_CLASS_POINTER:
106     {
107       deviceClass = Device::Class::POINTER;
108       break;
109     }
110     case ECORE_DEVICE_CLASS_GAMEPAD:
111     {
112       deviceClass = Device::Class::GAMEPAD;
113       break;
114     }
115     default:
116     {
117       deviceClass = Device::Class::NONE;
118       break;
119     }
120   }
121 }
122
123 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
124 {
125   switch(ecoreDeviceSubclass)
126   {
127     case ECORE_DEVICE_SUBCLASS_FINGER:
128     {
129       deviceSubclass = Device::Subclass::FINGER;
130       break;
131     }
132     case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
133     {
134       deviceSubclass = Device::Subclass::FINGERNAIL;
135       break;
136     }
137     case ECORE_DEVICE_SUBCLASS_KNUCKLE:
138     {
139       deviceSubclass = Device::Subclass::KNUCKLE;
140       break;
141     }
142     case ECORE_DEVICE_SUBCLASS_PALM:
143     {
144       deviceSubclass = Device::Subclass::PALM;
145       break;
146     }
147     case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
148     {
149       deviceSubclass = Device::Subclass::HAND_SIDE;
150       break;
151     }
152     case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
153     {
154       deviceSubclass = Device::Subclass::HAND_FLAT;
155       break;
156     }
157     case ECORE_DEVICE_SUBCLASS_PEN_TIP:
158     {
159       deviceSubclass = Device::Subclass::PEN_TIP;
160       break;
161     }
162     case ECORE_DEVICE_SUBCLASS_TRACKPAD:
163     {
164       deviceSubclass = Device::Subclass::TRACKPAD;
165       break;
166     }
167     case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
168     {
169       deviceSubclass = Device::Subclass::TRACKPOINT;
170       break;
171     }
172     case ECORE_DEVICE_SUBCLASS_TRACKBALL:
173     {
174       deviceSubclass = Device::Subclass::TRACKBALL;
175       break;
176     }
177     case ECORE_DEVICE_SUBCLASS_REMOCON:
178     {
179       deviceSubclass = Device::Subclass::REMOCON;
180       break;
181     }
182     case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
183     {
184       deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
185       break;
186     }
187     default:
188     {
189       deviceSubclass = Device::Subclass::NONE;
190       break;
191     }
192   }
193 }
194
195 /////////////////////////////////////////////////////////////////////////////////////////////////
196 // Window Callbacks
197 /////////////////////////////////////////////////////////////////////////////////////////////////
198
199 /// Called when the window iconify state is changed.
200 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
201 {
202   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
203   if(windowBase)
204   {
205     return windowBase->OnIconifyStateChanged(data, type, event);
206   }
207
208   return ECORE_CALLBACK_PASS_ON;
209 }
210
211 /// Called when the window gains focus
212 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
213 {
214   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
215   if(windowBase)
216   {
217     return windowBase->OnFocusIn(data, type, event);
218   }
219
220   return ECORE_CALLBACK_PASS_ON;
221 }
222
223 /// Called when the window loses focus
224 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
225 {
226   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
227   if(windowBase)
228   {
229     return windowBase->OnFocusOut(data, type, event);
230   }
231
232   return ECORE_CALLBACK_PASS_ON;
233 }
234
235 /// Called when the output is transformed
236 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
237 {
238   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
239   if(windowBase)
240   {
241     return windowBase->OnOutputTransform(data, type, event);
242   }
243
244   return ECORE_CALLBACK_PASS_ON;
245 }
246
247 /// Called when the output transform should be ignored
248 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
249 {
250   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
251   if(windowBase)
252   {
253     return windowBase->OnIgnoreOutputTransform(data, type, event);
254   }
255
256   return ECORE_CALLBACK_PASS_ON;
257 }
258
259 /**
260  * Called when rotate event is recevied.
261  */
262 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
263 {
264   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
265   if(windowBase)
266   {
267     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::EcoreEventRotate\n");
268     windowBase->OnRotation(data, type, event);
269   }
270   return ECORE_CALLBACK_PASS_ON;
271 }
272
273 /////////////////////////////////////////////////////////////////////////////////////////////////
274 // Touch Callbacks
275 /////////////////////////////////////////////////////////////////////////////////////////////////
276
277 /**
278  * Called when a touch down is received.
279  */
280 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
281 {
282   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
283   if(windowBase)
284   {
285     windowBase->OnMouseButtonDown(data, type, event);
286   }
287   return ECORE_CALLBACK_PASS_ON;
288 }
289
290 /**
291  * Called when a touch up is received.
292  */
293 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
294 {
295   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
296   if(windowBase)
297   {
298     windowBase->OnMouseButtonUp(data, type, event);
299   }
300   return ECORE_CALLBACK_PASS_ON;
301 }
302
303 /**
304  * Called when a touch motion is received.
305  */
306 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
307 {
308   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
309   if(windowBase)
310   {
311     windowBase->OnMouseButtonMove(data, type, event);
312   }
313   return ECORE_CALLBACK_PASS_ON;
314 }
315
316 /**
317  * Called when a touch is canceled.
318  */
319 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
320 {
321   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
322   if(windowBase)
323   {
324     windowBase->OnMouseButtonCancel(data, type, event);
325   }
326   return ECORE_CALLBACK_PASS_ON;
327 }
328
329 /**
330  * Called when a mouse wheel is received.
331  */
332 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
333 {
334   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
335   if(windowBase)
336   {
337     windowBase->OnMouseWheel(data, type, event);
338   }
339   return ECORE_CALLBACK_PASS_ON;
340 }
341
342 /**
343  * Called when a detent rotation event is recevied.
344  */
345 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
346 {
347   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
348   if(windowBase)
349   {
350     windowBase->OnDetentRotation(data, type, event);
351   }
352   return ECORE_CALLBACK_PASS_ON;
353 }
354
355 /////////////////////////////////////////////////////////////////////////////////////////////////
356 // Key Callbacks
357 /////////////////////////////////////////////////////////////////////////////////////////////////
358
359 /**
360  * Called when a key down is received.
361  */
362 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
363 {
364   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
365   if(windowBase)
366   {
367     windowBase->OnKeyDown(data, type, event);
368   }
369   return ECORE_CALLBACK_PASS_ON;
370 }
371
372 /**
373  * Called when a key up is received.
374  */
375 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
376 {
377   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
378   if(windowBase)
379   {
380     windowBase->OnKeyUp(data, type, event);
381   }
382   return ECORE_CALLBACK_PASS_ON;
383 }
384
385 /////////////////////////////////////////////////////////////////////////////////////////////////
386 // Selection Callbacks
387 /////////////////////////////////////////////////////////////////////////////////////////////////
388
389 /**
390  * Called when the source window notifies us the content in clipboard is selected.
391  */
392 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
393 {
394   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
395   if(windowBase)
396   {
397     windowBase->OnDataSend(data, type, event);
398   }
399   return ECORE_CALLBACK_PASS_ON;
400 }
401
402 /**
403 * Called when the source window sends us about the selected content.
404 * For example, when item is selected in the clipboard.
405 */
406 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
407 {
408   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
409   if(windowBase)
410   {
411     windowBase->OnDataReceive(data, type, event);
412   }
413   return ECORE_CALLBACK_PASS_ON;
414 }
415
416 /////////////////////////////////////////////////////////////////////////////////////////////////
417 // Font Callbacks
418 /////////////////////////////////////////////////////////////////////////////////////////////////
419
420 /**
421  * Called when a font name is changed.
422  */
423 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
424 {
425   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
426   if(windowBase)
427   {
428     windowBase->OnFontNameChanged();
429   }
430 }
431
432 /**
433  * Called when a font size is changed.
434  */
435 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
436 {
437   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
438   if(windowBase)
439   {
440     windowBase->OnFontSizeChanged();
441   }
442 }
443
444 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
445 {
446   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
447   if(windowBase)
448   {
449     windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
450   }
451 }
452
453 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
454 {
455   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
456   if(windowBase)
457   {
458     windowBase->RegistryGlobalCallbackRemove(data, registry, id);
459   }
460 }
461
462 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
463 {
464 }
465
466 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)
467 {
468 }
469
470 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
471 {
472   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
473   if(windowBase)
474   {
475     windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
476   }
477 }
478
479 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
480 {
481 }
482
483 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
484 {
485   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
486   if(windowBase)
487   {
488     windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
489   }
490 }
491
492 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
493 {
494 }
495
496 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
497 {
498 }
499
500 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
501 {
502 }
503
504 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
505 {
506 }
507
508 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)
509 {
510 }
511
512 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
513 {
514   WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
515   if(windowBase)
516   {
517     windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
518   }
519 }
520
521 const struct wl_registry_listener registryListener =
522   {
523     RegistryGlobalCallback,
524     RegistryGlobalCallbackRemove};
525
526 const struct tizen_policy_listener tizenPolicyListener =
527   {
528     TizenPolicyConformant,
529     TizenPolicyConformantArea,
530     TizenPolicyNotificationChangeDone,
531     TizenPolicyTransientForDone,
532     TizenPolicyScreenModeChangeDone,
533     TizenPolicyIconifyStateChanged,
534     TizenPolicySupportedAuxiliaryHints,
535     TizenPolicyAllowedAuxiliaryHint,
536     TizenPolicyAuxiliaryMessage,
537     TizenPolicyConformantRegion};
538
539 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
540   {
541     DisplayPolicyBrightnessChangeDone};
542
543 } // unnamed namespace
544
545 WindowBaseEcoreWl::WindowBaseEcoreWl(Dali::PositionSize positionSize, Any surface, bool isTransparent)
546 : mEcoreEventHandler(),
547   mEcoreWindow(nullptr),
548   mWlSurface(nullptr),
549   mEglWindow(nullptr),
550   mDisplay(nullptr),
551   mEventQueue(nullptr),
552   mTizenPolicy(nullptr),
553   mTizenDisplayPolicy(nullptr),
554   mSupportedAuxiliaryHints(),
555   mAuxiliaryHints(),
556   mNotificationLevel(-1),
557   mNotificationChangeState(0),
558   mNotificationLevelChangeDone(true),
559   mScreenOffMode(0),
560   mScreenOffModeChangeState(0),
561   mScreenOffModeChangeDone(true),
562   mBrightness(0),
563   mBrightnessChangeState(0),
564   mBrightnessChangeDone(true),
565   mOwnSurface(false),
566   mWindowRotationAngle(0),
567   mScreenRotationAngle(0),
568   mSupportedPreProtation(0)
569 {
570   Initialize(positionSize, surface, isTransparent);
571 }
572
573 WindowBaseEcoreWl::~WindowBaseEcoreWl()
574 {
575   vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
576   vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
577
578   for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
579   {
580     ecore_event_handler_del(*iter);
581   }
582   mEcoreEventHandler.Clear();
583
584   if(mEventQueue)
585   {
586     wl_event_queue_destroy(mEventQueue);
587   }
588
589   mSupportedAuxiliaryHints.clear();
590   mAuxiliaryHints.clear();
591
592   if(mEglWindow != NULL)
593   {
594     wl_egl_window_destroy(mEglWindow);
595     mEglWindow = NULL;
596   }
597
598   if(mOwnSurface)
599   {
600     ecore_wl_window_free(mEcoreWindow);
601
602     WindowSystem::Shutdown();
603   }
604 }
605
606 void WindowBaseEcoreWl::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
607 {
608   if(surface.Empty() == false)
609   {
610     // check we have a valid type
611     DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl_Window*)) && "Surface type is invalid");
612
613     mEcoreWindow = AnyCast<Ecore_Wl_Window*>(surface);
614   }
615   else
616   {
617     // we own the surface about to created
618     WindowSystem::Initialize();
619
620     mOwnSurface = true;
621     CreateWindow(positionSize);
622   }
623
624   mWlSurface = ecore_wl_window_surface_create(mEcoreWindow);
625
626   SetTransparency(isTransparent);
627
628   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
629   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
630   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
631   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
632   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
633
634   // Register Rotate event
635   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
636
637   // Register Touch events
638   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
639   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
640   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
641   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
642
643   // Register Mouse wheel events
644   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
645
646   // Register Detent event
647   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
648
649   // Register Key events
650   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
651   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
652
653   // Register Selection event - clipboard selection
654   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
655   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
656
657   // Register Vconf notify - font name and size
658   vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
659   vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
660
661   mDisplay = ecore_wl_display_get();
662
663   if(mDisplay)
664   {
665     wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
666     if(displayWrapper)
667     {
668       mEventQueue = wl_display_create_queue(mDisplay);
669       if(mEventQueue)
670       {
671         wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
672
673         wl_registry* registry = wl_display_get_registry(displayWrapper);
674         wl_registry_add_listener(registry, &registryListener, this);
675       }
676
677       wl_proxy_wrapper_destroy(displayWrapper);
678     }
679   }
680
681   // get auxiliary hint
682   Eina_List* hints = ecore_wl_window_aux_hints_supported_get(mEcoreWindow);
683   if(hints)
684   {
685     Eina_List* l    = NULL;
686     char*      hint = NULL;
687
688     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))))
689     {
690       mSupportedAuxiliaryHints.push_back(hint);
691
692       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint);
693     }
694   }
695 }
696
697 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged(void* data, int type, void* event)
698 {
699   Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl_Event_Window_Iconify_State_Change*>(event));
700   Eina_Bool                                   handled(ECORE_CALLBACK_PASS_ON);
701
702   if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
703   {
704     if(iconifyChangedEvent->iconified == EINA_TRUE)
705     {
706       mIconifyChangedSignal.Emit(true);
707     }
708     else
709     {
710       mIconifyChangedSignal.Emit(false);
711     }
712     handled = ECORE_CALLBACK_DONE;
713   }
714
715   return handled;
716 }
717
718 Eina_Bool WindowBaseEcoreWl::OnFocusIn(void* data, int type, void* event)
719 {
720   Ecore_Wl_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl_Event_Focus_In*>(event));
721
722   if(focusInEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
723   {
724     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
725
726     mFocusChangedSignal.Emit(true);
727   }
728
729   return ECORE_CALLBACK_PASS_ON;
730 }
731
732 Eina_Bool WindowBaseEcoreWl::OnFocusOut(void* data, int type, void* event)
733 {
734   Ecore_Wl_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl_Event_Focus_Out*>(event));
735
736   if(focusOutEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
737   {
738     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
739
740     mFocusChangedSignal.Emit(false);
741   }
742
743   return ECORE_CALLBACK_PASS_ON;
744 }
745
746 Eina_Bool WindowBaseEcoreWl::OnOutputTransform(void* data, int type, void* event)
747 {
748   Ecore_Wl_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl_Event_Output_Transform*>(event));
749
750   if(transformEvent->output == ecore_wl_window_output_find(mEcoreWindow))
751   {
752     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
753
754     mOutputTransformedSignal.Emit();
755   }
756
757   return ECORE_CALLBACK_PASS_ON;
758 }
759
760 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform(void* data, int type, void* event)
761 {
762   Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl_Event_Ignore_Output_Transform*>(event));
763
764   if(ignoreTransformEvent->win == mEcoreWindow)
765   {
766     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
767
768     mOutputTransformedSignal.Emit();
769   }
770
771   return ECORE_CALLBACK_PASS_ON;
772 }
773
774 void WindowBaseEcoreWl::OnRotation(void* data, int type, void* event)
775 {
776   Ecore_Wl_Event_Window_Rotate* ev(static_cast<Ecore_Wl_Event_Window_Rotate*>(event));
777
778   if(ev->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
779   {
780     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
781
782     RotationEvent rotationEvent;
783     rotationEvent.angle     = ev->angle;
784     rotationEvent.winResize = 0;
785
786     if(ev->angle == 0 || ev->angle == 180)
787     {
788       rotationEvent.width  = ev->w;
789       rotationEvent.height = ev->h;
790     }
791     else
792     {
793       rotationEvent.width  = ev->h;
794       rotationEvent.height = ev->w;
795     }
796
797     mRotationSignal.Emit(rotationEvent);
798   }
799 }
800
801 void WindowBaseEcoreWl::OnMouseButtonDown(void* data, int type, void* event)
802 {
803   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
804
805   if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
806   {
807     PointState::Type state(PointState::DOWN);
808
809     // Check if the buttons field is set and ensure it's the primary touch button.
810     // If this event was triggered by buttons other than the primary button (used for touch), then
811     // just send an interrupted event to Core.
812     if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
813     {
814       state = PointState::INTERRUPTED;
815     }
816
817     Device::Class::Type    deviceClass;
818     Device::Subclass::Type deviceSubclass;
819
820     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
821     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
822
823     Integration::Point point;
824     point.SetDeviceId(touchEvent->multi.device);
825     point.SetState(state);
826     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
827     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
828     point.SetPressure(touchEvent->multi.pressure);
829     point.SetAngle(Degree(touchEvent->multi.angle));
830     point.SetDeviceClass(deviceClass);
831     point.SetDeviceSubclass(deviceSubclass);
832
833     mTouchEventSignal.Emit(point, touchEvent->timestamp);
834   }
835 }
836
837 void WindowBaseEcoreWl::OnMouseButtonUp(void* data, int type, void* event)
838 {
839   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
840
841   if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
842   {
843     Device::Class::Type    deviceClass;
844     Device::Subclass::Type deviceSubclass;
845
846     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
847     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
848
849     Integration::Point point;
850     point.SetDeviceId(touchEvent->multi.device);
851     point.SetState(PointState::UP);
852     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
853     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
854     point.SetPressure(touchEvent->multi.pressure);
855     point.SetAngle(Degree(touchEvent->multi.angle));
856     point.SetDeviceClass(deviceClass);
857     point.SetDeviceSubclass(deviceSubclass);
858
859     mTouchEventSignal.Emit(point, touchEvent->timestamp);
860   }
861 }
862
863 void WindowBaseEcoreWl::OnMouseButtonMove(void* data, int type, void* event)
864 {
865   Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
866
867   if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
868   {
869     Device::Class::Type    deviceClass;
870     Device::Subclass::Type deviceSubclass;
871
872     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
873     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
874
875     Integration::Point point;
876     point.SetDeviceId(touchEvent->multi.device);
877     point.SetState(PointState::MOTION);
878     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
879     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
880     point.SetPressure(touchEvent->multi.pressure);
881     point.SetAngle(Degree(touchEvent->multi.angle));
882     point.SetDeviceClass(deviceClass);
883     point.SetDeviceSubclass(deviceSubclass);
884
885     mTouchEventSignal.Emit(point, touchEvent->timestamp);
886   }
887 }
888
889 void WindowBaseEcoreWl::OnMouseButtonCancel(void* data, int type, void* event)
890 {
891   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
892
893   if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
894   {
895     Integration::Point point;
896     point.SetDeviceId(touchEvent->multi.device);
897     point.SetState(PointState::INTERRUPTED);
898     point.SetScreenPosition(Vector2(0.0f, 0.0f));
899
900     mTouchEventSignal.Emit(point, touchEvent->timestamp);
901
902     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n");
903   }
904 }
905
906 void WindowBaseEcoreWl::OnMouseWheel(void* data, int type, void* event)
907 {
908   Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
909
910   if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
911   {
912     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
913
914     Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
915
916     mWheelEventSignal.Emit(wheelEvent);
917   }
918 }
919
920 void WindowBaseEcoreWl::OnDetentRotation(void* data, int type, void* event)
921 {
922   Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
923
924   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n");
925
926   int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
927   int timeStamp = detentEvent->timestamp;
928
929   Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp);
930
931   mWheelEventSignal.Emit(wheelEvent);
932 }
933
934 void WindowBaseEcoreWl::OnKeyDown(void* data, int type, void* event)
935 {
936   Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
937
938   if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
939   {
940     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n");
941
942     std::string keyName(keyEvent->keyname);
943     std::string logicalKey("");
944     std::string keyString("");
945     std::string compose("");
946
947     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
948     if(keyEvent->compose)
949     {
950       compose = keyEvent->compose;
951     }
952
953     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
954     if(keyEvent->key)
955     {
956       logicalKey = keyEvent->key;
957     }
958
959     int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
960     keyCode     = (keyCode == -1) ? 0 : keyCode;
961     int           modifier(keyEvent->modifiers);
962     unsigned long time = keyEvent->timestamp;
963     if(!strncmp(keyEvent->keyname, "Keycode-", 8))
964     {
965       keyCode = atoi(keyEvent->keyname + 8);
966     }
967
968     // Ensure key event string is not NULL as keys like SHIFT have a null string.
969     if(keyEvent->string)
970     {
971       keyString = keyEvent->string;
972     }
973
974     std::string            deviceName;
975     Device::Class::Type    deviceClass;
976     Device::Subclass::Type deviceSubclass;
977
978     GetDeviceName(keyEvent, deviceName);
979     GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
980     GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
981
982     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
983
984     mKeyEventSignal.Emit(keyEvent);
985   }
986 }
987
988 void WindowBaseEcoreWl::OnKeyUp(void* data, int type, void* event)
989 {
990   Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
991
992   if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
993   {
994     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n");
995
996 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
997     // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
998     if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
999     {
1000       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n");
1001       return;
1002     }
1003 #endif // Since ecore 1.23 version
1004
1005     std::string keyName(keyEvent->keyname);
1006     std::string logicalKey("");
1007     std::string keyString("");
1008     std::string compose("");
1009
1010     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1011     if(keyEvent->compose)
1012     {
1013       compose = keyEvent->compose;
1014     }
1015
1016     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1017     if(keyEvent->key)
1018     {
1019       logicalKey = keyEvent->key;
1020     }
1021
1022     int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1023     keyCode     = (keyCode == -1) ? 0 : keyCode;
1024     int           modifier(keyEvent->modifiers);
1025     unsigned long time = keyEvent->timestamp;
1026     if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1027     {
1028       keyCode = atoi(keyEvent->keyname + 8);
1029     }
1030
1031     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1032     if(keyEvent->string)
1033     {
1034       keyString = keyEvent->string;
1035     }
1036
1037     std::string            deviceName;
1038     Device::Class::Type    deviceClass;
1039     Device::Subclass::Type deviceSubclass;
1040
1041     GetDeviceName(keyEvent, deviceName);
1042     GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1043     GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1044
1045     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1046
1047     mKeyEventSignal.Emit(keyEvent);
1048   }
1049 }
1050
1051 void WindowBaseEcoreWl::OnDataSend(void* data, int type, void* event)
1052 {
1053   mSelectionDataSendSignal.Emit(event);
1054 }
1055
1056 void WindowBaseEcoreWl::OnDataReceive(void* data, int type, void* event)
1057 {
1058   mSelectionDataReceivedSignal.Emit(event);
1059 }
1060
1061 void WindowBaseEcoreWl::OnFontNameChanged()
1062 {
1063   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1064 }
1065
1066 void WindowBaseEcoreWl::OnFontSizeChanged()
1067 {
1068   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1069 }
1070
1071 void WindowBaseEcoreWl::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1072 {
1073   if(strcmp(interface, tizen_policy_interface.name) == 0)
1074   {
1075     uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1076
1077     mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1078     if(!mTizenPolicy)
1079     {
1080       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1081       return;
1082     }
1083
1084     tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1085
1086     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1087   }
1088   else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1089   {
1090     mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1091     if(!mTizenDisplayPolicy)
1092     {
1093       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1094       return;
1095     }
1096
1097     tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1098
1099     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1100   }
1101 }
1102
1103 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1104 {
1105   mTizenPolicy        = NULL;
1106   mTizenDisplayPolicy = NULL;
1107 }
1108
1109 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1110 {
1111   mNotificationLevel           = level;
1112   mNotificationChangeState     = state;
1113   mNotificationLevelChangeDone = true;
1114
1115   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1116 }
1117
1118 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1119 {
1120   mScreenOffMode            = mode;
1121   mScreenOffModeChangeState = state;
1122   mScreenOffModeChangeDone  = true;
1123
1124   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1125 }
1126
1127 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1128 {
1129   mBrightness            = brightness;
1130   mBrightnessChangeState = state;
1131   mBrightnessChangeDone  = true;
1132
1133   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1134 }
1135
1136 Any WindowBaseEcoreWl::GetNativeWindow()
1137 {
1138   return mEcoreWindow;
1139 }
1140
1141 int WindowBaseEcoreWl::GetNativeWindowId()
1142 {
1143   return ecore_wl_window_id_get(mEcoreWindow);
1144 }
1145
1146 std::string WindowBaseEcoreWl::GetNativeWindowResourceId()
1147 {
1148   return std::string();
1149 }
1150
1151 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow(int width, int height)
1152 {
1153   mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1154
1155   return static_cast<EGLNativeWindowType>(mEglWindow);
1156 }
1157
1158 void WindowBaseEcoreWl::DestroyEglWindow()
1159 {
1160   if(mEglWindow != NULL)
1161   {
1162     wl_egl_window_destroy(mEglWindow);
1163     mEglWindow = NULL;
1164   }
1165 }
1166
1167 void WindowBaseEcoreWl::SetEglWindowRotation(int angle)
1168 {
1169   wl_egl_window_rotation rotation;
1170
1171   switch(angle)
1172   {
1173     case 0:
1174     {
1175       rotation = ROTATION_0;
1176       break;
1177     }
1178     case 90:
1179     {
1180       rotation = ROTATION_270;
1181       break;
1182     }
1183     case 180:
1184     {
1185       rotation = ROTATION_180;
1186       break;
1187     }
1188     case 270:
1189     {
1190       rotation = ROTATION_90;
1191       break;
1192     }
1193     default:
1194     {
1195       rotation = ROTATION_0;
1196       break;
1197     }
1198   }
1199
1200   wl_egl_window_set_rotation(mEglWindow, rotation);
1201 }
1202
1203 void WindowBaseEcoreWl::SetEglWindowBufferTransform(int angle)
1204 {
1205   wl_output_transform bufferTransform;
1206
1207   switch(angle)
1208   {
1209     case 0:
1210     {
1211       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1212       break;
1213     }
1214     case 90:
1215     {
1216       bufferTransform = WL_OUTPUT_TRANSFORM_90;
1217       break;
1218     }
1219     case 180:
1220     {
1221       bufferTransform = WL_OUTPUT_TRANSFORM_180;
1222       break;
1223     }
1224     case 270:
1225     {
1226       bufferTransform = WL_OUTPUT_TRANSFORM_270;
1227       break;
1228     }
1229     default:
1230     {
1231       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1232       break;
1233     }
1234   }
1235
1236   wl_egl_window_set_buffer_transform(mEglWindow, bufferTransform);
1237 }
1238
1239 void WindowBaseEcoreWl::SetEglWindowTransform(int angle)
1240 {
1241   wl_output_transform windowTransform;
1242
1243   switch(angle)
1244   {
1245     case 0:
1246     {
1247       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1248       break;
1249     }
1250     case 90:
1251     {
1252       windowTransform = WL_OUTPUT_TRANSFORM_90;
1253       break;
1254     }
1255     case 180:
1256     {
1257       windowTransform = WL_OUTPUT_TRANSFORM_180;
1258       break;
1259     }
1260     case 270:
1261     {
1262       windowTransform = WL_OUTPUT_TRANSFORM_270;
1263       break;
1264     }
1265     default:
1266     {
1267       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1268       break;
1269     }
1270   }
1271
1272   wl_egl_window_set_window_transform(mEglWindow, windowTransform);
1273 }
1274
1275 void WindowBaseEcoreWl::ResizeEglWindow(PositionSize positionSize)
1276 {
1277   wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1278 }
1279
1280 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1281 {
1282   // Check capability
1283   wl_egl_window_capability capability = static_cast<wl_egl_window_capability>(wl_egl_window_get_capabilities(mEglWindow));
1284   if(capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED)
1285   {
1286     mSupportedPreProtation = true;
1287     return true;
1288   }
1289   mSupportedPreProtation = false;
1290   return false;
1291 }
1292
1293 void WindowBaseEcoreWl::Move(PositionSize positionSize)
1294 {
1295   ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1296 }
1297
1298 void WindowBaseEcoreWl::Resize(PositionSize positionSize)
1299 {
1300   ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1301 }
1302
1303 void WindowBaseEcoreWl::MoveResize(PositionSize positionSize)
1304 {
1305   ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1306   ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1307 }
1308
1309 void WindowBaseEcoreWl::SetClass(const std::string& name, const std::string& className)
1310 {
1311   ecore_wl_window_title_set(mEcoreWindow, name.c_str());
1312   ecore_wl_window_class_name_set(mEcoreWindow, className.c_str());
1313 }
1314
1315 void WindowBaseEcoreWl::Raise()
1316 {
1317   // Use ecore_wl_window_activate to prevent the window shown without rendering
1318   ecore_wl_window_activate(mEcoreWindow);
1319 }
1320
1321 void WindowBaseEcoreWl::Lower()
1322 {
1323   ecore_wl_window_lower(mEcoreWindow);
1324 }
1325
1326 void WindowBaseEcoreWl::Activate()
1327 {
1328   ecore_wl_window_activate(mEcoreWindow);
1329 }
1330
1331 void WindowBaseEcoreWl::Maximize(bool maximize)
1332 {
1333 }
1334
1335 bool WindowBaseEcoreWl::IsMaximized() const
1336 {
1337   return false;
1338 }
1339
1340 void WindowBaseEcoreWl::SetMaximumSize(Dali::Window::WindowSize size)
1341 {
1342 }
1343
1344 void WindowBaseEcoreWl::Minimize(bool minimize)
1345 {
1346 }
1347
1348 bool WindowBaseEcoreWl::IsMinimized() const
1349 {
1350   return false;
1351 }
1352
1353 void WindowBaseEcoreWl::SetMimimumSize(Dali::Window::WindowSize size)
1354 {
1355 }
1356
1357 void WindowBaseEcoreWl::SetAvailableAnlges(const std::vector<int>& angles)
1358 {
1359   int rotations[4] = {0};
1360   DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size());
1361   for(std::size_t i = 0; i < angles.size(); ++i)
1362   {
1363     rotations[i] = static_cast<int>(angles[i]);
1364     DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1365   }
1366   ecore_wl_window_rotation_available_rotations_set(mEcoreWindow, rotations, angles.size());
1367 }
1368
1369 void WindowBaseEcoreWl::SetPreferredAngle(int angle)
1370 {
1371   ecore_wl_window_rotation_preferred_rotation_set(mEcoreWindow, angle);
1372 }
1373
1374 void WindowBaseEcoreWl::SetAcceptFocus(bool accept)
1375 {
1376   ecore_wl_window_focus_skip_set(mEcoreWindow, !accept);
1377 }
1378
1379 void WindowBaseEcoreWl::Show()
1380 {
1381   ecore_wl_window_show(mEcoreWindow);
1382 }
1383
1384 void WindowBaseEcoreWl::Hide()
1385 {
1386   ecore_wl_window_hide(mEcoreWindow);
1387 }
1388
1389 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1390 {
1391   return mSupportedAuxiliaryHints.size();
1392 }
1393
1394 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint(unsigned int index) const
1395 {
1396   if(index >= GetSupportedAuxiliaryHintCount())
1397   {
1398     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1399   }
1400
1401   return mSupportedAuxiliaryHints[index];
1402 }
1403
1404 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1405 {
1406   bool supported = false;
1407
1408   // Check if the hint is suppported
1409   for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1410   {
1411     if(*iter == hint)
1412     {
1413       supported = true;
1414       break;
1415     }
1416   }
1417
1418   if(!supported)
1419   {
1420     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1421     return 0;
1422   }
1423
1424   // Check if the hint is already added
1425   for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1426   {
1427     if(mAuxiliaryHints[i].first == hint)
1428     {
1429       // Just change the value
1430       mAuxiliaryHints[i].second = value;
1431
1432       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1433
1434       return i + 1; // id is index + 1
1435     }
1436   }
1437
1438   // Add the hint
1439   mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1440
1441   unsigned int id = mAuxiliaryHints.size();
1442
1443   ecore_wl_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1444
1445   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1446
1447   return id;
1448 }
1449
1450 bool WindowBaseEcoreWl::RemoveAuxiliaryHint(unsigned int id)
1451 {
1452   if(id == 0 || id > mAuxiliaryHints.size())
1453   {
1454     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1455     return false;
1456   }
1457
1458   mAuxiliaryHints[id - 1].second = std::string();
1459
1460   ecore_wl_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1461
1462   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1463
1464   return true;
1465 }
1466
1467 bool WindowBaseEcoreWl::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1468 {
1469   if(id == 0 || id > mAuxiliaryHints.size())
1470   {
1471     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1472     return false;
1473   }
1474
1475   mAuxiliaryHints[id - 1].second = value;
1476
1477   ecore_wl_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1478
1479   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1480
1481   return true;
1482 }
1483
1484 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue(unsigned int id) const
1485 {
1486   if(id == 0 || id > mAuxiliaryHints.size())
1487   {
1488     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1489     return std::string();
1490   }
1491
1492   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1493
1494   return mAuxiliaryHints[id - 1].second;
1495 }
1496
1497 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId(const std::string& hint) const
1498 {
1499   for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1500   {
1501     if(mAuxiliaryHints[i].first == hint)
1502     {
1503       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1504       return i + 1;
1505     }
1506   }
1507
1508   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1509
1510   return 0;
1511 }
1512
1513 void WindowBaseEcoreWl::SetInputRegion(const Rect<int>& inputRegion)
1514 {
1515   ecore_wl_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1516 }
1517
1518 void WindowBaseEcoreWl::SetType(Dali::WindowType type)
1519 {
1520   Ecore_Wl_Window_Type windowType;
1521
1522   switch(type)
1523   {
1524     case Dali::WindowType::NORMAL:
1525     {
1526       windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1527       break;
1528     }
1529     case Dali::WindowType::NOTIFICATION:
1530     {
1531       windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1532       break;
1533     }
1534     case Dali::WindowType::UTILITY:
1535     {
1536       windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1537       break;
1538     }
1539     case Dali::WindowType::DIALOG:
1540     {
1541       windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1542       break;
1543     }
1544     default:
1545     {
1546       windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1547       break;
1548     }
1549   }
1550
1551   ecore_wl_window_type_set(mEcoreWindow, windowType);
1552 }
1553
1554 Dali::WindowType WindowBaseEcoreWl::GetType() const
1555 {
1556   return Dali::WindowType::NORMAL;
1557 }
1558
1559 Dali::WindowOperationResult WindowBaseEcoreWl::SetNotificationLevel(Dali::WindowNotificationLevel level)
1560 {
1561   while(!mTizenPolicy)
1562   {
1563     wl_display_dispatch_queue(mDisplay, mEventQueue);
1564   }
1565
1566   int notificationLevel;
1567
1568   switch(level)
1569   {
1570     case Dali::WindowNotificationLevel::NONE:
1571     {
1572       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1573       break;
1574     }
1575     case Dali::WindowNotificationLevel::BASE:
1576     {
1577       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1578       break;
1579     }
1580     case Dali::WindowNotificationLevel::MEDIUM:
1581     {
1582       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1583       break;
1584     }
1585     case Dali::WindowNotificationLevel::HIGH:
1586     {
1587       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1588       break;
1589     }
1590     case Dali::WindowNotificationLevel::TOP:
1591     {
1592       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1593       break;
1594     }
1595     default:
1596     {
1597       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level);
1598       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1599       break;
1600     }
1601   }
1602
1603   mNotificationLevelChangeDone = false;
1604   mNotificationChangeState     = TIZEN_POLICY_ERROR_STATE_NONE;
1605
1606   tizen_policy_set_notification_level(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), notificationLevel);
1607
1608   int count = 0;
1609
1610   while(!mNotificationLevelChangeDone && count < 3)
1611   {
1612     ecore_wl_flush();
1613     wl_display_dispatch_queue(mDisplay, mEventQueue);
1614     count++;
1615   }
1616
1617   if(!mNotificationLevelChangeDone)
1618   {
1619     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1620     return Dali::WindowOperationResult::UNKNOWN_ERROR;
1621   }
1622   else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1623   {
1624     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level);
1625     return Dali::WindowOperationResult::PERMISSION_DENIED;
1626   }
1627
1628   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1629
1630   return Dali::WindowOperationResult::SUCCEED;
1631 }
1632
1633 Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
1634 {
1635   while(!mTizenPolicy)
1636   {
1637     wl_display_dispatch_queue(mDisplay, mEventQueue);
1638   }
1639
1640   int count = 0;
1641
1642   while(!mNotificationLevelChangeDone && count < 3)
1643   {
1644     ecore_wl_flush();
1645     wl_display_dispatch_queue(mDisplay, mEventQueue);
1646     count++;
1647   }
1648
1649   if(!mNotificationLevelChangeDone)
1650   {
1651     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1652     return Dali::Window::NotificationLevel::NONE;
1653   }
1654
1655   Dali::WindowNotificationLevel level;
1656
1657   switch(mNotificationLevel)
1658   {
1659     case TIZEN_POLICY_LEVEL_NONE:
1660     {
1661       level = Dali::WindowNotificationLevel::NONE;
1662       break;
1663     }
1664     case TIZEN_POLICY_LEVEL_DEFAULT:
1665     {
1666       level = Dali::WindowNotificationLevel::BASE;
1667       break;
1668     }
1669     case TIZEN_POLICY_LEVEL_MEDIUM:
1670     {
1671       level = Dali::WindowNotificationLevel::MEDIUM;
1672       break;
1673     }
1674     case TIZEN_POLICY_LEVEL_HIGH:
1675     {
1676       level = Dali::WindowNotificationLevel::HIGH;
1677       break;
1678     }
1679     case TIZEN_POLICY_LEVEL_TOP:
1680     {
1681       level = Dali::WindowNotificationLevel::TOP;
1682       break;
1683     }
1684     default:
1685     {
1686       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
1687       level = Dali::WindowNotificationLevel::NONE;
1688       break;
1689     }
1690   }
1691
1692   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel);
1693
1694   return level;
1695 }
1696
1697 void WindowBaseEcoreWl::SetOpaqueState(bool opaque)
1698 {
1699   while(!mTizenPolicy)
1700   {
1701     wl_display_dispatch_queue(mDisplay, mEventQueue);
1702   }
1703
1704   tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
1705 }
1706
1707 Dali::WindowOperationResult WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1708 {
1709   while(!mTizenPolicy)
1710   {
1711     wl_display_dispatch_queue(mDisplay, mEventQueue);
1712   }
1713
1714   mScreenOffModeChangeDone  = false;
1715   mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1716
1717   unsigned int mode = 0;
1718
1719   switch(screenOffMode)
1720   {
1721     case WindowScreenOffMode::TIMEOUT:
1722     {
1723       mode = 0;
1724       break;
1725     }
1726     case WindowScreenOffMode::NEVER:
1727     {
1728       mode = 1;
1729       break;
1730     }
1731   }
1732
1733   tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), mode);
1734
1735   int count = 0;
1736
1737   while(!mScreenOffModeChangeDone && count < 3)
1738   {
1739     ecore_wl_flush();
1740     wl_display_dispatch_queue(mDisplay, mEventQueue);
1741     count++;
1742   }
1743
1744   if(!mScreenOffModeChangeDone)
1745   {
1746     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
1747     return Dali::WindowOperationResult::UNKNOWN_ERROR;
1748   }
1749   else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1750   {
1751     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
1752     return Dali::WindowOperationResult::PERMISSION_DENIED;
1753   }
1754
1755   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
1756
1757   return Dali::WindowOperationResult::SUCCEED;
1758 }
1759
1760 WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
1761 {
1762   while(!mTizenPolicy)
1763   {
1764     wl_display_dispatch_queue(mDisplay, mEventQueue);
1765   }
1766
1767   int count = 0;
1768
1769   while(!mScreenOffModeChangeDone && count < 3)
1770   {
1771     ecore_wl_flush();
1772     wl_display_dispatch_queue(mDisplay, mEventQueue);
1773     count++;
1774   }
1775
1776   if(!mScreenOffModeChangeDone)
1777   {
1778     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
1779     return WindowScreenOffMode::TIMEOUT;
1780   }
1781
1782   WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
1783
1784   switch(mScreenOffMode)
1785   {
1786     case 0:
1787     {
1788       screenMode = WindowScreenOffMode::TIMEOUT;
1789       break;
1790     }
1791     case 1:
1792     {
1793       screenMode = WindowScreenOffMode::NEVER;
1794       break;
1795     }
1796   }
1797
1798   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
1799
1800   return screenMode;
1801 }
1802
1803 Dali::WindowOperationResult WindowBaseEcoreWl::SetBrightness(int brightness)
1804 {
1805   while(!mTizenDisplayPolicy)
1806   {
1807     wl_display_dispatch_queue(mDisplay, mEventQueue);
1808   }
1809
1810   mBrightnessChangeDone  = false;
1811   mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1812
1813   tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl_window_surface_get(mEcoreWindow), brightness);
1814
1815   int count = 0;
1816
1817   while(!mBrightnessChangeDone && count < 3)
1818   {
1819     ecore_wl_flush();
1820     wl_display_dispatch_queue(mDisplay, mEventQueue);
1821     count++;
1822   }
1823
1824   if(!mBrightnessChangeDone)
1825   {
1826     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
1827     return Dali::WindowOperationResult::UNKNOWN_ERROR;
1828   }
1829   else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1830   {
1831     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness);
1832     return Dali::WindowOperationResult::PERMISSION_DENIED;
1833   }
1834
1835   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness);
1836
1837   return Dali::WindowOperationResult::SUCCEED;
1838 }
1839
1840 int WindowBaseEcoreWl::GetBrightness() const
1841 {
1842   while(!mTizenDisplayPolicy)
1843   {
1844     wl_display_dispatch_queue(mDisplay, mEventQueue);
1845   }
1846
1847   int count = 0;
1848
1849   while(!mBrightnessChangeDone && count < 3)
1850   {
1851     ecore_wl_flush();
1852     wl_display_dispatch_queue(mDisplay, mEventQueue);
1853     count++;
1854   }
1855
1856   if(!mBrightnessChangeDone)
1857   {
1858     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
1859     return 0;
1860   }
1861
1862   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness);
1863
1864   return mBrightness;
1865 }
1866
1867 bool WindowBaseEcoreWl::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
1868 {
1869   Ecore_Wl_Window_Keygrab_Mode mode;
1870
1871   switch(grabMode)
1872   {
1873     case KeyGrab::TOPMOST:
1874     {
1875       mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1876       break;
1877     }
1878     case KeyGrab::SHARED:
1879     {
1880       mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1881       break;
1882     }
1883     case KeyGrab::OVERRIDE_EXCLUSIVE:
1884     {
1885       mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1886       break;
1887     }
1888     case KeyGrab::EXCLUSIVE:
1889     {
1890       mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1891       break;
1892     }
1893     default:
1894     {
1895       return false;
1896     }
1897   }
1898
1899   return ecore_wl_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
1900 }
1901
1902 bool WindowBaseEcoreWl::UngrabKey(Dali::KEY key)
1903 {
1904   return ecore_wl_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
1905 }
1906
1907 bool WindowBaseEcoreWl::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
1908 {
1909   int keyCount         = key.Count();
1910   int keyGrabModeCount = grabMode.Count();
1911
1912   if(keyCount != keyGrabModeCount || keyCount == 0)
1913   {
1914     return false;
1915   }
1916
1917   eina_init();
1918
1919   Eina_List*                    keyList = NULL;
1920   Ecore_Wl_Window_Keygrab_Info* info    = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1921
1922   for(int index = 0; index < keyCount; ++index)
1923   {
1924     info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
1925
1926     switch(grabMode[index])
1927     {
1928       case KeyGrab::TOPMOST:
1929       {
1930         info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1931         break;
1932       }
1933       case KeyGrab::SHARED:
1934       {
1935         info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1936         break;
1937       }
1938       case KeyGrab::OVERRIDE_EXCLUSIVE:
1939       {
1940         info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1941         break;
1942       }
1943       case KeyGrab::EXCLUSIVE:
1944       {
1945         info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1946         break;
1947       }
1948       default:
1949       {
1950         info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1951         break;
1952       }
1953     }
1954
1955     keyList = eina_list_append(keyList, &info);
1956   }
1957
1958   Eina_List* grabList = ecore_wl_window_keygrab_list_set(mEcoreWindow, keyList);
1959
1960   result.Resize(keyCount, true);
1961
1962   Eina_List* l        = NULL;
1963   Eina_List* m        = NULL;
1964   void*      listData = NULL;
1965   void*      data     = NULL;
1966   if(grabList != NULL)
1967   {
1968     EINA_LIST_FOREACH(grabList, m, data)
1969     {
1970       int index = 0;
1971       EINA_LIST_FOREACH(keyList, l, listData)
1972       {
1973         if(static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key == NULL)
1974         {
1975           DALI_LOG_ERROR("input key list has null data!");
1976           break;
1977         }
1978
1979         if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
1980         {
1981           result[index] = false;
1982         }
1983         ++index;
1984       }
1985     }
1986   }
1987
1988   delete[] info;
1989
1990   eina_list_free(keyList);
1991   eina_list_free(grabList);
1992   eina_shutdown();
1993
1994   return true;
1995 }
1996
1997 bool WindowBaseEcoreWl::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
1998 {
1999   int keyCount = key.Count();
2000   if(keyCount == 0)
2001   {
2002     return false;
2003   }
2004
2005   eina_init();
2006
2007   Eina_List*                    keyList = NULL;
2008   Ecore_Wl_Window_Keygrab_Info* info    = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2009
2010   for(int index = 0; index < keyCount; ++index)
2011   {
2012     info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2013     keyList         = eina_list_append(keyList, &info);
2014   }
2015
2016   Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset(mEcoreWindow, keyList);
2017
2018   result.Resize(keyCount, true);
2019
2020   Eina_List* l        = NULL;
2021   Eina_List* m        = NULL;
2022   void*      listData = NULL;
2023   void*      data     = NULL;
2024
2025   if(ungrabList != NULL)
2026   {
2027     EINA_LIST_FOREACH(ungrabList, m, data)
2028     {
2029       int index = 0;
2030       EINA_LIST_FOREACH(keyList, l, listData)
2031       {
2032         if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
2033         {
2034           result[index] = false;
2035         }
2036         ++index;
2037       }
2038     }
2039   }
2040
2041   delete[] info;
2042
2043   eina_list_free(keyList);
2044   eina_list_free(ungrabList);
2045   eina_shutdown();
2046
2047   return true;
2048 }
2049
2050 void WindowBaseEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2051 {
2052   // calculate DPI
2053   float xres, yres;
2054
2055   // 1 inch = 25.4 millimeters
2056   xres = ecore_wl_dpi_get();
2057   yres = ecore_wl_dpi_get();
2058
2059   dpiHorizontal = int(xres + 0.5f); // rounding
2060   dpiVertical   = int(yres + 0.5f);
2061 }
2062
2063 int WindowBaseEcoreWl::GetOrientation() const
2064 {
2065   int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2066   if(mSupportedPreProtation)
2067   {
2068     orientation = 0;
2069   }
2070   return orientation;
2071 }
2072
2073 int WindowBaseEcoreWl::GetScreenRotationAngle()
2074 {
2075   int transform = 0;
2076
2077   if(ecore_wl_window_ignore_output_transform_get(mEcoreWindow))
2078   {
2079     transform = 0;
2080   }
2081   else
2082   {
2083     transform = ecore_wl_output_transform_get(ecore_wl_window_output_find(mEcoreWindow));
2084   }
2085
2086   mScreenRotationAngle = transform * 90;
2087   return mScreenRotationAngle;
2088 }
2089
2090 void WindowBaseEcoreWl::SetWindowRotationAngle(int degree)
2091 {
2092   mWindowRotationAngle = degree;
2093   ecore_wl_window_rotation_set(mEcoreWindow, degree);
2094 }
2095
2096 void WindowBaseEcoreWl::WindowRotationCompleted(int degree, int width, int height)
2097 {
2098   ecore_wl_window_rotation_change_done_send(mEcoreWindow);
2099 }
2100
2101 void WindowBaseEcoreWl::SetTransparency(bool transparent)
2102 {
2103   ecore_wl_window_alpha_set(mEcoreWindow, transparent);
2104 }
2105
2106 void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize)
2107 {
2108   mEcoreWindow = ecore_wl_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
2109
2110   if(mEcoreWindow == 0)
2111   {
2112     DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2113   }
2114 }
2115
2116 void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase, bool belowParent)
2117 {
2118   Ecore_Wl_Window* ecoreParent = NULL;
2119   if(parentWinBase)
2120   {
2121     WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>(parentWinBase);
2122     ecoreParent                     = winBaseEcore->mEcoreWindow;
2123   }
2124   ecore_wl_window_parent_set(mEcoreWindow, ecoreParent);
2125 }
2126
2127 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2128 {
2129   return -1;
2130 }
2131
2132 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2133 {
2134   return -1;
2135 }
2136
2137 void WindowBaseEcoreWl::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2138 {
2139 }
2140
2141 void WindowBaseEcoreWl::InitializeIme()
2142 {
2143 }
2144
2145 void WindowBaseEcoreWl::ImeWindowReadyToRender()
2146 {
2147 }
2148
2149 void WindowBaseEcoreWl::RequestMoveToServer()
2150 {
2151 }
2152
2153 void WindowBaseEcoreWl::RequestResizeToServer(WindowResizeDirection direction)
2154 {
2155 }
2156
2157 void WindowBaseEcoreWl::EnableFloatingMode(bool enable)
2158 {
2159 }
2160
2161 bool WindowBaseEcoreWl::IsFloatingModeEnabled() const
2162 {
2163   return false;
2164 }
2165
2166 void WindowBaseEcoreWl::IncludeInputRegion(const Rect<int>& inputRegion)
2167 {
2168 }
2169
2170 void WindowBaseEcoreWl::ExcludeInputRegion(const Rect<int>& inputRegion)
2171 {
2172 }
2173
2174 } // namespace Adaptor
2175
2176 } // namespace Internal
2177
2178 } // namespace Dali
2179
2180 #pragma GCC diagnostic pop