Manage the layout of the IME app window according to the binded window orientation.
authorBum-Sung Cho <bs0111.cho@samsung.com>
Mon, 15 Apr 2013 15:09:14 +0000 (00:09 +0900)
committerBum-Sung Cho <bs0111.cho@samsung.com>
Mon, 15 Apr 2013 15:09:14 +0000 (00:09 +0900)
Change-Id: If27e13d27ea66acffc317097f76772a6068963ca
Signed-off-by: Bum-Sung Cho <bs0111.cho@samsung.com>
src/FUiIme_InputServiceSignalListener.cpp
src/FUiIme_TargetWindowAgent.cpp

index d1f69c7..f7bbe89 100644 (file)
@@ -380,24 +380,6 @@ _InputServiceSignalListener::HideInputPanel(const scim::HelperAgent* pHelperAgen
        {\r
                __pIInputMethodProvider->HideInputPanel();\r
        }\r
-/* unset the target window\r
-       result r = E_SUCCESS;\r
-\r
-       _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-       _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-       Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-\r
-    Ecore_X_Window keyboardWindow = elm_win_xwindow_get(pEvasObject);\r
-\r
-       _TargetWindowAgent* pTargetWindowAgent = _TargetWindowAgent::GetInstance();\r
-       r = GetLastResult();\r
-       SysTryReturnVoidResult(NID_UI_IME, pTargetWindowAgent, r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
-       pTargetWindowAgent->UnsetTargetWindow(keyboardWindow);\r
-*/\r
 }\r
 \r
 void\r
@@ -430,30 +412,18 @@ _InputServiceSignalListener::ShowInputPanel(const scim::HelperAgent* pHelperAgen
        {\r
                __pIInputMethodProvider->ShowInputPanel();\r
        }\r
-/* set the target window and orientation\r
-       result r = E_SUCCESS;\r
 \r
-       _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-       _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-       Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject();\r
-       SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
-\r
-    Ecore_X_Window keyboardWindow = elm_win_xwindow_get(pEvasObject);\r
+       result r = E_SUCCESS;\r
 \r
        _TargetWindowAgent* pTargetWindowAgent = _TargetWindowAgent::GetInstance();\r
        r = GetLastResult();\r
        SysTryReturnVoidResult(NID_UI_IME, pTargetWindowAgent, r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
-       pTargetWindowAgent->SetTargetWindow(keyboardWindow);\r
-\r
        int angle = pTargetWindowAgent->GetOrientation();\r
        r = GetLastResult();\r
-       SysTryReturnVoidResult(NID_UI_IME, angle != -1, r, "[%s] Propagating.", GetErrorMessage(r));\r
+       SysTryReturnVoidResult(NID_UI_IME, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
        pTargetWindowAgent->SetOrientation(angle);\r
-*/\r
 }\r
 \r
 void\r
index e63316f..90f2e0f 100644 (file)
 #include <FUiIOrientationEventListener.h>\r
 \r
 #include "FUi_ControlManager.h"\r
+#include "FUi_EcoreEvas.h"\r
+#include "FUi_EcoreEvasMgr.h"\r
 #include "FUiCtrl_Form.h"\r
 #include "FUiCtrl_FormImpl.h"\r
 #include "FUiCtrl_Frame.h"\r
+#include "FUiCtrl_FrameImpl.h"\r
 #include "FUiIme_TargetWindowAgent.h"\r
 \r
 using namespace Tizen::Ui;\r
@@ -139,78 +142,109 @@ _TargetWindowAgent::UnsetTargetWindow(Ecore_X_Window inputPanelWindow)
 int\r
 _TargetWindowAgent::GetOrientation(void)\r
 {\r
-       SysTryReturn(NID_UI_IME, __inputPanelWindow != 0, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
+       unsigned int angle = 0;\r
 \r
+       // get the target window\r
        Atom actualTypeReturn;\r
        int actualFormatReturn;\r
        unsigned long nItemsReturn;\r
        unsigned long bytesAfterReturn;\r
        unsigned char* pPropReturn = null;\r
+       unsigned char* pAngleReturn = null;\r
+\r
+       _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();\r
+       SysTryReturn(NID_UI_IME, pEcoreEvasMgr, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
+       _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();\r
+       SysTryReturn(NID_UI_IME, pEcoreEvas, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
+       Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject();\r
+       SysTryReturn(NID_UI_IME, pEvasObject, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
+    Ecore_X_Window inputPanelWindow = elm_win_xwindow_get(pEvasObject);\r
 \r
     gint ret = 0;\r
        ret = XGetWindowProperty(static_cast<Display*>(ecore_x_display_get()),\r
-                                                       ecore_x_window_root_get(__inputPanelWindow),\r
-                                                       ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE"),\r
+                                                       ecore_x_window_root_get(inputPanelWindow),\r
+                                                       ecore_x_atom_get("_ISF_ACTIVE_WINDOW"),\r
                                                        0,\r
                                                        G_MAXLONG,\r
                                                        false,\r
-                                                       XA_CARDINAL,\r
+                                                       XA_WINDOW,\r
                                                        &actualTypeReturn,\r
                                                        &actualFormatReturn,\r
                                                        &nItemsReturn,\r
                                                        &bytesAfterReturn,\r
                                                        &pPropReturn);\r
-       SysTryReturn(NID_UI_IME, ret == Success, -1, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
+       SysTryCatch(NID_UI_IME, ret == Success, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
 \r
-       unsigned int angle = 0;\r
-       if (pPropReturn)\r
+       // get the orientation angle of the target window\r
+       if ((actualTypeReturn == XA_WINDOW) && (actualFormatReturn == 32) && pPropReturn)\r
        {\r
-               angle = ((actualTypeReturn == XA_CARDINAL)? *(reinterpret_cast<unsigned int*>(pPropReturn)): -1);\r
+               Ecore_X_Window targetWindow = *(reinterpret_cast<Ecore_X_Window*>(pPropReturn));\r
+               ret = XGetWindowProperty(static_cast<Display*>(ecore_x_display_get()),\r
+                                                               targetWindow,\r
+                                                               ecore_x_atom_get("_E_ILLUME_ROTATE_WINDOW_ANGLE"),\r
+                                                               0,\r
+                                                               G_MAXLONG,\r
+                                                               false,\r
+                                                               XA_CARDINAL,\r
+                                                               &actualTypeReturn,\r
+                                                               &actualFormatReturn,\r
+                                                               &nItemsReturn,\r
+                                                               &bytesAfterReturn,\r
+                                                               &pAngleReturn);\r
+               SysTryCatch(NID_UI_IME, ret == Success, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
+\r
+               if ((actualTypeReturn == XA_CARDINAL) && pAngleReturn)\r
+               {\r
+                       angle = *(reinterpret_cast<unsigned int*>(pAngleReturn));\r
+               }\r
+       }\r
 \r
+       // Fall through\r
+CATCH:\r
+       if (pPropReturn)\r
+       {\r
                XFree(pPropReturn);\r
        }\r
 \r
+       if (pAngleReturn)\r
+       {\r
+               XFree(pAngleReturn);\r
+       }\r
+\r
        return angle;\r
 }\r
 \r
 result\r
 _TargetWindowAgent::SetOrientation(int angle)\r
 {\r
-       SysTryReturnResult(NID_UI_IME, __inputPanelWindow != 0, E_OBJ_NOT_FOUND, "The required instance does not exist.");\r
-\r
        result r = E_SUCCESS;\r
 \r
-       Orientation orientation = ORIENTATION_NONE;\r
-       switch (angle)\r
+       _ControlManager* pControlManager = _ControlManager::GetInstance();\r
+       r = GetLastResult();\r
+       SysTryReturnResult(NID_UI_IME, pControlManager, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       _Window* pCurrentFrame = pControlManager->GetCurrentFrame();\r
+       r = GetLastResult();\r
+       SysTryReturnResult(NID_UI_IME, pCurrentFrame, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       _Frame* pFrame = static_cast<_Frame*>(pCurrentFrame);\r
+       SysTryReturnResult(NID_UI_IME, pFrame, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");\r
+\r
+       _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(pFrame->GetUserData());\r
+       r = GetLastResult();\r
+       SysTryReturnResult(NID_UI_IME, pFrameImpl, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       _FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm();\r
+       if (pCurrentFormImpl)\r
        {\r
-       case 0:\r
-               orientation = ORIENTATION_PORTRAIT;\r
-               break;\r
-       case 90:\r
-               orientation = ORIENTATION_LANDSCAPE_REVERSE;\r
-               break;\r
-       case 180:\r
-               orientation = ORIENTATION_PORTRAIT_REVERSE;\r
-               break;\r
-       case 270:\r
-               orientation = ORIENTATION_LANDSCAPE;\r
-               break;\r
-       default:\r
-               SysTryReturnResult(NID_UI_IME, true, E_INVALID_ARG, "Invalid argument(s) is used. The angle is %d.", angle);\r
-               break;\r
+               pCurrentFormImpl->UpdateOrientation(angle);\r
+       }\r
+       else\r
+       {\r
+               pFrameImpl->UpdateOrientation(angle);\r
        }\r
 \r
-       _ControlManager* pControlManager = _ControlManager::GetInstance();\r
-       SysTryReturnResult(NID_UI_IME, pControlManager, E_OBJ_NOT_FOUND, "The required instance does not exist.");\r
-       _Frame* pFrameCore = static_cast<_Frame*>(pControlManager->GetCurrentFrame());\r
-       SysTryReturnResult(NID_UI_IME, pFrameCore, E_OBJ_NOT_FOUND, "The required instance does not exist.");\r
-       _Form* pFormCore = pFrameCore->GetCurrentForm();\r
-       SysTryReturnResult(NID_UI_IME, pFormCore, E_OBJ_NOT_FOUND, "The required instance does not exist.");\r
-       _FormImpl* pFormImpl = static_cast<_FormImpl*>(pFormCore->GetUserData());\r
-       SysTryReturnResult(NID_UI_IME, pFormImpl, E_OBJ_NOT_FOUND, "The required instance does not exist.");\r
-       \r
-       pFormImpl->SetOrientation(orientation);\r
-       SysLog(NID_UI_IME, "Set the orientation of the current form to %d.", orientation);\r
+       SysLog(NID_UI_IME, "Update the orientation of the current form to %d.", angle);\r
 \r
        return r;\r
 }\r