Merge "Framework support for issue N_SE-45633" into tizen_2.2
[platform/framework/native/uifw.git] / src / ui / FUi_EcoreEvas.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUi_EcoreEvas.cpp
20  * @brief               This is the implementation file for the _EcoreEvas class.
21  */
22
23 #include <app.h>
24 #include <appcore-common.h>
25 #include <runtime_info.h>
26 #include <X11/Xlib.h>
27 #include <X11/Xatom.h>
28 #include <Ecore_X.h>
29 #include <Elementary.h>
30 #include <FGrpRectangle.h>
31 #include <FGrpFloatRectangle.h>
32 #include <FBaseInteger.h>
33 #include <FBaseErrors.h>
34 #include <FBaseSysLog.h>
35 #include <FBaseRtThread.h>
36 #include <FApp_IActiveWindowEventListener.h>
37 #include <FBase_StringConverter.h>
38 #include <FGrp_CanvasImpl.h>
39 #include "FUi_CoordinateSystemUtils.h"
40 #include "FUi_EcoreEvas.h"
41 #include "FUi_EcoreEvasMgr.h"
42 #include "FUi_Control.h"
43 #include <utilX.h>
44 #include "FUi_UiNotificationEvent.h"
45 #include "FUi_UiEventManager.h"
46 #include "FUi_Window.h"
47 #include "FUiAnim_EflLayer.h"
48 #include "FUiAnim_EflNode.h"
49 #include "FUiAnim_VisualElement.h"
50 #include "FUi_AccessibilityGesture.h"
51 #include "FUi_AccessibilitySystemSettingLoader.h"
52 #include "FUiAnim_RootVisualElement.h"
53 #include "FUiAnim_DisplayManager.h"
54 #include "FUiCtrl_Frame.h"
55 #include "FUiCtrl_FrameImpl.h"
56 #include "FUiCtrl_FormImpl.h"
57 #include "FUi_Clipboard.h"
58 #include "FUi_TouchManager.h"
59 #include "FUi_ControlManager.h"
60 #include "FUi_ActiveWindowEvent.h"
61 #include "FUi_ControlImplManager.h"
62 #include "FUiCtrl_Popup.h"
63 #include "FUiCtrl_ContextMenu.h"
64 #include "FUiAnim_DisplayContextImpl.h"
65 #include "FUiAnimDisplayContext.h"
66 #include "FUi_TouchManager.h"
67
68 using namespace Tizen::Base;
69 using namespace Tizen::Base::Runtime;
70 using namespace Tizen::App;
71 using namespace Tizen::Graphics;
72 using namespace Tizen::Ui;
73 using namespace Tizen::Ui::Animations;
74 using namespace Tizen::Ui::Controls;
75
76 #define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
77 #define ATOM_CBHM_MSG "CBHM_MSG"
78 #define ATOM_CBHM_COUNT_GET "CBHM_cCOUNT"
79 #define ATOM_CBHM_SERIAL_NUMBER "CBHM_SERIAL_NUMBER"
80 #define ATOM_CBHM_ERROR "CBHM_ERROR"
81 #define ATOM_CBHM_ITEM "CBHM_ITEM"
82 #define ATOM_CBHM_SET_ITEM "SET_ITEM"
83 #define ATOM_CBHM_CLIPBOARD_SHOW_ALL "show1"
84 #define ATOM_CBHM_CLIPBOARD_SHOW "show0"
85 #define ATOM_CBHM_CLIPBOARD_HIDE "cbhm_hide"
86 #define ATOM_CBHM_SELECTED_ITEM "CBHM_SELECTED_ITEM"
87 #define ATOM_ROTATE_AUTO "_E_WINDOW_ROTATION_SUPPORTED"
88
89 namespace Tizen { namespace Ui
90 {
91 static _EcoreEvas* _pEvas = null;
92 }} // Tizen::Ui
93
94 namespace
95 {
96
97 Ecore_X_Atom __atomRotateRootAngle = 0;
98
99 int __clipboardHeight = 0;
100
101 void
102 OnWindowStateChanged(Ecore_Evas* pEcoreEvas)
103 {
104         _ControlManager* pControlManager = _ControlManager::GetInstance();
105         if (!pControlManager)
106         {
107                 return;
108         }
109
110         Ecore_X_Window targetWin = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
111
112         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] OnWindowStateChanged is called.", targetWin);
113
114         int winCount = pControlManager->GetAllWindowCount();
115         for (int i = 0; i < winCount; i++)
116         {
117                 _Window* pWindow = pControlManager->GetAllWindow(i);
118                 if (!pWindow)
119                 {
120                         continue;
121                 }
122
123                 Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
124
125                 if (win == targetWin)
126                 {
127                         pWindow->OnWindowStateChanged();
128
129                         return;
130                 }
131         }
132 }
133
134 Eina_Bool
135 OnWindowPropertyChanged(void* pData, int type, void* pEvent)
136 {
137         Ecore_X_Event_Window_Property* pEv = (Ecore_X_Event_Window_Property*)pEvent;
138         if (!pEv)
139         {
140                 return ECORE_CALLBACK_PASS_ON;
141         }
142
143         Ecore_X_Window targetWin = pEv->win;
144         if (targetWin == 0)
145         {
146                 return ECORE_CALLBACK_PASS_ON;
147         }
148
149         if (pEv->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
150         {
151                 Ecore_X_Window zone = ecore_x_e_illume_zone_get(targetWin);
152                 Ecore_X_Illume_Clipboard_State clipboardState = ecore_x_e_illume_clipboard_state_get(zone);
153
154                 if (clipboardState == ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
155                 {
156                         int x = 0;
157                         int y = 0;
158                         int w = 0;
159                         int h = 0;
160                         ecore_x_e_illume_clipboard_geometry_get(zone, &x, &y, &w, &h);
161
162                         Dimension clipboardDim = _CoordinateSystemUtils::InverseTransform(Dimension(w, h));
163
164                         if (__clipboardHeight == 0)
165                         {
166                                 SysLog(NID_UI, "[Clipboard] Clipboard is opened. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
167                                 _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_OPENED, clipboardDim.width, clipboardDim.height);
168                                 __clipboardHeight = clipboardDim.height;
169                         }
170 //                      else
171 //                      {
172 //                              SysLog(NID_UI, "[Clipboard] The bounds of Clipboard is changed. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
173 //                              _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED, clipboardDim.width, clipboardDim.height);
174 //                      }
175                 }
176                 else if (clipboardState == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF)
177                 {
178                         SysLog(NID_UI, "[Clipboard] Clipboard is closed.");
179                         _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_CLOSED, 0, 0);
180                         __clipboardHeight = 0;
181                         _Clipboard::GetInstance()->HidePopup();
182                 }
183         }
184         else if (pEv->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY)
185         {
186                 // Only after opening Clipboard
187                 if (__clipboardHeight != 0)
188                 {
189                         Ecore_X_Window zone = ecore_x_e_illume_zone_get(targetWin);
190
191                         int x = 0;
192                         int y = 0;
193                         int w = 0;
194                         int h = 0;
195                         ecore_x_e_illume_clipboard_geometry_get(zone, &x, &y, &w, &h);
196
197                         Dimension clipboardDim = _CoordinateSystemUtils::InverseTransform(Dimension(w, h));
198
199                         if (clipboardDim.height != 0)
200                         {
201                                 SysLog(NID_UI, "[Clipboard] The bounds of Clipboard is changed. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
202                                 _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED, clipboardDim.width, clipboardDim.height);
203                         }
204                 }
205         }
206         else if (pEv->atom == ECORE_X_ATOM_WM_STATE)
207         {
208                 _ControlManager* pControlManager = _ControlManager::GetInstance();
209                 if (!pControlManager)
210                 {
211                         return ECORE_CALLBACK_PASS_ON;
212                 }
213
214                 int winCount = pControlManager->GetWindowCount();
215
216                 for (int i = 0; i < winCount; i++)
217                 {
218                         _Window* pWindow = pControlManager->GetWindow(i);
219                         if (!pWindow)
220                         {
221                                 continue;
222                         }
223
224                         Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
225                         if (win != targetWin)
226                         {
227                                 continue;
228                         }
229
230                         if (pWindow->IsOrientationRoot() == true)
231                         {
232                                 _Frame* pFrame = static_cast<_Frame*>(pWindow);
233                                 _DisplayContextImpl* pContext = _DisplayContextImpl::GetInstance(*pFrame->GetDisplayContext());
234                                 _EflLayer* pLayer = static_cast<_EflLayer*>(pContext->GetNativeLayer());
235
236
237                                 Ecore_X_Window_State_Hint state = ecore_x_icccm_state_get(targetWin);
238                                 switch (state)
239                                 {
240                                 case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
241                                         pLayer->SetRenderNeeded(false);
242                                         // Frame was hidden.
243                                         break;
244                                 case ECORE_X_WINDOW_STATE_HINT_ICONIC:
245                                         pLayer->SetRenderNeeded(false);
246                                         pFrame->OnFrameMinimized();
247                                         break;
248                                 case ECORE_X_WINDOW_STATE_HINT_NORMAL:
249                                         pLayer->SetRenderNeeded(true);
250                                         pFrame->OnFrameRestored();
251                                         break;
252                                 default:
253                                         break;
254                                 }
255
256                                 break;
257                         }
258                 }
259         }
260
261         return ECORE_CALLBACK_PASS_ON;
262 }
263
264 Eina_Bool
265 OnWindowVisibilityChanged(void* pData, int type, void* pEvent)
266 {
267         SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
268         SysTryReturn(NID_UI, pEvent, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
269
270         Ecore_X_Event_Window_Visibility_Change* pE = (Ecore_X_Event_Window_Visibility_Change*) pEvent;
271         _ControlManager* pControlManager = _ControlManager::GetInstance();
272
273         int count = pControlManager->GetWindowCount();
274
275         _Window* pWindow = null;
276         bool found = false;
277
278         for (int i = 0; i < count; i++)
279         {
280                 pWindow = pControlManager->GetWindow(i);
281                 if (pWindow)
282                 {
283                         NativeWindowHandle handle = pWindow->GetNativeHandle();
284                         if (handle == pE->win)
285                         {
286                                 found = true;
287                                 break;
288                         }
289                 }
290         }
291
292         Tizen::Base::Collection::ArrayList* pArgs = null;
293         String* pType = null;
294         Integer* pObscured = null;
295
296         if (found == true)
297         {
298                 const _Control* pDestination = pWindow;
299
300                 pArgs = new (std::nothrow) Tizen::Base::Collection::ArrayList;
301                 SysTryReturn(NID_UI, pArgs, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
302
303                 result r = pArgs->Construct();
304                 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
305
306                 pType = new (std::nothrow) String(L"VisibilityEvent");
307                 r = pArgs->Add(*pType);
308                 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
309
310                 pObscured = new (std::nothrow) Integer(pE->fully_obscured);
311                 r = pArgs->Add(*pObscured);
312                 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
313
314                 _UiNotificationEvent event(pDestination->GetHandle(), pArgs);
315
316                 r = _UiEventManager::GetInstance()->SendEvent(event);
317         }
318
319         return ECORE_CALLBACK_RENEW;
320
321 CATCH:
322         pArgs->RemoveAll(true);
323         delete pArgs;
324
325         if (pType)
326         {
327                 delete pType;
328         }
329
330         if (pObscured)
331         {
332                 delete pObscured;
333         }
334
335         return EINA_FALSE;
336 }
337
338 int frameX = 0;
339 int frameY = 0;
340 int frameW = 0;
341 int frameH = 0;
342
343 Eina_Bool
344 OnWindowConfigured(void* pData, int type, void* pEvent)
345 {
346         Ecore_X_Event_Window_Configure* pEv = (Ecore_X_Event_Window_Configure*)pEvent;
347         if (!pEv)
348         {
349                 return ECORE_CALLBACK_PASS_ON;
350         }
351
352         if (pEv->from_wm == EINA_FALSE)
353         {
354                 return ECORE_CALLBACK_PASS_ON;
355         }
356
357         Ecore_X_Window targetWin = pEv->win;
358         if (targetWin == 0)
359         {
360                 return ECORE_CALLBACK_PASS_ON;
361         }
362
363         if ((frameX == pEv->x) && (frameY == pEv->y) && (frameW == pEv->w) && (frameH == pEv->h))
364         {
365                 return ECORE_CALLBACK_PASS_ON;
366         }
367
368         frameX = pEv->x;
369         frameY = pEv->y;
370         frameW = pEv->w;
371         frameH = pEv->h;
372
373         _ControlManager* pControlManager = _ControlManager::GetInstance();
374         if (!pControlManager)
375         {
376                 return ECORE_CALLBACK_PASS_ON;
377         }
378
379         _TouchManager* pTouchManager = _TouchManager::GetInstance();
380         if (!pTouchManager)
381         {
382                 return ECORE_CALLBACK_PASS_ON;
383         }
384
385         if (pTouchManager->GetPointCount() > 0)
386         {
387                 return ECORE_CALLBACK_PASS_ON;
388         }
389
390         _Window* pWindow = pControlManager->GetCurrentFrame();
391         if (!pWindow)
392         {
393                 return ECORE_CALLBACK_PASS_ON;
394         }
395
396         if (pWindow->IsOrientationRoot() == false)
397         {
398                 return ECORE_CALLBACK_PASS_ON;
399         }
400
401         _Frame* pFrame = static_cast<_Frame*>(pWindow);
402         if (pFrame->GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN)
403         {
404                 return ECORE_CALLBACK_PASS_ON;
405         }
406
407         Ecore_X_Window win = (Ecore_X_Window)pFrame->GetNativeHandle();
408         if (win != targetWin)
409         {
410                 return ECORE_CALLBACK_PASS_ON;
411         }
412
413         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
414         if (!pEcoreEvas)
415         {
416                 return ECORE_CALLBACK_PASS_ON;
417         }
418
419         Rectangle frameBounds = pFrame->GetBounds();
420         int rotation = pEcoreEvas->GetWindowRotation(*pFrame);
421
422         Dimension winSize = _CoordinateSystemUtils::InverseTransform(Dimension(pEv->w, pEv->h));
423         Dimension newSize(winSize.width, winSize.height);
424         if ((rotation == 270) || (rotation == 90))
425         {
426                 newSize.width = winSize.height;
427                 newSize.height = winSize.width;
428         }
429
430         if ((frameBounds.width != newSize.width) || (frameBounds.height != newSize.height))
431         {
432                 return ECORE_CALLBACK_PASS_ON;
433         }
434
435         Dimension screenSize = pControlManager->GetScreenSize();
436         Point winPosition = _CoordinateSystemUtils::InverseTransform(Point(pEv->x, pEv->y));
437
438         Point newPosition(0, 0);
439         switch (rotation)
440         {
441         case 270:
442                 newPosition.x = winPosition.y;
443                 newPosition.y = screenSize.width - winPosition.x - frameBounds.height;
444                 break;
445         case 180:
446                 newPosition.x = screenSize.width - winPosition.x - frameBounds.width;
447                 newPosition.y = screenSize.height - winPosition.y - frameBounds.height;
448                 break;
449         case 90:
450                 newPosition.x = screenSize.height - winPosition.y - frameBounds.width;
451                 newPosition.y = winPosition.x;
452                 break;
453         default:
454                 newPosition.x = winPosition.x;
455                 newPosition.y = winPosition.y;
456                 break;
457         }
458
459         if ((frameBounds.x != newPosition.x) || (frameBounds.y != newPosition.y))
460         {
461                 pFrame->SetChangingBoundsEnabled(false);
462                 pFrame->SetPosition(newPosition);
463                 pFrame->SetChangingBoundsEnabled(true);
464         }
465
466         return ECORE_CALLBACK_PASS_ON;
467 }
468
469 Eina_Bool
470 OnWindowShown(void* pData, int type, void* pEvent)
471 {
472         return ECORE_CALLBACK_PASS_ON;
473 }
474
475 Eina_Bool
476 OnClientMessageReceived(void* pData, int type, void* pEvent)
477 {
478         Ecore_X_Event_Client_Message* pClientEvent = static_cast<Ecore_X_Event_Client_Message*>(pEvent);
479         SysTryReturn(NID_UI, pClientEvent, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
480
481         _ControlManager* pControlManager = _ControlManager::GetInstance();
482         if (!pControlManager)
483         {
484                 return ECORE_CALLBACK_RENEW;
485         }
486
487         if (pClientEvent->message_type == __atomRotateRootAngle)
488         {
489                 int angle = pClientEvent->data.l[0];
490
491                 SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
492
493                 pControlManager->OnWindowRotated(angle);
494         }
495
496         if (pClientEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
497         {
498                 bool bFind = false;
499                 int winCount = pControlManager->GetWindowCount();
500                 for (int i = 0; i < winCount; i++)
501                 {
502                         _Window* pWindow = pControlManager->GetWindow(i);
503                         if (!pWindow)
504                         {
505                                 continue;
506                         }
507
508                         Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
509
510                         if (win == (Ecore_X_Window)pClientEvent->data.l[0])
511                         {
512                                 bFind = true;
513                                 break;
514                         }
515                 }
516
517                 if (!bFind)
518                 {
519                         return ECORE_CALLBACK_RENEW;
520                 }
521
522                 int x = 0;
523                 int y = 0;
524                 if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
525                 {
526                         SysLog(NID_UI, "Accessibility action : Move next");
527                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN);
528                 }
529                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
530                 {
531                         SysLog(NID_UI, "Accessibility action : Move next");
532                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_RIGHT);
533                 }
534                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
535                 {
536                         SysLog(NID_UI, "Accessibility action : Move previous");
537                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_LEFT);
538                 }
539                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
540                 {
541                         SysLog(NID_UI, "Accessibility action : Move previous");
542                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_UP);
543                 }
544                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
545                 {
546                         SysLog(NID_UI, "Accessibility action : Activate");
547                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP);
548                 }
549                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
550                 {
551                         x = (Evas_Coord)pClientEvent->data.l[2];
552                         y = (Evas_Coord)pClientEvent->data.l[3];
553                         SysLog(NID_UI, "Accessibility action : Read");
554                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP, x, y);
555                 }
556                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
557                 {
558                         SysLog(NID_UI, "Accessibility action : value increased");
559                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED);
560                 }
561                 else if ((unsigned int)pClientEvent->data.l[1] == ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_SCROLL_"))
562                 {
563                         SysLog(NID_UI, "Accessibility action : scroll %d, %d, %d", pClientEvent->data.l[2], pClientEvent->data.l[3], pClientEvent->data.l[4]);
564                         x = (Evas_Coord)pClientEvent->data.l[3];
565                         y = (Evas_Coord)pClientEvent->data.l[4];
566                         if (pClientEvent->data.l[2] == 0)
567                         {
568                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED, x, y);
569                         }
570                         else if (pClientEvent->data.l[2] == 1)
571                         {
572                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED, x, y);
573                         }
574                         else if (pClientEvent->data.l[2] == 2)
575                         {
576                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED, x, y);
577                         }
578                 }
579                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_SCROLL)
580                 {
581                         SysLog(NID_UI, "Accessibility action : scroll %d, %d, %d", pClientEvent->data.l[2], pClientEvent->data.l[3], pClientEvent->data.l[4]);
582                         x = (Evas_Coord)pClientEvent->data.l[3];
583                         y = (Evas_Coord)pClientEvent->data.l[4];
584                         if (pClientEvent->data.l[2] == 0)
585                         {
586                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED, x, y);
587                         }
588                         else if (pClientEvent->data.l[2] == 1)
589                         {
590                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED, x, y);
591                         }
592                         else if (pClientEvent->data.l[2] == 2)
593                         {
594                                 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED, x, y);
595                         }
596                 }
597                 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
598                 {
599                         SysLog(NID_UI, "Accessibility action : value decreased");
600                         _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED);
601                 }
602         }
603
604         if (pClientEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST)
605         {
606                 SysLog(NID_UI, "[Ime Rotation]");
607
608                 _Window* pWindow = pControlManager->GetCurrentFrame();
609                 if (pWindow)
610                 {
611                         NativeWindowHandle handle = pWindow->GetNativeHandle();
612
613                         if (pClientEvent->win == handle)
614                         {
615                                 int angle = pClientEvent->data.l[1];
616                                 SysLog(NID_UI, "[Ime Rotation] Receive the client message(xid = 0x%x, angle = %d)", handle, angle);
617
618                                 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
619
620                                 if (pFrame)
621                                 {
622                                         _FrameImpl* pFrameImpl = static_cast<Controls::_FrameImpl*>(pFrame->GetUserData());
623                                         if (pFrameImpl)
624                                         {
625                                                 _FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm();
626
627                                                 if (pCurrentFormImpl)
628                                                 {
629                                                         pCurrentFormImpl->UpdateOrientation(angle);
630                                                 }
631                                                 else
632                                                 {
633                                                         pFrameImpl->UpdateOrientation(angle);
634                                                 }
635                                         }
636                                 }
637                         }
638                 }
639         }
640
641         return ECORE_CALLBACK_RENEW;
642 }
643
644 } // Anonymous
645
646 // For Clipboard
647 namespace
648 {
649 #define __UNUSED__
650
651 enum _ClipType
652 {
653         _CLIP_TYPE_PRIMARY,
654         _CLIP_TYPE_SECONDARY,
655         _CLIP_TYPE_CLIPBOARD,
656         _CLIP_TYPE_XDND,
657         _CLIP_TYPE_MAX,
658 };
659
660 struct _Clip
661 {
662         Ecore_X_Selection selection;
663         Eina_Bool (* set)(Ecore_X_Window window, const void* pData, int size);
664         Eina_Bool (* clear)(void);
665         void (* request)(Ecore_X_Window window, const char* pTarget);
666
667         bool active;
668         _ClipFormat format;
669         char* pBuffer;
670
671         _ClipFormat requestedFormat;
672         char* pRetrievedBuffer;
673         int bufferLength;
674         bool completed;
675 };
676
677 typedef Eina_Bool (*ClipConverter)(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
678 typedef int (*ClipResponseHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
679 typedef int (*ClipNotifyHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
680
681 enum
682 {
683         _ATOM_TARGETS = 0,
684         _ATOM_ATOM,
685         _ATOM_LISTING_ATOMS = _ATOM_ATOM,
686         _ATOM_TEXT_URI,
687         _ATOM_TEXT_URILIST,
688         _ATOM_TEXT_X_VCARD,
689         _ATOM_IMAGE_PNG,
690         _ATOM_IMAGE_JPEG,
691         _ATOM_IMAGE_BMP,
692         _ATOM_IMAGE_GIF,
693         _ATOM_IMAGE_TIFF,
694         _ATOM_IMAGE_SVG,
695         _ATOM_IMAGE_XPM,
696         _ATOM_IMAGE_TGA,
697         _ATOM_IMAGE_PPM,
698         _ATOM_XELM,
699         _ATOM_TEXT_HTML_UTF8,
700         _ATOM_TEXT_HTML,
701         _ATOM_STRING_UTF8,
702         _ATOM_STRING,
703         _ATOM_TEXT,
704         _ATOM_TEXT_PLAIN_UTF8,
705         _ATOM_TEXT_PLAIN,
706         _ATOM_MAX,
707 };
708
709 struct _Atom
710 {
711         const char* pName;
712         _ClipFormat formats;
713         ClipConverter convert;
714         ClipResponseHandler response;
715         ClipNotifyHandler notify;
716         Ecore_X_Atom atom;
717 };
718
719 Eina_Bool ClearClip(void* pData __UNUSED__, int type, void* pEvent);
720 Eina_Bool NotifyClip(void* pData __UNUSED__, int type, void* pEvent);
721
722 Eina_Bool ConvertClipIntoTarget(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
723 Eina_Bool ConvertClipIntoText(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
724 Eina_Bool ConvertClipIntoHtml(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
725 Eina_Bool ConvertClipIntoEdje(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
726 Eina_Bool ConvertClipIntoUri(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
727 Eina_Bool ConvertClipIntoImage(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
728 Eina_Bool ConvertClipIntoVCard(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
729
730 int NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
731 int NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
732 int NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
733 int NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
734 int NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
735 int NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
736
737 int RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
738
739 _Atom __atomList[_ATOM_MAX];
740 _Clip __clipList[_CLIP_TYPE_MAX];
741
742 Eina_Bool
743 ClearClip(void* pData __UNUSED__, int type __UNUSED__, void* pEvent)
744 {
745         SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
746
747         Ecore_X_Event_Selection_Clear* pE = (Ecore_X_Event_Selection_Clear*) pEvent;
748         Ecore_X_Window window = pE->win;
749
750         _ClipType clipType = _CLIP_TYPE_SECONDARY;
751         __clipList[clipType].requestedFormat = (_ClipFormat)(_CLIP_FORMAT_TEXT|_CLIP_FORMAT_IMAGE);
752
753         ecore_x_selection_secondary_request(window, ECORE_X_SELECTION_TARGET_TARGETS);
754
755         return ECORE_CALLBACK_PASS_ON;
756 }
757
758 Eina_Bool
759 ConvertClipIntoTarget(char* pTarget __UNUSED__, void* pData, int size__UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize)
760 {
761         return EINA_TRUE;
762
763         /*
764         SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
765         SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
766         SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
767         SysTryReturn(NID_UI, pType, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
768         SysTryReturn(NID_UI, pTypeSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
769
770         int index = *((int*) pData);
771         SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
772
773         int count = 0;
774         for (int i = 0; i < _ATOM_MAX; i++)
775         {
776                 if (__clipList[index].format & __atomList[i].formats)
777                         count++;
778         }
779
780         // Make the atom list to be possible to return data.
781         Ecore_X_Atom* pAtoms = null;
782         if (count > 0)
783         {
784                 pAtoms = (Ecore_X_Atom*) malloc(sizeof(Ecore_X_Atom) * count);
785                 SysTryReturn(NID_UI, pAtoms, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
786
787                 for (int i = 0, count = 0; i < _ATOM_MAX; i++)
788                 {
789                         if (__clipList[index].format & __atomList[i].formats)
790                                 pAtoms[count++] = __atomList[i].atom;
791                 }
792         }
793
794         *outData = pAtoms;
795         *outSize = count;
796         *pTypeSize = 32;
797         *pType = ECORE_X_ATOM_ATOM;
798
799         return EINA_TRUE;
800         */
801 }
802
803 Eina_Bool
804 ConvertClipIntoText(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
805 {
806         SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
807         SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
808         SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
809
810         int index = *((int*) pData);
811         SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
812         SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
813
814         if (__clipList[index].format & _CLIP_FORMAT_TEXT)
815         {
816                 *outData = strdup(__clipList[index].pBuffer);
817                 *outSize = strlen(__clipList[index].pBuffer);
818         }
819
820         return EINA_TRUE;
821 }
822
823 Eina_Bool
824 ConvertClipIntoHtml(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
825 {
826         SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
827         SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
828         SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
829
830         int index = *((int*) pData);
831         SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
832         SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
833
834         if (__clipList[index].format & _CLIP_FORMAT_HTML)
835         {
836                 *outData = strdup(__clipList[index].pBuffer);
837                 *outSize = strlen(__clipList[index].pBuffer);
838         }
839
840         return EINA_TRUE;
841 }
842
843 Eina_Bool
844 ConvertClipIntoEdje(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
845 {
846         return EINA_TRUE;
847 }
848
849 Eina_Bool
850 ConvertClipIntoUri(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
851 {
852         SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
853         SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
854         SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
855
856         int index = *((int*) pData);
857         SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
858         SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
859
860         if (__clipList[index].format & _CLIP_FORMAT_IMAGE)
861         {
862                 *outData = strdup(__clipList[index].pBuffer);
863                 *outSize = strlen(__clipList[index].pBuffer);
864         }
865
866         return EINA_TRUE;
867 }
868
869 Eina_Bool
870 ConvertClipIntoImage(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
871 {
872         return EINA_TRUE;
873 }
874
875 Eina_Bool
876 ConvertClipIntoVCard(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
877 {
878         return EINA_TRUE;
879 }
880
881 int
882 RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
883 {
884         return 0;
885 }
886
887 Eina_Bool
888 OnClipboardClosed(void* pData __UNUSED__, int type, void* pEvent)
889 {
890         SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
891
892         _Clipboard* pClipboard = _Clipboard::GetInstance();
893         if (pClipboard)
894         {
895                 bool visible = pClipboard->IsPopupVisible();
896
897                 if (visible == true)
898                 {
899                         pClipboard->FireEvent(0, null);
900                 }
901         }
902
903         return ECORE_CALLBACK_PASS_ON;
904 }
905
906 Eina_Bool
907 NotifyClip(void* pData __UNUSED__, int type, void* pEvent)
908 {
909         SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
910
911         Ecore_X_Event_Selection_Notify* pE = (Ecore_X_Event_Selection_Notify*) pEvent;
912
913         int i = 0;
914         for (i = 0; i < _CLIP_TYPE_MAX; i++)
915         {
916                 if (__clipList[i].selection == pE->selection)
917                 {
918                         break;
919                 }
920         }
921
922         SysTryReturn(NID_UI, i < _CLIP_TYPE_MAX, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
923
924         _Clip* pClip = __clipList + i;
925         for (i = 0; i < _ATOM_MAX; i++)
926         {
927                 if (!strcmp(pE->target, __atomList[i].pName))
928                 {
929                         if (__atomList[i].notify)
930                         {
931                                 __atomList[i].notify(pClip, pE);
932                         }
933                 }
934         }
935
936         return ECORE_CALLBACK_PASS_ON;
937 }
938
939 int
940 NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
941 {
942         SysTryReturn(NID_UI, pClip, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
943         SysTryReturn(NID_UI, pNotify, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
944
945         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
946         SysTryReturn(NID_UI, pEcoreEvas, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
947
948         _ControlManager* pControlManager = _ControlManager::GetInstance();
949         SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
950
951         _Window* pWindow = pControlManager->GetClipboardOwner();
952         SysTryReturn(NID_UI, pWindow, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
953
954         _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
955         SysTryReturn(NID_UI, pRootVE, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
956
957         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
958         SysTryReturn(NID_UI, pLayer, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
959
960         Ecore_Evas* pEE = pLayer->GetEcoreEvas();
961         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEE);
962
963         Ecore_X_Atom dataType = 0;
964         char* pBuffer = null;
965         if (pEcoreEvas->GetSelectedCbhmItem(&dataType, &pBuffer))
966         {
967                 free(pBuffer);
968
969                 const char* pHtmlAtomName = "text/html;charset=utf-8";
970                 Ecore_X_Atom htmlType = ecore_x_atom_get(pHtmlAtomName);
971
972                 if (dataType == htmlType)
973                 {
974                         pClip->request(window, pHtmlAtomName);
975                         return ECORE_CALLBACK_PASS_ON;
976                 }
977         }
978
979         Ecore_X_Selection_Data_Targets* pTargets = (Ecore_X_Selection_Data_Targets*) (pNotify->data);
980         Ecore_X_Atom* pAtomList = (Ecore_X_Atom*) (pTargets->data.data);
981
982         int i, j = 0;
983         for (j = (_ATOM_LISTING_ATOMS+1); j < _ATOM_MAX; j++)
984         {
985                 SysLog(NID_UI, "[Clipboard] __atomList[%d].atom = %d", j, __atomList[j].atom);
986
987                 if (!(__atomList[j].formats & pClip->requestedFormat))
988                 {
989                         continue;
990                 }
991
992                 for (i = 0; i < pTargets->data.length; i++)
993                 {
994                         SysLog(NID_UI, "[Clipboard] pAtomList[%d] = %d", i, pAtomList[i]);
995
996                         if ((__atomList[j].atom == pAtomList[i]) && (__atomList[j].notify))
997                         {
998                                 if ((j == _ATOM_XELM) && (!(pClip->requestedFormat & _CLIP_FORMAT_MARKUP)))
999                                 {
1000                                         continue;
1001                                 }
1002
1003                                 SysLog(NID_UI, "[Clipboard] go to __atomList[%d].atom = %d", j, __atomList[j].atom);
1004                                 goto FOUND;
1005                         }
1006                 }
1007         }
1008
1009         return ECORE_CALLBACK_PASS_ON;
1010
1011 FOUND:
1012         pClip->request(window, __atomList[j].pName);
1013         return ECORE_CALLBACK_PASS_ON;
1014 }
1015
1016 int
1017 NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1018 {
1019         SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1020         SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1021
1022         Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1023         SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1024
1025         pClip->bufferLength = (int) pData->length;
1026
1027         char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1028         if (pStr)
1029         {
1030                 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1031                 pStr[pClip->bufferLength] = '\0';
1032         }
1033         else
1034         {
1035                 SysLog(NID_UI, "[Clipboard] pStr is null.");
1036                 return 0;
1037         }
1038
1039         pClip->pRetrievedBuffer = pStr;
1040
1041         _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer);
1042
1043         return 0;
1044 }
1045
1046 int
1047 NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1048 {
1049         SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1050         SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1051
1052         Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1053         SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1054
1055         pClip->bufferLength = (int) pData->length;
1056
1057         char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1058         if (pStr)
1059         {
1060                 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1061                 pStr[pClip->bufferLength] = '\0';
1062         }
1063         else
1064         {
1065                 SysLog(NID_UI, "[Clipboard] pStr is null.");
1066                 return 0;
1067         }
1068
1069         pClip->pRetrievedBuffer = pStr;
1070
1071         _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer);
1072
1073         return 0;
1074 }
1075
1076 int
1077 NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1078 {
1079         SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1080         SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1081
1082         Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1083         SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1084
1085         pClip->bufferLength = (int) pData->length;
1086
1087         char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1088         if (pStr)
1089         {
1090                 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1091                 pStr[pClip->bufferLength] = '\0';
1092         }
1093         else
1094         {
1095                 SysLog(NID_UI, "[Clipboard] pStr is null.");
1096                 return 0;
1097         }
1098
1099         pClip->pRetrievedBuffer = pStr;
1100
1101         _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer);
1102
1103         return 0;
1104 }
1105
1106 int
1107 NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1108 {
1109         SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1110         SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1111
1112         Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1113         SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1114
1115         pClip->bufferLength = (int) pData->length;
1116
1117         char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1118         if (pStr)
1119         {
1120                 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1121                 pStr[pClip->bufferLength] = '\0';
1122         }
1123         else
1124         {
1125                 SysLog(NID_UI, "[Clipboard] pStr is null.");
1126                 return 0;
1127         }
1128
1129         pClip->pRetrievedBuffer = pStr;
1130
1131         _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer);
1132
1133         return 0;
1134 }
1135
1136 int
1137 NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1138 {
1139         SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1140         SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1141
1142         Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1143         SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1144
1145         pClip->bufferLength = (int) pData->length;
1146
1147         char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1148         if (pStr)
1149         {
1150                 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1151                 pStr[pClip->bufferLength] = '\0';
1152         }
1153         else
1154         {
1155                 SysLog(NID_UI, "[Clipboard] pStr is null.");
1156                 return 0;
1157         }
1158
1159         pClip->pRetrievedBuffer = pStr;
1160
1161         _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_HTML, pClip->pRetrievedBuffer);
1162
1163         return 0;
1164 }
1165 } // Anonymous
1166
1167 namespace Tizen { namespace Ui
1168 {
1169
1170 _EcoreEvas*
1171 _EcoreEvas::CreateInstanceN(void)
1172 {
1173         _EcoreEvas* pEcoreEvas = new (std::nothrow) _EcoreEvas;
1174         SysTryReturn(NID_UI, pEcoreEvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1175
1176         result r = GetLastResult();
1177         SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1178
1179         SetLastResult(E_SUCCESS);
1180
1181         return pEcoreEvas;
1182
1183 CATCH:
1184         delete pEcoreEvas;
1185         return null;
1186 }
1187
1188 _EcoreEvas::_EcoreEvas(void)
1189         : __pWindowVisibilityChanged(null)
1190         , __pWindowPropertyChanged(null)
1191         , __pWindowShown(null)
1192         , __pWindowConfigured(null)
1193         , __pClientMessageReceived(null)
1194         , __pClearClip(null)
1195         , __pNotifyClip(null)
1196         , __pClipboardClosed(null)
1197         , __pEvas(null)
1198         , __pForegroundWindow(null)
1199         , __pFrame(null)
1200         , __changeBounds(true)
1201         , __openClipboard(false)
1202 {
1203         int ret = appcore_unset_rotation_cb();
1204         SysLog(NID_UI, "[Window Manager Rotation] appcore_unset_rotation_cb = %d", ret);
1205
1206         __pWindowVisibilityChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, OnWindowVisibilityChanged, (void*) this);
1207         SysTryReturnVoidResult(NID_UI, __pWindowVisibilityChanged, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1208
1209         __pClientMessageReceived = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnClientMessageReceived, NULL);
1210
1211         ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_CONFIGURE);
1212         ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
1213
1214         _pEvas = this;
1215
1216         GetEcoreEvasMgr()->SetEcoreEvas(*this);
1217
1218         //int ret = 0;
1219         //ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, OnAutoRotationChanged, NULL);
1220         //SysTryCatch(NID_UI, ret == 0, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1221
1222         result r = InitializeAtomList();
1223         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1224
1225         __pWindowShown = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, OnWindowShown, (void*) this);
1226         SysTryCatch(NID_UI, __pWindowShown, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1227
1228         __pWindowConfigured = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, OnWindowConfigured, NULL);
1229         SysTryCatch(NID_UI, __pWindowConfigured, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1230
1231         __pWindowPropertyChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnWindowPropertyChanged, NULL);
1232         SysTryCatch(NID_UI, __pWindowPropertyChanged, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1233
1234         SetLastResult(E_SUCCESS);
1235
1236         return;
1237
1238 CATCH:
1239         if (__pWindowVisibilityChanged)
1240         {
1241                 ecore_event_handler_del(__pWindowVisibilityChanged);
1242                 __pWindowVisibilityChanged = null;
1243         }
1244
1245         if (__pWindowShown)
1246         {
1247                 ecore_event_handler_del(__pWindowShown);
1248                 __pWindowShown = null;
1249         }
1250
1251         if (__pWindowConfigured)
1252         {
1253                 ecore_event_handler_del(__pWindowConfigured);
1254                 __pWindowConfigured = null;
1255         }
1256 }
1257
1258 _EcoreEvas::~_EcoreEvas(void)
1259 {
1260         if (__pWindowVisibilityChanged)
1261         {
1262                 ecore_event_handler_del(__pWindowVisibilityChanged);
1263                 __pWindowVisibilityChanged = null;
1264         }
1265
1266         if (__pWindowShown)
1267         {
1268                 ecore_event_handler_del(__pWindowShown);
1269                 __pWindowShown = null;
1270         }
1271
1272         if (__pWindowConfigured)
1273         {
1274                 ecore_event_handler_del(__pWindowConfigured);
1275                 __pWindowConfigured = null;
1276         }
1277
1278         if (__pClientMessageReceived)
1279         {
1280                 ecore_event_handler_del(__pClientMessageReceived);
1281                 __pClientMessageReceived = null;
1282         }
1283
1284         for (int i = 0; i < _ATOM_MAX; i++)
1285         {
1286                 if (__atomList[i].atom)
1287                 {
1288                         ecore_x_selection_converter_atom_del(__atomList[i].atom);
1289                 }
1290         }
1291
1292         if (__pClearClip)
1293         {
1294                 ecore_event_handler_del(__pClearClip);
1295                 __pClearClip = null;
1296         }
1297
1298         if (__pNotifyClip)
1299         {
1300                 ecore_event_handler_del(__pNotifyClip);
1301                 __pNotifyClip = null;
1302         }
1303
1304         if (__pClipboardClosed)
1305         {
1306                 ecore_event_handler_del(__pClipboardClosed);
1307                 __pClipboardClosed = null;
1308         }
1309
1310         if (__pWindowPropertyChanged)
1311         {
1312                 ecore_event_handler_del(__pWindowPropertyChanged);
1313                 __pWindowPropertyChanged = null;
1314         }
1315
1316         //runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED);
1317 }
1318
1319 void
1320 _EcoreEvas::RotateWindow(const _Window& window, int orientation, bool rotateEvas)
1321 {
1322         // Set window bounds according to the rotation
1323         // Rotate Evas
1324
1325         _EflLayer* pLayer = GetEflLayer(window);
1326         if (!pLayer)
1327         {
1328                 return;
1329         }
1330
1331         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1332
1333         /*
1334         int curOrientation = ecore_evas_rotation_get(pEcoreEvas);
1335         if (curOrientation == orientation)
1336         {
1337                 return;
1338         }
1339         */
1340
1341         bool rotatePartial = true;
1342
1343         _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Window*>(&window));
1344         if (pFrame)
1345         {
1346                 FrameShowMode showMode = pFrame->GetShowMode(false);
1347                 if (showMode == FRAME_SHOW_MODE_FULL_SCREEN)
1348                 {
1349                         rotatePartial = false;
1350                 }
1351         }
1352
1353         _Window* pWindow = const_cast<_Window*>(&window);
1354         if (pWindow->IsLayoutChangable() == true)
1355         {
1356                 rotatePartial = false;
1357         }
1358
1359         Evas_Object* pWinObj = pLayer->GetElmWin();
1360         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1361
1362         int rootW = 0;
1363         int rootH = 0;
1364         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
1365
1366         if (rotatePartial == false)
1367         {
1368                 if (rotateEvas == true)
1369                 {
1370                         ecore_evas_rotation_with_resize_set(pEcoreEvas, orientation);
1371
1372                         evas_object_move(pWinObj, 0, 0);
1373
1374                         if ((orientation == 0) || (orientation == 180))
1375                         {
1376                                 evas_object_resize(pWinObj, rootW, rootH);
1377                         }
1378                         else
1379                         {
1380                                 evas_object_resize(pWinObj, rootH, rootW);
1381                         }
1382
1383                         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, FULL SCREEN] Rotate bounds(rot = %d).", win, orientation);
1384                 }
1385         }
1386         else
1387         {
1388                 if (rotateEvas == true)
1389                 {
1390                         ecore_evas_rotation_set(pEcoreEvas, orientation);
1391                 }
1392
1393                 Rectangle winBounds = _CoordinateSystemUtils::Transform(window.GetBounds());
1394                 int rotate = ecore_evas_rotation_get(pEcoreEvas);
1395
1396
1397                 int winX = winBounds.x;
1398                 int winY = winBounds.y;
1399
1400                 switch (rotate)
1401                 {
1402                 case 270:
1403                         winX = rootW - winBounds.y - winBounds.height;
1404                         winY = winBounds.x;
1405                         break;
1406                 case 90:
1407                         winX = winBounds.y;
1408                         winY = rootH - winBounds.x - winBounds.width;
1409                         break;
1410                 case 180:
1411                         winX = rootW - winBounds.x - winBounds.width;
1412                         winY = rootH - winBounds.y - winBounds.height;
1413                         break;
1414                 default:
1415                         break;
1416                 }
1417
1418                 int x = 0;
1419                 int y = 0;
1420                 int w = 0;
1421                 int h = 0;
1422                 Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
1423
1424                 evas_object_move(pWinObj, winX, winY);
1425
1426                 if (ret == EINA_FALSE)
1427                 {
1428                         evas_object_resize(pWinObj, winBounds.width, winBounds.height);
1429                         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, PARTIAL SCREEN] Rotate bounds(rot = %d, %d, %d, %d, %d).", win, orientation, winX, winY, winBounds.width, winBounds.height);
1430                 }
1431                 else
1432                 {
1433                         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, PARTIAL SCREEN] Rotate bounds(rot = %d, %d, %d) ONLY MOVE.", win, orientation, winX, winY);
1434                 }
1435         }
1436 }
1437
1438 _EflLayer*
1439 _EcoreEvas::GetEflLayer(const _Window& window) const
1440 {
1441         _RootVisualElement* pRootVisualElement = null;
1442
1443         pRootVisualElement = window.GetRootVisualElement();
1444         if (!pRootVisualElement)
1445         {
1446                 SysLog(NID_UI, "The root visual element is null.");
1447                 return null;
1448         }
1449
1450         _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer());
1451         if (!pEflLayer)
1452         {
1453                 SysLog(NID_UI, "The efl layer is null.");
1454                 return null;
1455         }
1456
1457         return pEflLayer;
1458 }
1459
1460 bool
1461 _EcoreEvas::GetFloatingMode(void) const
1462 {
1463         SysTryReturn(NID_UI, __pForegroundWindow, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1464
1465         Eina_Bool ret = elm_win_floating_mode_get(__pForegroundWindow);
1466
1467         SetLastResult(E_SUCCESS);
1468
1469         return (ret ? true : false);
1470 }
1471
1472 // [ToDo] Remove API
1473 bool
1474 _EcoreEvas::GetFloatingMode(const _Window& window) const
1475 {
1476         _EflLayer* pLayer = GetEflLayer(window);
1477         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1478
1479         Evas_Object* pWinObj = pLayer->GetElmWin();
1480         SysTryReturn(NID_UI, pWinObj, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1481
1482         Eina_Bool ret = elm_win_floating_mode_get(pWinObj);
1483
1484         SetLastResult(E_SUCCESS);
1485
1486         return (ret ? true : false);
1487 }
1488
1489 // [ToDo] Remove API
1490 void
1491 _EcoreEvas::AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1492 {
1493 }
1494
1495 // [ToDo] Remove API
1496 void
1497 _EcoreEvas::RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1498 {
1499 }
1500
1501 unsigned int
1502 _EcoreEvas::GetActiveWindow(void)
1503 {
1504         Ecore_X_Window* pRoots = null;
1505         Ecore_X_Window activeWin = 0;
1506         int num = 0;
1507
1508         pRoots = ecore_x_window_root_list(&num);
1509         if (pRoots)
1510         {
1511                 Ecore_X_Atom activeAtom = ecore_x_atom_get("_NET_ACTIVE_WINDOW");
1512                 int ret = ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1);
1513
1514                 free(pRoots);
1515
1516                 if (ret < 0)
1517                 {
1518                         return 0;
1519                 }
1520         }
1521
1522         return activeWin;
1523 }
1524
1525 int
1526 _EcoreEvas::GetProcessId(unsigned int window)
1527 {
1528         int pid = 0;
1529         Eina_Bool ret = ecore_x_netwm_pid_get(window, &pid);
1530
1531         if (ret != EINA_TRUE)
1532         {
1533                 return 0;
1534         }
1535
1536         return pid;
1537 }
1538
1539 void
1540 _EcoreEvas::SetOwner(NativeWindowHandle ownee, NativeWindowHandle owner)
1541 {
1542         Ecore_X_Window win = ecore_x_icccm_transient_for_get(ownee);
1543         if (win != owner)
1544         {
1545                 ecore_x_icccm_transient_for_unset(ownee);
1546                 ecore_x_icccm_transient_for_set(ownee, owner);
1547                 SysLog(NID_UI, "[Window Order Group][Window : 0x%x] transient_for_set -> 0x%x", ownee, owner);
1548         }
1549 }
1550
1551 void
1552 _EcoreEvas::ActivateWindow(const _Window& window)
1553 {
1554         _EflLayer* pLayer = GetEflLayer(window);
1555         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1556
1557         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1558         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1559
1560         ecore_evas_activate(pEcoreEvas);
1561
1562         NativeWindowHandle currentWindow = window.GetNativeHandle();
1563         unsigned int activeWindow = GetActiveWindow();
1564         int pid = GetProcessId(activeWindow);
1565         SysLog(NID_UI, "currentWindow = 0x%x, activeWindow = 0x%x, pid = %d", currentWindow, activeWindow, pid);
1566
1567         SetLastResult(E_SUCCESS);
1568 }
1569
1570 void
1571 _EcoreEvas::MinimizeWindow(_Window& window)
1572 {
1573         _EflLayer* pLayer = GetEflLayer(window);
1574         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1575
1576         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1577         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1578
1579         //ecore_evas_lower(pEcoreEvas);
1580         ecore_evas_iconified_set(pEcoreEvas, EINA_TRUE);
1581
1582         SetLastResult(E_SUCCESS);
1583 }
1584
1585 void
1586 _EcoreEvas::SetRenderBackend(_RenderBackend backend)
1587 {
1588         switch (backend)
1589         {
1590         case _RENDER_BACKEND_SW:
1591                 elm_config_preferred_engine_set("software_x11");
1592                 break;
1593         case _RENDER_BACKEND_GL:
1594                 elm_config_preferred_engine_set("opengl_x11");
1595                 break;
1596         case _RENDER_BACKEND_DEFAULT:
1597                 // fall through
1598         default:
1599                 elm_config_preferred_engine_set(NULL);
1600                 break;
1601         }
1602 }
1603
1604 _RenderBackend
1605 _EcoreEvas::GetRenderBackend(void)
1606 {
1607         _RenderBackend backend = _RENDER_BACKEND_DEFAULT;
1608
1609         const char* pEngine = elm_config_preferred_engine_get();
1610
1611         if (pEngine == NULL)
1612         {
1613                 backend = _RENDER_BACKEND_DEFAULT;
1614         }
1615         else if (strcmp(pEngine, "software_x11") == 0)
1616         {
1617                 backend = _RENDER_BACKEND_SW;
1618         }
1619         else if (strcmp(pEngine, "opengl_x11") == 0)
1620         {
1621                 backend = _RENDER_BACKEND_GL;
1622         }
1623
1624         return backend;
1625 }
1626
1627 result
1628 _EcoreEvas::CopyClip(_ClipFormat format, const char* pChar)
1629 {
1630         SysTryReturn(NID_UI, IsValidClipFormat(format), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid.");
1631         SysTryReturn(NID_UI, pChar, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid.");
1632
1633         Ecore_X_Atom dataType = 0;
1634
1635         switch (format)
1636         {
1637         case _CLIP_FORMAT_TEXT:
1638                 dataType = ecore_x_atom_get("UTF8_STRING");
1639                 break;
1640         case _CLIP_FORMAT_IMAGE:
1641                 dataType = ecore_x_atom_get("text/uri");
1642                 break;
1643         case _CLIP_FORMAT_HTML:
1644                 dataType = ecore_x_atom_get("text/html;charset=utf-8");
1645                 break;
1646         default:
1647                 break;
1648         }
1649
1650         _ControlManager* pControlManager = _ControlManager::GetInstance();
1651
1652         _Window* pWindow = pControlManager->GetClipboardOwner();
1653         if (!pWindow)
1654         {
1655                 return E_SUCCESS;
1656         }
1657
1658         _EflLayer* pLayer = GetEflLayer(*pWindow);
1659         if (!pLayer)
1660         {
1661                 return E_SUCCESS;
1662         }
1663
1664         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1665         SysAssert(window);
1666
1667         SetCbhmItem(window, dataType, (char*)pChar);
1668
1669         return E_SUCCESS;
1670 }
1671
1672 bool
1673 _EcoreEvas::RetrieveClipN(int index, int* format, char** pData)
1674 {
1675         Ecore_X_Atom dataType = 0;
1676
1677         _ControlManager* pControlManager = _ControlManager::GetInstance();
1678
1679         _Window* pWindow = pControlManager->GetClipboardOwner();
1680         if (!pWindow)
1681         {
1682                 return false;
1683         }
1684
1685         _EflLayer* pLayer = GetEflLayer(*pWindow);
1686         if (!pLayer)
1687         {
1688                 return false;
1689         }
1690
1691         GetCbhmItem(index, &dataType, pData);
1692
1693         if ((dataType == ecore_x_atom_get("UTF8_STRING"))
1694                 ||(dataType == ecore_x_atom_get("application/x-elementary-markup")))
1695         {
1696                 *format = _CLIP_FORMAT_TEXT;
1697         }
1698         else if (dataType == ecore_x_atom_get("text/uri"))
1699         {
1700                 *format = _CLIP_FORMAT_IMAGE;
1701         }
1702         else if (dataType == ecore_x_atom_get("text/html;charset=utf-8"))
1703         {
1704                 *format = _CLIP_FORMAT_HTML;
1705         }
1706
1707         if (*pData == null)
1708         {
1709                 return false;
1710         }
1711
1712         // Convert markup to utf8.
1713         if (dataType == ecore_x_atom_get("application/x-elementary-markup"))
1714         {
1715                 char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, *pData);
1716                 SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", *pData, pTempChar);
1717                 free(*pData);
1718
1719                 *pData = pTempChar;
1720         }
1721
1722         return true;
1723 }
1724
1725 int
1726 _EcoreEvas::GetClipCount(void) const
1727 {
1728         _ControlManager* pControlManager = _ControlManager::GetInstance();
1729
1730         _Window* pWindow = pControlManager->GetClipboardOwner();
1731         if (!pWindow)
1732         {
1733                 return 0;
1734         }
1735
1736         _EflLayer* pLayer = GetEflLayer(*pWindow);
1737         if (!pLayer)
1738         {
1739                 return 0;
1740         }
1741
1742         int count = GetCbhmItemCount();
1743
1744         return count;
1745 }
1746
1747 void
1748 _EcoreEvas::OpenClipboard(unsigned long clipFormats)
1749 {
1750         _ControlManager* pControlManager = _ControlManager::GetInstance();
1751
1752         _Window* pWindow = pControlManager->GetClipboardOwner();
1753         if (!pWindow)
1754         {
1755                 return;
1756         }
1757
1758         _EflLayer* pLayer = GetEflLayer(*pWindow);
1759         if (!pLayer)
1760         {
1761                 return;
1762         }
1763
1764         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1765         SysAssert(window);
1766
1767         ecore_x_selection_secondary_set(window, "", 1);
1768
1769         if (_CLIP_FORMAT_IMAGE & clipFormats)
1770         {
1771                 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW_ALL);
1772         }
1773         else
1774         {
1775                 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW);
1776         }
1777
1778         __openClipboard = true;
1779 }
1780
1781 void
1782 _EcoreEvas::CloseClipboard(void)
1783 {
1784         _ControlManager* pControlManager = _ControlManager::GetInstance();
1785
1786         _Window* pWindow = pControlManager->GetClipboardOwner();
1787         if (!pWindow)
1788         {
1789                 return;
1790         }
1791
1792         _EflLayer* pLayer = GetEflLayer(*pWindow);
1793         if (!pLayer)
1794         {
1795                 return;
1796         }
1797
1798         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1799         SysAssert(window);
1800
1801         __openClipboard = false;
1802         SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_HIDE);
1803 }
1804
1805 bool
1806 _EcoreEvas::IsClipboardOpened(void)
1807 {
1808         return __openClipboard;
1809 }
1810
1811 String
1812 _EcoreEvas::ConvertMarkupToUtf8(const String& string)
1813 {
1814         char* pChar = _Clipboard::GetInstance()->EncodeToCharN(string);
1815         if (!pChar)
1816         {
1817                 return String(L"");
1818         }
1819
1820         char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, pChar);
1821         SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", pChar, pTempChar);
1822         free(pChar);
1823
1824         String str(pTempChar);
1825         free(pTempChar);
1826
1827         return str;
1828 }
1829
1830 result
1831 _EcoreEvas::SetEventPropagation(const _Control& control, bool enable)
1832 {
1833         _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1834         SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1835
1836         Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1837         SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1838
1839         evas_object_propagate_events_set(pEvasObject, (enable ? EINA_TRUE : EINA_FALSE));
1840
1841         return E_SUCCESS;
1842 }
1843
1844 result
1845 _EcoreEvas::SetFocus(const _Control& control, bool focus)
1846 {
1847         _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1848         SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1849
1850         Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1851         SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1852
1853         evas_object_focus_set(pEvasObject, (focus ? EINA_TRUE : EINA_FALSE));
1854
1855         return E_SUCCESS;
1856 }
1857
1858 result
1859 _EcoreEvas::SetIndicatorShowState(const _Window& window, bool showState)
1860 {
1861         _EflLayer* pLayer = GetEflLayer(window);
1862         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1863
1864         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1865         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1866
1867         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1868
1869         if (showState)
1870         {
1871                 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1872         }
1873         else
1874         {
1875                 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1876         }
1877
1878         return E_SUCCESS;
1879 }
1880
1881 bool
1882 _EcoreEvas::GetIndicatorShowState(const _Window& window) const
1883 {
1884         _EflLayer* pLayer = GetEflLayer(window);
1885         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1886
1887         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1888         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1889
1890         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1891         Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(win);
1892
1893         bool showState = true;
1894         if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON)
1895         {
1896                 showState = true;
1897         }
1898         else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF)
1899         {
1900                 showState = false;
1901         }
1902
1903         return showState;
1904 }
1905
1906 // [ToDo] Remove API
1907 Rectangle
1908 _EcoreEvas::GetIndicatorBounds(const _Window& window) const
1909 {
1910         _EflLayer* pLayer = GetEflLayer(window);
1911         SysTryReturn(NID_UI, pLayer, Rectangle(0, 0, 0, 0), E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1912
1913         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1914         SysTryReturn(NID_UI, pEcoreEvas, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1915
1916         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1917         Ecore_X_Window rootWin = (Ecore_X_Window) ecore_x_window_root_get(win);
1918
1919         int x = 0;
1920         int y = 0;
1921         int width = 0;
1922         int height = 0;
1923
1924         bool ret = false;
1925         ret = ecore_x_e_illume_indicator_geometry_get(rootWin, &x, &y, &width, &height);
1926         SysTryReturn(NID_UI, ret == true, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1927
1928         SetLastResult(E_SUCCESS);
1929
1930         return Rectangle(x, y, width, height);
1931 }
1932
1933 // [ToDo] Remove API
1934 result
1935 _EcoreEvas::SetIndicatorOpacity(const _Window& window, _IndicatorOpacity opacity)
1936 {
1937         _EflLayer* pLayer = GetEflLayer(window);
1938         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1939
1940         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1941         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1942
1943         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1944
1945         Ecore_X_Illume_Indicator_Opacity_Mode mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1946         switch (opacity)
1947         {
1948         case _INDICATOR_OPACITY_UNKNOWN:
1949                 mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1950                 break;
1951         case _INDICATOR_OPACITY_OPAQUE:
1952                 mode = ECORE_X_ILLUME_INDICATOR_OPAQUE;
1953                 break;
1954         case _INDICATOR_OPACITY_TRANSLUCENT:
1955                 mode = ECORE_X_ILLUME_INDICATOR_TRANSLUCENT;
1956                 break;
1957         case _INDICATOR_OPACITY_TRANSPARENT:
1958                 mode = ECORE_X_ILLUME_INDICATOR_TRANSPARENT;
1959                 break;
1960         default:
1961                 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1962                 return E_INVALID_ARG;
1963         }
1964
1965         ecore_x_e_illume_indicator_opacity_set(win, mode);
1966
1967         return E_SUCCESS;
1968 }
1969
1970 // [ToDo] Remove API
1971 _IndicatorOpacity
1972 _EcoreEvas::GetIndicatorOpacity(const _Window& window) const
1973 {
1974         _EflLayer* pLayer = GetEflLayer(window);
1975         SysTryReturn(NID_UI, pLayer, _INDICATOR_OPACITY_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1976
1977         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1978         SysTryReturn(NID_UI, pEcoreEvas, _INDICATOR_OPACITY_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1979
1980         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1981         Ecore_X_Illume_Indicator_Opacity_Mode mode = ecore_x_e_illume_indicator_opacity_get(win);
1982
1983         _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN;
1984         switch (mode)
1985         {
1986         case ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN:
1987                 opacity = _INDICATOR_OPACITY_UNKNOWN;
1988                 break;
1989         case ECORE_X_ILLUME_INDICATOR_OPAQUE:
1990                 opacity = _INDICATOR_OPACITY_OPAQUE;
1991                 break;
1992         case ECORE_X_ILLUME_INDICATOR_TRANSLUCENT:
1993                 opacity = _INDICATOR_OPACITY_TRANSLUCENT;
1994                 break;
1995         case ECORE_X_ILLUME_INDICATOR_TRANSPARENT:
1996                 opacity = _INDICATOR_OPACITY_TRANSPARENT;
1997                 break;
1998         default:
1999                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2000                 return _INDICATOR_OPACITY_UNKNOWN;
2001         }
2002
2003         SetLastResult(E_SUCCESS);
2004
2005         return opacity;
2006 }
2007
2008 void
2009 _EcoreEvas::SetWindowActivationEnabled(const _Window& window, bool enable)
2010 {
2011         _EflLayer* pLayer = GetEflLayer(window);
2012         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2013
2014         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2015         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2016
2017         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2018
2019         Eina_Bool acceptsFocus;
2020         Ecore_X_Window_State_Hint initialState;
2021         Ecore_X_Pixmap iconPixmap;
2022         Ecore_X_Pixmap iconMask;
2023         Ecore_X_Window iconWindow;
2024         Ecore_X_Window windowGroup;
2025         Eina_Bool isUrgent;
2026
2027         ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2028         ecore_x_icccm_hints_set(win, (enable ? EINA_TRUE : EINA_FALSE), initialState, iconPixmap, iconMask, iconWindow, windowGroup, isUrgent);
2029 }
2030
2031 bool
2032 _EcoreEvas::IsWindowActivationEnabled(const _Window& window)
2033 {
2034         _EflLayer* pLayer = GetEflLayer(window);
2035         SysTryReturn(NID_UI, pLayer, true, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2036
2037         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2038         SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2039
2040         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2041
2042         Eina_Bool acceptsFocus;
2043         Ecore_X_Window_State_Hint initialState;
2044         Ecore_X_Pixmap iconPixmap;
2045         Ecore_X_Pixmap iconMask;
2046         Ecore_X_Window iconWindow;
2047         Ecore_X_Window windowGroup;
2048         Eina_Bool isUrgent;
2049
2050         ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2051
2052         return (acceptsFocus ? true : false);
2053 }
2054
2055 void
2056 _EcoreEvas::SetWindowName(const _Window& window, const Tizen::Base::String& name)
2057 {
2058         _EflLayer* pLayer = GetEflLayer(window);
2059         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2060
2061         Evas_Object* pWinObj = pLayer->GetElmWin();
2062         SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2063
2064         const char* windowName = _StringConverter::CopyToCharArrayN(name);
2065         if (windowName)
2066         {
2067                 elm_win_title_set(pWinObj, windowName);
2068
2069                 delete[] windowName;
2070         }
2071 }
2072
2073 void
2074 _EcoreEvas::SetWindowType(const _Window& window, int winType)
2075 {
2076         _EflLayer* pLayer = GetEflLayer(window);
2077         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2078
2079         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2080         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2081
2082         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2083
2084         if (winType == _WINDOW_TYPE_SUB)
2085         {
2086                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_UTILITY);
2087         }
2088 }
2089
2090 result
2091 _EcoreEvas::SetFloatingMode(const _Window& window, bool enable)
2092 {
2093         _EflLayer* pLayer = GetEflLayer(window);
2094         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2095
2096         Evas_Object* pWinObj = pLayer->GetElmWin();
2097         SysTryReturn(NID_UI, pWinObj, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2098
2099         elm_win_floating_mode_set(pWinObj, (enable ? EINA_TRUE : EINA_FALSE));
2100
2101         return E_SUCCESS;
2102 }
2103
2104 // [ToDo] Remove API
2105 Evas*
2106 _EcoreEvas::GetEvas(void) const
2107 {
2108         SysLog(NID_UI, "Do not use.");
2109         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2110         if (!pWindow)
2111         {
2112                 return null;
2113         }
2114
2115         _EflLayer* pLayer = GetEflLayer(*pWindow);
2116         if (!pLayer)
2117         {
2118                 return null;
2119         }
2120
2121         return pLayer->GetEvas();
2122 }
2123
2124 // [ToDo] Remove API
2125 Ecore_Evas*
2126 _EcoreEvas::GetEcoreEvas(void) const
2127 {
2128         SysLog(NID_UI, "Do not use.");
2129         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2130         if (!pWindow)
2131         {
2132                 return null;
2133         }
2134
2135         _EflLayer* pLayer = GetEflLayer(*pWindow);
2136         if (!pLayer)
2137         {
2138                 return null;
2139         }
2140
2141         return pLayer->GetEcoreEvas();
2142 }
2143
2144 // [ToDo] Remove API
2145 Evas_Object*
2146 _EcoreEvas::GetWindowObject(void) const
2147 {
2148         SysLog(NID_UI, "Do not use.");
2149         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2150         if (!pWindow)
2151         {
2152                 return null;
2153         }
2154
2155         _EflLayer* pLayer = GetEflLayer(*pWindow);
2156         if (!pLayer)
2157         {
2158                 return null;
2159         }
2160
2161         return pLayer->GetElmWin();
2162 }
2163
2164 // [ToDo] Remove API
2165 Ecore_X_Window
2166 _EcoreEvas::GetXWindow(void) const
2167 {
2168         SysLog(NID_UI, "Do not use.");
2169         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2170         if (!pWindow)
2171         {
2172                 return 0;
2173         }
2174
2175         _EflLayer* pLayer = GetEflLayer(*pWindow);
2176         if (!pLayer)
2177         {
2178                 return 0;
2179         }
2180
2181         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2182
2183         return win;
2184 }
2185
2186 void
2187 _EcoreEvas::AllowSetWindowBounds(bool allow)
2188 {
2189         __changeBounds = allow;
2190 }
2191
2192 bool
2193 _EcoreEvas::IsWindowVisible(const _Window& window)
2194 {
2195         _EflLayer* pLayer = GetEflLayer(window);
2196         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2197
2198         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2199         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2200
2201         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2202
2203         int ret = ecore_x_window_visible_get(win);
2204         if (ret == 1)
2205         {
2206                 return true;
2207         }
2208         else
2209         {
2210                 return false;
2211         }
2212 }
2213
2214 // [ToDo] Remove API
2215 void
2216 _EcoreEvas::SetQuickPanelScrollEnabled(const _Window& window, bool enable)
2217 {
2218         /*
2219         _EflLayer* pLayer = GetEflLayer(window);
2220         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2221
2222         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2223         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2224
2225         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2226         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2227
2228         unsigned int val[3];
2229         ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2230
2231         if (enable)
2232         {
2233                 val[1] = 1;
2234         }
2235         else
2236         {
2237                 val[1] = 0;
2238         }
2239
2240         ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
2241         */
2242 }
2243
2244 // [ToDo] Remove API
2245 bool
2246 _EcoreEvas::IsQuickPanelScrollEnabled(const _Window& window)
2247 {
2248         /*
2249         _EflLayer* pLayer = GetEflLayer(window);
2250         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2251
2252         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2253         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2254
2255         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2256         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2257
2258         unsigned int val[3];
2259         ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2260
2261         if (val[1] == 0)
2262         {
2263                 return false;
2264         }
2265         else
2266         {
2267                 return true;
2268         }
2269         */
2270
2271         return true;
2272 }
2273
2274 void
2275 _EcoreEvas::SetWindowLevel(const _Window& window, _WindowLevel level)
2276 {
2277         _EflLayer* pLayer = GetEflLayer(window);
2278         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2279
2280         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2281         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2282
2283         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2284         ecore_x_icccm_transient_for_unset(win);
2285
2286         if (level == _WINDOW_LEVEL_NORMAL)
2287         {
2288                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
2289         }
2290         else if (level == _WINDOW_LEVEL_NOTIFICATION_HIGH)
2291         {
2292                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2293                 utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_HIGH);
2294         }
2295         else if (level == _WINDOW_LEVEL_NOTIFICATION_MIDDLE)
2296         {
2297                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2298                 utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_NORMAL);
2299         }
2300
2301         SetLastResult(E_SUCCESS);
2302 }
2303
2304 _WindowLevel
2305 _EcoreEvas::GetWindowLevel(const _Window& window) const
2306 {
2307         _EflLayer* pLayer = GetEflLayer(window);
2308         SysTryReturn(NID_UI, pLayer, _WINDOW_LEVEL_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2309
2310         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2311         SysTryReturn(NID_UI, pEcoreEvas, _WINDOW_LEVEL_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2312
2313         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2314
2315         Ecore_X_Window_Type type = ECORE_X_WINDOW_TYPE_UNKNOWN;
2316         ecore_x_netwm_window_type_get(win, &type);
2317
2318         _WindowLevel winLevel = _WINDOW_LEVEL_UNKNOWN;
2319         if (type == ECORE_X_WINDOW_TYPE_NORMAL)
2320         {
2321                 winLevel = _WINDOW_LEVEL_NORMAL;
2322         }
2323         else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION)
2324         {
2325                 Utilx_Notification_Level notificationLevel = utilx_get_system_notification_level((Display*)ecore_x_display_get(), win);
2326
2327                 if (notificationLevel == UTILX_NOTIFICATION_LEVEL_HIGH)
2328                 {
2329                         winLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH;
2330                 }
2331                 else if (notificationLevel == UTILX_NOTIFICATION_LEVEL_NORMAL)
2332                 {
2333                         winLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE;
2334                 }
2335         }
2336
2337         SetLastResult(E_SUCCESS);
2338
2339         return winLevel;
2340 }
2341
2342 void
2343 _EcoreEvas::SetWindowBounds(const _Window& window, const Rectangle& bounds)
2344 {
2345         if (__changeBounds == false)
2346         {
2347                 return;
2348         }
2349
2350         _EflLayer* pLayer = GetEflLayer(window);
2351         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2352
2353         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2354         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2355
2356         Evas_Object* pWinObject = pLayer->GetElmWin();
2357         SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2358
2359         Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2360
2361         int rotate = ecore_evas_rotation_get(pEcoreEvas);
2362
2363 //      _Window* pWindow = const_cast<_Window*>(&window);
2364 //      _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2365 //      if (pContextMenu)
2366         if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2367         {
2368                 _ControlManager* pControlManager = _ControlManager::GetInstance();
2369                 if (pControlManager)
2370                 {
2371                         _Window* pCurFrame = pControlManager->GetCurrentFrame();
2372                         if (pCurFrame)
2373                         {
2374                                 int ownerRotate = GetWindowRotation(*pCurFrame);
2375                                 if (ownerRotate != rotate)
2376                                 {
2377                                         return;
2378                                 }
2379                         }
2380                 }
2381         }
2382
2383         int winX = winBounds.x;
2384         int winY = winBounds.y;
2385
2386         int rootW = 0;
2387         int rootH = 0;
2388         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2389
2390         switch (rotate)
2391         {
2392         case 270:
2393                 winX = rootW - winBounds.y - winBounds.height;
2394                 winY = winBounds.x;
2395                 break;
2396         case 90:
2397                 winX = winBounds.y;
2398                 winY = rootH - winBounds.x - winBounds.width;
2399                 break;
2400         case 180:
2401                 winX = rootW - winBounds.x - winBounds.width;
2402                 winY = rootH - winBounds.y - winBounds.height;
2403                 break;
2404         default:
2405                 break;
2406         }
2407
2408         int x = 0;
2409         int y = 0;
2410         int w = 0;
2411         int h = 0;
2412         Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2413
2414         evas_object_move(pWinObject, winX, winY);
2415
2416         if (ret == EINA_FALSE)
2417         {
2418                 evas_object_resize(pWinObject, winBounds.width, winBounds.height);
2419                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2420         }
2421         else
2422         {
2423                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY);
2424         }
2425
2426         SetLastResult(E_SUCCESS);
2427 }
2428
2429 void
2430 _EcoreEvas::SetWindowBounds(const _Window& window, const FloatRectangle& bounds)
2431 {
2432         if (__changeBounds == false)
2433         {
2434                 return;
2435         }
2436
2437         _EflLayer* pLayer = GetEflLayer(window);
2438         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2439
2440         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2441         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2442
2443         Evas_Object* pWinObject = pLayer->GetElmWin();
2444         SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2445
2446         FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2447         Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2448
2449         int rotate = ecore_evas_rotation_get(pEcoreEvas);
2450
2451 //      _Window* pWindow = const_cast<_Window*>(&window);
2452 //      _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2453 //      if (pContextMenu)
2454         if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2455         {
2456                 _ControlManager* pControlManager = _ControlManager::GetInstance();
2457                 if (pControlManager)
2458                 {
2459                         _Window* pCurFrame = pControlManager->GetCurrentFrame();
2460                         if (pCurFrame)
2461                         {
2462                                 int ownerRotate = GetWindowRotation(*pCurFrame);
2463                                 if (ownerRotate != rotate)
2464                                 {
2465                                         return;
2466                                 }
2467                         }
2468                 }
2469         }
2470
2471         int winX = winBounds.x;
2472         int winY = winBounds.y;
2473
2474         int rootW = 0;
2475         int rootH = 0;
2476         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2477
2478         switch (rotate)
2479         {
2480         case 270:
2481                 winX = rootW - winBounds.y - winBounds.height;
2482                 winY = winBounds.x;
2483                 break;
2484         case 90:
2485                 winX = winBounds.y;
2486                 winY = rootH - winBounds.x - winBounds.width;
2487                 break;
2488         case 180:
2489                 winX = rootW - winBounds.x - winBounds.width;
2490                 winY = rootH - winBounds.y - winBounds.height;
2491                 break;
2492         default:
2493                 break;
2494         }
2495
2496         int x = 0;
2497         int y = 0;
2498         int w = 0;
2499         int h = 0;
2500         Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2501
2502         evas_object_move(pWinObject, winX, winY);
2503
2504         if (ret == EINA_FALSE)
2505         {
2506                 evas_object_resize(pWinObject, winBounds.width, winBounds.height);
2507                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2508         }
2509         else
2510         {
2511                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY);
2512         }
2513
2514         SetLastResult(E_SUCCESS);
2515 }
2516
2517 void
2518 _EcoreEvas::SetWindowVisibleState(const _Window& window, bool visibleState)
2519 {
2520         _EflLayer* pLayer = GetEflLayer(window);
2521         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2522
2523         Evas_Object* pWinObj = pLayer->GetElmWin();
2524         SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2525
2526         pLayer->SetShowState(visibleState);
2527
2528         SetLastResult(E_SUCCESS);
2529 }
2530
2531 void
2532 _EcoreEvas::SetOwner(const _Window& ownee, const _Control& owner)
2533 {
2534         _Window* pOwnerWindow = owner.GetRootWindow();
2535         SysTryReturnVoidResult(NID_UI, pOwnerWindow, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a root window.");
2536
2537         _EflLayer* pOwnerLayer = GetEflLayer(*pOwnerWindow);
2538         SysTryReturnVoidResult(NID_UI, pOwnerLayer, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a elf layer.");
2539
2540         _EflLayer* pOwneeLayer = GetEflLayer(ownee);
2541         SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer.");
2542
2543         Ecore_X_Window ownerWin = (Ecore_X_Window) ecore_evas_window_get(pOwnerLayer->GetEcoreEvas());
2544         Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas());
2545
2546         Ecore_X_Window_Type type;
2547         ecore_x_netwm_window_type_get(owneeWin, &type);
2548         if ((type == ECORE_X_WINDOW_TYPE_NORMAL) || (type == ECORE_X_WINDOW_TYPE_UTILITY))
2549         {
2550                 Ecore_X_Window win = ecore_x_icccm_transient_for_get(owneeWin);
2551                 if (win != ownerWin)
2552                 {
2553                         ecore_x_icccm_transient_for_unset(owneeWin);
2554                         ecore_x_icccm_transient_for_set(owneeWin, ownerWin);
2555                         SysLog(NID_UI, "[Window Order Group][Window : 0x%x] transient_for_set -> 0x%x", owneeWin, ownerWin);
2556                 }
2557         }
2558         else
2559         {
2560                 SysLog(NID_UI, "[Window Order Group][Window : 0x%x] Skip to transient_for_set", owneeWin);
2561         }
2562
2563         // Ownee window
2564         // 1. IsLayoutChangable : true
2565         // 2. IsRotationSynchronized : true
2566         // -> available_set
2567
2568         if ((ownee.IsLayoutChangable() == true) || (ownee.IsRotationSynchronized() == true))
2569         {
2570                 int* rotations = null;
2571                 unsigned int count = 0;
2572                 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pOwnerLayer->GetEcoreEvas(), &rotations, &count);
2573
2574                 if (ret)
2575                 {
2576                         if (rotations)
2577                         {
2578                                 SetWindowAvailabledRotation(ownee, rotations, count);
2579                                 free(rotations);
2580                         }
2581                 }
2582
2583                 bool preferredRoation = pOwnerWindow->GetPreferredRotation();
2584                 if (preferredRoation == true)
2585                 {
2586                         int preferredRotation = ecore_evas_wm_rotation_preferred_rotation_get(pOwnerLayer->GetEcoreEvas());
2587                         SetWindowPreferredRotation(ownee, preferredRotation);
2588                 }
2589                 else
2590                 {
2591                         SetWindowPreferredRotation(ownee, -1);
2592                 }
2593         }
2594         else
2595         {
2596                 int ownerRotation = GetWindowRotation(*pOwnerWindow);
2597                 SetWindowPreferredRotation(ownee, ownerRotation);
2598         }
2599
2600         SetLastResult(E_SUCCESS);
2601 }
2602
2603 int
2604 _EcoreEvas::GetWindowRotation(const _Window& window)
2605 {
2606         _EflLayer* pLayer = GetEflLayer(window);
2607         if (!pLayer)
2608         {
2609                 return 0;
2610         }
2611
2612         int rotation = ecore_evas_rotation_get(pLayer->GetEcoreEvas());
2613         return rotation;
2614 }
2615
2616 void
2617 _EcoreEvas::SetWindowPreferredRotation(const _Window& window, int rotation, bool force)
2618 {
2619         _EflLayer* pLayer = GetEflLayer(window);
2620         if (!pLayer)
2621         {
2622                 return;
2623         }
2624
2625         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2626
2627         if (force == true)
2628         {
2629                 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2630         }
2631         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set window preferred rotation(%d).", win, rotation);
2632         ecore_evas_wm_rotation_preferred_rotation_set(pLayer->GetEcoreEvas(), rotation);
2633
2634         _Window* pWindow = const_cast<_Window*>(&window);
2635         if (pWindow)
2636         {
2637                 if (rotation == -1)
2638                 {
2639                         pWindow->SetPreferredRotation(false);
2640                 }
2641                 else
2642                 {
2643                         pWindow->SetPreferredRotation(true);
2644                 }
2645         }
2646 }
2647
2648 void
2649 _EcoreEvas::SetWindowAvailabledRotation(const _Window& window, int* rotations, unsigned int count, bool force)
2650 {
2651         _EflLayer* pLayer = GetEflLayer(window);
2652         if (!pLayer)
2653         {
2654                 return;
2655         }
2656
2657         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2658
2659         // Skip available_set if there is not change
2660         if (force == false)
2661         {
2662                 int* prevRotations = null;
2663                 unsigned int prevCount = 0;
2664                 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pLayer->GetEcoreEvas(), &prevRotations, &prevCount);
2665                 free(prevRotations);
2666
2667                 if (ret)
2668                 {
2669                         if (prevCount == count)
2670                         {
2671                                 return;
2672                         }
2673                 }
2674         }
2675         else
2676         {
2677                 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2678         }
2679
2680         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set window available rotation(%d).", win, count);
2681         ecore_evas_wm_rotation_available_rotations_set(pLayer->GetEcoreEvas(), rotations, count);
2682 }
2683
2684 void
2685 _EcoreEvas::RegisterWindowStateCallback(const _Window& window)
2686 {
2687         _EflLayer* pLayer = GetEflLayer(window);
2688         if (!pLayer)
2689         {
2690                 return;
2691         }
2692
2693         ecore_evas_callback_state_change_set(pLayer->GetEcoreEvas(), OnWindowStateChanged);
2694 }
2695
2696 void
2697 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::Rectangle& bounds)
2698 {
2699         _EflLayer* pLayer = GetEflLayer(window);
2700         if (!pLayer)
2701         {
2702                 return;
2703         }
2704
2705         Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2706
2707         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2708         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set rotation bounds(rot = %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2709         ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2710 }
2711
2712 void
2713 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::FloatRectangle& bounds)
2714 {
2715         _EflLayer* pLayer = GetEflLayer(window);
2716         if (!pLayer)
2717         {
2718                 return;
2719         }
2720
2721         FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2722         Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2723
2724         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2725         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set rotation bounds(rot = %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2726         ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2727 }
2728
2729 // [ToDo] Remove API
2730 const _Control*
2731 _EcoreEvas::GetFrame(void) const
2732 {
2733         SysLog(NID_UI, "Do not use.");
2734         return __pFrame;
2735 }
2736
2737 // [ToDo] Remove API
2738 _RootVisualElement*
2739 _EcoreEvas::GetRootVisualElement(void)const
2740 {
2741         SysLog(NID_UI, "Do not use.");
2742         return null;
2743 }
2744
2745 // [ToDo] Remove API
2746 void
2747 _EcoreEvas::SetFrame(const _Control& control)
2748 {
2749         SysLog(NID_UI, "Do not use.");
2750         __pFrame = const_cast<_Control*>(&control);
2751 }
2752
2753 bool
2754 _EcoreEvas::GetSelectedCbhmItem(Ecore_X_Atom* pDataType, char** pBuffer) const
2755 {
2756         Ecore_X_Window cbhmWin = GetCbhmWindow();
2757         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_SELECTED_ITEM);
2758         Ecore_X_Atom atomItemType = 0;
2759
2760         char* pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
2761         if (pRet)
2762         {
2763                 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
2764                 if (atomItemType == x_atom_cbhm_error)
2765                 {
2766                         free(pRet);
2767                         return false;
2768                 }
2769
2770                 if (pBuffer)
2771                 {
2772                         *pBuffer = pRet;
2773                 }
2774                 else
2775                 {
2776                         free(pRet);
2777                 }
2778
2779                 if (pDataType)
2780                 {
2781                         *pDataType = atomItemType;
2782                 }
2783
2784                 return true;
2785         }
2786
2787         return false;
2788 }
2789
2790 bool
2791 _EcoreEvas::IsAccessibilityScreenReaderActivated(void)
2792 {
2793         Eina_Bool acc = elm_config_access_get();
2794         return acc;
2795 }
2796
2797 void* _GetEcoreEvasHandle(void)
2798 {
2799         _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2800         if (pEcoreEvasMgr == null)
2801         {
2802                 return null;
2803         }
2804
2805         _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2806         if (pUiEcoreEvas == null)
2807         {
2808                 return null;
2809         }
2810
2811         return (void*)pUiEcoreEvas->GetEcoreEvas();
2812 }
2813
2814 void* _GetEvasHandle(void)
2815 {
2816         _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2817         if (pEcoreEvasMgr == null)
2818         {
2819                 return null;
2820         }
2821
2822         _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2823         if (pUiEcoreEvas == null)
2824         {
2825                 return null;
2826         }
2827
2828         return (void*)pUiEcoreEvas->GetEvas();
2829 }
2830
2831 result
2832 _EcoreEvas::InitializeAtomList(void)
2833 {
2834         __atomList[_ATOM_TARGETS].pName = "TARGETS";
2835         __atomList[_ATOM_TARGETS].formats = _CLIP_FORMAT_TARGETS;
2836         __atomList[_ATOM_TARGETS].convert = ConvertClipIntoTarget;
2837         __atomList[_ATOM_TARGETS].response = RequestClip;
2838         __atomList[_ATOM_TARGETS].notify = NotifyTarget;
2839         __atomList[_ATOM_TARGETS].atom = 0;
2840
2841         __atomList[_ATOM_ATOM].pName = "ATOM";
2842         __atomList[_ATOM_ATOM].formats = _CLIP_FORMAT_TARGETS;
2843         __atomList[_ATOM_ATOM].convert = ConvertClipIntoTarget;
2844         __atomList[_ATOM_ATOM].response = RequestClip;
2845         __atomList[_ATOM_ATOM].notify = NotifyTarget;
2846         __atomList[_ATOM_ATOM].atom = 0;
2847
2848         __atomList[_ATOM_XELM].pName = "application/x-elementary-markup";
2849         __atomList[_ATOM_XELM].formats = _CLIP_FORMAT_MARKUP;
2850         __atomList[_ATOM_XELM].convert = ConvertClipIntoEdje;
2851         __atomList[_ATOM_XELM].response = null;
2852         __atomList[_ATOM_XELM].notify = NotifyEdje;
2853         __atomList[_ATOM_XELM].atom = 0;
2854
2855         __atomList[_ATOM_TEXT_URI].pName = "text/uri";
2856         __atomList[_ATOM_TEXT_URI].formats = _CLIP_FORMAT_IMAGE;
2857         __atomList[_ATOM_TEXT_URI].convert = ConvertClipIntoUri;
2858         __atomList[_ATOM_TEXT_URI].response = null;
2859         __atomList[_ATOM_TEXT_URI].notify = NotifyUri;
2860         __atomList[_ATOM_TEXT_URI].atom = 0;
2861
2862         __atomList[_ATOM_TEXT_URILIST].pName = "text/uri-list";
2863         __atomList[_ATOM_TEXT_URILIST].formats = _CLIP_FORMAT_IMAGE;
2864         __atomList[_ATOM_TEXT_URILIST].convert = ConvertClipIntoUri;
2865         __atomList[_ATOM_TEXT_URILIST].response = null;
2866         __atomList[_ATOM_TEXT_URILIST].notify = NotifyUri;
2867         __atomList[_ATOM_TEXT_URILIST].atom = 0;
2868
2869         __atomList[_ATOM_TEXT_X_VCARD].pName = "text/x-vcard";
2870         __atomList[_ATOM_TEXT_X_VCARD].formats = _CLIP_FORMAT_VCARD;
2871         __atomList[_ATOM_TEXT_X_VCARD].convert = null;
2872         __atomList[_ATOM_TEXT_X_VCARD].response = null;
2873         __atomList[_ATOM_TEXT_X_VCARD].notify = null;
2874         __atomList[_ATOM_TEXT_X_VCARD].atom = 0;
2875
2876         __atomList[_ATOM_IMAGE_PNG].pName = "image/png";
2877         __atomList[_ATOM_IMAGE_PNG].formats = _CLIP_FORMAT_IMAGE;
2878         __atomList[_ATOM_IMAGE_PNG].convert = ConvertClipIntoImage;
2879         __atomList[_ATOM_IMAGE_PNG].response = null;
2880         __atomList[_ATOM_IMAGE_PNG].notify = NotifyImage;
2881         __atomList[_ATOM_IMAGE_PNG].atom = 0;
2882
2883         __atomList[_ATOM_IMAGE_JPEG].pName = "image/jpeg";
2884         __atomList[_ATOM_IMAGE_JPEG].formats = _CLIP_FORMAT_IMAGE;
2885         __atomList[_ATOM_IMAGE_JPEG].convert = ConvertClipIntoImage;
2886         __atomList[_ATOM_IMAGE_JPEG].response = null;
2887         __atomList[_ATOM_IMAGE_JPEG].notify = NotifyImage;
2888         __atomList[_ATOM_IMAGE_JPEG].atom = 0;
2889
2890         __atomList[_ATOM_IMAGE_BMP].pName = "image/x-ms-bmp";
2891         __atomList[_ATOM_IMAGE_BMP].formats = _CLIP_FORMAT_IMAGE;
2892         __atomList[_ATOM_IMAGE_BMP].convert = ConvertClipIntoImage;
2893         __atomList[_ATOM_IMAGE_BMP].response = null;
2894         __atomList[_ATOM_IMAGE_BMP].notify = NotifyImage;
2895         __atomList[_ATOM_IMAGE_BMP].atom = 0;
2896
2897         __atomList[_ATOM_IMAGE_GIF].pName = "image/gif";
2898         __atomList[_ATOM_IMAGE_GIF].formats = _CLIP_FORMAT_IMAGE;
2899         __atomList[_ATOM_IMAGE_GIF].convert = ConvertClipIntoImage;
2900         __atomList[_ATOM_IMAGE_GIF].response = null;
2901         __atomList[_ATOM_IMAGE_GIF].notify = NotifyImage;
2902         __atomList[_ATOM_IMAGE_GIF].atom = 0;
2903
2904         __atomList[_ATOM_IMAGE_TIFF].pName = "image/tiff";
2905         __atomList[_ATOM_IMAGE_TIFF].formats = _CLIP_FORMAT_IMAGE;
2906         __atomList[_ATOM_IMAGE_TIFF].convert = ConvertClipIntoImage;
2907         __atomList[_ATOM_IMAGE_TIFF].response = null;
2908         __atomList[_ATOM_IMAGE_TIFF].notify = NotifyImage;
2909         __atomList[_ATOM_IMAGE_TIFF].atom = 0;
2910
2911         __atomList[_ATOM_IMAGE_SVG].pName = "image/svg+xml";
2912         __atomList[_ATOM_IMAGE_SVG].formats = _CLIP_FORMAT_IMAGE;
2913         __atomList[_ATOM_IMAGE_SVG].convert = ConvertClipIntoImage;
2914         __atomList[_ATOM_IMAGE_SVG].response = null;
2915         __atomList[_ATOM_IMAGE_SVG].notify = NotifyImage;
2916         __atomList[_ATOM_IMAGE_SVG].atom = 0;
2917
2918         __atomList[_ATOM_IMAGE_XPM].pName = "image/x-xpixmap";
2919         __atomList[_ATOM_IMAGE_XPM].formats = _CLIP_FORMAT_IMAGE;
2920         __atomList[_ATOM_IMAGE_XPM].convert = ConvertClipIntoImage;
2921         __atomList[_ATOM_IMAGE_XPM].response = null;
2922         __atomList[_ATOM_IMAGE_XPM].notify = NotifyImage;
2923         __atomList[_ATOM_IMAGE_XPM].atom = 0;
2924
2925         __atomList[_ATOM_IMAGE_TGA].pName = "image/x-tga";
2926         __atomList[_ATOM_IMAGE_TGA].formats = _CLIP_FORMAT_IMAGE;
2927         __atomList[_ATOM_IMAGE_TGA].convert = ConvertClipIntoImage;
2928         __atomList[_ATOM_IMAGE_TGA].response = null;
2929         __atomList[_ATOM_IMAGE_TGA].notify = NotifyImage;
2930         __atomList[_ATOM_IMAGE_TGA].atom = 0;
2931
2932         __atomList[_ATOM_IMAGE_PPM].pName = "image/x-portable-pixmap";
2933         __atomList[_ATOM_IMAGE_PPM].formats = _CLIP_FORMAT_IMAGE;
2934         __atomList[_ATOM_IMAGE_PPM].convert = ConvertClipIntoImage;
2935         __atomList[_ATOM_IMAGE_PPM].response = null;
2936         __atomList[_ATOM_IMAGE_PPM].notify = NotifyImage;
2937         __atomList[_ATOM_IMAGE_PPM].atom = 0;
2938
2939         __atomList[_ATOM_TEXT_HTML_UTF8].pName = "text/html;charset=utf-8";
2940         __atomList[_ATOM_TEXT_HTML_UTF8].formats = _CLIP_FORMAT_HTML;
2941         __atomList[_ATOM_TEXT_HTML_UTF8].convert = ConvertClipIntoHtml;
2942         __atomList[_ATOM_TEXT_HTML_UTF8].response = null;
2943         __atomList[_ATOM_TEXT_HTML_UTF8].notify = NotifyHtml;
2944         __atomList[_ATOM_TEXT_HTML_UTF8].atom = 0;
2945
2946         __atomList[_ATOM_TEXT_HTML].pName = "text/html";
2947         __atomList[_ATOM_TEXT_HTML].formats = _CLIP_FORMAT_HTML;
2948         __atomList[_ATOM_TEXT_HTML].convert = ConvertClipIntoHtml;
2949         __atomList[_ATOM_TEXT_HTML].response = null;
2950         __atomList[_ATOM_TEXT_HTML].notify = NotifyHtml;
2951         __atomList[_ATOM_TEXT_HTML].atom = 0;
2952
2953         __atomList[_ATOM_STRING_UTF8].pName = "UTF8_STRING";
2954         __atomList[_ATOM_STRING_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2955         __atomList[_ATOM_STRING_UTF8].convert = ConvertClipIntoText;
2956         __atomList[_ATOM_STRING_UTF8].response = null;
2957         __atomList[_ATOM_STRING_UTF8].notify = NotifyText;
2958         __atomList[_ATOM_STRING_UTF8].atom = 0;
2959
2960         __atomList[_ATOM_STRING].pName = "STRING";
2961         __atomList[_ATOM_STRING].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2962         __atomList[_ATOM_STRING].convert = ConvertClipIntoText;
2963         __atomList[_ATOM_STRING].response = null;
2964         __atomList[_ATOM_STRING].notify = NotifyText;
2965         __atomList[_ATOM_STRING].atom = 0;
2966
2967         __atomList[_ATOM_TEXT].pName = "TEXT";
2968         __atomList[_ATOM_TEXT].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2969         __atomList[_ATOM_TEXT].convert = ConvertClipIntoText;
2970         __atomList[_ATOM_TEXT].response = null;
2971         __atomList[_ATOM_TEXT].notify = null;
2972         __atomList[_ATOM_TEXT].atom = 0;
2973
2974         __atomList[_ATOM_TEXT_PLAIN_UTF8].pName = "text/plain;charset=utf-8";
2975         __atomList[_ATOM_TEXT_PLAIN_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2976         __atomList[_ATOM_TEXT_PLAIN_UTF8].convert = ConvertClipIntoText;
2977         __atomList[_ATOM_TEXT_PLAIN_UTF8].response = null;
2978         __atomList[_ATOM_TEXT_PLAIN_UTF8].notify = null;
2979         __atomList[_ATOM_TEXT_PLAIN_UTF8].atom = 0;
2980
2981         __atomList[_ATOM_TEXT_PLAIN].pName = "text/plain";
2982         __atomList[_ATOM_TEXT_PLAIN].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2983         __atomList[_ATOM_TEXT_PLAIN].convert = ConvertClipIntoText;
2984         __atomList[_ATOM_TEXT_PLAIN].response = null;
2985         __atomList[_ATOM_TEXT_PLAIN].notify = null;
2986         __atomList[_ATOM_TEXT_PLAIN].atom = 0;
2987
2988         __clipList[_CLIP_TYPE_PRIMARY].selection = ECORE_X_SELECTION_PRIMARY;
2989         __clipList[_CLIP_TYPE_PRIMARY].set = ecore_x_selection_primary_set;
2990         __clipList[_CLIP_TYPE_PRIMARY].clear = ecore_x_selection_primary_clear;
2991         __clipList[_CLIP_TYPE_PRIMARY].request = ecore_x_selection_primary_request;
2992         __clipList[_CLIP_TYPE_PRIMARY].active = false;
2993         __clipList[_CLIP_TYPE_PRIMARY].pBuffer = null;
2994         __clipList[_CLIP_TYPE_PRIMARY].pRetrievedBuffer = null;
2995         __clipList[_CLIP_TYPE_PRIMARY].bufferLength = 0;
2996         __clipList[_CLIP_TYPE_PRIMARY].completed = false;
2997
2998         __clipList[_CLIP_TYPE_SECONDARY].selection = ECORE_X_SELECTION_SECONDARY;
2999         __clipList[_CLIP_TYPE_SECONDARY].set = ecore_x_selection_secondary_set;
3000         __clipList[_CLIP_TYPE_SECONDARY].clear = ecore_x_selection_secondary_clear;
3001         __clipList[_CLIP_TYPE_SECONDARY].request = ecore_x_selection_secondary_request;
3002         __clipList[_CLIP_TYPE_SECONDARY].active = false;
3003         __clipList[_CLIP_TYPE_SECONDARY].pBuffer = null;
3004         __clipList[_CLIP_TYPE_SECONDARY].pRetrievedBuffer = null;
3005         __clipList[_CLIP_TYPE_SECONDARY].bufferLength = 0;
3006         __clipList[_CLIP_TYPE_SECONDARY].completed = false;
3007
3008         __clipList[_CLIP_TYPE_CLIPBOARD].selection = ECORE_X_SELECTION_CLIPBOARD;
3009         __clipList[_CLIP_TYPE_CLIPBOARD].set = ecore_x_selection_clipboard_set;
3010         __clipList[_CLIP_TYPE_CLIPBOARD].clear = ecore_x_selection_clipboard_clear;
3011         __clipList[_CLIP_TYPE_CLIPBOARD].request = ecore_x_selection_clipboard_request;
3012         __clipList[_CLIP_TYPE_CLIPBOARD].active = false;
3013         __clipList[_CLIP_TYPE_CLIPBOARD].pBuffer = null;
3014         __clipList[_CLIP_TYPE_CLIPBOARD].pRetrievedBuffer = null;
3015         __clipList[_CLIP_TYPE_CLIPBOARD].bufferLength = 0;
3016         __clipList[_CLIP_TYPE_CLIPBOARD].completed = false;
3017
3018         __clipList[_CLIP_TYPE_XDND].selection = ECORE_X_SELECTION_XDND;
3019         __clipList[_CLIP_TYPE_XDND].request = ecore_x_selection_xdnd_request;
3020         __clipList[_CLIP_TYPE_XDND].active = false;
3021         __clipList[_CLIP_TYPE_XDND].pBuffer = null;
3022         __clipList[_CLIP_TYPE_XDND].pRetrievedBuffer = null;
3023         __clipList[_CLIP_TYPE_XDND].bufferLength = 0;
3024         __clipList[_CLIP_TYPE_XDND].completed = false;
3025
3026         for (int i = 0; i < _ATOM_MAX; i++)
3027         {
3028                 __atomList[i].atom = ecore_x_atom_get(__atomList[i].pName);
3029                 //ecore_x_selection_converter_atom_add(__atomList[i].atom, __atomList[i].convert);
3030
3031                 SysLog(NID_UI, "[Clipboard] __atomList[%d] : pName = %s, atom = %d", i, __atomList[i].pName, __atomList[i].atom);
3032         }
3033
3034         result r = E_SUCCESS;
3035
3036         __pClearClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, ClearClip, NULL);
3037         SysTryCatch(NID_UI, __pClearClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3038
3039         __pNotifyClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, NotifyClip, NULL);
3040         SysTryCatch(NID_UI, __pNotifyClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3041
3042         __pClipboardClosed = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, OnClipboardClosed, null);
3043         SysTryCatch(NID_UI, __pClipboardClosed, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3044
3045         __atomRotateRootAngle = ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE");
3046
3047         return r;
3048
3049 CATCH:
3050         for (int i = 0; i < _ATOM_MAX; i++)
3051         {
3052                 if (__atomList[i].atom)
3053                 {
3054                         ecore_x_selection_converter_atom_del(__atomList[i].atom);
3055                 }
3056         }
3057
3058         if (__pClearClip)
3059         {
3060                 ecore_event_handler_del(__pClearClip);
3061                 __pClearClip = null;
3062         }
3063
3064         if (__pNotifyClip)
3065         {
3066                 ecore_event_handler_del(__pNotifyClip);
3067                 __pNotifyClip = null;
3068         }
3069
3070         if (__pClipboardClosed)
3071         {
3072                 ecore_event_handler_del(__pClipboardClosed);
3073                 __pClipboardClosed = null;
3074         }
3075
3076         return r;
3077 }
3078
3079 bool
3080 _EcoreEvas::IsValidClipFormat(_ClipFormat clipFormat)
3081 {
3082         return ((_CLIP_FORMAT_TEXT & clipFormat) ||
3083                 (_CLIP_FORMAT_MARKUP & clipFormat) ||
3084                 (_CLIP_FORMAT_IMAGE & clipFormat) ||
3085                 (_CLIP_FORMAT_VCARD & clipFormat) ||
3086                 (_CLIP_FORMAT_HTML & clipFormat));
3087 }
3088
3089 Ecore_X_Window
3090 _EcoreEvas::GetCbhmWindow(void) const
3091 {
3092         Ecore_X_Atom atomCbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME);
3093         Ecore_X_Window cbhmWin = 0;
3094
3095         unsigned char* pBuf = NULL;
3096         int num = 0;
3097         int ret = ecore_x_window_prop_property_get(0, atomCbhm, XA_WINDOW, 0, &pBuf, &num);
3098
3099         if (ret && num)
3100         {
3101                 memcpy(&cbhmWin, pBuf, sizeof(Ecore_X_Window));
3102         }
3103
3104         if (pBuf)
3105         {
3106                 free(pBuf);
3107         }
3108
3109         return cbhmWin;
3110 }
3111
3112 bool
3113 _EcoreEvas::SendCbhmMessage(Ecore_X_Window xwin, const char* pMsg)
3114 {
3115         Ecore_X_Window cbhmWin = GetCbhmWindow();
3116         Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(ATOM_CBHM_MSG);
3117
3118         if (!cbhmWin || !atomCbhmMsg)
3119         {
3120                 return false;
3121         }
3122
3123         XClientMessageEvent m;
3124         memset(&m, 0, sizeof(m));
3125         m.type = ClientMessage;
3126         m.display = (Display*)ecore_x_display_get();
3127         m.window = xwin;
3128         m.message_type = atomCbhmMsg;
3129         m.format = 8;
3130         snprintf(m.data.b, 20, "%s", pMsg);
3131
3132         XSendEvent((Display*)ecore_x_display_get(), cbhmWin, False, NoEventMask, (XEvent*)&m);
3133
3134         ecore_x_sync();
3135
3136         // [SLP]
3137         Thread::Sleep(100);
3138
3139         return true;
3140 }
3141
3142 bool
3143 _EcoreEvas::SetCbhmItem(Ecore_X_Window xwin, Ecore_X_Atom dataType, char* pItemData)
3144 {
3145         Ecore_X_Window cbhmWin = GetCbhmWindow();
3146         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_ITEM);
3147
3148         ecore_x_sync();
3149         ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, pItemData, strlen(pItemData) + 1);
3150         ecore_x_sync();
3151
3152         if (SendCbhmMessage(xwin, ATOM_CBHM_SET_ITEM))
3153         {
3154                 return true;
3155         }
3156
3157         return false;
3158 }
3159
3160 void*
3161 _EcoreEvas::GetCbhmReply(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom* pDataType, int* pNum) const
3162 {
3163         unsigned char* pData = null;
3164
3165         if (pDataType)
3166         {
3167                 *pDataType = 0;
3168         }
3169
3170         if (!property)
3171         {
3172                 return null;
3173         }
3174
3175         ecore_x_sync();
3176
3177         if (pNum)
3178         {
3179                 *pNum = 0;
3180         }
3181
3182         long unsigned int numRet = 0;
3183         long unsigned int bytes = 0;
3184         int ret = 0;
3185         int sizeRet = 0;
3186         unsigned int i = 0;
3187         unsigned char* pPropRet = null;
3188         Ecore_X_Atom typeRet;
3189
3190         ret = XGetWindowProperty((Display*)ecore_x_display_get(), xwin, property, 0, LONG_MAX, False,
3191                                                         ecore_x_window_prop_any_type(), (Atom*)&typeRet, &sizeRet, &numRet, &bytes, &pPropRet);
3192         if (ret != Success)
3193         {
3194                 return null;
3195         }
3196
3197         if (!numRet)
3198         {
3199                 XFree(pPropRet);
3200                 return null;
3201         }
3202
3203         if (!(pData = (unsigned char*)malloc(numRet * sizeRet / 8)))
3204         {
3205                 XFree(pPropRet);
3206                 return null;
3207         }
3208
3209         switch (sizeRet)
3210         {
3211         case 8:
3212                 for (i = 0; i < numRet; i++)
3213                 (pData)[i] = pPropRet[i];
3214                 break;
3215         case 16:
3216                 for (i = 0; i < numRet; i++)
3217                 ((unsigned short *)pData)[i] = ((unsigned short *)pPropRet)[i];
3218                 break;
3219         case 32:
3220                 for (i = 0; i < numRet; i++)
3221                 ((unsigned int *)pData)[i] = ((unsigned long *)pPropRet)[i];
3222                 break;
3223         }
3224
3225         XFree(pPropRet);
3226
3227         // [SLP]
3228         Thread::Sleep(100);
3229
3230         if (pNum)
3231         {
3232                 *pNum = numRet;
3233         }
3234
3235         if (pDataType)
3236         {
3237                 *pDataType = typeRet;
3238         }
3239
3240         return pData;
3241 }
3242
3243 int
3244 _EcoreEvas::GetCbhmItemCount(void) const
3245 {
3246         char* pRet = null;
3247         int count = null;
3248
3249         Ecore_X_Atom atomCbhmCountGet = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
3250         Ecore_X_Window cbhmWin = GetCbhmWindow();
3251
3252         pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmCountGet, null, null);
3253         if (pRet)
3254         {
3255                 count = atoi(pRet);
3256                 free(pRet);
3257                 return count;
3258         }
3259
3260         return -1;
3261 }
3262
3263 bool
3264 _EcoreEvas::GetCbhmItem(int index, Ecore_X_Atom* pDataType, char** pBuffer) const
3265 {
3266         if (pBuffer)
3267         {
3268                 *pBuffer = null;
3269         }
3270
3271         if (pDataType)
3272         {
3273                 *(int*)pDataType = 0;
3274         }
3275
3276         Ecore_X_Window cbhmWin = GetCbhmWindow();
3277         char sendBuf[20];
3278         char* pRet;
3279
3280         snprintf(sendBuf, 20, "CBHM_ITEM%d", index);
3281         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(sendBuf);
3282         Ecore_X_Atom atomItemType = 0;
3283
3284         pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
3285         if (pRet)
3286         {
3287                 if (pBuffer)
3288                 {
3289                         *pBuffer = pRet;
3290                 }
3291                 else
3292                 {
3293                         free(pRet);
3294                 }
3295
3296                 if (pDataType)
3297                 {
3298                         *pDataType = atomItemType;
3299                 }
3300
3301                 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
3302                 if (atomItemType == x_atom_cbhm_error)
3303                 {
3304                         return false;
3305                 }
3306
3307                 return true;
3308         }
3309
3310         return false;
3311 }
3312
3313 }} // Tizen::Ui
3314
3315 #ifdef __cplusplus
3316 extern "C"
3317 {
3318 #endif
3319
3320 // [ToDo] Remove API
3321 _OSP_EXPORT_ void
3322 _AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3323 {
3324         GetEcoreEvasMgr()->GetEcoreEvas()->AddActiveWindowEventListener(listener);
3325 }
3326
3327 // [ToDo] Remove API
3328 _OSP_EXPORT_ void
3329 _RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3330 {
3331         GetEcoreEvasMgr()->GetEcoreEvas()->RemoveActiveWindowEventListener(listener);
3332 }
3333
3334 // [ToDo] Remove API
3335 _OSP_EXPORT_ unsigned int
3336 _GetActiveWindow(void)
3337 {
3338         return GetEcoreEvasMgr()->GetEcoreEvas()->GetActiveWindow();
3339 }
3340
3341 // [ToDo] Remove API
3342 _OSP_EXPORT_ int
3343 _GetProcessId(unsigned int window)
3344 {
3345         return GetEcoreEvasMgr()->GetEcoreEvas()->GetProcessId(window);
3346 }
3347
3348 #ifdef __cplusplus
3349 }
3350 #endif
3351