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