2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUi_EcoreEvas.cpp
20 * @brief This is the implementation file for the _EcoreEvas class.
24 #include <appcore-common.h>
25 #include <runtime_info.h>
27 #include <X11/Xatom.h>
29 #include <Elementary.h>
30 #include <FGrpRectangle.h>
31 #include <FGrpFloatRectangle.h>
32 #include <FBaseInteger.h>
33 #include <FBaseErrors.h>
34 #include <FBaseSysLog.h>
35 #include <FBaseRtThread.h>
36 #include <FApp_IActiveWindowEventListener.h>
37 #include <FBase_StringConverter.h>
38 #include <FGrp_CanvasImpl.h>
39 #include "FUi_CoordinateSystemUtils.h"
40 #include "FUi_EcoreEvas.h"
41 #include "FUi_EcoreEvasMgr.h"
42 #include "FUi_Control.h"
44 #include "FUi_UiNotificationEvent.h"
45 #include "FUi_UiEventManager.h"
46 #include "FUi_Window.h"
47 #include "FUiAnim_EflLayer.h"
48 #include "FUiAnim_EflNode.h"
49 #include "FUiAnim_VisualElement.h"
50 #include "FUi_AccessibilityGesture.h"
51 #include "FUi_AccessibilitySystemSettingLoader.h"
52 #include "FUiAnim_RootVisualElement.h"
53 #include "FUiAnim_DisplayManager.h"
54 #include "FUiCtrl_Frame.h"
55 #include "FUiCtrl_FrameImpl.h"
56 #include "FUiCtrl_FormImpl.h"
57 #include "FUi_Clipboard.h"
58 #include "FUi_TouchManager.h"
59 #include "FUi_ControlManager.h"
60 #include "FUi_ActiveWindowEvent.h"
61 #include "FUi_ControlImplManager.h"
62 #include "FUiCtrl_Popup.h"
63 #include "FUiCtrl_ContextMenu.h"
64 #include "FUiAnim_DisplayContextImpl.h"
65 #include "FUiAnimDisplayContext.h"
66 #include "FUi_TouchManager.h"
68 using namespace Tizen::Base;
69 using namespace Tizen::Base::Runtime;
70 using namespace Tizen::App;
71 using namespace Tizen::Graphics;
72 using namespace Tizen::Ui;
73 using namespace Tizen::Ui::Animations;
74 using namespace Tizen::Ui::Controls;
76 #define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
77 #define ATOM_CBHM_MSG "CBHM_MSG"
78 #define ATOM_CBHM_COUNT_GET "CBHM_cCOUNT"
79 #define ATOM_CBHM_SERIAL_NUMBER "CBHM_SERIAL_NUMBER"
80 #define ATOM_CBHM_ERROR "CBHM_ERROR"
81 #define ATOM_CBHM_ITEM "CBHM_ITEM"
82 #define ATOM_CBHM_SET_ITEM "SET_ITEM"
83 #define ATOM_CBHM_CLIPBOARD_SHOW_ALL "show1"
84 #define ATOM_CBHM_CLIPBOARD_SHOW "show0"
85 #define ATOM_CBHM_CLIPBOARD_HIDE "cbhm_hide"
86 #define ATOM_CBHM_SELECTED_ITEM "CBHM_SELECTED_ITEM"
87 #define ATOM_ROTATE_AUTO "_E_WINDOW_ROTATION_SUPPORTED"
89 namespace Tizen { namespace Ui
91 static _EcoreEvas* _pEvas = null;
97 Ecore_X_Atom __atomRotateRootAngle = 0;
99 int __clipboardHeight = 0;
102 OnWindowStateChanged(Ecore_Evas* pEcoreEvas)
104 _ControlManager* pControlManager = _ControlManager::GetInstance();
105 if (!pControlManager)
110 Ecore_X_Window targetWin = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
112 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] OnWindowStateChanged is called.", targetWin);
114 int winCount = pControlManager->GetAllWindowCount();
115 for (int i = 0; i < winCount; i++)
117 _Window* pWindow = pControlManager->GetAllWindow(i);
123 Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
125 if (win == targetWin)
127 pWindow->OnWindowStateChanged();
135 OnWindowPropertyChanged(void* pData, int type, void* pEvent)
137 Ecore_X_Event_Window_Property* pEv = (Ecore_X_Event_Window_Property*)pEvent;
140 return ECORE_CALLBACK_PASS_ON;
143 Ecore_X_Window targetWin = pEv->win;
146 return ECORE_CALLBACK_PASS_ON;
149 if (pEv->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
151 Ecore_X_Window zone = ecore_x_e_illume_zone_get(targetWin);
152 Ecore_X_Illume_Clipboard_State clipboardState = ecore_x_e_illume_clipboard_state_get(zone);
154 if (clipboardState == ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
160 ecore_x_e_illume_clipboard_geometry_get(zone, &x, &y, &w, &h);
162 Dimension clipboardDim = _CoordinateSystemUtils::InverseTransform(Dimension(w, h));
164 if (__clipboardHeight == 0)
166 SysLog(NID_UI, "[Clipboard] Clipboard is opened. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
167 _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_OPENED, clipboardDim.width, clipboardDim.height);
168 __clipboardHeight = clipboardDim.height;
172 // SysLog(NID_UI, "[Clipboard] The bounds of Clipboard is changed. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
173 // _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED, clipboardDim.width, clipboardDim.height);
176 else if (clipboardState == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF)
178 SysLog(NID_UI, "[Clipboard] Clipboard is closed.");
179 _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_CLOSED, 0, 0);
180 __clipboardHeight = 0;
181 _Clipboard::GetInstance()->HidePopup();
184 else if (pEv->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY)
186 // Only after opening Clipboard
187 if (__clipboardHeight != 0)
189 Ecore_X_Window zone = ecore_x_e_illume_zone_get(targetWin);
195 ecore_x_e_illume_clipboard_geometry_get(zone, &x, &y, &w, &h);
197 Dimension clipboardDim = _CoordinateSystemUtils::InverseTransform(Dimension(w, h));
199 if (clipboardDim.height != 0)
201 SysLog(NID_UI, "[Clipboard] The bounds of Clipboard is changed. -> w = %d, h = %d", clipboardDim.width, clipboardDim.height);
202 _Clipboard::GetInstance()->FirePopupEvent(_CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED, clipboardDim.width, clipboardDim.height);
206 else if (pEv->atom == ECORE_X_ATOM_WM_STATE)
208 _ControlManager* pControlManager = _ControlManager::GetInstance();
209 if (!pControlManager)
211 return ECORE_CALLBACK_PASS_ON;
214 int winCount = pControlManager->GetWindowCount();
216 for (int i = 0; i < winCount; i++)
218 _Window* pWindow = pControlManager->GetWindow(i);
224 Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
225 if (win != targetWin)
230 if (pWindow->IsOrientationRoot() == true)
232 _Frame* pFrame = static_cast<_Frame*>(pWindow);
233 _DisplayContextImpl* pContext = _DisplayContextImpl::GetInstance(*pFrame->GetDisplayContext());
234 _EflLayer* pLayer = static_cast<_EflLayer*>(pContext->GetNativeLayer());
237 Ecore_X_Window_State_Hint state = ecore_x_icccm_state_get(targetWin);
240 case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
241 pLayer->SetRenderNeeded(false);
244 case ECORE_X_WINDOW_STATE_HINT_ICONIC:
245 pLayer->SetRenderNeeded(false);
246 pFrame->OnFrameMinimized();
248 case ECORE_X_WINDOW_STATE_HINT_NORMAL:
249 pLayer->SetRenderNeeded(true);
250 pFrame->OnFrameRestored();
261 return ECORE_CALLBACK_PASS_ON;
265 OnWindowVisibilityChanged(void* pData, int type, void* pEvent)
267 SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
268 SysTryReturn(NID_UI, pEvent, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
270 Ecore_X_Event_Window_Visibility_Change* pE = (Ecore_X_Event_Window_Visibility_Change*) pEvent;
271 _ControlManager* pControlManager = _ControlManager::GetInstance();
273 int count = pControlManager->GetWindowCount();
275 _Window* pWindow = null;
278 for (int i = 0; i < count; i++)
280 pWindow = pControlManager->GetWindow(i);
283 NativeWindowHandle handle = pWindow->GetNativeHandle();
284 if (handle == pE->win)
292 Tizen::Base::Collection::ArrayList* pArgs = null;
293 String* pType = null;
294 Integer* pObscured = null;
298 const _Control* pDestination = pWindow;
300 pArgs = new (std::nothrow) Tizen::Base::Collection::ArrayList;
301 SysTryReturn(NID_UI, pArgs, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
303 result r = pArgs->Construct();
304 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
306 pType = new (std::nothrow) String(L"VisibilityEvent");
307 r = pArgs->Add(*pType);
308 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
310 pObscured = new (std::nothrow) Integer(pE->fully_obscured);
311 r = pArgs->Add(*pObscured);
312 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
314 _UiNotificationEvent event(pDestination->GetHandle(), pArgs);
316 r = _UiEventManager::GetInstance()->SendEvent(event);
319 return ECORE_CALLBACK_RENEW;
322 pArgs->RemoveAll(true);
344 OnWindowConfigured(void* pData, int type, void* pEvent)
346 Ecore_X_Event_Window_Configure* pEv = (Ecore_X_Event_Window_Configure*)pEvent;
349 return ECORE_CALLBACK_PASS_ON;
352 if (pEv->from_wm == EINA_FALSE)
354 return ECORE_CALLBACK_PASS_ON;
357 Ecore_X_Window targetWin = pEv->win;
360 return ECORE_CALLBACK_PASS_ON;
363 if ((frameX == pEv->x) && (frameY == pEv->y) && (frameW == pEv->w) && (frameH == pEv->h))
365 return ECORE_CALLBACK_PASS_ON;
373 _ControlManager* pControlManager = _ControlManager::GetInstance();
374 if (!pControlManager)
376 return ECORE_CALLBACK_PASS_ON;
379 _TouchManager* pTouchManager = _TouchManager::GetInstance();
382 return ECORE_CALLBACK_PASS_ON;
385 if (pTouchManager->GetPointCount() > 0)
387 return ECORE_CALLBACK_PASS_ON;
390 _Window* pWindow = pControlManager->GetCurrentFrame();
393 return ECORE_CALLBACK_PASS_ON;
396 if (pWindow->IsOrientationRoot() == false)
398 return ECORE_CALLBACK_PASS_ON;
401 _Frame* pFrame = static_cast<_Frame*>(pWindow);
402 if (pFrame->GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN)
404 return ECORE_CALLBACK_PASS_ON;
407 Ecore_X_Window win = (Ecore_X_Window)pFrame->GetNativeHandle();
408 if (win != targetWin)
410 return ECORE_CALLBACK_PASS_ON;
413 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
416 return ECORE_CALLBACK_PASS_ON;
419 Rectangle frameBounds = pFrame->GetBounds();
420 int rotation = pEcoreEvas->GetWindowRotation(*pFrame);
422 Dimension winSize = _CoordinateSystemUtils::InverseTransform(Dimension(pEv->w, pEv->h));
423 Dimension newSize(winSize.width, winSize.height);
424 if ((rotation == 270) || (rotation == 90))
426 newSize.width = winSize.height;
427 newSize.height = winSize.width;
430 if ((frameBounds.width != newSize.width) || (frameBounds.height != newSize.height))
432 return ECORE_CALLBACK_PASS_ON;
435 Dimension screenSize = pControlManager->GetScreenSize();
436 Point winPosition = _CoordinateSystemUtils::InverseTransform(Point(pEv->x, pEv->y));
438 Point newPosition(0, 0);
442 newPosition.x = winPosition.y;
443 newPosition.y = screenSize.width - winPosition.x - frameBounds.height;
446 newPosition.x = screenSize.width - winPosition.x - frameBounds.width;
447 newPosition.y = screenSize.height - winPosition.y - frameBounds.height;
450 newPosition.x = screenSize.height - winPosition.y - frameBounds.width;
451 newPosition.y = winPosition.x;
454 newPosition.x = winPosition.x;
455 newPosition.y = winPosition.y;
459 if ((frameBounds.x != newPosition.x) || (frameBounds.y != newPosition.y))
461 pFrame->SetChangingBoundsEnabled(false);
462 pFrame->SetPosition(newPosition);
463 pFrame->SetChangingBoundsEnabled(true);
466 return ECORE_CALLBACK_PASS_ON;
470 OnWindowShown(void* pData, int type, void* pEvent)
472 return ECORE_CALLBACK_PASS_ON;
476 OnClientMessageReceived(void* pData, int type, void* pEvent)
478 Ecore_X_Event_Client_Message* pClientEvent = static_cast<Ecore_X_Event_Client_Message*>(pEvent);
479 SysTryReturn(NID_UI, pClientEvent, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
481 _ControlManager* pControlManager = _ControlManager::GetInstance();
482 if (!pControlManager)
484 return ECORE_CALLBACK_RENEW;
487 if (pClientEvent->message_type == __atomRotateRootAngle)
489 int angle = pClientEvent->data.l[0];
491 SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
493 pControlManager->OnWindowRotated(angle);
496 if (pClientEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
499 int winCount = pControlManager->GetWindowCount();
500 for (int i = 0; i < winCount; i++)
502 _Window* pWindow = pControlManager->GetWindow(i);
508 Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
510 if (win == (Ecore_X_Window)pClientEvent->data.l[0])
519 return ECORE_CALLBACK_RENEW;
524 if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
526 SysLog(NID_UI, "Accessibility action : Move next");
527 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN);
529 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
531 SysLog(NID_UI, "Accessibility action : Move next");
532 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_RIGHT);
534 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
536 SysLog(NID_UI, "Accessibility action : Move previous");
537 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_LEFT);
539 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
541 SysLog(NID_UI, "Accessibility action : Move previous");
542 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_UP);
544 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
546 SysLog(NID_UI, "Accessibility action : Activate");
547 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP);
549 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
551 x = (Evas_Coord)pClientEvent->data.l[2];
552 y = (Evas_Coord)pClientEvent->data.l[3];
553 SysLog(NID_UI, "Accessibility action : Read");
554 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP, x, y);
556 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
558 SysLog(NID_UI, "Accessibility action : value increased");
559 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED);
561 else if ((unsigned int)pClientEvent->data.l[1] == ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_SCROLL_"))
563 SysLog(NID_UI, "Accessibility action : scroll %d, %d, %d", pClientEvent->data.l[2], pClientEvent->data.l[3], pClientEvent->data.l[4]);
564 x = (Evas_Coord)pClientEvent->data.l[3];
565 y = (Evas_Coord)pClientEvent->data.l[4];
566 if (pClientEvent->data.l[2] == 0)
568 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED, x, y);
570 else if (pClientEvent->data.l[2] == 1)
572 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED, x, y);
574 else if (pClientEvent->data.l[2] == 2)
576 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED, x, y);
579 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_SCROLL)
581 SysLog(NID_UI, "Accessibility action : scroll %d, %d, %d", pClientEvent->data.l[2], pClientEvent->data.l[3], pClientEvent->data.l[4]);
582 x = (Evas_Coord)pClientEvent->data.l[3];
583 y = (Evas_Coord)pClientEvent->data.l[4];
584 if (pClientEvent->data.l[2] == 0)
586 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED, x, y);
588 else if (pClientEvent->data.l[2] == 1)
590 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED, x, y);
592 else if (pClientEvent->data.l[2] == 2)
594 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED, x, y);
597 else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
599 SysLog(NID_UI, "Accessibility action : value decreased");
600 _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED);
604 if (pClientEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST)
606 SysLog(NID_UI, "[Ime Rotation]");
608 _Window* pWindow = pControlManager->GetCurrentFrame();
611 NativeWindowHandle handle = pWindow->GetNativeHandle();
613 if (pClientEvent->win == handle)
615 int angle = pClientEvent->data.l[1];
616 SysLog(NID_UI, "[Ime Rotation] Receive the client message(xid = 0x%x, angle = %d)", handle, angle);
618 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
622 _FrameImpl* pFrameImpl = static_cast<Controls::_FrameImpl*>(pFrame->GetUserData());
625 _FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm();
627 if (pCurrentFormImpl)
629 pCurrentFormImpl->UpdateOrientation(angle);
633 pFrameImpl->UpdateOrientation(angle);
641 return ECORE_CALLBACK_RENEW;
654 _CLIP_TYPE_SECONDARY,
655 _CLIP_TYPE_CLIPBOARD,
662 Ecore_X_Selection selection;
663 Eina_Bool (* set)(Ecore_X_Window window, const void* pData, int size);
664 Eina_Bool (* clear)(void);
665 void (* request)(Ecore_X_Window window, const char* pTarget);
671 _ClipFormat requestedFormat;
672 char* pRetrievedBuffer;
677 typedef Eina_Bool (*ClipConverter)(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
678 typedef int (*ClipResponseHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
679 typedef int (*ClipNotifyHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
685 _ATOM_LISTING_ATOMS = _ATOM_ATOM,
699 _ATOM_TEXT_HTML_UTF8,
704 _ATOM_TEXT_PLAIN_UTF8,
713 ClipConverter convert;
714 ClipResponseHandler response;
715 ClipNotifyHandler notify;
719 Eina_Bool ClearClip(void* pData __UNUSED__, int type, void* pEvent);
720 Eina_Bool NotifyClip(void* pData __UNUSED__, int type, void* pEvent);
722 Eina_Bool ConvertClipIntoTarget(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
723 Eina_Bool ConvertClipIntoText(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
724 Eina_Bool ConvertClipIntoHtml(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
725 Eina_Bool ConvertClipIntoEdje(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
726 Eina_Bool ConvertClipIntoUri(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
727 Eina_Bool ConvertClipIntoImage(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
728 Eina_Bool ConvertClipIntoVCard(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize);
730 int NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
731 int NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
732 int NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
733 int NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
734 int NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
735 int NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
737 int RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify);
739 _Atom __atomList[_ATOM_MAX];
740 _Clip __clipList[_CLIP_TYPE_MAX];
743 ClearClip(void* pData __UNUSED__, int type __UNUSED__, void* pEvent)
745 SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
747 Ecore_X_Event_Selection_Clear* pE = (Ecore_X_Event_Selection_Clear*) pEvent;
748 Ecore_X_Window window = pE->win;
750 _ClipType clipType = _CLIP_TYPE_SECONDARY;
751 __clipList[clipType].requestedFormat = (_ClipFormat)(_CLIP_FORMAT_TEXT|_CLIP_FORMAT_IMAGE);
753 ecore_x_selection_secondary_request(window, ECORE_X_SELECTION_TARGET_TARGETS);
755 return ECORE_CALLBACK_PASS_ON;
759 ConvertClipIntoTarget(char* pTarget __UNUSED__, void* pData, int size__UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize)
764 SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
765 SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
766 SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
767 SysTryReturn(NID_UI, pType, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
768 SysTryReturn(NID_UI, pTypeSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
770 int index = *((int*) pData);
771 SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
774 for (int i = 0; i < _ATOM_MAX; i++)
776 if (__clipList[index].format & __atomList[i].formats)
780 // Make the atom list to be possible to return data.
781 Ecore_X_Atom* pAtoms = null;
784 pAtoms = (Ecore_X_Atom*) malloc(sizeof(Ecore_X_Atom) * count);
785 SysTryReturn(NID_UI, pAtoms, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
787 for (int i = 0, count = 0; i < _ATOM_MAX; i++)
789 if (__clipList[index].format & __atomList[i].formats)
790 pAtoms[count++] = __atomList[i].atom;
797 *pType = ECORE_X_ATOM_ATOM;
804 ConvertClipIntoText(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
806 SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
807 SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
808 SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
810 int index = *((int*) pData);
811 SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
812 SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
814 if (__clipList[index].format & _CLIP_FORMAT_TEXT)
816 *outData = strdup(__clipList[index].pBuffer);
817 *outSize = strlen(__clipList[index].pBuffer);
824 ConvertClipIntoHtml(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
826 SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
827 SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
828 SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
830 int index = *((int*) pData);
831 SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
832 SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
834 if (__clipList[index].format & _CLIP_FORMAT_HTML)
836 *outData = strdup(__clipList[index].pBuffer);
837 *outSize = strlen(__clipList[index].pBuffer);
844 ConvertClipIntoEdje(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
850 ConvertClipIntoUri(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
852 SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
853 SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
854 SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
856 int index = *((int*) pData);
857 SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
858 SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
860 if (__clipList[index].format & _CLIP_FORMAT_IMAGE)
862 *outData = strdup(__clipList[index].pBuffer);
863 *outSize = strlen(__clipList[index].pBuffer);
870 ConvertClipIntoImage(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
876 ConvertClipIntoVCard(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__)
882 RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
888 OnClipboardClosed(void* pData __UNUSED__, int type, void* pEvent)
890 SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
892 _Clipboard* pClipboard = _Clipboard::GetInstance();
895 bool visible = pClipboard->IsPopupVisible();
899 pClipboard->FireEvent(0, null);
903 return ECORE_CALLBACK_PASS_ON;
907 NotifyClip(void* pData __UNUSED__, int type, void* pEvent)
909 SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
911 Ecore_X_Event_Selection_Notify* pE = (Ecore_X_Event_Selection_Notify*) pEvent;
914 for (i = 0; i < _CLIP_TYPE_MAX; i++)
916 if (__clipList[i].selection == pE->selection)
922 SysTryReturn(NID_UI, i < _CLIP_TYPE_MAX, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
924 _Clip* pClip = __clipList + i;
925 for (i = 0; i < _ATOM_MAX; i++)
927 if (!strcmp(pE->target, __atomList[i].pName))
929 if (__atomList[i].notify)
931 __atomList[i].notify(pClip, pE);
936 return ECORE_CALLBACK_PASS_ON;
940 NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
942 SysTryReturn(NID_UI, pClip, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
943 SysTryReturn(NID_UI, pNotify, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
945 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
946 SysTryReturn(NID_UI, pEcoreEvas, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
948 _ControlManager* pControlManager = _ControlManager::GetInstance();
949 SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
951 _Window* pWindow = pControlManager->GetClipboardOwner();
952 SysTryReturn(NID_UI, pWindow, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
954 _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
955 SysTryReturn(NID_UI, pRootVE, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
957 _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
958 SysTryReturn(NID_UI, pLayer, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
960 Ecore_Evas* pEE = pLayer->GetEcoreEvas();
961 Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEE);
963 Ecore_X_Atom dataType = 0;
964 char* pBuffer = null;
965 if (pEcoreEvas->GetSelectedCbhmItem(&dataType, &pBuffer))
969 const char* pHtmlAtomName = "text/html;charset=utf-8";
970 Ecore_X_Atom htmlType = ecore_x_atom_get(pHtmlAtomName);
972 if (dataType == htmlType)
974 pClip->request(window, pHtmlAtomName);
975 return ECORE_CALLBACK_PASS_ON;
979 Ecore_X_Selection_Data_Targets* pTargets = (Ecore_X_Selection_Data_Targets*) (pNotify->data);
980 Ecore_X_Atom* pAtomList = (Ecore_X_Atom*) (pTargets->data.data);
983 for (j = (_ATOM_LISTING_ATOMS+1); j < _ATOM_MAX; j++)
985 SysLog(NID_UI, "[Clipboard] __atomList[%d].atom = %d", j, __atomList[j].atom);
987 if (!(__atomList[j].formats & pClip->requestedFormat))
992 for (i = 0; i < pTargets->data.length; i++)
994 SysLog(NID_UI, "[Clipboard] pAtomList[%d] = %d", i, pAtomList[i]);
996 if ((__atomList[j].atom == pAtomList[i]) && (__atomList[j].notify))
998 if ((j == _ATOM_XELM) && (!(pClip->requestedFormat & _CLIP_FORMAT_MARKUP)))
1003 SysLog(NID_UI, "[Clipboard] go to __atomList[%d].atom = %d", j, __atomList[j].atom);
1009 return ECORE_CALLBACK_PASS_ON;
1012 pClip->request(window, __atomList[j].pName);
1013 return ECORE_CALLBACK_PASS_ON;
1017 NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1019 SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1020 SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1022 Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1023 SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1025 pClip->bufferLength = (int) pData->length;
1027 char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1030 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1031 pStr[pClip->bufferLength] = '\0';
1035 SysLog(NID_UI, "[Clipboard] pStr is null.");
1039 pClip->pRetrievedBuffer = pStr;
1041 _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer);
1047 NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1049 SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1050 SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1052 Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1053 SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1055 pClip->bufferLength = (int) pData->length;
1057 char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1060 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1061 pStr[pClip->bufferLength] = '\0';
1065 SysLog(NID_UI, "[Clipboard] pStr is null.");
1069 pClip->pRetrievedBuffer = pStr;
1071 _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer);
1077 NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1079 SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1080 SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1082 Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1083 SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1085 pClip->bufferLength = (int) pData->length;
1087 char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1090 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1091 pStr[pClip->bufferLength] = '\0';
1095 SysLog(NID_UI, "[Clipboard] pStr is null.");
1099 pClip->pRetrievedBuffer = pStr;
1101 _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer);
1107 NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1109 SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1110 SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1112 Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1113 SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1115 pClip->bufferLength = (int) pData->length;
1117 char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1120 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1121 pStr[pClip->bufferLength] = '\0';
1125 SysLog(NID_UI, "[Clipboard] pStr is null.");
1129 pClip->pRetrievedBuffer = pStr;
1131 _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer);
1137 NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify)
1139 SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1140 SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1142 Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data;
1143 SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1145 pClip->bufferLength = (int) pData->length;
1147 char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1));
1150 strncpy(pStr, (char*)pData->data, pClip->bufferLength);
1151 pStr[pClip->bufferLength] = '\0';
1155 SysLog(NID_UI, "[Clipboard] pStr is null.");
1159 pClip->pRetrievedBuffer = pStr;
1161 _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_HTML, pClip->pRetrievedBuffer);
1167 namespace Tizen { namespace Ui
1171 _EcoreEvas::CreateInstanceN(void)
1173 _EcoreEvas* pEcoreEvas = new (std::nothrow) _EcoreEvas;
1174 SysTryReturn(NID_UI, pEcoreEvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1176 result r = GetLastResult();
1177 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1179 SetLastResult(E_SUCCESS);
1188 _EcoreEvas::_EcoreEvas(void)
1189 : __pWindowVisibilityChanged(null)
1190 , __pWindowPropertyChanged(null)
1191 , __pWindowShown(null)
1192 , __pWindowConfigured(null)
1193 , __pClientMessageReceived(null)
1194 , __pClearClip(null)
1195 , __pNotifyClip(null)
1196 , __pClipboardClosed(null)
1198 , __pForegroundWindow(null)
1200 , __changeBounds(true)
1201 , __openClipboard(false)
1203 int ret = appcore_unset_rotation_cb();
1204 SysLog(NID_UI, "[Window Manager Rotation] appcore_unset_rotation_cb = %d", ret);
1206 __pWindowVisibilityChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, OnWindowVisibilityChanged, (void*) this);
1207 SysTryReturnVoidResult(NID_UI, __pWindowVisibilityChanged, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1209 __pClientMessageReceived = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnClientMessageReceived, NULL);
1211 ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_CONFIGURE);
1212 ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
1216 GetEcoreEvasMgr()->SetEcoreEvas(*this);
1219 //ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, OnAutoRotationChanged, NULL);
1220 //SysTryCatch(NID_UI, ret == 0, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1222 result r = InitializeAtomList();
1223 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1225 __pWindowShown = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, OnWindowShown, (void*) this);
1226 SysTryCatch(NID_UI, __pWindowShown, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1228 __pWindowConfigured = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, OnWindowConfigured, NULL);
1229 SysTryCatch(NID_UI, __pWindowConfigured, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1231 __pWindowPropertyChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnWindowPropertyChanged, NULL);
1232 SysTryCatch(NID_UI, __pWindowPropertyChanged, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1234 SetLastResult(E_SUCCESS);
1239 if (__pWindowVisibilityChanged)
1241 ecore_event_handler_del(__pWindowVisibilityChanged);
1242 __pWindowVisibilityChanged = null;
1247 ecore_event_handler_del(__pWindowShown);
1248 __pWindowShown = null;
1251 if (__pWindowConfigured)
1253 ecore_event_handler_del(__pWindowConfigured);
1254 __pWindowConfigured = null;
1258 _EcoreEvas::~_EcoreEvas(void)
1260 if (__pWindowVisibilityChanged)
1262 ecore_event_handler_del(__pWindowVisibilityChanged);
1263 __pWindowVisibilityChanged = null;
1268 ecore_event_handler_del(__pWindowShown);
1269 __pWindowShown = null;
1272 if (__pWindowConfigured)
1274 ecore_event_handler_del(__pWindowConfigured);
1275 __pWindowConfigured = null;
1278 if (__pClientMessageReceived)
1280 ecore_event_handler_del(__pClientMessageReceived);
1281 __pClientMessageReceived = null;
1284 for (int i = 0; i < _ATOM_MAX; i++)
1286 if (__atomList[i].atom)
1288 ecore_x_selection_converter_atom_del(__atomList[i].atom);
1294 ecore_event_handler_del(__pClearClip);
1295 __pClearClip = null;
1300 ecore_event_handler_del(__pNotifyClip);
1301 __pNotifyClip = null;
1304 if (__pClipboardClosed)
1306 ecore_event_handler_del(__pClipboardClosed);
1307 __pClipboardClosed = null;
1310 if (__pWindowPropertyChanged)
1312 ecore_event_handler_del(__pWindowPropertyChanged);
1313 __pWindowPropertyChanged = null;
1316 //runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED);
1320 _EcoreEvas::RotateWindow(const _Window& window, int orientation, bool rotateEvas)
1322 // Set window bounds according to the rotation
1325 _EflLayer* pLayer = GetEflLayer(window);
1331 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1334 int curOrientation = ecore_evas_rotation_get(pEcoreEvas);
1335 if (curOrientation == orientation)
1341 bool rotatePartial = true;
1343 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Window*>(&window));
1346 FrameShowMode showMode = pFrame->GetShowMode(false);
1347 if (showMode == FRAME_SHOW_MODE_FULL_SCREEN)
1349 rotatePartial = false;
1353 _Window* pWindow = const_cast<_Window*>(&window);
1354 if (pWindow->IsLayoutChangable() == true)
1356 rotatePartial = false;
1359 Evas_Object* pWinObj = pLayer->GetElmWin();
1360 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1364 ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
1366 if (rotatePartial == false)
1368 if (rotateEvas == true)
1370 ecore_evas_rotation_with_resize_set(pEcoreEvas, orientation);
1372 evas_object_move(pWinObj, 0, 0);
1374 if ((orientation == 0) || (orientation == 180))
1376 evas_object_resize(pWinObj, rootW, rootH);
1380 evas_object_resize(pWinObj, rootH, rootW);
1383 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, FULL SCREEN] Rotate bounds(rot = %d).", win, orientation);
1388 if (rotateEvas == true)
1390 ecore_evas_rotation_set(pEcoreEvas, orientation);
1393 Rectangle winBounds = _CoordinateSystemUtils::Transform(window.GetBounds());
1394 int rotate = ecore_evas_rotation_get(pEcoreEvas);
1397 int winX = winBounds.x;
1398 int winY = winBounds.y;
1403 winX = rootW - winBounds.y - winBounds.height;
1408 winY = rootH - winBounds.x - winBounds.width;
1411 winX = rootW - winBounds.x - winBounds.width;
1412 winY = rootH - winBounds.y - winBounds.height;
1422 Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
1424 evas_object_move(pWinObj, winX, winY);
1426 if (ret == EINA_FALSE)
1428 evas_object_resize(pWinObj, winBounds.width, winBounds.height);
1429 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, PARTIAL SCREEN] Rotate bounds(rot = %d, %d, %d, %d, %d).", win, orientation, winX, winY, winBounds.width, winBounds.height);
1433 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, PARTIAL SCREEN] Rotate bounds(rot = %d, %d, %d) ONLY MOVE.", win, orientation, winX, winY);
1439 _EcoreEvas::GetEflLayer(const _Window& window) const
1441 _RootVisualElement* pRootVisualElement = null;
1443 pRootVisualElement = window.GetRootVisualElement();
1444 if (!pRootVisualElement)
1446 SysLog(NID_UI, "The root visual element is null.");
1450 _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer());
1453 SysLog(NID_UI, "The efl layer is null.");
1461 _EcoreEvas::GetFloatingMode(void) const
1463 SysTryReturn(NID_UI, __pForegroundWindow, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1465 Eina_Bool ret = elm_win_floating_mode_get(__pForegroundWindow);
1467 SetLastResult(E_SUCCESS);
1469 return (ret ? true : false);
1472 // [ToDo] Remove API
1474 _EcoreEvas::GetFloatingMode(const _Window& window) const
1476 _EflLayer* pLayer = GetEflLayer(window);
1477 SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1479 Evas_Object* pWinObj = pLayer->GetElmWin();
1480 SysTryReturn(NID_UI, pWinObj, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1482 Eina_Bool ret = elm_win_floating_mode_get(pWinObj);
1484 SetLastResult(E_SUCCESS);
1486 return (ret ? true : false);
1489 // [ToDo] Remove API
1491 _EcoreEvas::AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1495 // [ToDo] Remove API
1497 _EcoreEvas::RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
1502 _EcoreEvas::GetActiveWindow(void)
1504 Ecore_X_Window* pRoots = null;
1505 Ecore_X_Window activeWin = 0;
1508 pRoots = ecore_x_window_root_list(&num);
1511 Ecore_X_Atom activeAtom = ecore_x_atom_get("_NET_ACTIVE_WINDOW");
1512 int ret = ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1);
1526 _EcoreEvas::GetProcessId(unsigned int window)
1529 Eina_Bool ret = ecore_x_netwm_pid_get(window, &pid);
1531 if (ret != EINA_TRUE)
1540 _EcoreEvas::SetOwner(NativeWindowHandle ownee, NativeWindowHandle owner)
1542 Ecore_X_Window win = ecore_x_icccm_transient_for_get(ownee);
1545 ecore_x_icccm_transient_for_unset(ownee);
1546 ecore_x_icccm_transient_for_set(ownee, owner);
1547 SysLog(NID_UI, "[Window Order Group][Window : 0x%x] transient_for_set -> 0x%x", ownee, owner);
1552 _EcoreEvas::ActivateWindow(const _Window& window)
1554 _EflLayer* pLayer = GetEflLayer(window);
1555 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1557 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1558 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1560 ecore_evas_activate(pEcoreEvas);
1562 NativeWindowHandle currentWindow = window.GetNativeHandle();
1563 unsigned int activeWindow = GetActiveWindow();
1564 int pid = GetProcessId(activeWindow);
1565 SysLog(NID_UI, "currentWindow = 0x%x, activeWindow = 0x%x, pid = %d", currentWindow, activeWindow, pid);
1567 SetLastResult(E_SUCCESS);
1571 _EcoreEvas::MinimizeWindow(_Window& window)
1573 _EflLayer* pLayer = GetEflLayer(window);
1574 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1576 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1577 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1579 //ecore_evas_lower(pEcoreEvas);
1580 ecore_evas_iconified_set(pEcoreEvas, EINA_TRUE);
1582 SetLastResult(E_SUCCESS);
1586 _EcoreEvas::SetRenderBackend(_RenderBackend backend)
1590 case _RENDER_BACKEND_SW:
1591 elm_config_preferred_engine_set("software_x11");
1593 case _RENDER_BACKEND_GL:
1594 elm_config_preferred_engine_set("opengl_x11");
1596 case _RENDER_BACKEND_DEFAULT:
1599 elm_config_preferred_engine_set(NULL);
1605 _EcoreEvas::GetRenderBackend(void)
1607 _RenderBackend backend = _RENDER_BACKEND_DEFAULT;
1609 const char* pEngine = elm_config_preferred_engine_get();
1611 if (pEngine == NULL)
1613 backend = _RENDER_BACKEND_DEFAULT;
1615 else if (strcmp(pEngine, "software_x11") == 0)
1617 backend = _RENDER_BACKEND_SW;
1619 else if (strcmp(pEngine, "opengl_x11") == 0)
1621 backend = _RENDER_BACKEND_GL;
1628 _EcoreEvas::CopyClip(_ClipFormat format, const char* pChar)
1630 SysTryReturn(NID_UI, IsValidClipFormat(format), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid.");
1631 SysTryReturn(NID_UI, pChar, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid.");
1633 Ecore_X_Atom dataType = 0;
1637 case _CLIP_FORMAT_TEXT:
1638 dataType = ecore_x_atom_get("UTF8_STRING");
1640 case _CLIP_FORMAT_IMAGE:
1641 dataType = ecore_x_atom_get("text/uri");
1643 case _CLIP_FORMAT_HTML:
1644 dataType = ecore_x_atom_get("text/html;charset=utf-8");
1650 _ControlManager* pControlManager = _ControlManager::GetInstance();
1652 _Window* pWindow = pControlManager->GetClipboardOwner();
1658 _EflLayer* pLayer = GetEflLayer(*pWindow);
1664 Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1667 SetCbhmItem(window, dataType, (char*)pChar);
1673 _EcoreEvas::RetrieveClipN(int index, int* format, char** pData)
1675 Ecore_X_Atom dataType = 0;
1677 _ControlManager* pControlManager = _ControlManager::GetInstance();
1679 _Window* pWindow = pControlManager->GetClipboardOwner();
1685 _EflLayer* pLayer = GetEflLayer(*pWindow);
1691 GetCbhmItem(index, &dataType, pData);
1693 if ((dataType == ecore_x_atom_get("UTF8_STRING"))
1694 ||(dataType == ecore_x_atom_get("application/x-elementary-markup")))
1696 *format = _CLIP_FORMAT_TEXT;
1698 else if (dataType == ecore_x_atom_get("text/uri"))
1700 *format = _CLIP_FORMAT_IMAGE;
1702 else if (dataType == ecore_x_atom_get("text/html;charset=utf-8"))
1704 *format = _CLIP_FORMAT_HTML;
1712 // Convert markup to utf8.
1713 if (dataType == ecore_x_atom_get("application/x-elementary-markup"))
1715 char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, *pData);
1716 SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", *pData, pTempChar);
1726 _EcoreEvas::GetClipCount(void) const
1728 _ControlManager* pControlManager = _ControlManager::GetInstance();
1730 _Window* pWindow = pControlManager->GetClipboardOwner();
1736 _EflLayer* pLayer = GetEflLayer(*pWindow);
1742 int count = GetCbhmItemCount();
1748 _EcoreEvas::OpenClipboard(unsigned long clipFormats)
1750 _ControlManager* pControlManager = _ControlManager::GetInstance();
1752 _Window* pWindow = pControlManager->GetClipboardOwner();
1758 _EflLayer* pLayer = GetEflLayer(*pWindow);
1764 Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1767 ecore_x_selection_secondary_set(window, "", 1);
1769 if (_CLIP_FORMAT_IMAGE & clipFormats)
1771 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW_ALL);
1775 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW);
1778 __openClipboard = true;
1782 _EcoreEvas::CloseClipboard(void)
1784 _ControlManager* pControlManager = _ControlManager::GetInstance();
1786 _Window* pWindow = pControlManager->GetClipboardOwner();
1792 _EflLayer* pLayer = GetEflLayer(*pWindow);
1798 Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
1801 __openClipboard = false;
1802 SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_HIDE);
1806 _EcoreEvas::IsClipboardOpened(void)
1808 return __openClipboard;
1812 _EcoreEvas::ConvertMarkupToUtf8(const String& string)
1814 char* pChar = _Clipboard::GetInstance()->EncodeToCharN(string);
1820 char* pTempChar = evas_textblock_text_markup_to_utf8(NULL, pChar);
1821 SysLog(NID_UI, "[Clipboard] markup[%s] -> utf8[%s]", pChar, pTempChar);
1824 String str(pTempChar);
1831 _EcoreEvas::SetEventPropagation(const _Control& control, bool enable)
1833 _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1834 SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1836 Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1837 SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1839 evas_object_propagate_events_set(pEvasObject, (enable ? EINA_TRUE : EINA_FALSE));
1845 _EcoreEvas::SetFocus(const _Control& control, bool focus)
1847 _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode());
1848 SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1850 Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer();
1851 SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1853 evas_object_focus_set(pEvasObject, (focus ? EINA_TRUE : EINA_FALSE));
1859 _EcoreEvas::SetIndicatorShowState(const _Window& window, bool showState)
1861 _EflLayer* pLayer = GetEflLayer(window);
1862 SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1864 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1865 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1867 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1871 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1875 ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1882 _EcoreEvas::GetIndicatorShowState(const _Window& window) const
1884 _EflLayer* pLayer = GetEflLayer(window);
1885 SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1887 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1888 SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1890 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1891 Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(win);
1893 bool showState = true;
1894 if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON)
1898 else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF)
1906 // [ToDo] Remove API
1908 _EcoreEvas::GetIndicatorBounds(const _Window& window) const
1910 _EflLayer* pLayer = GetEflLayer(window);
1911 SysTryReturn(NID_UI, pLayer, Rectangle(0, 0, 0, 0), E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1913 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1914 SysTryReturn(NID_UI, pEcoreEvas, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1916 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1917 Ecore_X_Window rootWin = (Ecore_X_Window) ecore_x_window_root_get(win);
1925 ret = ecore_x_e_illume_indicator_geometry_get(rootWin, &x, &y, &width, &height);
1926 SysTryReturn(NID_UI, ret == true, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1928 SetLastResult(E_SUCCESS);
1930 return Rectangle(x, y, width, height);
1933 // [ToDo] Remove API
1935 _EcoreEvas::SetIndicatorOpacity(const _Window& window, _IndicatorOpacity opacity)
1937 _EflLayer* pLayer = GetEflLayer(window);
1938 SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1940 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1941 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1943 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1945 Ecore_X_Illume_Indicator_Opacity_Mode mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1948 case _INDICATOR_OPACITY_UNKNOWN:
1949 mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN;
1951 case _INDICATOR_OPACITY_OPAQUE:
1952 mode = ECORE_X_ILLUME_INDICATOR_OPAQUE;
1954 case _INDICATOR_OPACITY_TRANSLUCENT:
1955 mode = ECORE_X_ILLUME_INDICATOR_TRANSLUCENT;
1957 case _INDICATOR_OPACITY_TRANSPARENT:
1958 mode = ECORE_X_ILLUME_INDICATOR_TRANSPARENT;
1961 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid.");
1962 return E_INVALID_ARG;
1965 ecore_x_e_illume_indicator_opacity_set(win, mode);
1970 // [ToDo] Remove API
1972 _EcoreEvas::GetIndicatorOpacity(const _Window& window) const
1974 _EflLayer* pLayer = GetEflLayer(window);
1975 SysTryReturn(NID_UI, pLayer, _INDICATOR_OPACITY_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
1977 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1978 SysTryReturn(NID_UI, pEcoreEvas, _INDICATOR_OPACITY_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1980 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
1981 Ecore_X_Illume_Indicator_Opacity_Mode mode = ecore_x_e_illume_indicator_opacity_get(win);
1983 _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN;
1986 case ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN:
1987 opacity = _INDICATOR_OPACITY_UNKNOWN;
1989 case ECORE_X_ILLUME_INDICATOR_OPAQUE:
1990 opacity = _INDICATOR_OPACITY_OPAQUE;
1992 case ECORE_X_ILLUME_INDICATOR_TRANSLUCENT:
1993 opacity = _INDICATOR_OPACITY_TRANSLUCENT;
1995 case ECORE_X_ILLUME_INDICATOR_TRANSPARENT:
1996 opacity = _INDICATOR_OPACITY_TRANSPARENT;
1999 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2000 return _INDICATOR_OPACITY_UNKNOWN;
2003 SetLastResult(E_SUCCESS);
2009 _EcoreEvas::SetWindowActivationEnabled(const _Window& window, bool enable)
2011 _EflLayer* pLayer = GetEflLayer(window);
2012 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2014 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2015 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2017 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2019 Eina_Bool acceptsFocus;
2020 Ecore_X_Window_State_Hint initialState;
2021 Ecore_X_Pixmap iconPixmap;
2022 Ecore_X_Pixmap iconMask;
2023 Ecore_X_Window iconWindow;
2024 Ecore_X_Window windowGroup;
2027 ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2028 ecore_x_icccm_hints_set(win, (enable ? EINA_TRUE : EINA_FALSE), initialState, iconPixmap, iconMask, iconWindow, windowGroup, isUrgent);
2032 _EcoreEvas::IsWindowActivationEnabled(const _Window& window)
2034 _EflLayer* pLayer = GetEflLayer(window);
2035 SysTryReturn(NID_UI, pLayer, true, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2037 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2038 SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2040 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2042 Eina_Bool acceptsFocus;
2043 Ecore_X_Window_State_Hint initialState;
2044 Ecore_X_Pixmap iconPixmap;
2045 Ecore_X_Pixmap iconMask;
2046 Ecore_X_Window iconWindow;
2047 Ecore_X_Window windowGroup;
2050 ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent);
2052 return (acceptsFocus ? true : false);
2056 _EcoreEvas::SetWindowName(const _Window& window, const Tizen::Base::String& name)
2058 _EflLayer* pLayer = GetEflLayer(window);
2059 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2061 Evas_Object* pWinObj = pLayer->GetElmWin();
2062 SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2064 const char* windowName = _StringConverter::CopyToCharArrayN(name);
2067 elm_win_title_set(pWinObj, windowName);
2069 delete[] windowName;
2074 _EcoreEvas::SetWindowType(const _Window& window, int winType)
2076 _EflLayer* pLayer = GetEflLayer(window);
2077 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2079 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2080 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2082 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2084 if (winType == _WINDOW_TYPE_SUB)
2086 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_UTILITY);
2091 _EcoreEvas::SetFloatingMode(const _Window& window, bool enable)
2093 _EflLayer* pLayer = GetEflLayer(window);
2094 SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2096 Evas_Object* pWinObj = pLayer->GetElmWin();
2097 SysTryReturn(NID_UI, pWinObj, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2099 elm_win_floating_mode_set(pWinObj, (enable ? EINA_TRUE : EINA_FALSE));
2104 // [ToDo] Remove API
2106 _EcoreEvas::GetEvas(void) const
2108 SysLog(NID_UI, "Do not use.");
2109 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2115 _EflLayer* pLayer = GetEflLayer(*pWindow);
2121 return pLayer->GetEvas();
2124 // [ToDo] Remove API
2126 _EcoreEvas::GetEcoreEvas(void) const
2128 SysLog(NID_UI, "Do not use.");
2129 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2135 _EflLayer* pLayer = GetEflLayer(*pWindow);
2141 return pLayer->GetEcoreEvas();
2144 // [ToDo] Remove API
2146 _EcoreEvas::GetWindowObject(void) const
2148 SysLog(NID_UI, "Do not use.");
2149 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2155 _EflLayer* pLayer = GetEflLayer(*pWindow);
2161 return pLayer->GetElmWin();
2164 // [ToDo] Remove API
2166 _EcoreEvas::GetXWindow(void) const
2168 SysLog(NID_UI, "Do not use.");
2169 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
2175 _EflLayer* pLayer = GetEflLayer(*pWindow);
2181 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2187 _EcoreEvas::AllowSetWindowBounds(bool allow)
2189 __changeBounds = allow;
2193 _EcoreEvas::IsWindowVisible(const _Window& window)
2195 _EflLayer* pLayer = GetEflLayer(window);
2196 SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2198 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2199 SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2201 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2203 int ret = ecore_x_window_visible_get(win);
2214 // [ToDo] Remove API
2216 _EcoreEvas::SetQuickPanelScrollEnabled(const _Window& window, bool enable)
2219 _EflLayer* pLayer = GetEflLayer(window);
2220 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2222 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2223 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2225 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2226 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2228 unsigned int val[3];
2229 ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2240 ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
2244 // [ToDo] Remove API
2246 _EcoreEvas::IsQuickPanelScrollEnabled(const _Window& window)
2249 _EflLayer* pLayer = GetEflLayer(window);
2250 SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2252 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2253 SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2255 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2256 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
2258 unsigned int val[3];
2259 ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
2275 _EcoreEvas::SetWindowLevel(const _Window& window, _WindowLevel level)
2277 _EflLayer* pLayer = GetEflLayer(window);
2278 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2280 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2281 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2283 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2284 ecore_x_icccm_transient_for_unset(win);
2286 if (level == _WINDOW_LEVEL_NORMAL)
2288 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
2290 else if (level == _WINDOW_LEVEL_NOTIFICATION_HIGH)
2292 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2293 utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_HIGH);
2295 else if (level == _WINDOW_LEVEL_NOTIFICATION_MIDDLE)
2297 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2298 utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_NORMAL);
2301 SetLastResult(E_SUCCESS);
2305 _EcoreEvas::GetWindowLevel(const _Window& window) const
2307 _EflLayer* pLayer = GetEflLayer(window);
2308 SysTryReturn(NID_UI, pLayer, _WINDOW_LEVEL_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2310 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2311 SysTryReturn(NID_UI, pEcoreEvas, _WINDOW_LEVEL_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2313 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2315 Ecore_X_Window_Type type = ECORE_X_WINDOW_TYPE_UNKNOWN;
2316 ecore_x_netwm_window_type_get(win, &type);
2318 _WindowLevel winLevel = _WINDOW_LEVEL_UNKNOWN;
2319 if (type == ECORE_X_WINDOW_TYPE_NORMAL)
2321 winLevel = _WINDOW_LEVEL_NORMAL;
2323 else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION)
2325 Utilx_Notification_Level notificationLevel = utilx_get_system_notification_level((Display*)ecore_x_display_get(), win);
2327 if (notificationLevel == UTILX_NOTIFICATION_LEVEL_HIGH)
2329 winLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH;
2331 else if (notificationLevel == UTILX_NOTIFICATION_LEVEL_NORMAL)
2333 winLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE;
2337 SetLastResult(E_SUCCESS);
2343 _EcoreEvas::SetWindowBounds(const _Window& window, const Rectangle& bounds)
2345 if (__changeBounds == false)
2350 _EflLayer* pLayer = GetEflLayer(window);
2351 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2353 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2354 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2356 Evas_Object* pWinObject = pLayer->GetElmWin();
2357 SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2359 Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2361 int rotate = ecore_evas_rotation_get(pEcoreEvas);
2363 // _Window* pWindow = const_cast<_Window*>(&window);
2364 // _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2365 // if (pContextMenu)
2366 if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2368 _ControlManager* pControlManager = _ControlManager::GetInstance();
2369 if (pControlManager)
2371 _Window* pCurFrame = pControlManager->GetCurrentFrame();
2374 int ownerRotate = GetWindowRotation(*pCurFrame);
2375 if (ownerRotate != rotate)
2383 int winX = winBounds.x;
2384 int winY = winBounds.y;
2388 ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2393 winX = rootW - winBounds.y - winBounds.height;
2398 winY = rootH - winBounds.x - winBounds.width;
2401 winX = rootW - winBounds.x - winBounds.width;
2402 winY = rootH - winBounds.y - winBounds.height;
2412 Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2414 evas_object_move(pWinObject, winX, winY);
2416 if (ret == EINA_FALSE)
2418 evas_object_resize(pWinObject, winBounds.width, winBounds.height);
2419 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2423 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY);
2426 SetLastResult(E_SUCCESS);
2430 _EcoreEvas::SetWindowBounds(const _Window& window, const FloatRectangle& bounds)
2432 if (__changeBounds == false)
2437 _EflLayer* pLayer = GetEflLayer(window);
2438 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2440 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
2441 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
2443 Evas_Object* pWinObject = pLayer->GetElmWin();
2444 SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2446 FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2447 Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2449 int rotate = ecore_evas_rotation_get(pEcoreEvas);
2451 // _Window* pWindow = const_cast<_Window*>(&window);
2452 // _ContextMenu* pContextMenu = dynamic_cast<_ContextMenu*>(pWindow);
2453 // if (pContextMenu)
2454 if ((window.IsOrientationRoot() == false) && (window.IsRotationSynchronized() == false))
2456 _ControlManager* pControlManager = _ControlManager::GetInstance();
2457 if (pControlManager)
2459 _Window* pCurFrame = pControlManager->GetCurrentFrame();
2462 int ownerRotate = GetWindowRotation(*pCurFrame);
2463 if (ownerRotate != rotate)
2471 int winX = winBounds.x;
2472 int winY = winBounds.y;
2476 ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
2481 winX = rootW - winBounds.y - winBounds.height;
2486 winY = rootH - winBounds.x - winBounds.width;
2489 winX = rootW - winBounds.x - winBounds.width;
2490 winY = rootH - winBounds.y - winBounds.height;
2500 Eina_Bool ret = ecore_x_e_window_rotation_geometry_get(win, rotate, &x, &y, &w, &h);
2502 evas_object_move(pWinObject, winX, winY);
2504 if (ret == EINA_FALSE)
2506 evas_object_resize(pWinObject, winBounds.width, winBounds.height);
2507 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d, %d, %d).", win, rotate, winX, winY, winBounds.width, winBounds.height);
2511 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set bounds(rot = %d, %d, %d) ONLY MOVE.", win, rotate, winX, winY);
2514 SetLastResult(E_SUCCESS);
2518 _EcoreEvas::SetWindowVisibleState(const _Window& window, bool visibleState)
2520 _EflLayer* pLayer = GetEflLayer(window);
2521 SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer.");
2523 Evas_Object* pWinObj = pLayer->GetElmWin();
2524 SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
2526 pLayer->SetShowState(visibleState);
2528 SetLastResult(E_SUCCESS);
2532 _EcoreEvas::SetOwner(const _Window& ownee, const _Control& owner)
2534 _Window* pOwnerWindow = owner.GetRootWindow();
2535 SysTryReturnVoidResult(NID_UI, pOwnerWindow, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a root window.");
2537 _EflLayer* pOwnerLayer = GetEflLayer(*pOwnerWindow);
2538 SysTryReturnVoidResult(NID_UI, pOwnerLayer, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a elf layer.");
2540 _EflLayer* pOwneeLayer = GetEflLayer(ownee);
2541 SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer.");
2543 Ecore_X_Window ownerWin = (Ecore_X_Window) ecore_evas_window_get(pOwnerLayer->GetEcoreEvas());
2544 Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas());
2546 Ecore_X_Window_Type type;
2547 ecore_x_netwm_window_type_get(owneeWin, &type);
2548 if ((type == ECORE_X_WINDOW_TYPE_NORMAL) || (type == ECORE_X_WINDOW_TYPE_UTILITY))
2550 Ecore_X_Window win = ecore_x_icccm_transient_for_get(owneeWin);
2551 if (win != ownerWin)
2553 ecore_x_icccm_transient_for_unset(owneeWin);
2554 ecore_x_icccm_transient_for_set(owneeWin, ownerWin);
2555 SysLog(NID_UI, "[Window Order Group][Window : 0x%x] transient_for_set -> 0x%x", owneeWin, ownerWin);
2560 SysLog(NID_UI, "[Window Order Group][Window : 0x%x] Skip to transient_for_set", owneeWin);
2564 // 1. IsLayoutChangable : true
2565 // 2. IsRotationSynchronized : true
2568 if ((ownee.IsLayoutChangable() == true) || (ownee.IsRotationSynchronized() == true))
2570 int* rotations = null;
2571 unsigned int count = 0;
2572 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pOwnerLayer->GetEcoreEvas(), &rotations, &count);
2578 SetWindowAvailabledRotation(ownee, rotations, count);
2583 bool preferredRoation = pOwnerWindow->GetPreferredRotation();
2584 if (preferredRoation == true)
2586 int preferredRotation = ecore_evas_wm_rotation_preferred_rotation_get(pOwnerLayer->GetEcoreEvas());
2587 SetWindowPreferredRotation(ownee, preferredRotation);
2591 SetWindowPreferredRotation(ownee, -1);
2596 int ownerRotation = GetWindowRotation(*pOwnerWindow);
2597 SetWindowPreferredRotation(ownee, ownerRotation);
2600 SetLastResult(E_SUCCESS);
2604 _EcoreEvas::GetWindowRotation(const _Window& window)
2606 _EflLayer* pLayer = GetEflLayer(window);
2612 int rotation = ecore_evas_rotation_get(pLayer->GetEcoreEvas());
2617 _EcoreEvas::SetWindowPreferredRotation(const _Window& window, int rotation, bool force)
2619 _EflLayer* pLayer = GetEflLayer(window);
2625 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2629 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2631 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set window preferred rotation(%d).", win, rotation);
2632 ecore_evas_wm_rotation_preferred_rotation_set(pLayer->GetEcoreEvas(), rotation);
2634 _Window* pWindow = const_cast<_Window*>(&window);
2639 pWindow->SetPreferredRotation(false);
2643 pWindow->SetPreferredRotation(true);
2649 _EcoreEvas::SetWindowAvailabledRotation(const _Window& window, int* rotations, unsigned int count, bool force)
2651 _EflLayer* pLayer = GetEflLayer(window);
2657 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2659 // Skip available_set if there is not change
2662 int* prevRotations = null;
2663 unsigned int prevCount = 0;
2664 Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pLayer->GetEcoreEvas(), &prevRotations, &prevCount);
2665 free(prevRotations);
2669 if (prevCount == count)
2677 ecore_x_e_window_rotation_app_set(win, EINA_TRUE);
2680 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set window available rotation(%d).", win, count);
2681 ecore_evas_wm_rotation_available_rotations_set(pLayer->GetEcoreEvas(), rotations, count);
2685 _EcoreEvas::RegisterWindowStateCallback(const _Window& window)
2687 _EflLayer* pLayer = GetEflLayer(window);
2693 ecore_evas_callback_state_change_set(pLayer->GetEcoreEvas(), OnWindowStateChanged);
2697 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::Rectangle& bounds)
2699 _EflLayer* pLayer = GetEflLayer(window);
2705 Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds);
2707 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2708 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set rotation bounds(rot = %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2709 ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2713 _EcoreEvas::SetWindowRotationBounds(const _Window& window, int rotation, const Tizen::Graphics::FloatRectangle& bounds)
2715 _EflLayer* pLayer = GetEflLayer(window);
2721 FloatRectangle winBoundsF = _CoordinateSystemUtils::Transform(bounds);
2722 Rectangle winBounds = _CoordinateSystemUtils::ConvertToInteger(winBoundsF);
2724 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
2725 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x] Set rotation bounds(rot = %d, %d, %d, %d, %d).", win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2726 ecore_x_e_window_rotation_geometry_set(win, rotation, winBounds.x, winBounds.y, winBounds.width, winBounds.height);
2729 // [ToDo] Remove API
2731 _EcoreEvas::GetFrame(void) const
2733 SysLog(NID_UI, "Do not use.");
2737 // [ToDo] Remove API
2739 _EcoreEvas::GetRootVisualElement(void)const
2741 SysLog(NID_UI, "Do not use.");
2745 // [ToDo] Remove API
2747 _EcoreEvas::SetFrame(const _Control& control)
2749 SysLog(NID_UI, "Do not use.");
2750 __pFrame = const_cast<_Control*>(&control);
2754 _EcoreEvas::GetSelectedCbhmItem(Ecore_X_Atom* pDataType, char** pBuffer) const
2756 Ecore_X_Window cbhmWin = GetCbhmWindow();
2757 Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_SELECTED_ITEM);
2758 Ecore_X_Atom atomItemType = 0;
2760 char* pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
2763 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
2764 if (atomItemType == x_atom_cbhm_error)
2781 *pDataType = atomItemType;
2791 _EcoreEvas::IsAccessibilityScreenReaderActivated(void)
2793 Eina_Bool acc = elm_config_access_get();
2797 void* _GetEcoreEvasHandle(void)
2799 _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2800 if (pEcoreEvasMgr == null)
2805 _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2806 if (pUiEcoreEvas == null)
2811 return (void*)pUiEcoreEvas->GetEcoreEvas();
2814 void* _GetEvasHandle(void)
2816 _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
2817 if (pEcoreEvasMgr == null)
2822 _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
2823 if (pUiEcoreEvas == null)
2828 return (void*)pUiEcoreEvas->GetEvas();
2832 _EcoreEvas::InitializeAtomList(void)
2834 __atomList[_ATOM_TARGETS].pName = "TARGETS";
2835 __atomList[_ATOM_TARGETS].formats = _CLIP_FORMAT_TARGETS;
2836 __atomList[_ATOM_TARGETS].convert = ConvertClipIntoTarget;
2837 __atomList[_ATOM_TARGETS].response = RequestClip;
2838 __atomList[_ATOM_TARGETS].notify = NotifyTarget;
2839 __atomList[_ATOM_TARGETS].atom = 0;
2841 __atomList[_ATOM_ATOM].pName = "ATOM";
2842 __atomList[_ATOM_ATOM].formats = _CLIP_FORMAT_TARGETS;
2843 __atomList[_ATOM_ATOM].convert = ConvertClipIntoTarget;
2844 __atomList[_ATOM_ATOM].response = RequestClip;
2845 __atomList[_ATOM_ATOM].notify = NotifyTarget;
2846 __atomList[_ATOM_ATOM].atom = 0;
2848 __atomList[_ATOM_XELM].pName = "application/x-elementary-markup";
2849 __atomList[_ATOM_XELM].formats = _CLIP_FORMAT_MARKUP;
2850 __atomList[_ATOM_XELM].convert = ConvertClipIntoEdje;
2851 __atomList[_ATOM_XELM].response = null;
2852 __atomList[_ATOM_XELM].notify = NotifyEdje;
2853 __atomList[_ATOM_XELM].atom = 0;
2855 __atomList[_ATOM_TEXT_URI].pName = "text/uri";
2856 __atomList[_ATOM_TEXT_URI].formats = _CLIP_FORMAT_IMAGE;
2857 __atomList[_ATOM_TEXT_URI].convert = ConvertClipIntoUri;
2858 __atomList[_ATOM_TEXT_URI].response = null;
2859 __atomList[_ATOM_TEXT_URI].notify = NotifyUri;
2860 __atomList[_ATOM_TEXT_URI].atom = 0;
2862 __atomList[_ATOM_TEXT_URILIST].pName = "text/uri-list";
2863 __atomList[_ATOM_TEXT_URILIST].formats = _CLIP_FORMAT_IMAGE;
2864 __atomList[_ATOM_TEXT_URILIST].convert = ConvertClipIntoUri;
2865 __atomList[_ATOM_TEXT_URILIST].response = null;
2866 __atomList[_ATOM_TEXT_URILIST].notify = NotifyUri;
2867 __atomList[_ATOM_TEXT_URILIST].atom = 0;
2869 __atomList[_ATOM_TEXT_X_VCARD].pName = "text/x-vcard";
2870 __atomList[_ATOM_TEXT_X_VCARD].formats = _CLIP_FORMAT_VCARD;
2871 __atomList[_ATOM_TEXT_X_VCARD].convert = null;
2872 __atomList[_ATOM_TEXT_X_VCARD].response = null;
2873 __atomList[_ATOM_TEXT_X_VCARD].notify = null;
2874 __atomList[_ATOM_TEXT_X_VCARD].atom = 0;
2876 __atomList[_ATOM_IMAGE_PNG].pName = "image/png";
2877 __atomList[_ATOM_IMAGE_PNG].formats = _CLIP_FORMAT_IMAGE;
2878 __atomList[_ATOM_IMAGE_PNG].convert = ConvertClipIntoImage;
2879 __atomList[_ATOM_IMAGE_PNG].response = null;
2880 __atomList[_ATOM_IMAGE_PNG].notify = NotifyImage;
2881 __atomList[_ATOM_IMAGE_PNG].atom = 0;
2883 __atomList[_ATOM_IMAGE_JPEG].pName = "image/jpeg";
2884 __atomList[_ATOM_IMAGE_JPEG].formats = _CLIP_FORMAT_IMAGE;
2885 __atomList[_ATOM_IMAGE_JPEG].convert = ConvertClipIntoImage;
2886 __atomList[_ATOM_IMAGE_JPEG].response = null;
2887 __atomList[_ATOM_IMAGE_JPEG].notify = NotifyImage;
2888 __atomList[_ATOM_IMAGE_JPEG].atom = 0;
2890 __atomList[_ATOM_IMAGE_BMP].pName = "image/x-ms-bmp";
2891 __atomList[_ATOM_IMAGE_BMP].formats = _CLIP_FORMAT_IMAGE;
2892 __atomList[_ATOM_IMAGE_BMP].convert = ConvertClipIntoImage;
2893 __atomList[_ATOM_IMAGE_BMP].response = null;
2894 __atomList[_ATOM_IMAGE_BMP].notify = NotifyImage;
2895 __atomList[_ATOM_IMAGE_BMP].atom = 0;
2897 __atomList[_ATOM_IMAGE_GIF].pName = "image/gif";
2898 __atomList[_ATOM_IMAGE_GIF].formats = _CLIP_FORMAT_IMAGE;
2899 __atomList[_ATOM_IMAGE_GIF].convert = ConvertClipIntoImage;
2900 __atomList[_ATOM_IMAGE_GIF].response = null;
2901 __atomList[_ATOM_IMAGE_GIF].notify = NotifyImage;
2902 __atomList[_ATOM_IMAGE_GIF].atom = 0;
2904 __atomList[_ATOM_IMAGE_TIFF].pName = "image/tiff";
2905 __atomList[_ATOM_IMAGE_TIFF].formats = _CLIP_FORMAT_IMAGE;
2906 __atomList[_ATOM_IMAGE_TIFF].convert = ConvertClipIntoImage;
2907 __atomList[_ATOM_IMAGE_TIFF].response = null;
2908 __atomList[_ATOM_IMAGE_TIFF].notify = NotifyImage;
2909 __atomList[_ATOM_IMAGE_TIFF].atom = 0;
2911 __atomList[_ATOM_IMAGE_SVG].pName = "image/svg+xml";
2912 __atomList[_ATOM_IMAGE_SVG].formats = _CLIP_FORMAT_IMAGE;
2913 __atomList[_ATOM_IMAGE_SVG].convert = ConvertClipIntoImage;
2914 __atomList[_ATOM_IMAGE_SVG].response = null;
2915 __atomList[_ATOM_IMAGE_SVG].notify = NotifyImage;
2916 __atomList[_ATOM_IMAGE_SVG].atom = 0;
2918 __atomList[_ATOM_IMAGE_XPM].pName = "image/x-xpixmap";
2919 __atomList[_ATOM_IMAGE_XPM].formats = _CLIP_FORMAT_IMAGE;
2920 __atomList[_ATOM_IMAGE_XPM].convert = ConvertClipIntoImage;
2921 __atomList[_ATOM_IMAGE_XPM].response = null;
2922 __atomList[_ATOM_IMAGE_XPM].notify = NotifyImage;
2923 __atomList[_ATOM_IMAGE_XPM].atom = 0;
2925 __atomList[_ATOM_IMAGE_TGA].pName = "image/x-tga";
2926 __atomList[_ATOM_IMAGE_TGA].formats = _CLIP_FORMAT_IMAGE;
2927 __atomList[_ATOM_IMAGE_TGA].convert = ConvertClipIntoImage;
2928 __atomList[_ATOM_IMAGE_TGA].response = null;
2929 __atomList[_ATOM_IMAGE_TGA].notify = NotifyImage;
2930 __atomList[_ATOM_IMAGE_TGA].atom = 0;
2932 __atomList[_ATOM_IMAGE_PPM].pName = "image/x-portable-pixmap";
2933 __atomList[_ATOM_IMAGE_PPM].formats = _CLIP_FORMAT_IMAGE;
2934 __atomList[_ATOM_IMAGE_PPM].convert = ConvertClipIntoImage;
2935 __atomList[_ATOM_IMAGE_PPM].response = null;
2936 __atomList[_ATOM_IMAGE_PPM].notify = NotifyImage;
2937 __atomList[_ATOM_IMAGE_PPM].atom = 0;
2939 __atomList[_ATOM_TEXT_HTML_UTF8].pName = "text/html;charset=utf-8";
2940 __atomList[_ATOM_TEXT_HTML_UTF8].formats = _CLIP_FORMAT_HTML;
2941 __atomList[_ATOM_TEXT_HTML_UTF8].convert = ConvertClipIntoHtml;
2942 __atomList[_ATOM_TEXT_HTML_UTF8].response = null;
2943 __atomList[_ATOM_TEXT_HTML_UTF8].notify = NotifyHtml;
2944 __atomList[_ATOM_TEXT_HTML_UTF8].atom = 0;
2946 __atomList[_ATOM_TEXT_HTML].pName = "text/html";
2947 __atomList[_ATOM_TEXT_HTML].formats = _CLIP_FORMAT_HTML;
2948 __atomList[_ATOM_TEXT_HTML].convert = ConvertClipIntoHtml;
2949 __atomList[_ATOM_TEXT_HTML].response = null;
2950 __atomList[_ATOM_TEXT_HTML].notify = NotifyHtml;
2951 __atomList[_ATOM_TEXT_HTML].atom = 0;
2953 __atomList[_ATOM_STRING_UTF8].pName = "UTF8_STRING";
2954 __atomList[_ATOM_STRING_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2955 __atomList[_ATOM_STRING_UTF8].convert = ConvertClipIntoText;
2956 __atomList[_ATOM_STRING_UTF8].response = null;
2957 __atomList[_ATOM_STRING_UTF8].notify = NotifyText;
2958 __atomList[_ATOM_STRING_UTF8].atom = 0;
2960 __atomList[_ATOM_STRING].pName = "STRING";
2961 __atomList[_ATOM_STRING].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2962 __atomList[_ATOM_STRING].convert = ConvertClipIntoText;
2963 __atomList[_ATOM_STRING].response = null;
2964 __atomList[_ATOM_STRING].notify = NotifyText;
2965 __atomList[_ATOM_STRING].atom = 0;
2967 __atomList[_ATOM_TEXT].pName = "TEXT";
2968 __atomList[_ATOM_TEXT].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2969 __atomList[_ATOM_TEXT].convert = ConvertClipIntoText;
2970 __atomList[_ATOM_TEXT].response = null;
2971 __atomList[_ATOM_TEXT].notify = null;
2972 __atomList[_ATOM_TEXT].atom = 0;
2974 __atomList[_ATOM_TEXT_PLAIN_UTF8].pName = "text/plain;charset=utf-8";
2975 __atomList[_ATOM_TEXT_PLAIN_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2976 __atomList[_ATOM_TEXT_PLAIN_UTF8].convert = ConvertClipIntoText;
2977 __atomList[_ATOM_TEXT_PLAIN_UTF8].response = null;
2978 __atomList[_ATOM_TEXT_PLAIN_UTF8].notify = null;
2979 __atomList[_ATOM_TEXT_PLAIN_UTF8].atom = 0;
2981 __atomList[_ATOM_TEXT_PLAIN].pName = "text/plain";
2982 __atomList[_ATOM_TEXT_PLAIN].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML);
2983 __atomList[_ATOM_TEXT_PLAIN].convert = ConvertClipIntoText;
2984 __atomList[_ATOM_TEXT_PLAIN].response = null;
2985 __atomList[_ATOM_TEXT_PLAIN].notify = null;
2986 __atomList[_ATOM_TEXT_PLAIN].atom = 0;
2988 __clipList[_CLIP_TYPE_PRIMARY].selection = ECORE_X_SELECTION_PRIMARY;
2989 __clipList[_CLIP_TYPE_PRIMARY].set = ecore_x_selection_primary_set;
2990 __clipList[_CLIP_TYPE_PRIMARY].clear = ecore_x_selection_primary_clear;
2991 __clipList[_CLIP_TYPE_PRIMARY].request = ecore_x_selection_primary_request;
2992 __clipList[_CLIP_TYPE_PRIMARY].active = false;
2993 __clipList[_CLIP_TYPE_PRIMARY].pBuffer = null;
2994 __clipList[_CLIP_TYPE_PRIMARY].pRetrievedBuffer = null;
2995 __clipList[_CLIP_TYPE_PRIMARY].bufferLength = 0;
2996 __clipList[_CLIP_TYPE_PRIMARY].completed = false;
2998 __clipList[_CLIP_TYPE_SECONDARY].selection = ECORE_X_SELECTION_SECONDARY;
2999 __clipList[_CLIP_TYPE_SECONDARY].set = ecore_x_selection_secondary_set;
3000 __clipList[_CLIP_TYPE_SECONDARY].clear = ecore_x_selection_secondary_clear;
3001 __clipList[_CLIP_TYPE_SECONDARY].request = ecore_x_selection_secondary_request;
3002 __clipList[_CLIP_TYPE_SECONDARY].active = false;
3003 __clipList[_CLIP_TYPE_SECONDARY].pBuffer = null;
3004 __clipList[_CLIP_TYPE_SECONDARY].pRetrievedBuffer = null;
3005 __clipList[_CLIP_TYPE_SECONDARY].bufferLength = 0;
3006 __clipList[_CLIP_TYPE_SECONDARY].completed = false;
3008 __clipList[_CLIP_TYPE_CLIPBOARD].selection = ECORE_X_SELECTION_CLIPBOARD;
3009 __clipList[_CLIP_TYPE_CLIPBOARD].set = ecore_x_selection_clipboard_set;
3010 __clipList[_CLIP_TYPE_CLIPBOARD].clear = ecore_x_selection_clipboard_clear;
3011 __clipList[_CLIP_TYPE_CLIPBOARD].request = ecore_x_selection_clipboard_request;
3012 __clipList[_CLIP_TYPE_CLIPBOARD].active = false;
3013 __clipList[_CLIP_TYPE_CLIPBOARD].pBuffer = null;
3014 __clipList[_CLIP_TYPE_CLIPBOARD].pRetrievedBuffer = null;
3015 __clipList[_CLIP_TYPE_CLIPBOARD].bufferLength = 0;
3016 __clipList[_CLIP_TYPE_CLIPBOARD].completed = false;
3018 __clipList[_CLIP_TYPE_XDND].selection = ECORE_X_SELECTION_XDND;
3019 __clipList[_CLIP_TYPE_XDND].request = ecore_x_selection_xdnd_request;
3020 __clipList[_CLIP_TYPE_XDND].active = false;
3021 __clipList[_CLIP_TYPE_XDND].pBuffer = null;
3022 __clipList[_CLIP_TYPE_XDND].pRetrievedBuffer = null;
3023 __clipList[_CLIP_TYPE_XDND].bufferLength = 0;
3024 __clipList[_CLIP_TYPE_XDND].completed = false;
3026 for (int i = 0; i < _ATOM_MAX; i++)
3028 __atomList[i].atom = ecore_x_atom_get(__atomList[i].pName);
3029 //ecore_x_selection_converter_atom_add(__atomList[i].atom, __atomList[i].convert);
3031 SysLog(NID_UI, "[Clipboard] __atomList[%d] : pName = %s, atom = %d", i, __atomList[i].pName, __atomList[i].atom);
3034 result r = E_SUCCESS;
3036 __pClearClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, ClearClip, NULL);
3037 SysTryCatch(NID_UI, __pClearClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3039 __pNotifyClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, NotifyClip, NULL);
3040 SysTryCatch(NID_UI, __pNotifyClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3042 __pClipboardClosed = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, OnClipboardClosed, null);
3043 SysTryCatch(NID_UI, __pClipboardClosed, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
3045 __atomRotateRootAngle = ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE");
3050 for (int i = 0; i < _ATOM_MAX; i++)
3052 if (__atomList[i].atom)
3054 ecore_x_selection_converter_atom_del(__atomList[i].atom);
3060 ecore_event_handler_del(__pClearClip);
3061 __pClearClip = null;
3066 ecore_event_handler_del(__pNotifyClip);
3067 __pNotifyClip = null;
3070 if (__pClipboardClosed)
3072 ecore_event_handler_del(__pClipboardClosed);
3073 __pClipboardClosed = null;
3080 _EcoreEvas::IsValidClipFormat(_ClipFormat clipFormat)
3082 return ((_CLIP_FORMAT_TEXT & clipFormat) ||
3083 (_CLIP_FORMAT_MARKUP & clipFormat) ||
3084 (_CLIP_FORMAT_IMAGE & clipFormat) ||
3085 (_CLIP_FORMAT_VCARD & clipFormat) ||
3086 (_CLIP_FORMAT_HTML & clipFormat));
3090 _EcoreEvas::GetCbhmWindow(void) const
3092 Ecore_X_Atom atomCbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME);
3093 Ecore_X_Window cbhmWin = 0;
3095 unsigned char* pBuf = NULL;
3097 int ret = ecore_x_window_prop_property_get(0, atomCbhm, XA_WINDOW, 0, &pBuf, &num);
3101 memcpy(&cbhmWin, pBuf, sizeof(Ecore_X_Window));
3113 _EcoreEvas::SendCbhmMessage(Ecore_X_Window xwin, const char* pMsg)
3115 Ecore_X_Window cbhmWin = GetCbhmWindow();
3116 Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(ATOM_CBHM_MSG);
3118 if (!cbhmWin || !atomCbhmMsg)
3123 XClientMessageEvent m;
3124 memset(&m, 0, sizeof(m));
3125 m.type = ClientMessage;
3126 m.display = (Display*)ecore_x_display_get();
3128 m.message_type = atomCbhmMsg;
3130 snprintf(m.data.b, 20, "%s", pMsg);
3132 XSendEvent((Display*)ecore_x_display_get(), cbhmWin, False, NoEventMask, (XEvent*)&m);
3143 _EcoreEvas::SetCbhmItem(Ecore_X_Window xwin, Ecore_X_Atom dataType, char* pItemData)
3145 Ecore_X_Window cbhmWin = GetCbhmWindow();
3146 Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_ITEM);
3149 ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, pItemData, strlen(pItemData) + 1);
3152 if (SendCbhmMessage(xwin, ATOM_CBHM_SET_ITEM))
3161 _EcoreEvas::GetCbhmReply(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom* pDataType, int* pNum) const
3163 unsigned char* pData = null;
3182 long unsigned int numRet = 0;
3183 long unsigned int bytes = 0;
3187 unsigned char* pPropRet = null;
3188 Ecore_X_Atom typeRet;
3190 ret = XGetWindowProperty((Display*)ecore_x_display_get(), xwin, property, 0, LONG_MAX, False,
3191 ecore_x_window_prop_any_type(), (Atom*)&typeRet, &sizeRet, &numRet, &bytes, &pPropRet);
3203 if (!(pData = (unsigned char*)malloc(numRet * sizeRet / 8)))
3212 for (i = 0; i < numRet; i++)
3213 (pData)[i] = pPropRet[i];
3216 for (i = 0; i < numRet; i++)
3217 ((unsigned short *)pData)[i] = ((unsigned short *)pPropRet)[i];
3220 for (i = 0; i < numRet; i++)
3221 ((unsigned int *)pData)[i] = ((unsigned long *)pPropRet)[i];
3237 *pDataType = typeRet;
3244 _EcoreEvas::GetCbhmItemCount(void) const
3249 Ecore_X_Atom atomCbhmCountGet = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
3250 Ecore_X_Window cbhmWin = GetCbhmWindow();
3252 pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmCountGet, null, null);
3264 _EcoreEvas::GetCbhmItem(int index, Ecore_X_Atom* pDataType, char** pBuffer) const
3273 *(int*)pDataType = 0;
3276 Ecore_X_Window cbhmWin = GetCbhmWindow();
3280 snprintf(sendBuf, 20, "CBHM_ITEM%d", index);
3281 Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(sendBuf);
3282 Ecore_X_Atom atomItemType = 0;
3284 pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL);
3298 *pDataType = atomItemType;
3301 Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
3302 if (atomItemType == x_atom_cbhm_error)
3320 // [ToDo] Remove API
3322 _AddActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3324 GetEcoreEvasMgr()->GetEcoreEvas()->AddActiveWindowEventListener(listener);
3327 // [ToDo] Remove API
3329 _RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener)
3331 GetEcoreEvasMgr()->GetEcoreEvas()->RemoveActiveWindowEventListener(listener);
3334 // [ToDo] Remove API
3335 _OSP_EXPORT_ unsigned int
3336 _GetActiveWindow(void)
3338 return GetEcoreEvasMgr()->GetEcoreEvas()->GetActiveWindow();
3341 // [ToDo] Remove API
3343 _GetProcessId(unsigned int window)
3345 return GetEcoreEvasMgr()->GetEcoreEvas()->GetProcessId(window);