Changed indicator bg color.
[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, "[WM ROTATION][WIN 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, "[WM 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         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1360
1361         int rootW = 0;
1362         int rootH = 0;
1363         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
1364
1365         if (rotatePartial == false)
1366         {
1367                 if (rotateEvas == true)
1368                 {
1369                         ecore_evas_rotation_with_resize_set(pEcoreEvas, orientation);
1370
1371
1372                         if ((orientation == 0) || (orientation == 180))
1373                         {
1374                                 pLayer->SetBounds(FloatRectangle(0, 0, rootW, rootH));
1375                         }
1376                         else
1377                         {
1378                                 pLayer->SetBounds(FloatRectangle(0, 0, rootH, rootW));
1379                         }
1380
1381                         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x, FULL SCREEN] Rotate bounds(ROT %d).", win, orientation);
1382                 }
1383         }
1384         else
1385         {
1386                 if (rotateEvas == true)
1387                 {
1388                         ecore_evas_rotation_set(pEcoreEvas, orientation);
1389                 }
1390
1391                 Rectangle winBounds = _CoordinateSystemUtils::Transform(window.GetBounds());
1392                 int rotate = ecore_evas_rotation_get(pEcoreEvas);
1393
1394                 int winX = winBounds.x;
1395                 int winY = winBounds.y;
1396
1397                 switch (rotate)
1398                 {
1399                 case 270:
1400                         winX = rootW - winBounds.y - winBounds.height;
1401                         winY = winBounds.x;
1402                         break;
1403                 case 90:
1404                         winX = winBounds.y;
1405                         winY = rootH - winBounds.x - winBounds.width;
1406                         break;
1407                 case 180:
1408                         winX = rootW - winBounds.x - winBounds.width;
1409                         winY = rootH - winBounds.y - winBounds.height;
1410                         break;
1411                 default:
1412                         break;
1413                 }
1414
1415                 int x = 0;
1416                 int y = 0;
1417                 int w = 0;
1418                 int h = 0;
1419                 Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
1420
1421
1422                 if (ret == EINA_FALSE)
1423                 {
1424                         pLayer->SetBounds(FloatRectangle(winX, winY, winBounds.width, winBounds.height));
1425                         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x, PARTIAL SCREEN] Rotate bounds(ROT %d, %d, %d, %d, %d).", win, orientation, winX, winY, winBounds.width, winBounds.height);
1426                 }
1427                 else
1428                 {
1429                         pLayer->SetBounds(FloatRectangle(winX, winY, w, h));
1430                         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x, PARTIAL SCREEN] Rotate bounds(ROT %d, %d, %d) ONLY MOVE.", win, orientation, winX, winY);
1431                 }
1432         }
1433 }
1434
1435 _EflLayer*
1436 _EcoreEvas::GetEflLayer(const _Window& window) const
1437 {
1438         _RootVisualElement* pRootVisualElement = null;
1439
1440         pRootVisualElement = window.GetRootVisualElement();
1441         if (!pRootVisualElement)
1442         {
1443                 SysLog(NID_UI, "The root visual element is null.");
1444                 return null;
1445         }
1446
1447         _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer());
1448         if (!pEflLayer)
1449         {
1450                 SysLog(NID_UI, "The efl layer is null.");
1451                 return null;
1452         }
1453
1454         return pEflLayer;
1455 }
1456
1457 bool
1458 _EcoreEvas::GetFloatingMode(void) const
1459 {
1460         SysTryReturn(NID_UI, __pForegroundWindow, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1461
1462         Eina_Bool ret = elm_win_floating_mode_get(__pForegroundWindow);
1463
1464         SetLastResult(E_SUCCESS);
1465
1466         return (ret ? true : false);
1467 }
1468
1469 // [ToDo] Remove API
1470 bool
1471 _EcoreEvas::GetFloatingMode(const _Window& window) const
1472 {
1473         _EflLayer* pLayer = GetEflLayer(window);
1474         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1475
1476         Evas_Object* pWinObj = pLayer->GetElmWin();
1477         SysTryReturn(NID_UI, pWinObj, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1478
1479         Eina_Bool ret = elm_win_floating_mode_get(pWinObj);
1480
1481         SetLastResult(E_SUCCESS);
1482
1483         return (ret ? true : false);
1484 }
1485
1486 // [ToDo] Remove API
1487 void
1488 _EcoreEvas::AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1489 {
1490 }
1491
1492 // [ToDo] Remove API
1493 void
1494 _EcoreEvas::RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1495 {
1496 }
1497
1498 unsigned int
1499 _EcoreEvas::GetActiveWindow(void)
1500 {
1501         Ecore_X_Window* pRoots = null;
1502         Ecore_X_Window activeWin = 0;
1503         int num = 0;
1504
1505         pRoots = ecore_x_window_root_list(&num);
1506         if (pRoots)
1507         {
1508                 Ecore_X_Atom activeAtom = ecore_x_atom_get("_NET_ACTIVE_WINDOW");
1509                 int ret = ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1);
1510
1511                 free(pRoots);
1512
1513                 if (ret < 0)
1514                 {
1515                         return 0;
1516                 }
1517         }
1518
1519         return activeWin;
1520 }
1521
1522 int
1523 _EcoreEvas::GetProcessId(unsigned int window)
1524 {
1525         int pid = 0;
1526         Eina_Bool ret = ecore_x_netwm_pid_get(window, &pid);
1527
1528         if (ret != EINA_TRUE)
1529         {
1530                 return 0;
1531         }
1532
1533         return pid;
1534 }
1535
1536 void
1537 _EcoreEvas::SetOwner(NativeWindowHandle ownee, NativeWindowHandle owner)
1538 {
1539         Ecore_X_Window win = ecore_x_icccm_transient_for_get(ownee);
1540         if (win != owner)
1541         {
1542                 ecore_x_icccm_transient_for_unset(ownee);
1543                 ecore_x_icccm_transient_for_set(ownee, owner);
1544                 SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] transient_for_set -> 0x%x", ownee, owner);
1545         }
1546 }
1547
1548 void
1549 _EcoreEvas::ActivateWindow(const _Window& window)
1550 {
1551         _EflLayer* pLayer = GetEflLayer(window);
1552         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1553
1554         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1555         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1556
1557         ecore_evas_activate(pEcoreEvas);
1558
1559         NativeWindowHandle currentWindow = window.GetNativeHandle();
1560         unsigned int activeWindow = GetActiveWindow();
1561         int pid = GetProcessId(activeWindow);
1562         SysLog(NID_UI, "currentWindow = 0x%x, activeWindow = 0x%x, pid = %d", currentWindow, activeWindow, pid);
1563
1564         SetLastResult(E_SUCCESS);
1565 }
1566
1567 void
1568 _EcoreEvas::MinimizeWindow(_Window& window)
1569 {
1570         _EflLayer* pLayer = GetEflLayer(window);
1571         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1572
1573         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1574         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1575
1576         //ecore_evas_lower(pEcoreEvas);
1577         ecore_evas_iconified_set(pEcoreEvas, EINA_TRUE);
1578
1579         SetLastResult(E_SUCCESS);
1580 }
1581
1582 void
1583 _EcoreEvas::SetRenderBackend(_RenderBackend backend)
1584 {
1585         switch (backend)
1586         {
1587         case _RENDER_BACKEND_SW:
1588                 elm_config_preferred_engine_set("software_x11");
1589                 break;
1590         case _RENDER_BACKEND_GL:
1591                 elm_config_preferred_engine_set("opengl_x11");
1592                 break;
1593         case _RENDER_BACKEND_DEFAULT:
1594                 // fall through
1595         default:
1596                 elm_config_preferred_engine_set(NULL);
1597                 break;
1598         }
1599 }
1600
1601 _RenderBackend
1602 _EcoreEvas::GetRenderBackend(void)
1603 {
1604         _RenderBackend backend = _RENDER_BACKEND_DEFAULT;
1605
1606         const char* pEngine = elm_config_preferred_engine_get();
1607
1608         if (pEngine == NULL)
1609         {
1610                 backend = _RENDER_BACKEND_DEFAULT;
1611         }
1612         else if (strcmp(pEngine, "software_x11") == 0)
1613         {
1614                 backend = _RENDER_BACKEND_SW;
1615         }
1616         else if (strcmp(pEngine, "opengl_x11") == 0)
1617         {
1618                 backend = _RENDER_BACKEND_GL;
1619         }
1620
1621         return backend;
1622 }
1623
1624 result
1625 _EcoreEvas::CopyClip(_ClipFormat format, const char* pChar)
1626 {
1627         SysTryReturn(NID_UI, IsValidClipFormat(format), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid.");
1628         SysTryReturn(NID_UI, pChar, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid.");
1629
1630         Ecore_X_Atom dataType = 0;
1631
1632         switch (format)
1633         {
1634         case _CLIP_FORMAT_TEXT:
1635                 dataType = ecore_x_atom_get("UTF8_STRING");
1636                 break;
1637         case _CLIP_FORMAT_IMAGE:
1638                 dataType = ecore_x_atom_get("text/uri");
1639                 break;
1640         case _CLIP_FORMAT_HTML:
1641                 dataType = ecore_x_atom_get("text/html;charset=utf-8");
1642                 break;
1643         default:
1644                 break;
1645         }
1646
1647         _ControlManager* pControlManager = _ControlManager::GetInstance();
1648
1649         _Window* pWindow = pControlManager->GetClipboardOwner();
1650         if (!pWindow)
1651         {
1652                 return E_SUCCESS;
1653         }
1654
1655         _EflLayer* pLayer = GetEflLayer(*pWindow);
1656         if (!pLayer)
1657         {
1658                 return E_SUCCESS;
1659         }
1660
1661         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1662         SysAssert(window);
1663
1664         SetCbhmItem(window, dataType, (char*)pChar);
1665
1666         return E_SUCCESS;
1667 }
1668
1669 bool
1670 _EcoreEvas::RetrieveClipN(int index, int* format, char** pData)
1671 {
1672         Ecore_X_Atom dataType = 0;
1673
1674         _ControlManager* pControlManager = _ControlManager::GetInstance();
1675
1676         _Window* pWindow = pControlManager->GetClipboardOwner();
1677         if (!pWindow)
1678         {
1679                 return false;
1680         }
1681
1682         _EflLayer* pLayer = GetEflLayer(*pWindow);
1683         if (!pLayer)
1684         {
1685                 return false;
1686         }
1687
1688         GetCbhmItem(index, &dataType, pData);
1689
1690         if ((dataType == ecore_x_atom_get("UTF8_STRING"))
1691                 ||(dataType == ecore_x_atom_get("application/x-elementary-markup")))
1692         {
1693                 *format = _CLIP_FORMAT_TEXT;
1694         }
1695         else if (dataType == ecore_x_atom_get("text/uri"))
1696         {
1697                 *format = _CLIP_FORMAT_IMAGE;
1698         }
1699         else if (dataType == ecore_x_atom_get("text/html;charset=utf-8"))
1700         {
1701                 *format = _CLIP_FORMAT_HTML;
1702         }
1703
1704         if (*pData == null)
1705         {
1706                 return false;
1707         }
1708
1709         // Convert markup to utf8.
1710         if (dataType == ecore_x_atom_get("application/x-elementary-markup"))
1711         {
1712                 char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, *pData);
1713                 SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", *pData, pTempChar);
1714                 free(*pData);
1715
1716                 *pData = pTempChar;
1717         }
1718
1719         return true;
1720 }
1721
1722 int
1723 _EcoreEvas::GetClipCount(void) const
1724 {
1725         _ControlManager* pControlManager = _ControlManager::GetInstance();
1726
1727         _Window* pWindow = pControlManager->GetClipboardOwner();
1728         if (!pWindow)
1729         {
1730                 return 0;
1731         }
1732
1733         _EflLayer* pLayer = GetEflLayer(*pWindow);
1734         if (!pLayer)
1735         {
1736                 return 0;
1737         }
1738
1739         int count = GetCbhmItemCount();
1740
1741         return count;
1742 }
1743
1744 void
1745 _EcoreEvas::OpenClipboard(unsigned long clipFormats)
1746 {
1747         _ControlManager* pControlManager = _ControlManager::GetInstance();
1748
1749         _Window* pWindow = pControlManager->GetClipboardOwner();
1750         if (!pWindow)
1751         {
1752                 return;
1753         }
1754
1755         _EflLayer* pLayer = GetEflLayer(*pWindow);
1756         if (!pLayer)
1757         {
1758                 return;
1759         }
1760
1761         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1762         SysAssert(window);
1763
1764         ecore_x_selection_secondary_set(window, "", 1);
1765
1766         if (_CLIP_FORMAT_IMAGE & clipFormats)
1767         {
1768                 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW_ALL);
1769         }
1770         else
1771         {
1772                 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW);
1773         }
1774
1775         __openClipboard = true;
1776 }
1777
1778 void
1779 _EcoreEvas::CloseClipboard(void)
1780 {
1781         _ControlManager* pControlManager = _ControlManager::GetInstance();
1782
1783         _Window* pWindow = pControlManager->GetClipboardOwner();
1784         if (!pWindow)
1785         {
1786                 return;
1787         }
1788
1789         _EflLayer* pLayer = GetEflLayer(*pWindow);
1790         if (!pLayer)
1791         {
1792                 return;
1793         }
1794
1795         Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1796         SysAssert(window);
1797
1798         __openClipboard = false;
1799         SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_HIDE);
1800 }
1801
1802 bool
1803 _EcoreEvas::IsClipboardOpened(void)
1804 {
1805         return __openClipboard;
1806 }
1807
1808 String
1809 _EcoreEvas::ConvertMarkupToUtf8(const String& string)
1810 {
1811         char* pChar = _Clipboard::GetInstance()->EncodeToCharN(string);
1812         if (!pChar)
1813         {
1814                 return String(L"");
1815         }
1816
1817         char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, pChar);
1818         SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", pChar, pTempChar);
1819         free(pChar);
1820
1821         String str(pTempChar);
1822         free(pTempChar);
1823
1824         return str;
1825 }
1826
1827 result
1828 _EcoreEvas::SetEventPropagation(const _Control& control, bool enable)
1829 {
1830         _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1831         SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1832
1833         Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1834         SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1835
1836         evas_object_propagate_events_set(pEvasObject, (enable ? EINA_TRUE : EINA_FALSE));
1837
1838         return E_SUCCESS;
1839 }
1840
1841 result
1842 _EcoreEvas::SetFocus(const _Control& control, bool focus)
1843 {
1844         _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1845         SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1846
1847         Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1848         SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1849
1850         evas_object_focus_set(pEvasObject, (focus ? EINA_TRUE : EINA_FALSE));
1851
1852         return E_SUCCESS;
1853 }
1854
1855 result
1856 _EcoreEvas::SetIndicatorShowState(const _Window& window, bool showState)
1857 {
1858         _EflLayer* pLayer = GetEflLayer(window);
1859         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1860
1861         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1862         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1863
1864         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1865
1866         if (showState)
1867         {
1868                 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1869         }
1870         else
1871         {
1872                 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1873         }
1874
1875         return E_SUCCESS;
1876 }
1877
1878 bool
1879 _EcoreEvas::GetIndicatorShowState(const _Window& window) const
1880 {
1881         _EflLayer* pLayer = GetEflLayer(window);
1882         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1883
1884         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1885         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1886
1887         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1888         Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(win);
1889
1890         bool showState = true;
1891         if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON)
1892         {
1893                 showState = true;
1894         }
1895         else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF)
1896         {
1897                 showState = false;
1898         }
1899
1900         return showState;
1901 }
1902
1903 // [ToDo] Remove API
1904 Rectangle
1905 _EcoreEvas::GetIndicatorBounds(const _Window& window) const
1906 {
1907         _EflLayer* pLayer = GetEflLayer(window);
1908         SysTryReturn(NID_UI, pLayer, Rectangle(0, 0, 0, 0), E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1909
1910         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1911         SysTryReturn(NID_UI, pEcoreEvas, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1912
1913         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1914         Ecore_X_Window rootWin = (Ecore_X_Window) ecore_x_window_root_get(win);
1915
1916         int x = 0;
1917         int y = 0;
1918         int width = 0;
1919         int height = 0;
1920
1921         bool ret = false;
1922         ret = ecore_x_e_illume_indicator_geometry_get(rootWin, &x, &y, &width, &height);
1923         SysTryReturn(NID_UI, ret == true, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1924
1925         SetLastResult(E_SUCCESS);
1926
1927         return Rectangle(x, y, width, height);
1928 }
1929
1930 // [ToDo] Remove API
1931 result
1932 _EcoreEvas::SetIndicatorOpacity(const _Window& window, _IndicatorOpacity opacity)
1933 {
1934         _EflLayer* pLayer = GetEflLayer(window);
1935         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1936
1937         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1938         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1939
1940         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1941
1942         Ecore_X_Illume_Indicator_Opacity_Mode mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1943         switch (opacity)
1944         {
1945         case _INDICATOR_OPACITY_UNKNOWN:
1946                 mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1947                 break;
1948         case _INDICATOR_OPACITY_OPAQUE:
1949                 mode = ECORE_X_ILLUME_INDICATOR_OPAQUE;
1950                 break;
1951         case _INDICATOR_OPACITY_TRANSLUCENT:
1952                 mode = ECORE_X_ILLUME_INDICATOR_TRANSLUCENT;
1953                 break;
1954         case _INDICATOR_OPACITY_TRANSPARENT:
1955                 mode = ECORE_X_ILLUME_INDICATOR_TRANSPARENT;
1956                 break;
1957         default:
1958                 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1959                 return E_INVALID_ARG;
1960         }
1961
1962         ecore_x_e_illume_indicator_opacity_set(win, mode);
1963
1964         return E_SUCCESS;
1965 }
1966
1967 // [ToDo] Remove API
1968 _IndicatorOpacity
1969 _EcoreEvas::GetIndicatorOpacity(const _Window& window) const
1970 {
1971         _EflLayer* pLayer = GetEflLayer(window);
1972         SysTryReturn(NID_UI, pLayer, _INDICATOR_OPACITY_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1973
1974         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1975         SysTryReturn(NID_UI, pEcoreEvas, _INDICATOR_OPACITY_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1976
1977         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1978         Ecore_X_Illume_Indicator_Opacity_Mode mode = ecore_x_e_illume_indicator_opacity_get(win);
1979
1980         _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN;
1981         switch (mode)
1982         {
1983         case ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN:
1984                 opacity = _INDICATOR_OPACITY_UNKNOWN;
1985                 break;
1986         case ECORE_X_ILLUME_INDICATOR_OPAQUE:
1987                 opacity = _INDICATOR_OPACITY_OPAQUE;
1988                 break;
1989         case ECORE_X_ILLUME_INDICATOR_TRANSLUCENT:
1990                 opacity = _INDICATOR_OPACITY_TRANSLUCENT;
1991                 break;
1992         case ECORE_X_ILLUME_INDICATOR_TRANSPARENT:
1993                 opacity = _INDICATOR_OPACITY_TRANSPARENT;
1994                 break;
1995         default:
1996                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1997                 return _INDICATOR_OPACITY_UNKNOWN;
1998         }
1999
2000         SetLastResult(E_SUCCESS);
2001
2002         return opacity;
2003 }
2004
2005 void
2006 _EcoreEvas::SetWindowActivationEnabled(const _Window& window, bool enable)
2007 {
2008         _EflLayer* pLayer = GetEflLayer(window);
2009         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2010
2011         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2012         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2013
2014         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2015
2016         Eina_Bool acceptsFocus;
2017         Ecore_X_Window_State_Hint initialState;
2018         Ecore_X_Pixmap iconPixmap;
2019         Ecore_X_Pixmap iconMask;
2020         Ecore_X_Window iconWindow;
2021         Ecore_X_Window windowGroup;
2022         Eina_Bool isUrgent;
2023
2024         ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2025         ecore_x_icccm_hints_set(win, (enable ? EINA_TRUE : EINA_FALSE), initialState, iconPixmap, iconMask, iconWindow, windowGroup, isUrgent);
2026 }
2027
2028 bool
2029 _EcoreEvas::IsWindowActivationEnabled(const _Window& window)
2030 {
2031         _EflLayer* pLayer = GetEflLayer(window);
2032         SysTryReturn(NID_UI, pLayer, true, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2033
2034         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2035         SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2036
2037         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2038
2039         Eina_Bool acceptsFocus;
2040         Ecore_X_Window_State_Hint initialState;
2041         Ecore_X_Pixmap iconPixmap;
2042         Ecore_X_Pixmap iconMask;
2043         Ecore_X_Window iconWindow;
2044         Ecore_X_Window windowGroup;
2045         Eina_Bool isUrgent;
2046
2047         ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2048
2049         return (acceptsFocus ? true : false);
2050 }
2051
2052 void
2053 _EcoreEvas::SetWindowName(const _Window& window, const Tizen::Base::String& name)
2054 {
2055         _EflLayer* pLayer = GetEflLayer(window);
2056         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2057
2058         Evas_Object* pWinObj = pLayer->GetElmWin();
2059         SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2060
2061         const char* windowName = _StringConverter::CopyToCharArrayN(name);
2062         if (windowName)
2063         {
2064                 elm_win_title_set(pWinObj, windowName);
2065
2066                 delete[] windowName;
2067         }
2068 }
2069
2070 void
2071 _EcoreEvas::SetWindowType(const _Window& window, int winType)
2072 {
2073         _EflLayer* pLayer = GetEflLayer(window);
2074         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2075
2076         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2077         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2078
2079         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2080
2081         if (winType == _WINDOW_TYPE_SUB)
2082         {
2083                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_UTILITY);
2084         }
2085 }
2086
2087 result
2088 _EcoreEvas::SetFloatingMode(const _Window& window, bool enable)
2089 {
2090         _EflLayer* pLayer = GetEflLayer(window);
2091         SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2092
2093         Evas_Object* pWinObj = pLayer->GetElmWin();
2094         SysTryReturn(NID_UI, pWinObj, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2095
2096         elm_win_floating_mode_set(pWinObj, (enable ? EINA_TRUE : EINA_FALSE));
2097
2098         return E_SUCCESS;
2099 }
2100
2101 // [ToDo] Remove API
2102 Evas*
2103 _EcoreEvas::GetEvas(void) const
2104 {
2105         SysLog(NID_UI, "Do not use.");
2106         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2107         if (!pWindow)
2108         {
2109                 return null;
2110         }
2111
2112         _EflLayer* pLayer = GetEflLayer(*pWindow);
2113         if (!pLayer)
2114         {
2115                 return null;
2116         }
2117
2118         return pLayer->GetEvas();
2119 }
2120
2121 // [ToDo] Remove API
2122 Ecore_Evas*
2123 _EcoreEvas::GetEcoreEvas(void) const
2124 {
2125         SysLog(NID_UI, "Do not use.");
2126         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2127         if (!pWindow)
2128         {
2129                 return null;
2130         }
2131
2132         _EflLayer* pLayer = GetEflLayer(*pWindow);
2133         if (!pLayer)
2134         {
2135                 return null;
2136         }
2137
2138         return pLayer->GetEcoreEvas();
2139 }
2140
2141 // [ToDo] Remove API
2142 Evas_Object*
2143 _EcoreEvas::GetWindowObject(void) const
2144 {
2145         SysLog(NID_UI, "Do not use.");
2146         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2147         if (!pWindow)
2148         {
2149                 return null;
2150         }
2151
2152         _EflLayer* pLayer = GetEflLayer(*pWindow);
2153         if (!pLayer)
2154         {
2155                 return null;
2156         }
2157
2158         return pLayer->GetElmWin();
2159 }
2160
2161 // [ToDo] Remove API
2162 Ecore_X_Window
2163 _EcoreEvas::GetXWindow(void) const
2164 {
2165         SysLog(NID_UI, "Do not use.");
2166         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2167         if (!pWindow)
2168         {
2169                 return 0;
2170         }
2171
2172         _EflLayer* pLayer = GetEflLayer(*pWindow);
2173         if (!pLayer)
2174         {
2175                 return 0;
2176         }
2177
2178         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2179
2180         return win;
2181 }
2182
2183 void
2184 _EcoreEvas::AllowSetWindowBounds(bool allow)
2185 {
2186         __changeBounds = allow;
2187 }
2188
2189 bool
2190 _EcoreEvas::IsWindowVisible(const _Window& window)
2191 {
2192         _EflLayer* pLayer = GetEflLayer(window);
2193         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2194
2195         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2196         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2197
2198         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2199
2200         int ret = ecore_x_window_visible_get(win);
2201         if (ret == 1)
2202         {
2203                 return true;
2204         }
2205         else
2206         {
2207                 return false;
2208         }
2209 }
2210
2211 // [ToDo] Remove API
2212 void
2213 _EcoreEvas::SetQuickPanelScrollEnabled(const _Window& window, bool enable)
2214 {
2215         /*
2216         _EflLayer* pLayer = GetEflLayer(window);
2217         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2218
2219         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2220         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2221
2222         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2223         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2224
2225         unsigned int val[3];
2226         ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2227
2228         if (enable)
2229         {
2230                 val[1] = 1;
2231         }
2232         else
2233         {
2234                 val[1] = 0;
2235         }
2236
2237         ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
2238         */
2239 }
2240
2241 // [ToDo] Remove API
2242 bool
2243 _EcoreEvas::IsQuickPanelScrollEnabled(const _Window& window)
2244 {
2245         /*
2246         _EflLayer* pLayer = GetEflLayer(window);
2247         SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2248
2249         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2250         SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2251
2252         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2253         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2254
2255         unsigned int val[3];
2256         ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2257
2258         if (val[1] == 0)
2259         {
2260                 return false;
2261         }
2262         else
2263         {
2264                 return true;
2265         }
2266         */
2267
2268         return true;
2269 }
2270
2271 void
2272 _EcoreEvas::SetWindowLevel(const _Window& window, _WindowLevel level)
2273 {
2274         _EflLayer* pLayer = GetEflLayer(window);
2275         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2276
2277         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2278         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2279
2280         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2281         ecore_x_icccm_transient_for_unset(win);
2282         SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] transient_for_unset", win);
2283
2284         if (level == _WINDOW_LEVEL_NORMAL)
2285         {
2286                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
2287                 SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] set : ECORE_X_WINDOW_TYPE_NORMAL", win);
2288         }
2289         else if (level == _WINDOW_LEVEL_NOTIFICATION_HIGH)
2290         {
2291                 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2292                 utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_HIGH);
2293                 SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] set : ECORE_X_WINDOW_TYPE_NOTIFICATION, UTILX_NOTIFICATION_LEVEL_HIGH", win);
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                 SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] set : ECORE_X_WINDOW_TYPE_NOTIFICATION, UTILX_NOTIFICATION_LEVEL_NORMAL", win);
2300         }
2301
2302         SetLastResult(E_SUCCESS);
2303 }
2304
2305 _WindowLevel
2306 _EcoreEvas::GetWindowLevel(const _Window& window) const
2307 {
2308         _EflLayer* pLayer = GetEflLayer(window);
2309         SysTryReturn(NID_UI, pLayer, _WINDOW_LEVEL_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2310
2311         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2312         SysTryReturn(NID_UI, pEcoreEvas, _WINDOW_LEVEL_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2313
2314         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2315
2316         Ecore_X_Window_Type type = ECORE_X_WINDOW_TYPE_UNKNOWN;
2317         ecore_x_netwm_window_type_get(win, &type);
2318
2319         _WindowLevel winLevel = _WINDOW_LEVEL_UNKNOWN;
2320         if (type == ECORE_X_WINDOW_TYPE_NORMAL)
2321         {
2322                 winLevel = _WINDOW_LEVEL_NORMAL;
2323         }
2324         else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION)
2325         {
2326                 Utilx_Notification_Level notificationLevel = utilx_get_system_notification_level((Display*)ecore_x_display_get(), win);
2327
2328                 if (notificationLevel == UTILX_NOTIFICATION_LEVEL_HIGH)
2329                 {
2330                         winLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH;
2331                 }
2332                 else if (notificationLevel == UTILX_NOTIFICATION_LEVEL_NORMAL)
2333                 {
2334                         winLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE;
2335                 }
2336         }
2337
2338         SetLastResult(E_SUCCESS);
2339
2340         return winLevel;
2341 }
2342
2343 void
2344 _EcoreEvas::SetWindowBounds(const _Window& window, const Rectangle& bounds)
2345 {
2346         if (__changeBounds == false)
2347         {
2348                 return;
2349         }
2350
2351         _EflLayer* pLayer = GetEflLayer(window);
2352         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2353
2354         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2355         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2356
2357         Evas_Object* pWinObject = pLayer->GetElmWin();
2358         SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2359
2360         Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2361
2362         int rotate = ecore_evas_rotation_get(pEcoreEvas);
2363
2364 //      _Window* pWindow = const_cast<_Window*>(&window);
2365 //      _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2366 //      if (pContextMenu)
2367         if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2368         {
2369                 _ControlManager* pControlManager = _ControlManager::GetInstance();
2370                 if (pControlManager)
2371                 {
2372                         _Window* pCurFrame = pControlManager->GetCurrentFrame();
2373                         if (pCurFrame)
2374                         {
2375                                 int ownerRotate = GetWindowRotation(*pCurFrame);
2376                                 if (ownerRotate != rotate)
2377                                 {
2378                                         return;
2379                                 }
2380                         }
2381                 }
2382         }
2383
2384         int winX = winBounds.x;
2385         int winY = winBounds.y;
2386
2387         int rootW = 0;
2388         int rootH = 0;
2389         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2390
2391         switch (rotate)
2392         {
2393         case 270:
2394                 winX = rootW - winBounds.y - winBounds.height;
2395                 winY = winBounds.x;
2396                 break;
2397         case 90:
2398                 winX = winBounds.y;
2399                 winY = rootH - winBounds.x - winBounds.width;
2400                 break;
2401         case 180:
2402                 winX = rootW - winBounds.x - winBounds.width;
2403                 winY = rootH - winBounds.y - winBounds.height;
2404                 break;
2405         default:
2406                 break;
2407         }
2408
2409         int x = 0;
2410         int y = 0;
2411         int w = 0;
2412         int h = 0;
2413         Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2414
2415
2416         if (ret == EINA_FALSE)
2417         {
2418                 pLayer->SetBounds(FloatRectangle(winX, winY, winBounds.width, winBounds.height));
2419                 SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set bounds(ROT %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2420         }
2421         else
2422         {
2423                 pLayer->SetBounds(FloatRectangle(winX, winY, w, h));
2424                 SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set bounds(ROT %d, %d, %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY, w, h);
2425         }
2426
2427         SetLastResult(E_SUCCESS);
2428 }
2429
2430 void
2431 _EcoreEvas::SetWindowBounds(const _Window& window, const FloatRectangle& bounds)
2432 {
2433         if (__changeBounds == false)
2434         {
2435                 return;
2436         }
2437
2438         _EflLayer* pLayer = GetEflLayer(window);
2439         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2440
2441         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2442         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2443
2444         Evas_Object* pWinObject = pLayer->GetElmWin();
2445         SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2446
2447         FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2448         Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2449
2450         int rotate = ecore_evas_rotation_get(pEcoreEvas);
2451
2452 //      _Window* pWindow = const_cast<_Window*>(&window);
2453 //      _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2454 //      if (pContextMenu)
2455         if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2456         {
2457                 _ControlManager* pControlManager = _ControlManager::GetInstance();
2458                 if (pControlManager)
2459                 {
2460                         _Window* pCurFrame = pControlManager->GetCurrentFrame();
2461                         if (pCurFrame)
2462                         {
2463                                 int ownerRotate = GetWindowRotation(*pCurFrame);
2464                                 if (ownerRotate != rotate)
2465                                 {
2466                                         return;
2467                                 }
2468                         }
2469                 }
2470         }
2471
2472         int winX = winBounds.x;
2473         int winY = winBounds.y;
2474
2475         int rootW = 0;
2476         int rootH = 0;
2477         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2478
2479         switch (rotate)
2480         {
2481         case 270:
2482                 winX = rootW - winBounds.y - winBounds.height;
2483                 winY = winBounds.x;
2484                 break;
2485         case 90:
2486                 winX = winBounds.y;
2487                 winY = rootH - winBounds.x - winBounds.width;
2488                 break;
2489         case 180:
2490                 winX = rootW - winBounds.x - winBounds.width;
2491                 winY = rootH - winBounds.y - winBounds.height;
2492                 break;
2493         default:
2494                 break;
2495         }
2496
2497         int x = 0;
2498         int y = 0;
2499         int w = 0;
2500         int h = 0;
2501         Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2502
2503
2504         if (ret == EINA_FALSE)
2505         {
2506                 pLayer->SetBounds(FloatRectangle(winX, winY, winBounds.width, winBounds.height));
2507                 SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set bounds(ROT %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2508         }
2509         else
2510         {
2511                 pLayer->SetBounds(FloatRectangle(winX, winY, w, h));
2512                 SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set bounds(ROT %d, %d, %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY, w, h);
2513         }
2514
2515         SetLastResult(E_SUCCESS);
2516 }
2517
2518 void
2519 _EcoreEvas::SetWindowVisibleState(const _Window& window, bool visibleState)
2520 {
2521         _EflLayer* pLayer = GetEflLayer(window);
2522         SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2523
2524         Evas_Object* pWinObj = pLayer->GetElmWin();
2525         SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2526
2527         pLayer->SetShowState(visibleState);
2528
2529         SetLastResult(E_SUCCESS);
2530 }
2531
2532 void
2533 _EcoreEvas::SetOwner(const _Window& ownee, const _Control& owner)
2534 {
2535         _Window* pOwnerWindow = owner.GetRootWindow();
2536         SysTryReturnVoidResult(NID_UI, pOwnerWindow, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a root window.");
2537
2538         _EflLayer* pOwnerLayer = GetEflLayer(*pOwnerWindow);
2539         SysTryReturnVoidResult(NID_UI, pOwnerLayer, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a elf layer.");
2540
2541         _EflLayer* pOwneeLayer = GetEflLayer(ownee);
2542         SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer.");
2543
2544         Ecore_X_Window ownerWin = (Ecore_X_Window) ecore_evas_window_get(pOwnerLayer->GetEcoreEvas());
2545         Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas());
2546
2547         Ecore_X_Window_Type type;
2548         ecore_x_netwm_window_type_get(owneeWin, &type);
2549         if ((type == ECORE_X_WINDOW_TYPE_NORMAL) || (type == ECORE_X_WINDOW_TYPE_UTILITY))
2550         {
2551                 Ecore_X_Window win = ecore_x_icccm_transient_for_get(owneeWin);
2552                 if (win != ownerWin)
2553                 {
2554                         ecore_x_icccm_transient_for_unset(owneeWin);
2555                         ecore_x_icccm_transient_for_set(owneeWin, ownerWin);
2556                         SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] transient_for_set -> 0x%x", owneeWin, ownerWin);
2557                 }
2558         }
2559         else
2560         {
2561                 SysLog(NID_UI, "[WIN ORDER][WIN 0x%x] Skip to transient_for_set", owneeWin);
2562         }
2563
2564         // Ownee window
2565         // 1. IsLayoutChangable : true
2566         // 2. IsRotationSynchronized : true
2567         // -> available_set
2568
2569         if ((ownee.IsLayoutChangable() == true) || (ownee.IsRotationSynchronized() == true))
2570         {
2571                 int* rotations = null;
2572                 unsigned int count = 0;
2573                 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pOwnerLayer->GetEcoreEvas(), &rotations, &count);
2574
2575                 if (ret)
2576                 {
2577                         if (rotations)
2578                         {
2579                                 SetWindowAvailabledRotation(ownee, rotations, count);
2580                                 free(rotations);
2581                         }
2582                 }
2583
2584                 bool preferredRoation = pOwnerWindow->GetPreferredRotation();
2585                 if (preferredRoation == true)
2586                 {
2587                         //int preferredRotation = ecore_evas_wm_rotation_preferred_rotation_get(pOwnerLayer->GetEcoreEvas());
2588                         int preferredRotation = 0;
2589                         ecore_x_e_window_rotation_preferred_rotation_get(ownerWin, &preferredRotation);
2590                         SetWindowPreferredRotation(ownee, preferredRotation);
2591                 }
2592                 else
2593                 {
2594                         SetWindowPreferredRotation(ownee, -1);
2595                 }
2596         }
2597         else
2598         {
2599                 int ownerRotation = GetWindowRotation(*pOwnerWindow);
2600                 SetWindowPreferredRotation(ownee, ownerRotation);
2601         }
2602
2603         SetLastResult(E_SUCCESS);
2604 }
2605
2606 int
2607 _EcoreEvas::GetWindowRotation(const _Window& window)
2608 {
2609         _EflLayer* pLayer = GetEflLayer(window);
2610         if (!pLayer)
2611         {
2612                 return 0;
2613         }
2614
2615         int rotation = ecore_evas_rotation_get(pLayer->GetEcoreEvas());
2616         return rotation;
2617 }
2618
2619 void
2620 _EcoreEvas::SetWindowPreferredRotation(const _Window& window, int rotation, bool force)
2621 {
2622         _EflLayer* pLayer = GetEflLayer(window);
2623         if (!pLayer)
2624         {
2625                 return;
2626         }
2627
2628         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2629
2630         if (force == true)
2631         {
2632                 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2633         }
2634         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set window preferred rotation(%d).", win, rotation);
2635         ecore_evas_wm_rotation_preferred_rotation_set(pLayer->GetEcoreEvas(), rotation);
2636
2637         _Window* pWindow = const_cast<_Window*>(&window);
2638         if (pWindow)
2639         {
2640                 if (rotation == -1)
2641                 {
2642                         pWindow->SetPreferredRotation(false);
2643                 }
2644                 else
2645                 {
2646                         pWindow->SetPreferredRotation(true);
2647                 }
2648         }
2649 }
2650
2651 void
2652 _EcoreEvas::SetWindowAvailabledRotation(const _Window& window, int* rotations, unsigned int count, bool force)
2653 {
2654         _EflLayer* pLayer = GetEflLayer(window);
2655         if (!pLayer)
2656         {
2657                 return;
2658         }
2659
2660         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2661
2662         // Skip available_set if there is not change
2663         if (force == false)
2664         {
2665                 int* prevRotations = null;
2666                 unsigned int prevCount = 0;
2667                 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pLayer->GetEcoreEvas(), &prevRotations, &prevCount);
2668                 free(prevRotations);
2669
2670                 if (ret)
2671                 {
2672                         if (prevCount == count)
2673                         {
2674                                 return;
2675                         }
2676                 }
2677         }
2678         else
2679         {
2680                 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2681         }
2682
2683         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set window available rotation(%d).", win, count);
2684         ecore_evas_wm_rotation_available_rotations_set(pLayer->GetEcoreEvas(), rotations, count);
2685 }
2686
2687 void
2688 _EcoreEvas::RegisterWindowStateCallback(const _Window& window)
2689 {
2690         _EflLayer* pLayer = GetEflLayer(window);
2691         if (!pLayer)
2692         {
2693                 return;
2694         }
2695
2696         ecore_evas_callback_state_change_set(pLayer->GetEcoreEvas(), OnWindowStateChanged);
2697 }
2698
2699 void
2700 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::Rectangle& bounds)
2701 {
2702         _EflLayer* pLayer = GetEflLayer(window);
2703         if (!pLayer)
2704         {
2705                 return;
2706         }
2707
2708         Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2709
2710         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2711         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set rotation bounds(ROT %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2712         ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2713 }
2714
2715 void
2716 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::FloatRectangle& bounds)
2717 {
2718         _EflLayer* pLayer = GetEflLayer(window);
2719         if (!pLayer)
2720         {
2721                 return;
2722         }
2723
2724         FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2725         Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2726
2727         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2728         SysLog(NID_UI, "[WM ROTATION][WIN 0x%x] Set rotation bounds(ROT %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2729         ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2730 }
2731
2732 // [ToDo] Remove API
2733 const _Control*
2734 _EcoreEvas::GetFrame(void) const
2735 {
2736         SysLog(NID_UI, "Do not use.");
2737         return __pFrame;
2738 }
2739
2740 // [ToDo] Remove API
2741 _RootVisualElement*
2742 _EcoreEvas::GetRootVisualElement(void)const
2743 {
2744         SysLog(NID_UI, "Do not use.");
2745         return null;
2746 }
2747
2748 // [ToDo] Remove API
2749 void
2750 _EcoreEvas::SetFrame(const _Control& control)
2751 {
2752         SysLog(NID_UI, "Do not use.");
2753         __pFrame = const_cast<_Control*>(&control);
2754 }
2755
2756 bool
2757 _EcoreEvas::GetSelectedCbhmItem(Ecore_X_Atom* pDataType, char** pBuffer) const
2758 {
2759         Ecore_X_Window cbhmWin = GetCbhmWindow();
2760         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_SELECTED_ITEM);
2761         Ecore_X_Atom atomItemType = 0;
2762
2763         char* pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
2764         if (pRet)
2765         {
2766                 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
2767                 if (atomItemType == x_atom_cbhm_error)
2768                 {
2769                         free(pRet);
2770                         return false;
2771                 }
2772
2773                 if (pBuffer)
2774                 {
2775                         *pBuffer = pRet;
2776                 }
2777                 else
2778                 {
2779                         free(pRet);
2780                 }
2781
2782                 if (pDataType)
2783                 {
2784                         *pDataType = atomItemType;
2785                 }
2786
2787                 return true;
2788         }
2789
2790         return false;
2791 }
2792
2793 bool
2794 _EcoreEvas::IsAccessibilityScreenReaderActivated(void)
2795 {
2796         Eina_Bool acc = elm_config_access_get();
2797         return acc;
2798 }
2799
2800 void* _GetEcoreEvasHandle(void)
2801 {
2802         _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2803         if (pEcoreEvasMgr == null)
2804         {
2805                 return null;
2806         }
2807
2808         _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2809         if (pUiEcoreEvas == null)
2810         {
2811                 return null;
2812         }
2813
2814         return (void*)pUiEcoreEvas->GetEcoreEvas();
2815 }
2816
2817 void* _GetEvasHandle(void)
2818 {
2819         _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2820         if (pEcoreEvasMgr == null)
2821         {
2822                 return null;
2823         }
2824
2825         _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2826         if (pUiEcoreEvas == null)
2827         {
2828                 return null;
2829         }
2830
2831         return (void*)pUiEcoreEvas->GetEvas();
2832 }
2833
2834 result
2835 _EcoreEvas::InitializeAtomList(void)
2836 {
2837         __atomList[_ATOM_TARGETS].pName = "TARGETS";
2838         __atomList[_ATOM_TARGETS].formats = _CLIP_FORMAT_TARGETS;
2839         __atomList[_ATOM_TARGETS].convert = ConvertClipIntoTarget;
2840         __atomList[_ATOM_TARGETS].response = RequestClip;
2841         __atomList[_ATOM_TARGETS].notify = NotifyTarget;
2842         __atomList[_ATOM_TARGETS].atom = 0;
2843
2844         __atomList[_ATOM_ATOM].pName = "ATOM";
2845         __atomList[_ATOM_ATOM].formats = _CLIP_FORMAT_TARGETS;
2846         __atomList[_ATOM_ATOM].convert = ConvertClipIntoTarget;
2847         __atomList[_ATOM_ATOM].response = RequestClip;
2848         __atomList[_ATOM_ATOM].notify = NotifyTarget;
2849         __atomList[_ATOM_ATOM].atom = 0;
2850
2851         __atomList[_ATOM_XELM].pName = "application/x-elementary-markup";
2852         __atomList[_ATOM_XELM].formats = _CLIP_FORMAT_MARKUP;
2853         __atomList[_ATOM_XELM].convert = ConvertClipIntoEdje;
2854         __atomList[_ATOM_XELM].response = null;
2855         __atomList[_ATOM_XELM].notify = NotifyEdje;
2856         __atomList[_ATOM_XELM].atom = 0;
2857
2858         __atomList[_ATOM_TEXT_URI].pName = "text/uri";
2859         __atomList[_ATOM_TEXT_URI].formats = _CLIP_FORMAT_IMAGE;
2860         __atomList[_ATOM_TEXT_URI].convert = ConvertClipIntoUri;
2861         __atomList[_ATOM_TEXT_URI].response = null;
2862         __atomList[_ATOM_TEXT_URI].notify = NotifyUri;
2863         __atomList[_ATOM_TEXT_URI].atom = 0;
2864
2865         __atomList[_ATOM_TEXT_URILIST].pName = "text/uri-list";
2866         __atomList[_ATOM_TEXT_URILIST].formats = _CLIP_FORMAT_IMAGE;
2867         __atomList[_ATOM_TEXT_URILIST].convert = ConvertClipIntoUri;
2868         __atomList[_ATOM_TEXT_URILIST].response = null;
2869         __atomList[_ATOM_TEXT_URILIST].notify = NotifyUri;
2870         __atomList[_ATOM_TEXT_URILIST].atom = 0;
2871
2872         __atomList[_ATOM_TEXT_X_VCARD].pName = "text/x-vcard";
2873         __atomList[_ATOM_TEXT_X_VCARD].formats = _CLIP_FORMAT_VCARD;
2874         __atomList[_ATOM_TEXT_X_VCARD].convert = null;
2875         __atomList[_ATOM_TEXT_X_VCARD].response = null;
2876         __atomList[_ATOM_TEXT_X_VCARD].notify = null;
2877         __atomList[_ATOM_TEXT_X_VCARD].atom = 0;
2878
2879         __atomList[_ATOM_IMAGE_PNG].pName = "image/png";
2880         __atomList[_ATOM_IMAGE_PNG].formats = _CLIP_FORMAT_IMAGE;
2881         __atomList[_ATOM_IMAGE_PNG].convert = ConvertClipIntoImage;
2882         __atomList[_ATOM_IMAGE_PNG].response = null;
2883         __atomList[_ATOM_IMAGE_PNG].notify = NotifyImage;
2884         __atomList[_ATOM_IMAGE_PNG].atom = 0;
2885
2886         __atomList[_ATOM_IMAGE_JPEG].pName = "image/jpeg";
2887         __atomList[_ATOM_IMAGE_JPEG].formats = _CLIP_FORMAT_IMAGE;
2888         __atomList[_ATOM_IMAGE_JPEG].convert = ConvertClipIntoImage;
2889         __atomList[_ATOM_IMAGE_JPEG].response = null;
2890         __atomList[_ATOM_IMAGE_JPEG].notify = NotifyImage;
2891         __atomList[_ATOM_IMAGE_JPEG].atom = 0;
2892
2893         __atomList[_ATOM_IMAGE_BMP].pName = "image/x-ms-bmp";
2894         __atomList[_ATOM_IMAGE_BMP].formats = _CLIP_FORMAT_IMAGE;
2895         __atomList[_ATOM_IMAGE_BMP].convert = ConvertClipIntoImage;
2896         __atomList[_ATOM_IMAGE_BMP].response = null;
2897         __atomList[_ATOM_IMAGE_BMP].notify = NotifyImage;
2898         __atomList[_ATOM_IMAGE_BMP].atom = 0;
2899
2900         __atomList[_ATOM_IMAGE_GIF].pName = "image/gif";
2901         __atomList[_ATOM_IMAGE_GIF].formats = _CLIP_FORMAT_IMAGE;
2902         __atomList[_ATOM_IMAGE_GIF].convert = ConvertClipIntoImage;
2903         __atomList[_ATOM_IMAGE_GIF].response = null;
2904         __atomList[_ATOM_IMAGE_GIF].notify = NotifyImage;
2905         __atomList[_ATOM_IMAGE_GIF].atom = 0;
2906
2907         __atomList[_ATOM_IMAGE_TIFF].pName = "image/tiff";
2908         __atomList[_ATOM_IMAGE_TIFF].formats = _CLIP_FORMAT_IMAGE;
2909         __atomList[_ATOM_IMAGE_TIFF].convert = ConvertClipIntoImage;
2910         __atomList[_ATOM_IMAGE_TIFF].response = null;
2911         __atomList[_ATOM_IMAGE_TIFF].notify = NotifyImage;
2912         __atomList[_ATOM_IMAGE_TIFF].atom = 0;
2913
2914         __atomList[_ATOM_IMAGE_SVG].pName = "image/svg+xml";
2915         __atomList[_ATOM_IMAGE_SVG].formats = _CLIP_FORMAT_IMAGE;
2916         __atomList[_ATOM_IMAGE_SVG].convert = ConvertClipIntoImage;
2917         __atomList[_ATOM_IMAGE_SVG].response = null;
2918         __atomList[_ATOM_IMAGE_SVG].notify = NotifyImage;
2919         __atomList[_ATOM_IMAGE_SVG].atom = 0;
2920
2921         __atomList[_ATOM_IMAGE_XPM].pName = "image/x-xpixmap";
2922         __atomList[_ATOM_IMAGE_XPM].formats = _CLIP_FORMAT_IMAGE;
2923         __atomList[_ATOM_IMAGE_XPM].convert = ConvertClipIntoImage;
2924         __atomList[_ATOM_IMAGE_XPM].response = null;
2925         __atomList[_ATOM_IMAGE_XPM].notify = NotifyImage;
2926         __atomList[_ATOM_IMAGE_XPM].atom = 0;
2927
2928         __atomList[_ATOM_IMAGE_TGA].pName = "image/x-tga";
2929         __atomList[_ATOM_IMAGE_TGA].formats = _CLIP_FORMAT_IMAGE;
2930         __atomList[_ATOM_IMAGE_TGA].convert = ConvertClipIntoImage;
2931         __atomList[_ATOM_IMAGE_TGA].response = null;
2932         __atomList[_ATOM_IMAGE_TGA].notify = NotifyImage;
2933         __atomList[_ATOM_IMAGE_TGA].atom = 0;
2934
2935         __atomList[_ATOM_IMAGE_PPM].pName = "image/x-portable-pixmap";
2936         __atomList[_ATOM_IMAGE_PPM].formats = _CLIP_FORMAT_IMAGE;
2937         __atomList[_ATOM_IMAGE_PPM].convert = ConvertClipIntoImage;
2938         __atomList[_ATOM_IMAGE_PPM].response = null;
2939         __atomList[_ATOM_IMAGE_PPM].notify = NotifyImage;
2940         __atomList[_ATOM_IMAGE_PPM].atom = 0;
2941
2942         __atomList[_ATOM_TEXT_HTML_UTF8].pName = "text/html;charset=utf-8";
2943         __atomList[_ATOM_TEXT_HTML_UTF8].formats = _CLIP_FORMAT_HTML;
2944         __atomList[_ATOM_TEXT_HTML_UTF8].convert = ConvertClipIntoHtml;
2945         __atomList[_ATOM_TEXT_HTML_UTF8].response = null;
2946         __atomList[_ATOM_TEXT_HTML_UTF8].notify = NotifyHtml;
2947         __atomList[_ATOM_TEXT_HTML_UTF8].atom = 0;
2948
2949         __atomList[_ATOM_TEXT_HTML].pName = "text/html";
2950         __atomList[_ATOM_TEXT_HTML].formats = _CLIP_FORMAT_HTML;
2951         __atomList[_ATOM_TEXT_HTML].convert = ConvertClipIntoHtml;
2952         __atomList[_ATOM_TEXT_HTML].response = null;
2953         __atomList[_ATOM_TEXT_HTML].notify = NotifyHtml;
2954         __atomList[_ATOM_TEXT_HTML].atom = 0;
2955
2956         __atomList[_ATOM_STRING_UTF8].pName = "UTF8_STRING";
2957         __atomList[_ATOM_STRING_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2958         __atomList[_ATOM_STRING_UTF8].convert = ConvertClipIntoText;
2959         __atomList[_ATOM_STRING_UTF8].response = null;
2960         __atomList[_ATOM_STRING_UTF8].notify = NotifyText;
2961         __atomList[_ATOM_STRING_UTF8].atom = 0;
2962
2963         __atomList[_ATOM_STRING].pName = "STRING";
2964         __atomList[_ATOM_STRING].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2965         __atomList[_ATOM_STRING].convert = ConvertClipIntoText;
2966         __atomList[_ATOM_STRING].response = null;
2967         __atomList[_ATOM_STRING].notify = NotifyText;
2968         __atomList[_ATOM_STRING].atom = 0;
2969
2970         __atomList[_ATOM_TEXT].pName = "TEXT";
2971         __atomList[_ATOM_TEXT].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2972         __atomList[_ATOM_TEXT].convert = ConvertClipIntoText;
2973         __atomList[_ATOM_TEXT].response = null;
2974         __atomList[_ATOM_TEXT].notify = null;
2975         __atomList[_ATOM_TEXT].atom = 0;
2976
2977         __atomList[_ATOM_TEXT_PLAIN_UTF8].pName = "text/plain;charset=utf-8";
2978         __atomList[_ATOM_TEXT_PLAIN_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2979         __atomList[_ATOM_TEXT_PLAIN_UTF8].convert = ConvertClipIntoText;
2980         __atomList[_ATOM_TEXT_PLAIN_UTF8].response = null;
2981         __atomList[_ATOM_TEXT_PLAIN_UTF8].notify = null;
2982         __atomList[_ATOM_TEXT_PLAIN_UTF8].atom = 0;
2983
2984         __atomList[_ATOM_TEXT_PLAIN].pName = "text/plain";
2985         __atomList[_ATOM_TEXT_PLAIN].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2986         __atomList[_ATOM_TEXT_PLAIN].convert = ConvertClipIntoText;
2987         __atomList[_ATOM_TEXT_PLAIN].response = null;
2988         __atomList[_ATOM_TEXT_PLAIN].notify = null;
2989         __atomList[_ATOM_TEXT_PLAIN].atom = 0;
2990
2991         __clipList[_CLIP_TYPE_PRIMARY].selection = ECORE_X_SELECTION_PRIMARY;
2992         __clipList[_CLIP_TYPE_PRIMARY].set = ecore_x_selection_primary_set;
2993         __clipList[_CLIP_TYPE_PRIMARY].clear = ecore_x_selection_primary_clear;
2994         __clipList[_CLIP_TYPE_PRIMARY].request = ecore_x_selection_primary_request;
2995         __clipList[_CLIP_TYPE_PRIMARY].active = false;
2996         __clipList[_CLIP_TYPE_PRIMARY].pBuffer = null;
2997         __clipList[_CLIP_TYPE_PRIMARY].pRetrievedBuffer = null;
2998         __clipList[_CLIP_TYPE_PRIMARY].bufferLength = 0;
2999         __clipList[_CLIP_TYPE_PRIMARY].completed = false;
3000
3001         __clipList[_CLIP_TYPE_SECONDARY].selection = ECORE_X_SELECTION_SECONDARY;
3002         __clipList[_CLIP_TYPE_SECONDARY].set = ecore_x_selection_secondary_set;
3003         __clipList[_CLIP_TYPE_SECONDARY].clear = ecore_x_selection_secondary_clear;
3004         __clipList[_CLIP_TYPE_SECONDARY].request = ecore_x_selection_secondary_request;
3005         __clipList[_CLIP_TYPE_SECONDARY].active = false;
3006         __clipList[_CLIP_TYPE_SECONDARY].pBuffer = null;
3007         __clipList[_CLIP_TYPE_SECONDARY].pRetrievedBuffer = null;
3008         __clipList[_CLIP_TYPE_SECONDARY].bufferLength = 0;
3009         __clipList[_CLIP_TYPE_SECONDARY].completed = false;
3010
3011         __clipList[_CLIP_TYPE_CLIPBOARD].selection = ECORE_X_SELECTION_CLIPBOARD;
3012         __clipList[_CLIP_TYPE_CLIPBOARD].set = ecore_x_selection_clipboard_set;
3013         __clipList[_CLIP_TYPE_CLIPBOARD].clear = ecore_x_selection_clipboard_clear;
3014         __clipList[_CLIP_TYPE_CLIPBOARD].request = ecore_x_selection_clipboard_request;
3015         __clipList[_CLIP_TYPE_CLIPBOARD].active = false;
3016         __clipList[_CLIP_TYPE_CLIPBOARD].pBuffer = null;
3017         __clipList[_CLIP_TYPE_CLIPBOARD].pRetrievedBuffer = null;
3018         __clipList[_CLIP_TYPE_CLIPBOARD].bufferLength = 0;
3019         __clipList[_CLIP_TYPE_CLIPBOARD].completed = false;
3020
3021         __clipList[_CLIP_TYPE_XDND].selection = ECORE_X_SELECTION_XDND;
3022         __clipList[_CLIP_TYPE_XDND].request = ecore_x_selection_xdnd_request;
3023         __clipList[_CLIP_TYPE_XDND].active = false;
3024         __clipList[_CLIP_TYPE_XDND].pBuffer = null;
3025         __clipList[_CLIP_TYPE_XDND].pRetrievedBuffer = null;
3026         __clipList[_CLIP_TYPE_XDND].bufferLength = 0;
3027         __clipList[_CLIP_TYPE_XDND].completed = false;
3028
3029         for (int i = 0; i < _ATOM_MAX; i++)
3030         {
3031                 __atomList[i].atom = ecore_x_atom_get(__atomList[i].pName);
3032                 //ecore_x_selection_converter_atom_add(__atomList[i].atom, __atomList[i].convert);
3033
3034                 SysLog(NID_UI, "[Clipboard] __atomList[%d] : pName = %s, atom = %d", i, __atomList[i].pName, __atomList[i].atom);
3035         }
3036
3037         result r = E_SUCCESS;
3038
3039         __pClearClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, ClearClip, NULL);
3040         SysTryCatch(NID_UI, __pClearClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3041
3042         __pNotifyClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, NotifyClip, NULL);
3043         SysTryCatch(NID_UI, __pNotifyClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3044
3045         __pClipboardClosed = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, OnClipboardClosed, null);
3046         SysTryCatch(NID_UI, __pClipboardClosed, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3047
3048         __atomRotateRootAngle = ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE");
3049
3050         return r;
3051
3052 CATCH:
3053         for (int i = 0; i < _ATOM_MAX; i++)
3054         {
3055                 if (__atomList[i].atom)
3056                 {
3057                         ecore_x_selection_converter_atom_del(__atomList[i].atom);
3058                 }
3059         }
3060
3061         if (__pClearClip)
3062         {
3063                 ecore_event_handler_del(__pClearClip);
3064                 __pClearClip = null;
3065         }
3066
3067         if (__pNotifyClip)
3068         {
3069                 ecore_event_handler_del(__pNotifyClip);
3070                 __pNotifyClip = null;
3071         }
3072
3073         if (__pClipboardClosed)
3074         {
3075                 ecore_event_handler_del(__pClipboardClosed);
3076                 __pClipboardClosed = null;
3077         }
3078
3079         return r;
3080 }
3081
3082 bool
3083 _EcoreEvas::IsValidClipFormat(_ClipFormat clipFormat)
3084 {
3085         return ((_CLIP_FORMAT_TEXT & clipFormat) ||
3086                 (_CLIP_FORMAT_MARKUP & clipFormat) ||
3087                 (_CLIP_FORMAT_IMAGE & clipFormat) ||
3088                 (_CLIP_FORMAT_VCARD & clipFormat) ||
3089                 (_CLIP_FORMAT_HTML & clipFormat));
3090 }
3091
3092 Ecore_X_Window
3093 _EcoreEvas::GetCbhmWindow(void) const
3094 {
3095         Ecore_X_Atom atomCbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME);
3096         Ecore_X_Window cbhmWin = 0;
3097
3098         unsigned char* pBuf = NULL;
3099         int num = 0;
3100         int ret = ecore_x_window_prop_property_get(0, atomCbhm, XA_WINDOW, 0, &pBuf, &num);
3101
3102         if (ret && num)
3103         {
3104                 memcpy(&cbhmWin, pBuf, sizeof(Ecore_X_Window));
3105         }
3106
3107         if (pBuf)
3108         {
3109                 free(pBuf);
3110         }
3111
3112         return cbhmWin;
3113 }
3114
3115 bool
3116 _EcoreEvas::SendCbhmMessage(Ecore_X_Window xwin, const char* pMsg)
3117 {
3118         Ecore_X_Window cbhmWin = GetCbhmWindow();
3119         Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(ATOM_CBHM_MSG);
3120
3121         if (!cbhmWin || !atomCbhmMsg)
3122         {
3123                 return false;
3124         }
3125
3126         XClientMessageEvent m;
3127         memset(&m, 0, sizeof(m));
3128         m.type = ClientMessage;
3129         m.display = (Display*)ecore_x_display_get();
3130         m.window = xwin;
3131         m.message_type = atomCbhmMsg;
3132         m.format = 8;
3133         snprintf(m.data.b, 20, "%s", pMsg);
3134
3135         XSendEvent((Display*)ecore_x_display_get(), cbhmWin, False, NoEventMask, (XEvent*)&m);
3136
3137         ecore_x_sync();
3138
3139         // [SLP]
3140         Thread::Sleep(100);
3141
3142         return true;
3143 }
3144
3145 bool
3146 _EcoreEvas::SetCbhmItem(Ecore_X_Window xwin, Ecore_X_Atom dataType, char* pItemData)
3147 {
3148         Ecore_X_Window cbhmWin = GetCbhmWindow();
3149         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_ITEM);
3150
3151         ecore_x_sync();
3152         ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, pItemData, strlen(pItemData) + 1);
3153         ecore_x_sync();
3154
3155         if (SendCbhmMessage(xwin, ATOM_CBHM_SET_ITEM))
3156         {
3157                 return true;
3158         }
3159
3160         return false;
3161 }
3162
3163 void*
3164 _EcoreEvas::GetCbhmReply(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom* pDataType, int* pNum) const
3165 {
3166         unsigned char* pData = null;
3167
3168         if (pDataType)
3169         {
3170                 *pDataType = 0;
3171         }
3172
3173         if (!property)
3174         {
3175                 return null;
3176         }
3177
3178         ecore_x_sync();
3179
3180         if (pNum)
3181         {
3182                 *pNum = 0;
3183         }
3184
3185         long unsigned int numRet = 0;
3186         long unsigned int bytes = 0;
3187         int ret = 0;
3188         int sizeRet = 0;
3189         unsigned int i = 0;
3190         unsigned char* pPropRet = null;
3191         Ecore_X_Atom typeRet;
3192
3193         ret = XGetWindowProperty((Display*)ecore_x_display_get(), xwin, property, 0, LONG_MAX, False,
3194                                                         ecore_x_window_prop_any_type(), (Atom*)&typeRet, &sizeRet, &numRet, &bytes, &pPropRet);
3195         if (ret != Success)
3196         {
3197                 return null;
3198         }
3199
3200         if (!numRet)
3201         {
3202                 XFree(pPropRet);
3203                 return null;
3204         }
3205
3206         if (!(pData = (unsigned char*)malloc(numRet * sizeRet / 8)))
3207         {
3208                 XFree(pPropRet);
3209                 return null;
3210         }
3211
3212         switch (sizeRet)
3213         {
3214         case 8:
3215                 for (i = 0; i < numRet; i++)
3216                 (pData)[i] = pPropRet[i];
3217                 break;
3218         case 16:
3219                 for (i = 0; i < numRet; i++)
3220                 ((unsigned short *)pData)[i] = ((unsigned short *)pPropRet)[i];
3221                 break;
3222         case 32:
3223                 for (i = 0; i < numRet; i++)
3224                 ((unsigned int *)pData)[i] = ((unsigned long *)pPropRet)[i];
3225                 break;
3226         }
3227
3228         XFree(pPropRet);
3229
3230         // [SLP]
3231         Thread::Sleep(100);
3232
3233         if (pNum)
3234         {
3235                 *pNum = numRet;
3236         }
3237
3238         if (pDataType)
3239         {
3240                 *pDataType = typeRet;
3241         }
3242
3243         return pData;
3244 }
3245
3246 int
3247 _EcoreEvas::GetCbhmItemCount(void) const
3248 {
3249         char* pRet = null;
3250         int count = null;
3251
3252         Ecore_X_Atom atomCbhmCountGet = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
3253         Ecore_X_Window cbhmWin = GetCbhmWindow();
3254
3255         pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmCountGet, null, null);
3256         if (pRet)
3257         {
3258                 count = atoi(pRet);
3259                 free(pRet);
3260                 return count;
3261         }
3262
3263         return -1;
3264 }
3265
3266 bool
3267 _EcoreEvas::GetCbhmItem(int index, Ecore_X_Atom* pDataType, char** pBuffer) const
3268 {
3269         if (pBuffer)
3270         {
3271                 *pBuffer = null;
3272         }
3273
3274         if (pDataType)
3275         {
3276                 *(int*)pDataType = 0;
3277         }
3278
3279         Ecore_X_Window cbhmWin = GetCbhmWindow();
3280         char sendBuf[20];
3281         char* pRet;
3282
3283         snprintf(sendBuf, 20, "CBHM_ITEM%d", index);
3284         Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(sendBuf);
3285         Ecore_X_Atom atomItemType = 0;
3286
3287         pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
3288         if (pRet)
3289         {
3290                 if (pBuffer)
3291                 {
3292                         *pBuffer = pRet;
3293                 }
3294                 else
3295                 {
3296                         free(pRet);
3297                 }
3298
3299                 if (pDataType)
3300                 {
3301                         *pDataType = atomItemType;
3302                 }
3303
3304                 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
3305                 if (atomItemType == x_atom_cbhm_error)
3306                 {
3307                         return false;
3308                 }
3309
3310                 return true;
3311         }
3312
3313         return false;
3314 }
3315
3316 }} // Tizen::Ui
3317
3318 #ifdef __cplusplus
3319 extern "C"
3320 {
3321 #endif
3322
3323 // [ToDo] Remove API
3324 _OSP_EXPORT_ void
3325 _AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3326 {
3327         GetEcoreEvasMgr()->GetEcoreEvas()->AddActiveWindowEventListener(listener);
3328 }
3329
3330 // [ToDo] Remove API
3331 _OSP_EXPORT_ void
3332 _RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3333 {
3334         GetEcoreEvasMgr()->GetEcoreEvas()->RemoveActiveWindowEventListener(listener);
3335 }
3336
3337 // [ToDo] Remove API
3338 _OSP_EXPORT_ unsigned int
3339 _GetActiveWindow(void)
3340 {
3341         return GetEcoreEvasMgr()->GetEcoreEvas()->GetActiveWindow();
3342 }
3343
3344 // [ToDo] Remove API
3345 _OSP_EXPORT_ int
3346 _GetProcessId(unsigned int window)
3347 {
3348         return GetEcoreEvasMgr()->GetEcoreEvas()->GetProcessId(window);
3349 }
3350
3351 #ifdef __cplusplus
3352 }
3353 #endif
3354