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