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