* @brief This is the implementation for the _UiAppImpl class.
*/
-#include <bundle.h>
#include <appsvc/appsvc.h>
+#include <bundle.h>
+#include <glib.h>
#include <unique_ptr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
#include <FBaseSysLog.h>
#include <FBaseColArrayList.h>
}
+long
+_UiAppImpl::GetTargetWindowHandle(void) const
+{
+ result r = E_SUCCESS;
+
+ _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
+ r = GetLastResult();
+ SysTryReturn(NID_APP, pEcoreEvasMgr, -1, r, "Propagating.");
+
+ _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
+ r = GetLastResult();
+ SysTryReturn(NID_APP, pEcoreEvas, -1, r, "Propagating.");
+
+ Atom actualTypeReturn;
+ int actualFormatReturn;
+ unsigned long nItemsReturn;
+ unsigned long bytesAfterReturn;
+ unsigned char* pPropReturn = null;
+
+ gint ret = 0;
+ ret = XGetWindowProperty(static_cast<Display*>(ecore_x_display_get()),
+ ecore_x_window_root_get(pEcoreEvas->GetXWindow()),
+ ecore_x_atom_get("_ISF_ACTIVE_WINDOW"),
+ 0,
+ G_MAXLONG,
+ false,
+ XA_WINDOW,
+ &actualTypeReturn,
+ &actualFormatReturn,
+ &nItemsReturn,
+ &bytesAfterReturn,
+ &pPropReturn);
+ SysTryReturn(NID_APP, ret == Success, -1, E_SYSTEM, "A failure occurs from the underlying system.");
+
+ Ecore_X_Window targetWindow = 0;
+
+ if (pPropReturn)
+ {
+ if (actualTypeReturn == XA_WINDOW)
+ {
+ targetWindow = *(reinterpret_cast<Ecore_X_Window*>(pPropReturn));
+ SysLog(NID_APP, "The handle of the target window is %x.", targetWindow);
+ }
+
+ XFree(pPropReturn);
+ }
+
+ return targetWindow? targetWindow: -1;
+}
+
+
static int
TransientResponseCb(void* pData)
{
long
_UiAppImpl::OnWindowHandleRequest(void)
{
- const _EcoreEvas* const pEvas = GetEcoreEvasMgr()->GetEcoreEvas();
- return (pEvas) ? static_cast<long>(pEvas->GetXWindow()) : -1;
+ long handle = -1;
+ int type = _AppInfo::GetAppType();
+
+ if (type & _APP_TYPE_IME_APP)
+ {
+ handle = GetTargetWindowHandle();
+ }
+ else
+ {
+ const _EcoreEvas* const pEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+ handle = (pEvas) ? static_cast<long>(pEvas->GetXWindow()) : -1;
+ }
+
+ return handle;
}