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