*/
int aul_window_info_get_geometry(aul_window_info_h info, int *x, int *y, int *w, int *h);
+
+/**
+ * @par Description:
+ * This API gets pid for the focused window.
+ *
+ * @param[out] pid focused pid
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_get_focused_pid(pid_t *pid);
+
+
#ifdef __cplusplus
}
#endif
#define WM_BUS_NAME "org.enlightenment.wm"
#define WM_OBJECT_PATH "/org/enlightenment/wm"
#define WM_INTERFACE_NAME "org.enlightenment.wm.proc"
-#define WM_METHOD_NAME "GetVisibleWinInfo"
+#define WM_METHOD_NAME_INFO "GetVisibleWinInfo"
+#define WM_METHOD_NAME_FOCUS "GetFocusProc"
+
typedef struct _window_info {
unsigned int gid;
msg = g_dbus_message_new_method_call(WM_BUS_NAME,
WM_OBJECT_PATH,
WM_INTERFACE_NAME,
- WM_METHOD_NAME);
+ WM_METHOD_NAME_INFO);
if (msg == NULL) {
_E("g_dbus_message_new_method_call() is failed.");
return -1;
return 0;
}
+API int aul_window_get_focused_pid(pid_t *pid)
+{
+ GError *err = NULL;
+ GDBusMessage *msg;
+ GDBusMessage *reply;
+ GDBusConnection *conn;
+ int res = 0;
+ GVariant *body;
+ gint32 focused_pid = 0;
+
+ if (system_conn == NULL) {
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (conn == NULL) {
+ _E("g_bus_get_sync() is failed. %s", err->message);
+ g_error_free(err);
+ return -1;
+ }
+ system_conn = conn;
+ }
+
+ msg = g_dbus_message_new_method_call(WM_BUS_NAME,
+ WM_OBJECT_PATH,
+ WM_INTERFACE_NAME,
+ WM_METHOD_NAME_FOCUS);
+ if (msg == NULL) {
+ _E("g_dbus_message_new_method_call() is failed.");
+ return -1;
+ }
+
+ reply = g_dbus_connection_send_message_with_reply_sync(system_conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+
+ if (!reply) {
+ if (err != NULL) {
+ _E("Failed to get info [%s]", err->message);
+ g_error_free(err);
+ }
+ res = -1;
+ goto out;
+ }
+
+ body = g_dbus_message_get_body(reply);
+ if (!body) {
+ res = -1;
+ goto out;
+ }
+
+ g_variant_get(body, "(i)", &focused_pid);
+ *pid = (pid_t)focused_pid;
+out:
+ if (msg)
+ g_object_unref(msg);
+ if (reply)
+ g_object_unref(reply);
+
+ return res;
+}
+
+