Merge "Modify window configure notification event callback" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
21
22 // CLASS HEADER
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
24
25 // INTERNAL HEADERS
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/window-system/common/window-impl.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/window-system/common/window-system.h>
30
31 // EXTERNAL_HEADERS
32 #include <Ecore_Input.h>
33 #include <dali/integration-api/debug.h>
34 #include <dali/public-api/adaptor-framework/window-enumerations.h>
35 #include <dali/public-api/events/mouse-button.h>
36 #include <dali/public-api/object/any.h>
37 #include <vconf-keys.h>
38 #include <vconf.h>
39 #include <wayland-egl-tizen.h>
40
41 namespace Dali
42 {
43 namespace Internal
44 {
45 namespace Adaptor
46 {
47 namespace
48 {
49 #if defined(DEBUG_ENABLED)
50 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
51 #endif
52
53 const uint32_t     MAX_TIZEN_CLIENT_VERSION = 7;
54 const unsigned int PRIMARY_TOUCH_BUTTON_ID  = 1;
55
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
58 // DBUS accessibility
59 const char* BUS       = "org.enlightenment.wm-screen-reader";
60 const char* INTERFACE = "org.tizen.GestureNavigation";
61 const char* PATH      = "/org/tizen/GestureNavigation";
62
63 struct KeyCodeMap
64 {
65   xkb_keysym_t  keySym;
66   xkb_keycode_t keyCode;
67   bool          isKeyCode;
68 };
69
70 /**
71  * Get the device name from the provided ecore key event
72  */
73 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
74 {
75   const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
76
77   if(ecoreDeviceName)
78   {
79     result = ecoreDeviceName;
80   }
81 }
82
83 /**
84  * Get the device class from the provided ecore event
85  */
86 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
87 {
88   switch(ecoreDeviceClass)
89   {
90     case ECORE_DEVICE_CLASS_SEAT:
91     {
92       deviceClass = Device::Class::USER;
93       break;
94     }
95     case ECORE_DEVICE_CLASS_KEYBOARD:
96     {
97       deviceClass = Device::Class::KEYBOARD;
98       break;
99     }
100     case ECORE_DEVICE_CLASS_MOUSE:
101     {
102       deviceClass = Device::Class::MOUSE;
103       break;
104     }
105     case ECORE_DEVICE_CLASS_TOUCH:
106     {
107       deviceClass = Device::Class::TOUCH;
108       break;
109     }
110     case ECORE_DEVICE_CLASS_PEN:
111     {
112       deviceClass = Device::Class::PEN;
113       break;
114     }
115     case ECORE_DEVICE_CLASS_POINTER:
116     {
117       deviceClass = Device::Class::POINTER;
118       break;
119     }
120     case ECORE_DEVICE_CLASS_GAMEPAD:
121     {
122       deviceClass = Device::Class::GAMEPAD;
123       break;
124     }
125     default:
126     {
127       deviceClass = Device::Class::NONE;
128       break;
129     }
130   }
131 }
132
133 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
134 {
135   switch(ecoreDeviceSubclass)
136   {
137     case ECORE_DEVICE_SUBCLASS_FINGER:
138     {
139       deviceSubclass = Device::Subclass::FINGER;
140       break;
141     }
142     case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
143     {
144       deviceSubclass = Device::Subclass::FINGERNAIL;
145       break;
146     }
147     case ECORE_DEVICE_SUBCLASS_KNUCKLE:
148     {
149       deviceSubclass = Device::Subclass::KNUCKLE;
150       break;
151     }
152     case ECORE_DEVICE_SUBCLASS_PALM:
153     {
154       deviceSubclass = Device::Subclass::PALM;
155       break;
156     }
157     case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
158     {
159       deviceSubclass = Device::Subclass::HAND_SIDE;
160       break;
161     }
162     case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
163     {
164       deviceSubclass = Device::Subclass::HAND_FLAT;
165       break;
166     }
167     case ECORE_DEVICE_SUBCLASS_PEN_TIP:
168     {
169       deviceSubclass = Device::Subclass::PEN_TIP;
170       break;
171     }
172     case ECORE_DEVICE_SUBCLASS_TRACKPAD:
173     {
174       deviceSubclass = Device::Subclass::TRACKPAD;
175       break;
176     }
177     case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
178     {
179       deviceSubclass = Device::Subclass::TRACKPOINT;
180       break;
181     }
182     case ECORE_DEVICE_SUBCLASS_TRACKBALL:
183     {
184       deviceSubclass = Device::Subclass::TRACKBALL;
185       break;
186     }
187     case ECORE_DEVICE_SUBCLASS_REMOCON:
188     {
189       deviceSubclass = Device::Subclass::REMOCON;
190       break;
191     }
192     case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
193     {
194       deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
195       break;
196     }
197     default:
198     {
199       deviceSubclass = Device::Subclass::NONE;
200       break;
201     }
202   }
203 }
204
205 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
206 {
207   KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
208   if(foundKeyCode->isKeyCode)
209   {
210     return;
211   }
212
213   xkb_keysym_t        keySym  = foundKeyCode->keySym;
214   int                 nsyms   = 0;
215   const xkb_keysym_t* symsOut = NULL;
216
217   nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
218
219   if(nsyms && symsOut)
220   {
221     if(*symsOut == keySym)
222     {
223       foundKeyCode->keyCode   = key;
224       foundKeyCode->isKeyCode = true;
225     }
226   }
227 }
228
229 /////////////////////////////////////////////////////////////////////////////////////////////////
230 // Window Callbacks
231 /////////////////////////////////////////////////////////////////////////////////////////////////
232
233 /// Called when the window iconify state is changed.
234 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
235 {
236   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
237   if(windowBase)
238   {
239     return windowBase->OnIconifyStateChanged(data, type, event);
240   }
241
242   return ECORE_CALLBACK_PASS_ON;
243 }
244
245 /// Called when the window gains focus
246 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
247 {
248   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
249   if(windowBase)
250   {
251     return windowBase->OnFocusIn(data, type, event);
252   }
253
254   return ECORE_CALLBACK_PASS_ON;
255 }
256
257 /// Called when the window loses focus
258 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
259 {
260   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
261   if(windowBase)
262   {
263     return windowBase->OnFocusOut(data, type, event);
264   }
265
266   return ECORE_CALLBACK_PASS_ON;
267 }
268
269 /// Called when the output is transformed
270 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
271 {
272   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
273   if(windowBase)
274   {
275     return windowBase->OnOutputTransform(data, type, event);
276   }
277
278   return ECORE_CALLBACK_PASS_ON;
279 }
280
281 /// Called when the output transform should be ignored
282 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
283 {
284   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
285   if(windowBase)
286   {
287     return windowBase->OnIgnoreOutputTransform(data, type, event);
288   }
289
290   return ECORE_CALLBACK_PASS_ON;
291 }
292
293 /**
294  * Called when rotate event is recevied.
295  */
296 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
297 {
298   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
299   if(windowBase)
300   {
301     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
302     windowBase->OnRotation(data, type, event);
303   }
304   return ECORE_CALLBACK_PASS_ON;
305 }
306
307 /**
308  * Called when configure event is recevied.
309  */
310 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
311 {
312   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
313   if(windowBase)
314   {
315     windowBase->OnConfiguration(data, type, event);
316   }
317   return ECORE_CALLBACK_PASS_ON;
318 }
319
320 /////////////////////////////////////////////////////////////////////////////////////////////////
321 // Touch Callbacks
322 /////////////////////////////////////////////////////////////////////////////////////////////////
323
324 /**
325  * Called when a touch down is received.
326  */
327 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
328 {
329   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
330   if(windowBase)
331   {
332     windowBase->OnMouseButtonDown(data, type, event);
333   }
334   return ECORE_CALLBACK_PASS_ON;
335 }
336
337 /**
338  * Called when a touch up is received.
339  */
340 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
341 {
342   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
343   if(windowBase)
344   {
345     windowBase->OnMouseButtonUp(data, type, event);
346   }
347   return ECORE_CALLBACK_PASS_ON;
348 }
349
350 /**
351  * Called when a touch motion is received.
352  */
353 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
354 {
355   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
356   if(windowBase)
357   {
358     windowBase->OnMouseButtonMove(data, type, event);
359   }
360   return ECORE_CALLBACK_PASS_ON;
361 }
362
363 /**
364  * Called when a touch is canceled.
365  */
366 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
367 {
368   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
369   if(windowBase)
370   {
371     windowBase->OnMouseButtonCancel(data, type, event);
372   }
373   return ECORE_CALLBACK_PASS_ON;
374 }
375
376 /**
377  * Called when a mouse wheel is received.
378  */
379 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
380 {
381   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
382   if(windowBase)
383   {
384     windowBase->OnMouseWheel(data, type, event);
385   }
386   return ECORE_CALLBACK_PASS_ON;
387 }
388
389 /**
390  * Called when a detent rotation event is recevied.
391  */
392 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
393 {
394   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
395   if(windowBase)
396   {
397     windowBase->OnDetentRotation(data, type, event);
398   }
399   return ECORE_CALLBACK_PASS_ON;
400 }
401
402 /////////////////////////////////////////////////////////////////////////////////////////////////
403 // Key Callbacks
404 /////////////////////////////////////////////////////////////////////////////////////////////////
405
406 /**
407  * Called when a key down is received.
408  */
409 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
410 {
411   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
412   if(windowBase)
413   {
414     windowBase->OnKeyDown(data, type, event);
415   }
416   return ECORE_CALLBACK_PASS_ON;
417 }
418
419 /**
420  * Called when a key up is received.
421  */
422 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
423 {
424   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
425   if(windowBase)
426   {
427     windowBase->OnKeyUp(data, type, event);
428   }
429   return ECORE_CALLBACK_PASS_ON;
430 }
431
432 /////////////////////////////////////////////////////////////////////////////////////////////////
433 // Selection Callbacks
434 /////////////////////////////////////////////////////////////////////////////////////////////////
435
436 /**
437  * Called when the source window notifies us the content in clipboard is selected.
438  */
439 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
440 {
441   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
442   if(windowBase)
443   {
444     windowBase->OnDataSend(data, type, event);
445   }
446   return ECORE_CALLBACK_PASS_ON;
447 }
448
449 /**
450 * Called when the source window sends us about the selected content.
451 * For example, when item is selected in the clipboard.
452 */
453 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
454 {
455   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
456   if(windowBase)
457   {
458     windowBase->OnDataReceive(data, type, event);
459   }
460   return ECORE_CALLBACK_PASS_ON;
461 }
462
463 /////////////////////////////////////////////////////////////////////////////////////////////////
464 // Effect Start/End Callbacks
465 /////////////////////////////////////////////////////////////////////////////////////////////////
466
467 /**
468  * Called when transition animation of the window's shown/hidden is started by window manager.
469  */
470 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
471 {
472   WindowBaseEcoreWl2*           windowBase  = static_cast<WindowBaseEcoreWl2*>(data);
473   Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
474   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
475   if(windowBase)
476   {
477     if(effectStart->type < 3) // only under restack
478     {
479       windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
480     }
481   }
482   return ECORE_CALLBACK_PASS_ON;
483 }
484
485 /**
486  * Called when transition animation of the window's shown/hidden is ended by window manager.
487  */
488 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
489 {
490   Ecore_Wl2_Event_Effect_Start* effectEnd  = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
491   WindowBaseEcoreWl2*           windowBase = static_cast<WindowBaseEcoreWl2*>(data);
492   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
493   if(windowBase)
494   {
495     if(effectEnd->type < 3) // only under restack
496     {
497       windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
498     }
499   }
500   return ECORE_CALLBACK_PASS_ON;
501 }
502
503 /////////////////////////////////////////////////////////////////////////////////////////////////
504 // Keyboard Repeat Settings Changed Callbacks
505 /////////////////////////////////////////////////////////////////////////////////////////////////
506
507 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
508 {
509   Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed* keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event);
510   WindowBaseEcoreWl2*                           windowBase     = static_cast<WindowBaseEcoreWl2*>(data);
511   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id);
512   if(windowBase)
513   {
514     windowBase->OnKeyboardRepeatSettingsChanged();
515   }
516
517   return ECORE_CALLBACK_RENEW;
518 }
519
520 /////////////////////////////////////////////////////////////////////////////////////////////////
521 // Keymap Changed Callbacks
522 /////////////////////////////////////////////////////////////////////////////////////////////////
523
524 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
525 {
526   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
527   if(windowBase)
528   {
529     windowBase->KeymapChanged(data, type, event);
530   }
531
532   return ECORE_CALLBACK_RENEW;
533 }
534
535 /////////////////////////////////////////////////////////////////////////////////////////////////
536 // Font Callbacks
537 /////////////////////////////////////////////////////////////////////////////////////////////////
538
539 /**
540  * Called when a font name is changed.
541  */
542 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
543 {
544   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
545   if(windowBase)
546   {
547     windowBase->OnFontNameChanged();
548   }
549 }
550
551 /**
552  * Called when a font size is changed.
553  */
554 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
555 {
556   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
557   if(windowBase)
558   {
559     windowBase->OnFontSizeChanged();
560   }
561 }
562
563 /////////////////////////////////////////////////////////////////////////////////////////////////
564 // Window Redraw Request Event Callbacks
565 /////////////////////////////////////////////////////////////////////////////////////////////////
566
567 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
568 {
569   Ecore_Wl2_Event_Window_Redraw_Request* windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event);
570   WindowBaseEcoreWl2*                    windowBase          = static_cast<WindowBaseEcoreWl2*>(data);
571   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win);
572   if(windowBase)
573   {
574     windowBase->OnEcoreEventWindowRedrawRequest();
575   }
576
577   return ECORE_CALLBACK_RENEW;
578 }
579
580 /////////////////////////////////////////////////////////////////////////////////////////////////
581 // ElDBus Accessibility Callbacks
582 /////////////////////////////////////////////////////////////////////////////////////////////////
583
584 #ifdef DALI_ELDBUS_AVAILABLE
585 // Callback for Ecore ElDBus accessibility events.
586 static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
587 {
588   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(context);
589   if(windowBase)
590   {
591     windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
592   }
593 }
594 #endif // DALI_ELDBUS_AVAILABLE
595
596 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
597 {
598   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
599   if(windowBase)
600   {
601     windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
602   }
603 }
604
605 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
606 {
607   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
608   if(windowBase)
609   {
610     windowBase->RegistryGlobalCallbackRemove(data, registry, id);
611   }
612 }
613
614 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
615 {
616 }
617
618 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)
619 {
620 }
621
622 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
623 {
624   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
625   if(windowBase)
626   {
627     windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
628   }
629 }
630
631 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
632 {
633 }
634
635 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
636 {
637   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
638   if(windowBase)
639   {
640     windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
641   }
642 }
643
644 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
645 {
646 }
647
648 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
649 {
650 }
651
652 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
653 {
654 }
655
656 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
657 {
658 }
659
660 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)
661 {
662 }
663
664 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
665 {
666   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
667   if(windowBase)
668   {
669     windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
670   }
671 }
672
673 const struct wl_registry_listener registryListener =
674   {
675     RegistryGlobalCallback,
676     RegistryGlobalCallbackRemove};
677
678 const struct tizen_policy_listener tizenPolicyListener =
679   {
680     TizenPolicyConformant,
681     TizenPolicyConformantArea,
682     TizenPolicyNotificationChangeDone,
683     TizenPolicyTransientForDone,
684     TizenPolicyScreenModeChangeDone,
685     TizenPolicyIconifyStateChanged,
686     TizenPolicySupportedAuxiliaryHints,
687     TizenPolicyAllowedAuxiliaryHint,
688     TizenPolicyAuxiliaryMessage,
689     TizenPolicyConformantRegion};
690
691 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
692   {
693     DisplayPolicyBrightnessChangeDone};
694
695 } // unnamed namespace
696
697 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
698 : mEcoreEventHandler(),
699   mEcoreWindow(nullptr),
700   mWlSurface(nullptr),
701   mEglWindow(nullptr),
702   mDisplay(nullptr),
703   mEventQueue(nullptr),
704   mTizenPolicy(nullptr),
705   mTizenDisplayPolicy(nullptr),
706   mKeyMap(nullptr),
707   mSupportedAuxiliaryHints(),
708   mAuxiliaryHints(),
709   mNotificationLevel(-1),
710   mNotificationChangeState(0),
711   mNotificationLevelChangeDone(true),
712   mScreenOffMode(0),
713   mScreenOffModeChangeState(0),
714   mScreenOffModeChangeDone(true),
715   mBrightness(0),
716   mBrightnessChangeState(0),
717   mBrightnessChangeDone(true),
718   mVisible(true),
719   mWindowPositionSize(positionSize),
720   mOwnSurface(false),
721   mMoveResizeSerial(0),
722   mLastSubmittedMoveResizeSerial(0),
723   mWindowRotationAngle(0),
724   mScreenRotationAngle(0),
725   mSupportedPreProtation(0)
726 #ifdef DALI_ELDBUS_AVAILABLE
727   ,
728   mSystemConnection(NULL)
729 #endif
730 {
731   Initialize(positionSize, surface, isTransparent);
732 }
733
734 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
735 {
736 #ifdef DALI_ELDBUS_AVAILABLE
737   // Close down ElDBus connections.
738   if(mSystemConnection)
739   {
740     eldbus_connection_unref(mSystemConnection);
741   }
742 #endif // DALI_ELDBUS_AVAILABLE
743
744   vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
745   vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
746
747   for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
748   {
749     ecore_event_handler_del(*iter);
750   }
751   mEcoreEventHandler.Clear();
752
753   if(mEventQueue)
754   {
755     wl_event_queue_destroy(mEventQueue);
756   }
757
758   mSupportedAuxiliaryHints.clear();
759   mAuxiliaryHints.clear();
760
761   if(mEglWindow != NULL)
762   {
763     wl_egl_window_destroy(mEglWindow);
764     mEglWindow = NULL;
765   }
766
767   if(mOwnSurface)
768   {
769     ecore_wl2_window_free(mEcoreWindow);
770
771     WindowSystem::Shutdown();
772   }
773 }
774
775 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
776 {
777   if(surface.Empty() == false)
778   {
779     // check we have a valid type
780     DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
781
782     mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
783   }
784   else
785   {
786     // we own the surface about to created
787     WindowSystem::Initialize();
788
789     mOwnSurface = true;
790     CreateWindow(positionSize);
791   }
792
793   mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
794
795   SetTransparency(isTransparent);
796
797   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
798   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
799   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
800   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
801   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
802
803   // Register Rotate event
804   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
805
806   // Register Configure event
807   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
808
809   // Register Touch events
810   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
811   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
812   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
813   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
814
815   // Register Mouse wheel events
816   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
817
818   // Register Detent event
819   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
820
821   // Register Key events
822   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
823   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
824
825   // Register Selection event - clipboard selection
826   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
827   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
828
829   // Register Effect Start/End event
830   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
831   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
832
833   // Register Keyboard repeat event
834   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
835
836   // Register Window redraw request event
837   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
838
839   // Register Vconf notify - font name and size
840   vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
841   vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
842
843   InitializeEcoreElDBus();
844
845   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
846   mDisplay                   = ecore_wl2_display_get(display);
847
848   if(mDisplay)
849   {
850     wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
851     if(displayWrapper)
852     {
853       mEventQueue = wl_display_create_queue(mDisplay);
854       if(mEventQueue)
855       {
856         wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
857
858         wl_registry* registry = wl_display_get_registry(displayWrapper);
859         wl_registry_add_listener(registry, &registryListener, this);
860       }
861
862       wl_proxy_wrapper_destroy(displayWrapper);
863     }
864   }
865
866   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
867
868   if(ecoreWlInput)
869   {
870     mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
871
872     mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
873   }
874
875   // get auxiliary hint
876   Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
877   if(hints)
878   {
879     Eina_List* l    = NULL;
880     char*      hint = NULL;
881
882     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))))
883     {
884       mSupportedAuxiliaryHints.push_back(hint);
885
886       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
887     }
888   }
889 }
890
891 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
892 {
893   Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
894   Eina_Bool                                    handled(ECORE_CALLBACK_PASS_ON);
895
896   if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
897   {
898     if(iconifyChangedEvent->iconified == EINA_TRUE)
899     {
900       mIconifyChangedSignal.Emit(true);
901     }
902     else
903     {
904       mIconifyChangedSignal.Emit(false);
905     }
906     handled = ECORE_CALLBACK_DONE;
907   }
908
909   return handled;
910 }
911
912 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
913 {
914   Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
915
916   if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
917   {
918     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
919
920     mFocusChangedSignal.Emit(true);
921   }
922
923   return ECORE_CALLBACK_PASS_ON;
924 }
925
926 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
927 {
928   Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
929
930   if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
931   {
932     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
933
934     mFocusChangedSignal.Emit(false);
935   }
936
937   return ECORE_CALLBACK_PASS_ON;
938 }
939
940 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
941 {
942   Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
943
944   if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
945   {
946     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
947
948     mScreenRotationAngle = GetScreenRotationAngle();
949
950     mOutputTransformedSignal.Emit();
951   }
952
953   return ECORE_CALLBACK_PASS_ON;
954 }
955
956 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
957 {
958   Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
959
960   if(ignoreTransformEvent->win == mEcoreWindow)
961   {
962     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
963
964     mScreenRotationAngle = GetScreenRotationAngle();
965
966     mOutputTransformedSignal.Emit();
967   }
968
969   return ECORE_CALLBACK_PASS_ON;
970 }
971
972 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
973 {
974   Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
975
976   if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
977   {
978     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
979
980     RotationEvent rotationEvent;
981     rotationEvent.angle     = ev->angle;
982     rotationEvent.winResize = 0;
983     mWindowRotationAngle    = ev->angle;
984
985     if(ev->angle == 0 || ev->angle == 180)
986     {
987       rotationEvent.width  = ev->w;
988       rotationEvent.height = ev->h;
989     }
990     else
991     {
992       rotationEvent.width  = ev->h;
993       rotationEvent.height = ev->w;
994     }
995
996     mWindowPositionSize.width  = rotationEvent.width;
997     mWindowPositionSize.height = rotationEvent.height;
998
999     mRotationSignal.Emit(rotationEvent);
1000   }
1001 }
1002
1003 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1004 {
1005   Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1006
1007   if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1008   {
1009     // Note: To comply with the wayland protocol, Dali should make an ack_configure
1010     // by calling ecore_wl2_window_commit
1011
1012     int tempWidth  = static_cast<int>(ev->w);
1013     int tempHeight = static_cast<int>(ev->h);
1014
1015     // Initialize with previous size for skip resize when new size is 0.
1016     // When window is just moved or window is resized by client application,
1017     // The configure notification event's size will be 0.
1018     // If new size is 0, the resized work should be skip.
1019     int newWidth = mWindowPositionSize.width;
1020     int newHeight = mWindowPositionSize.height;
1021     bool windowMoved = false, windowResized = false;
1022
1023     if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1024     {
1025       windowMoved = true;
1026     }
1027
1028     if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1029     {
1030       windowResized = true;
1031       newWidth = tempWidth;
1032       newHeight = tempHeight;
1033     }
1034
1035     if(windowMoved || windowResized)
1036     {
1037       Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
1038       mUpdatePositionSizeSignal.Emit(newPositionSize);
1039     }
1040
1041     ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1042   }
1043 }
1044
1045 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1046 {
1047   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1048
1049   if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1050   {
1051     Device::Class::Type    deviceClass;
1052     Device::Subclass::Type deviceSubclass;
1053
1054     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1055     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1056
1057     PointState::Type state(PointState::DOWN);
1058
1059     if(deviceClass != Device::Class::Type::MOUSE)
1060     {
1061       // Check if the buttons field is set and ensure it's the primary touch button.
1062       // If this event was triggered by buttons other than the primary button (used for touch), then
1063       // just send an interrupted event to Core.
1064       if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1065       {
1066         state = PointState::INTERRUPTED;
1067       }
1068     }
1069
1070     Integration::Point point;
1071     point.SetDeviceId(touchEvent->multi.device);
1072     point.SetState(state);
1073     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1074     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1075     point.SetPressure(touchEvent->multi.pressure);
1076     point.SetAngle(Degree(touchEvent->multi.angle));
1077     point.SetDeviceClass(deviceClass);
1078     point.SetDeviceSubclass(deviceSubclass);
1079     point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1080
1081     mTouchEventSignal.Emit(point, touchEvent->timestamp);
1082   }
1083 }
1084
1085 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1086 {
1087   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1088
1089   if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1090   {
1091     Device::Class::Type    deviceClass;
1092     Device::Subclass::Type deviceSubclass;
1093
1094     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1095     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1096
1097     Integration::Point point;
1098     point.SetDeviceId(touchEvent->multi.device);
1099     point.SetState(PointState::UP);
1100     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1101     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1102     point.SetPressure(touchEvent->multi.pressure);
1103     point.SetAngle(Degree(touchEvent->multi.angle));
1104     point.SetDeviceClass(deviceClass);
1105     point.SetDeviceSubclass(deviceSubclass);
1106     point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1107
1108     mTouchEventSignal.Emit(point, touchEvent->timestamp);
1109   }
1110 }
1111
1112 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1113 {
1114   Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1115
1116   if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1117   {
1118     Device::Class::Type    deviceClass;
1119     Device::Subclass::Type deviceSubclass;
1120
1121     GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1122     GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1123
1124     Integration::Point point;
1125     point.SetDeviceId(touchEvent->multi.device);
1126     point.SetState(PointState::MOTION);
1127     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1128     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1129     point.SetPressure(touchEvent->multi.pressure);
1130     point.SetAngle(Degree(touchEvent->multi.angle));
1131     point.SetDeviceClass(deviceClass);
1132     point.SetDeviceSubclass(deviceSubclass);
1133
1134     mTouchEventSignal.Emit(point, touchEvent->timestamp);
1135   }
1136 }
1137
1138 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1139 {
1140   Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1141
1142   if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1143   {
1144     Integration::Point point;
1145     point.SetDeviceId(touchEvent->multi.device);
1146     point.SetState(PointState::INTERRUPTED);
1147     point.SetScreenPosition(Vector2(0.0f, 0.0f));
1148
1149     mTouchEventSignal.Emit(point, touchEvent->timestamp);
1150
1151     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1152   }
1153 }
1154
1155 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1156 {
1157   Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1158
1159   if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1160   {
1161     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
1162
1163     Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1164
1165     mWheelEventSignal.Emit(wheelEvent);
1166   }
1167 }
1168
1169 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1170 {
1171   Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1172
1173   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1174
1175   int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1176   int timeStamp = detentEvent->timestamp;
1177
1178   Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2(0.0f, 0.0f), 0, timeStamp);
1179
1180   mWheelEventSignal.Emit(wheelEvent);
1181 }
1182
1183 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1184 {
1185   Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1186
1187   if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1188   {
1189     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n");
1190
1191     std::string keyName(keyEvent->keyname);
1192     std::string logicalKey("");
1193     std::string keyString("");
1194     std::string compose("");
1195
1196     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1197     if(keyEvent->compose)
1198     {
1199       compose = keyEvent->compose;
1200     }
1201
1202     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1203     if(keyEvent->key)
1204     {
1205       logicalKey = keyEvent->key;
1206     }
1207
1208     int keyCode = 0;
1209     GetKeyCode(keyName, keyCode); // Get key code dynamically.
1210
1211     if(keyCode == 0)
1212     {
1213       // Get a specific key code from dali key look up table.
1214       keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1215     }
1216
1217     keyCode = (keyCode == -1) ? 0 : keyCode;
1218     int           modifier(keyEvent->modifiers);
1219     unsigned long time = keyEvent->timestamp;
1220     if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1221     {
1222       keyCode = atoi(keyEvent->keyname + 8);
1223     }
1224
1225     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1226     if(keyEvent->string)
1227     {
1228       keyString = keyEvent->string;
1229     }
1230
1231     std::string            deviceName;
1232     Device::Class::Type    deviceClass;
1233     Device::Subclass::Type deviceSubclass;
1234
1235     GetDeviceName(keyEvent, deviceName);
1236     GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1237     GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1238
1239     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1240
1241     mKeyEventSignal.Emit(keyEvent);
1242   }
1243 }
1244
1245 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1246 {
1247   Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1248
1249   if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1250   {
1251     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n");
1252
1253 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1254     // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1255     if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1256     {
1257       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1258       return;
1259     }
1260 #endif // Since ecore 1.23 version
1261
1262     std::string keyName(keyEvent->keyname);
1263     std::string logicalKey("");
1264     std::string keyString("");
1265     std::string compose("");
1266
1267     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1268     if(keyEvent->compose)
1269     {
1270       compose = keyEvent->compose;
1271     }
1272
1273     // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1274     if(keyEvent->key)
1275     {
1276       logicalKey = keyEvent->key;
1277     }
1278
1279     int keyCode = 0;
1280     GetKeyCode(keyName, keyCode); // Get key code dynamically.
1281
1282     if(keyCode == 0)
1283     {
1284       // Get a specific key code from dali key look up table.
1285       keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1286     }
1287
1288     keyCode = (keyCode == -1) ? 0 : keyCode;
1289     int           modifier(keyEvent->modifiers);
1290     unsigned long time = keyEvent->timestamp;
1291     if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1292     {
1293       keyCode = atoi(keyEvent->keyname + 8);
1294     }
1295
1296     // Ensure key event string is not NULL as keys like SHIFT have a null string.
1297     if(keyEvent->string)
1298     {
1299       keyString = keyEvent->string;
1300     }
1301
1302     std::string            deviceName;
1303     Device::Class::Type    deviceClass;
1304     Device::Subclass::Type deviceSubclass;
1305
1306     GetDeviceName(keyEvent, deviceName);
1307     GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1308     GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1309
1310     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1311
1312     mKeyEventSignal.Emit(keyEvent);
1313   }
1314 }
1315
1316 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1317 {
1318   mSelectionDataSendSignal.Emit(event);
1319 }
1320
1321 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1322 {
1323   mSelectionDataReceivedSignal.Emit(event);
1324 }
1325
1326 void WindowBaseEcoreWl2::OnFontNameChanged()
1327 {
1328   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1329 }
1330
1331 void WindowBaseEcoreWl2::OnFontSizeChanged()
1332 {
1333   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1334 }
1335
1336 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
1337 {
1338 #ifdef DALI_ELDBUS_AVAILABLE
1339   AccessibilityInfo info;
1340
1341   // The string defines the arg-list's respective types.
1342   if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
1343   {
1344     DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
1345   }
1346
1347   mAccessibilitySignal.Emit(info);
1348 #endif
1349 }
1350
1351 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1352 {
1353   mTransitionEffectEventSignal.Emit(state, type);
1354 }
1355
1356 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1357 {
1358   mKeyboardRepeatSettingsChangedSignal.Emit();
1359 }
1360
1361 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1362 {
1363   mWindowRedrawRequestSignal.Emit();
1364 }
1365
1366 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1367 {
1368   Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1369   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1370   Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1371   if(ecoreWlInput)
1372   {
1373     mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1374   }
1375 }
1376
1377 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1378 {
1379   if(strcmp(interface, tizen_policy_interface.name) == 0)
1380   {
1381     uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1382
1383     mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1384     if(!mTizenPolicy)
1385     {
1386       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1387       return;
1388     }
1389
1390     tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1391
1392     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1393   }
1394   else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1395   {
1396     mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1397     if(!mTizenDisplayPolicy)
1398     {
1399       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1400       return;
1401     }
1402
1403     tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1404
1405     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1406   }
1407 }
1408
1409 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1410 {
1411   mTizenPolicy        = NULL;
1412   mTizenDisplayPolicy = NULL;
1413 }
1414
1415 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1416 {
1417   mNotificationLevel           = level;
1418   mNotificationChangeState     = state;
1419   mNotificationLevelChangeDone = true;
1420
1421   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1422 }
1423
1424 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1425 {
1426   mScreenOffMode            = mode;
1427   mScreenOffModeChangeState = state;
1428   mScreenOffModeChangeDone  = true;
1429
1430   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1431 }
1432
1433 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1434 {
1435   mBrightness            = brightness;
1436   mBrightnessChangeState = state;
1437   mBrightnessChangeDone  = true;
1438
1439   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1440 }
1441
1442 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1443 {
1444   xkb_keysym_t sym = XKB_KEY_NoSymbol;
1445   KeyCodeMap   foundKeyCode;
1446
1447   sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1448   if(sym == XKB_KEY_NoSymbol)
1449   {
1450     DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1451     return;
1452   }
1453
1454   foundKeyCode.keySym    = sym;
1455   foundKeyCode.isKeyCode = false;
1456   xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1457   keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1458 }
1459
1460 Any WindowBaseEcoreWl2::GetNativeWindow()
1461 {
1462   return mEcoreWindow;
1463 }
1464
1465 int WindowBaseEcoreWl2::GetNativeWindowId()
1466 {
1467   return ecore_wl2_window_id_get(mEcoreWindow);
1468 }
1469
1470 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1471 {
1472   int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1473   if(totalAngle == 90 || totalAngle == 270)
1474   {
1475     mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1476   }
1477   else
1478   {
1479     mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1480   }
1481
1482   return static_cast<EGLNativeWindowType>(mEglWindow);
1483 }
1484
1485 void WindowBaseEcoreWl2::DestroyEglWindow()
1486 {
1487   if(mEglWindow != NULL)
1488   {
1489     wl_egl_window_destroy(mEglWindow);
1490     mEglWindow = NULL;
1491   }
1492 }
1493
1494 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1495 {
1496   wl_egl_window_tizen_rotation rotation;
1497
1498   switch(angle)
1499   {
1500     case 0:
1501     {
1502       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1503       break;
1504     }
1505     case 90:
1506     {
1507       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1508       break;
1509     }
1510     case 180:
1511     {
1512       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1513       break;
1514     }
1515     case 270:
1516     {
1517       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1518       break;
1519     }
1520     default:
1521     {
1522       rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1523       break;
1524     }
1525   }
1526
1527   wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1528 }
1529
1530 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1531 {
1532   wl_output_transform bufferTransform;
1533
1534   switch(angle)
1535   {
1536     case 0:
1537     {
1538       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1539       break;
1540     }
1541     case 90:
1542     {
1543       bufferTransform = WL_OUTPUT_TRANSFORM_90;
1544       break;
1545     }
1546     case 180:
1547     {
1548       bufferTransform = WL_OUTPUT_TRANSFORM_180;
1549       break;
1550     }
1551     case 270:
1552     {
1553       bufferTransform = WL_OUTPUT_TRANSFORM_270;
1554       break;
1555     }
1556     default:
1557     {
1558       bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1559       break;
1560     }
1561   }
1562
1563   wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1564 }
1565
1566 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1567 {
1568   wl_output_transform windowTransform;
1569
1570   switch(angle)
1571   {
1572     case 0:
1573     {
1574       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1575       break;
1576     }
1577     case 90:
1578     {
1579       windowTransform = WL_OUTPUT_TRANSFORM_90;
1580       break;
1581     }
1582     case 180:
1583     {
1584       windowTransform = WL_OUTPUT_TRANSFORM_180;
1585       break;
1586     }
1587     case 270:
1588     {
1589       windowTransform = WL_OUTPUT_TRANSFORM_270;
1590       break;
1591     }
1592     default:
1593     {
1594       windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1595       break;
1596     }
1597   }
1598
1599   wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1600 }
1601
1602 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1603 {
1604   wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1605
1606   // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1607   if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1608   {
1609     wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1610     mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1611   }
1612 }
1613
1614 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1615 {
1616   // Check capability
1617   wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1618   if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1619   {
1620     mSupportedPreProtation = true;
1621     return true;
1622   }
1623   mSupportedPreProtation = false;
1624   return false;
1625 }
1626
1627 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1628 {
1629   mWindowPositionSize = positionSize;
1630   ecore_wl2_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1631 }
1632
1633 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1634 {
1635   mWindowPositionSize = positionSize;
1636   ecore_wl2_window_geometry_set(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1637 }
1638
1639 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1640 {
1641   mWindowPositionSize = positionSize;
1642   ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1643 }
1644
1645 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1646 {
1647   ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1648   ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1649 }
1650
1651 void WindowBaseEcoreWl2::Raise()
1652 {
1653   // Use ecore_wl2_window_activate to prevent the window shown without rendering
1654   ecore_wl2_window_activate(mEcoreWindow);
1655 }
1656
1657 void WindowBaseEcoreWl2::Lower()
1658 {
1659   ecore_wl2_window_lower(mEcoreWindow);
1660 }
1661
1662 void WindowBaseEcoreWl2::Activate()
1663 {
1664   ecore_wl2_window_activate(mEcoreWindow);
1665 }
1666
1667 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1668 {
1669   int rotations[4] = {0};
1670   DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1671   for(std::size_t i = 0; i < angles.size(); ++i)
1672   {
1673     rotations[i] = static_cast<int>(angles[i]);
1674     DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1675   }
1676   ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1677 }
1678
1679 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
1680 {
1681   DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
1682   ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
1683 }
1684
1685 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
1686 {
1687   ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
1688 }
1689
1690 void WindowBaseEcoreWl2::Show()
1691 {
1692   if(!mVisible)
1693   {
1694     // Ecore-wl2 has the original window size
1695     // and he always sends the window rotation event with the swapped size.
1696     // So, to restore, dali should set the reswapped size(original window size) to ecore-wl2 for restoring.
1697     if(mWindowRotationAngle == 0 || mWindowRotationAngle == 180)
1698     {
1699       ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1700     }
1701     else
1702     {
1703       ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.height, mWindowPositionSize.width);
1704     }
1705   }
1706   mVisible = true;
1707
1708   ecore_wl2_window_show(mEcoreWindow);
1709 }
1710
1711 void WindowBaseEcoreWl2::Hide()
1712 {
1713   mVisible = false;
1714   ecore_wl2_window_hide(mEcoreWindow);
1715 }
1716
1717 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1718 {
1719   return mSupportedAuxiliaryHints.size();
1720 }
1721
1722 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
1723 {
1724   if(index >= GetSupportedAuxiliaryHintCount())
1725   {
1726     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1727   }
1728
1729   return mSupportedAuxiliaryHints[index];
1730 }
1731
1732 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1733 {
1734   bool supported = false;
1735
1736   // Check if the hint is suppported
1737   for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1738   {
1739     if(*iter == hint)
1740     {
1741       supported = true;
1742       break;
1743     }
1744   }
1745
1746   if(!supported)
1747   {
1748     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1749     return 0;
1750   }
1751
1752   // Check if the hint is already added
1753   for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1754   {
1755     if(mAuxiliaryHints[i].first == hint)
1756     {
1757       // Just change the value
1758       mAuxiliaryHints[i].second = value;
1759
1760       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1761
1762       return i + 1; // id is index + 1
1763     }
1764   }
1765
1766   // Add the hint
1767   mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1768
1769   unsigned int id = mAuxiliaryHints.size();
1770
1771   ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1772
1773   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1774
1775   return id;
1776 }
1777
1778 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
1779 {
1780   if(id == 0 || id > mAuxiliaryHints.size())
1781   {
1782     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1783     return false;
1784   }
1785
1786   mAuxiliaryHints[id - 1].second = std::string();
1787
1788   ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1789
1790   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1791
1792   return true;
1793 }
1794
1795 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1796 {
1797   if(id == 0 || id > mAuxiliaryHints.size())
1798   {
1799     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1800     return false;
1801   }
1802
1803   mAuxiliaryHints[id - 1].second = value;
1804
1805   ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1806
1807   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1808
1809   return true;
1810 }
1811
1812 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
1813 {
1814   if(id == 0 || id > mAuxiliaryHints.size())
1815   {
1816     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1817     return std::string();
1818   }
1819
1820   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1821
1822   return mAuxiliaryHints[id - 1].second;
1823 }
1824
1825 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
1826 {
1827   for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1828   {
1829     if(mAuxiliaryHints[i].first == hint)
1830     {
1831       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1832       return i + 1;
1833     }
1834   }
1835
1836   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1837
1838   return 0;
1839 }
1840
1841 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
1842 {
1843   ecore_wl2_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1844 }
1845
1846 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
1847 {
1848   Ecore_Wl2_Window_Type windowType;
1849
1850   switch(type)
1851   {
1852     case Dali::WindowType::NORMAL:
1853     {
1854       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1855       break;
1856     }
1857     case Dali::WindowType::NOTIFICATION:
1858     {
1859       windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1860       break;
1861     }
1862     case Dali::WindowType::UTILITY:
1863     {
1864       windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1865       break;
1866     }
1867     case Dali::WindowType::DIALOG:
1868     {
1869       windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1870       break;
1871     }
1872     default:
1873     {
1874       windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1875       break;
1876     }
1877   }
1878
1879   ecore_wl2_window_type_set(mEcoreWindow, windowType);
1880 }
1881
1882 bool WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
1883 {
1884   while(!mTizenPolicy)
1885   {
1886     wl_display_dispatch_queue(mDisplay, mEventQueue);
1887   }
1888
1889   int notificationLevel;
1890
1891   switch(level)
1892   {
1893     case Dali::WindowNotificationLevel::NONE:
1894     {
1895       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1896       break;
1897     }
1898     case Dali::WindowNotificationLevel::BASE:
1899     {
1900       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1901       break;
1902     }
1903     case Dali::WindowNotificationLevel::MEDIUM:
1904     {
1905       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1906       break;
1907     }
1908     case Dali::WindowNotificationLevel::HIGH:
1909     {
1910       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1911       break;
1912     }
1913     case Dali::WindowNotificationLevel::TOP:
1914     {
1915       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1916       break;
1917     }
1918     default:
1919     {
1920       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
1921       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1922       break;
1923     }
1924   }
1925
1926   mNotificationLevelChangeDone = false;
1927   mNotificationChangeState     = TIZEN_POLICY_ERROR_STATE_NONE;
1928
1929   tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
1930
1931   int count = 0;
1932
1933   while(!mNotificationLevelChangeDone && count < 3)
1934   {
1935     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1936     wl_display_dispatch_queue(mDisplay, mEventQueue);
1937     count++;
1938   }
1939
1940   if(!mNotificationLevelChangeDone)
1941   {
1942     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1943     return false;
1944   }
1945   else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1946   {
1947     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
1948     return false;
1949   }
1950
1951   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1952
1953   return true;
1954 }
1955
1956 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
1957 {
1958   while(!mTizenPolicy)
1959   {
1960     wl_display_dispatch_queue(mDisplay, mEventQueue);
1961   }
1962
1963   int count = 0;
1964
1965   while(!mNotificationLevelChangeDone && count < 3)
1966   {
1967     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1968     wl_display_dispatch_queue(mDisplay, mEventQueue);
1969     count++;
1970   }
1971
1972   if(!mNotificationLevelChangeDone)
1973   {
1974     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1975     return Dali::WindowNotificationLevel::NONE;
1976   }
1977
1978   Dali::WindowNotificationLevel level;
1979
1980   switch(mNotificationLevel)
1981   {
1982     case TIZEN_POLICY_LEVEL_NONE:
1983     {
1984       level = Dali::WindowNotificationLevel::NONE;
1985       break;
1986     }
1987     case TIZEN_POLICY_LEVEL_DEFAULT:
1988     {
1989       level = Dali::WindowNotificationLevel::BASE;
1990       break;
1991     }
1992     case TIZEN_POLICY_LEVEL_MEDIUM:
1993     {
1994       level = Dali::WindowNotificationLevel::MEDIUM;
1995       break;
1996     }
1997     case TIZEN_POLICY_LEVEL_HIGH:
1998     {
1999       level = Dali::WindowNotificationLevel::HIGH;
2000       break;
2001     }
2002     case TIZEN_POLICY_LEVEL_TOP:
2003     {
2004       level = Dali::WindowNotificationLevel::TOP;
2005       break;
2006     }
2007     default:
2008     {
2009       DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2010       level = Dali::WindowNotificationLevel::NONE;
2011       break;
2012     }
2013   }
2014
2015   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2016
2017   return level;
2018 }
2019
2020 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2021 {
2022   while(!mTizenPolicy)
2023   {
2024     wl_display_dispatch_queue(mDisplay, mEventQueue);
2025   }
2026
2027   tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2028 }
2029
2030 bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2031 {
2032   while(!mTizenPolicy)
2033   {
2034     wl_display_dispatch_queue(mDisplay, mEventQueue);
2035   }
2036
2037   mScreenOffModeChangeDone  = false;
2038   mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2039
2040   unsigned int mode = 0;
2041
2042   switch(screenOffMode)
2043   {
2044     case WindowScreenOffMode::TIMEOUT:
2045     {
2046       mode = 0;
2047       break;
2048     }
2049     case WindowScreenOffMode::NEVER:
2050     {
2051       mode = 1;
2052       break;
2053     }
2054   }
2055
2056   tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2057
2058   int count = 0;
2059
2060   while(!mScreenOffModeChangeDone && count < 3)
2061   {
2062     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2063     wl_display_dispatch_queue(mDisplay, mEventQueue);
2064     count++;
2065   }
2066
2067   if(!mScreenOffModeChangeDone)
2068   {
2069     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2070     return false;
2071   }
2072   else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2073   {
2074     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2075     return false;
2076   }
2077
2078   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2079
2080   return true;
2081 }
2082
2083 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2084 {
2085   while(!mTizenPolicy)
2086   {
2087     wl_display_dispatch_queue(mDisplay, mEventQueue);
2088   }
2089
2090   int count = 0;
2091
2092   while(!mScreenOffModeChangeDone && count < 3)
2093   {
2094     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2095     wl_display_dispatch_queue(mDisplay, mEventQueue);
2096     count++;
2097   }
2098
2099   if(!mScreenOffModeChangeDone)
2100   {
2101     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2102     return WindowScreenOffMode::TIMEOUT;
2103   }
2104
2105   WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2106
2107   switch(mScreenOffMode)
2108   {
2109     case 0:
2110     {
2111       screenMode = WindowScreenOffMode::TIMEOUT;
2112       break;
2113     }
2114     case 1:
2115     {
2116       screenMode = WindowScreenOffMode::NEVER;
2117       break;
2118     }
2119   }
2120
2121   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2122
2123   return screenMode;
2124 }
2125
2126 bool WindowBaseEcoreWl2::SetBrightness(int brightness)
2127 {
2128   while(!mTizenDisplayPolicy)
2129   {
2130     wl_display_dispatch_queue(mDisplay, mEventQueue);
2131   }
2132
2133   mBrightnessChangeDone  = false;
2134   mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2135
2136   tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2137
2138   int count = 0;
2139
2140   while(!mBrightnessChangeDone && count < 3)
2141   {
2142     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2143     wl_display_dispatch_queue(mDisplay, mEventQueue);
2144     count++;
2145   }
2146
2147   if(!mBrightnessChangeDone)
2148   {
2149     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2150     return false;
2151   }
2152   else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2153   {
2154     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2155     return false;
2156   }
2157
2158   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2159
2160   return true;
2161 }
2162
2163 int WindowBaseEcoreWl2::GetBrightness() const
2164 {
2165   while(!mTizenDisplayPolicy)
2166   {
2167     wl_display_dispatch_queue(mDisplay, mEventQueue);
2168   }
2169
2170   int count = 0;
2171
2172   while(!mBrightnessChangeDone && count < 3)
2173   {
2174     ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2175     wl_display_dispatch_queue(mDisplay, mEventQueue);
2176     count++;
2177   }
2178
2179   if(!mBrightnessChangeDone)
2180   {
2181     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2182     return 0;
2183   }
2184
2185   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2186
2187   return mBrightness;
2188 }
2189
2190 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2191 {
2192   Ecore_Wl2_Window_Keygrab_Mode mode;
2193
2194   switch(grabMode)
2195   {
2196     case KeyGrab::TOPMOST:
2197     {
2198       mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2199       break;
2200     }
2201     case KeyGrab::SHARED:
2202     {
2203       mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2204       break;
2205     }
2206     case KeyGrab::OVERRIDE_EXCLUSIVE:
2207     {
2208       mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2209       break;
2210     }
2211     case KeyGrab::EXCLUSIVE:
2212     {
2213       mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2214       break;
2215     }
2216     default:
2217     {
2218       return false;
2219     }
2220   }
2221
2222   return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2223 }
2224
2225 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2226 {
2227   return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2228 }
2229
2230 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2231 {
2232   int keyCount         = key.Count();
2233   int keyGrabModeCount = grabMode.Count();
2234
2235   if(keyCount != keyGrabModeCount || keyCount == 0)
2236   {
2237     return false;
2238   }
2239
2240   eina_init();
2241
2242   Eina_List*                     keyList = NULL;
2243   Ecore_Wl2_Window_Keygrab_Info* info    = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2244
2245   for(int index = 0; index < keyCount; ++index)
2246   {
2247     info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2248
2249     switch(grabMode[index])
2250     {
2251       case KeyGrab::TOPMOST:
2252       {
2253         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2254         break;
2255       }
2256       case KeyGrab::SHARED:
2257       {
2258         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2259         break;
2260       }
2261       case KeyGrab::OVERRIDE_EXCLUSIVE:
2262       {
2263         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2264         break;
2265       }
2266       case KeyGrab::EXCLUSIVE:
2267       {
2268         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2269         break;
2270       }
2271       default:
2272       {
2273         info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2274         break;
2275       }
2276     }
2277
2278     keyList = eina_list_append(keyList, &info);
2279   }
2280
2281   Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2282
2283   result.Resize(keyCount, true);
2284
2285   Eina_List* l        = NULL;
2286   Eina_List* m        = NULL;
2287   void*      listData = NULL;
2288   void*      data     = NULL;
2289   if(grabList != NULL)
2290   {
2291     EINA_LIST_FOREACH(grabList, m, data)
2292     {
2293       int index = 0;
2294       EINA_LIST_FOREACH(keyList, l, listData)
2295       {
2296         if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2297         {
2298           DALI_LOG_ERROR("input key list has null data!");
2299           break;
2300         }
2301
2302         if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2303         {
2304           result[index] = false;
2305         }
2306         ++index;
2307       }
2308     }
2309   }
2310
2311   delete[] info;
2312
2313   eina_list_free(keyList);
2314   eina_list_free(grabList);
2315   eina_shutdown();
2316
2317   return true;
2318 }
2319
2320 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2321 {
2322   int keyCount = key.Count();
2323   if(keyCount == 0)
2324   {
2325     return false;
2326   }
2327
2328   eina_init();
2329
2330   Eina_List*                     keyList = NULL;
2331   Ecore_Wl2_Window_Keygrab_Info* info    = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2332
2333   for(int index = 0; index < keyCount; ++index)
2334   {
2335     info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2336     keyList         = eina_list_append(keyList, &info);
2337   }
2338
2339   Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2340
2341   result.Resize(keyCount, true);
2342
2343   Eina_List* l        = NULL;
2344   Eina_List* m        = NULL;
2345   void*      listData = NULL;
2346   void*      data     = NULL;
2347
2348   if(ungrabList != NULL)
2349   {
2350     EINA_LIST_FOREACH(ungrabList, m, data)
2351     {
2352       int index = 0;
2353       EINA_LIST_FOREACH(keyList, l, listData)
2354       {
2355         if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2356         {
2357           result[index] = false;
2358         }
2359         ++index;
2360       }
2361     }
2362   }
2363
2364   delete[] info;
2365
2366   eina_list_free(keyList);
2367   eina_list_free(ungrabList);
2368   eina_shutdown();
2369
2370   return true;
2371 }
2372
2373 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2374 {
2375   // calculate DPI
2376   float xres, yres;
2377
2378   Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2379
2380   // 1 inch = 25.4 millimeters
2381   xres = ecore_wl2_output_dpi_get(output);
2382   yres = ecore_wl2_output_dpi_get(output);
2383
2384   dpiHorizontal = int(xres + 0.5f); // rounding
2385   dpiVertical   = int(yres + 0.5f);
2386 }
2387
2388 int WindowBaseEcoreWl2::GetOrientation() const
2389 {
2390   int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2391   if(mSupportedPreProtation)
2392   {
2393     orientation = 0;
2394   }
2395   return orientation;
2396 }
2397
2398 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2399 {
2400   int transform = 0;
2401
2402   if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2403   {
2404     transform = 0;
2405   }
2406   else
2407   {
2408     transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2409   }
2410   mScreenRotationAngle = transform * 90;
2411   return mScreenRotationAngle;
2412 }
2413
2414 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2415 {
2416   mWindowRotationAngle = degree;
2417   ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2418 }
2419
2420 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2421 {
2422   ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2423 }
2424
2425 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2426 {
2427   ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2428 }
2429
2430 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2431 {
2432 #ifdef DALI_ELDBUS_AVAILABLE
2433   Eldbus_Object* object;
2434   Eldbus_Proxy*  manager;
2435
2436   if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
2437   {
2438     DALI_LOG_ERROR("Unable to get system bus\n");
2439   }
2440
2441   object = eldbus_object_get(mSystemConnection, BUS, PATH);
2442   if(!object)
2443   {
2444     DALI_LOG_ERROR("Getting object failed\n");
2445     return;
2446   }
2447
2448   manager = eldbus_proxy_get(object, INTERFACE);
2449   if(!manager)
2450   {
2451     DALI_LOG_ERROR("Getting proxy failed\n");
2452     return;
2453   }
2454
2455   if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
2456   {
2457     DALI_LOG_ERROR("No signal handler returned\n");
2458   }
2459 #endif
2460 }
2461
2462 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2463 {
2464   Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2465   if(!display)
2466   {
2467     DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2468   }
2469
2470   ecore_wl2_display_sync(display);
2471
2472   mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2473
2474   if(mEcoreWindow == 0)
2475   {
2476     DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2477   }
2478
2479   // Set default type
2480   ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2481 }
2482
2483 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase)
2484 {
2485   Ecore_Wl2_Window* ecoreParent = NULL;
2486   if(parentWinBase)
2487   {
2488     WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2489     ecoreParent                       = winBaseEcore2->mEcoreWindow;
2490   }
2491   ecore_wl2_window_parent_set(mEcoreWindow, ecoreParent);
2492 }
2493
2494 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2495 {
2496   return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2497 }
2498
2499 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2500 {
2501   return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2502 }
2503
2504 } // namespace Adaptor
2505
2506 } // namespace Internal
2507
2508 } // namespace Dali
2509
2510 #pragma GCC diagnostic pop