From 79d8b797aa3789d6fe288b3d30d6de2067d09240 Mon Sep 17 00:00:00 2001 From: Bum-Sung Cho Date: Tue, 16 Apr 2013 00:09:14 +0900 Subject: [PATCH] Manage the layout of the IME app window according to the binded window orientation. Change-Id: If27e13d27ea66acffc317097f76772a6068963ca Signed-off-by: Bum-Sung Cho --- src/FUiIme_InputServiceSignalListener.cpp | 34 +-------- src/FUiIme_TargetWindowAgent.cpp | 110 +++++++++++++++++++----------- 2 files changed, 74 insertions(+), 70 deletions(-) diff --git a/src/FUiIme_InputServiceSignalListener.cpp b/src/FUiIme_InputServiceSignalListener.cpp index d1f69c7..f7bbe89 100644 --- a/src/FUiIme_InputServiceSignalListener.cpp +++ b/src/FUiIme_InputServiceSignalListener.cpp @@ -380,24 +380,6 @@ _InputServiceSignalListener::HideInputPanel(const scim::HelperAgent* pHelperAgen { __pIInputMethodProvider->HideInputPanel(); } -/* unset the target window - result r = E_SUCCESS; - - _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); - SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); - SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject(); - SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - - Ecore_X_Window keyboardWindow = elm_win_xwindow_get(pEvasObject); - - _TargetWindowAgent* pTargetWindowAgent = _TargetWindowAgent::GetInstance(); - r = GetLastResult(); - SysTryReturnVoidResult(NID_UI_IME, pTargetWindowAgent, r, "[%s] Propagating.", GetErrorMessage(r)); - - pTargetWindowAgent->UnsetTargetWindow(keyboardWindow); -*/ } void @@ -430,30 +412,18 @@ _InputServiceSignalListener::ShowInputPanel(const scim::HelperAgent* pHelperAgen { __pIInputMethodProvider->ShowInputPanel(); } -/* set the target window and orientation - result r = E_SUCCESS; - _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); - SysTryReturnVoidResult(NID_UI_IME, pEcoreEvasMgr, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); - SysTryReturnVoidResult(NID_UI_IME, pEcoreEvas, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject(); - SysTryReturnVoidResult(NID_UI_IME, pEvasObject, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); - - Ecore_X_Window keyboardWindow = elm_win_xwindow_get(pEvasObject); + result r = E_SUCCESS; _TargetWindowAgent* pTargetWindowAgent = _TargetWindowAgent::GetInstance(); r = GetLastResult(); SysTryReturnVoidResult(NID_UI_IME, pTargetWindowAgent, r, "[%s] Propagating.", GetErrorMessage(r)); - pTargetWindowAgent->SetTargetWindow(keyboardWindow); - int angle = pTargetWindowAgent->GetOrientation(); r = GetLastResult(); - SysTryReturnVoidResult(NID_UI_IME, angle != -1, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_IME, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); pTargetWindowAgent->SetOrientation(angle); -*/ } void diff --git a/src/FUiIme_TargetWindowAgent.cpp b/src/FUiIme_TargetWindowAgent.cpp index e63316f..90f2e0f 100644 --- a/src/FUiIme_TargetWindowAgent.cpp +++ b/src/FUiIme_TargetWindowAgent.cpp @@ -33,9 +33,12 @@ #include #include "FUi_ControlManager.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" #include "FUiCtrl_Form.h" #include "FUiCtrl_FormImpl.h" #include "FUiCtrl_Frame.h" +#include "FUiCtrl_FrameImpl.h" #include "FUiIme_TargetWindowAgent.h" using namespace Tizen::Ui; @@ -139,78 +142,109 @@ _TargetWindowAgent::UnsetTargetWindow(Ecore_X_Window inputPanelWindow) int _TargetWindowAgent::GetOrientation(void) { - SysTryReturn(NID_UI_IME, __inputPanelWindow != 0, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + unsigned int angle = 0; + // get the target window Atom actualTypeReturn; int actualFormatReturn; unsigned long nItemsReturn; unsigned long bytesAfterReturn; unsigned char* pPropReturn = null; + unsigned char* pAngleReturn = null; + + _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); + SysTryReturn(NID_UI_IME, pEcoreEvasMgr, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + SysTryReturn(NID_UI_IME, pEcoreEvas, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + Evas_Object* pEvasObject = pEcoreEvas->GetWindowObject(); + SysTryReturn(NID_UI_IME, pEvasObject, 0, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + Ecore_X_Window inputPanelWindow = elm_win_xwindow_get(pEvasObject); gint ret = 0; ret = XGetWindowProperty(static_cast(ecore_x_display_get()), - ecore_x_window_root_get(__inputPanelWindow), - ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE"), + ecore_x_window_root_get(inputPanelWindow), + ecore_x_atom_get("_ISF_ACTIVE_WINDOW"), 0, G_MAXLONG, false, - XA_CARDINAL, + XA_WINDOW, &actualTypeReturn, &actualFormatReturn, &nItemsReturn, &bytesAfterReturn, &pPropReturn); - SysTryReturn(NID_UI_IME, ret == Success, -1, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + SysTryCatch(NID_UI_IME, ret == Success, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); - unsigned int angle = 0; - if (pPropReturn) + // get the orientation angle of the target window + if ((actualTypeReturn == XA_WINDOW) && (actualFormatReturn == 32) && pPropReturn) { - angle = ((actualTypeReturn == XA_CARDINAL)? *(reinterpret_cast(pPropReturn)): -1); + Ecore_X_Window targetWindow = *(reinterpret_cast(pPropReturn)); + ret = XGetWindowProperty(static_cast(ecore_x_display_get()), + targetWindow, + ecore_x_atom_get("_E_ILLUME_ROTATE_WINDOW_ANGLE"), + 0, + G_MAXLONG, + false, + XA_CARDINAL, + &actualTypeReturn, + &actualFormatReturn, + &nItemsReturn, + &bytesAfterReturn, + &pAngleReturn); + SysTryCatch(NID_UI_IME, ret == Success, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + + if ((actualTypeReturn == XA_CARDINAL) && pAngleReturn) + { + angle = *(reinterpret_cast(pAngleReturn)); + } + } + // Fall through +CATCH: + if (pPropReturn) + { XFree(pPropReturn); } + if (pAngleReturn) + { + XFree(pAngleReturn); + } + return angle; } result _TargetWindowAgent::SetOrientation(int angle) { - SysTryReturnResult(NID_UI_IME, __inputPanelWindow != 0, E_OBJ_NOT_FOUND, "The required instance does not exist."); - result r = E_SUCCESS; - Orientation orientation = ORIENTATION_NONE; - switch (angle) + _ControlManager* pControlManager = _ControlManager::GetInstance(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pControlManager, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Window* pCurrentFrame = pControlManager->GetCurrentFrame(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pCurrentFrame, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Frame* pFrame = static_cast<_Frame*>(pCurrentFrame); + SysTryReturnResult(NID_UI_IME, pFrame, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist."); + + _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(pFrame->GetUserData()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pFrameImpl, r, "[%s] Propagating.", GetErrorMessage(r)); + + _FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm(); + if (pCurrentFormImpl) { - case 0: - orientation = ORIENTATION_PORTRAIT; - break; - case 90: - orientation = ORIENTATION_LANDSCAPE_REVERSE; - break; - case 180: - orientation = ORIENTATION_PORTRAIT_REVERSE; - break; - case 270: - orientation = ORIENTATION_LANDSCAPE; - break; - default: - SysTryReturnResult(NID_UI_IME, true, E_INVALID_ARG, "Invalid argument(s) is used. The angle is %d.", angle); - break; + pCurrentFormImpl->UpdateOrientation(angle); + } + else + { + pFrameImpl->UpdateOrientation(angle); } - _ControlManager* pControlManager = _ControlManager::GetInstance(); - SysTryReturnResult(NID_UI_IME, pControlManager, E_OBJ_NOT_FOUND, "The required instance does not exist."); - _Frame* pFrameCore = static_cast<_Frame*>(pControlManager->GetCurrentFrame()); - SysTryReturnResult(NID_UI_IME, pFrameCore, E_OBJ_NOT_FOUND, "The required instance does not exist."); - _Form* pFormCore = pFrameCore->GetCurrentForm(); - SysTryReturnResult(NID_UI_IME, pFormCore, E_OBJ_NOT_FOUND, "The required instance does not exist."); - _FormImpl* pFormImpl = static_cast<_FormImpl*>(pFormCore->GetUserData()); - SysTryReturnResult(NID_UI_IME, pFormImpl, E_OBJ_NOT_FOUND, "The required instance does not exist."); - - pFormImpl->SetOrientation(orientation); - SysLog(NID_UI_IME, "Set the orientation of the current form to %d.", orientation); + SysLog(NID_UI_IME, "Update the orientation of the current form to %d.", angle); return r; } -- 2.7.4