Merge "Get focused pid to set foreground" into tizen
authorWonnam Jang <wn.jang@samsung.com>
Fri, 17 Mar 2017 08:32:05 +0000 (01:32 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 17 Mar 2017 08:32:05 +0000 (01:32 -0700)
server/vcd_client_data.c

index 9b2a00f..b033950 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <app_manager.h>
 #include <aul.h>
+#include <aul_window.h>
 
 #include "vcd_client_data.h"
 #include "vcd_config.h"
@@ -1396,9 +1397,14 @@ void vcd_client_update_foreground_pid()
 {
        int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND;
        vcd_config_get_foreground(&tmp_pid);
-       SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", tmp_pid);
 
-       char appid[255] = {'\0',};
+       int pid = VC_RUNTIME_INFO_NO_FOREGROUND;
+       int ret = aul_window_get_focused_pid(&pid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get focused pid, ret(%d)", ret);
+       }
+       SLOG(LOG_INFO, TAG_VCD, "[INFO] Foreground pid (%d), Focused pid (%d)", tmp_pid, pid);
+
        GSList *iter = NULL;
        vc_client_info_s *data = NULL;
 
@@ -1417,10 +1423,7 @@ void vcd_client_update_foreground_pid()
 
                        if (NULL != data) {
                                SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, data->pid);
-                               memset(appid, 0, 255);
-                               aul_app_get_appid_bypid(data->pid, appid, sizeof(appid));
-                               int status = aul_app_get_status(appid);
-                               if (status == STATUS_FOCUS) {
+                               if (pid == data->pid) {
                                        SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", data->pid);
                                        vcd_config_set_foreground(data->pid, true);
                                        if (tmp_pid != data->pid) {
@@ -1448,10 +1451,7 @@ void vcd_client_update_foreground_pid()
 
                        if (NULL != widget_data) {
                                SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, widget_data->pid);
-                               memset(appid, 0, 255);
-                               aul_app_get_appid_bypid(widget_data->pid, appid, sizeof(appid));
-                               int status = aul_app_get_status(appid);
-                               if (status == STATUS_FOCUS) {
+                               if (pid == widget_data->pid) {
                                        SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", widget_data->pid);
                                        vcd_config_set_foreground(widget_data->pid, true);
                                        if (tmp_pid != widget_data->pid) {