Revert "Revert "[N_SE-40957] Set 'transient_for' from the keyboard settings to the...
authorwoojin nam <w.nam@samsung.com>
Fri, 28 Jun 2013 13:33:30 +0000 (13:33 +0000)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Fri, 28 Jun 2013 13:33:30 +0000 (13:33 +0000)
 This reverts commit 8d91bd8cf6477c6a6028fe72b3c25b45bce6ddc7"

This reverts commit e4005345e929ce83b99b60ac6b8512ef6de9ea9b

Change-Id: I852c4242bc9de64fa672b0c8bb8deabfe1a03642

src/app/FApp_UiAppImpl.cpp
src/app/inc/FApp_UiAppImpl.h

index 9097615..0ab942b 100755 (executable)
  * @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>
@@ -119,6 +122,57 @@ _UiAppImpl::RaiseFrame(Frame& frame)
 }
 
 
+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)
 {
@@ -285,8 +339,20 @@ _UiAppImpl::OnFrameRaiseRequested(void)
 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;
 }
 
 
index 5c6c7c9..0546e1d 100755 (executable)
@@ -311,6 +311,8 @@ private:
         */
        void RaiseFrame(Tizen::Ui::Controls::Frame& frame);
 
+       long GetTargetWindowHandle(void) const;
+
 private:
        static _UiAppImpl* __pUiAppImpl;