added initial code 23/58023/1 accepted/tizen/common/20160223.110203 accepted/tizen/ivi/20160218.024431 accepted/tizen/mobile/20160127.072844 accepted/tizen/tv/20160127.072900 accepted/tizen/wearable/20160127.072913 submit/tizen/20160127.043012 submit/tizen_common/20160218.142243 submit/tizen_common/20160219.083441 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000004
authorDoyoun Kang <doyoun.kang@samsung.com>
Wed, 27 Jan 2016 00:10:49 +0000 (09:10 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 27 Jan 2016 00:11:13 +0000 (09:11 +0900)
Change-Id: Ic63687e2e7a6bf4f0833ebcd4c8eda2df8deb915

12 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
packaging/e-mod-tizen-processmgr.spec [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/e_mod_main.c [new file with mode: 0644]
src/e_mod_main.h [new file with mode: 0644]
src/e_mod_processmgr.c [new file with mode: 0644]
src/e_mod_processmgr.h [new file with mode: 0644]
src/e_mod_processmgr_shared_types.h [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..0a64e68
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Doyoun Kang <doyoun.kang@samsung.com>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..f3bbff3
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,25 @@
+Copyright notice for Enlightenment:
+
+Copyright (C) 2000-2012 Carsten Haitzler and various contributors (see AUTHORS)
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..a30d363
--- /dev/null
@@ -0,0 +1,8 @@
+#maintainer-clean removes everything
+MAINTAINERCLEANFILES = aclocal.m4 compile config.sub config.guess config.h.in \
+                      configure depcomp install-sh ltmain.sh Makefile.in missing
+
+SUBDIRS = src
+
+MAINTAINERCLEANFILES = \
+                      Makefile.in
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..1ac867a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+#rm -rf autom4te.cache
+#rm -f aclocal.m4 ltmain.sh
+
+#echo "Running autoreconf..." ; autoreconf -v --install || exit 1
+#echo "Running configure..." ; ./configure --enable-maintainer-mode
+
+set  -x
+aclocal
+autoconf
+libtoolize --copy --force
+autoheader
+automake --foreign --add-missing --copy
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..956fd6b
--- /dev/null
@@ -0,0 +1,119 @@
+# Process this file with autoconf to produce a configure script.
+dnl Process this file with autoconf to produce a configure script.
+
+# Note )
+#
+# AC_DEFINE(VARIABLE, VALUE, DESCRIPTION)
+#   output the following to config.h
+#   /* DESCRIPTION */
+#   #define VARIABLE VALUE
+#
+# AC_SUBST(VARIABLE, [VALUE])
+#   define $(VARIABLE) as VALUE in Makefile
+
+dnl ========================================================================
+# initialization
+dnl ========================================================================
+AC_INIT([e-mod-tizen-processmgr], [0.1], [doyoun.kang@samsung.com])
+
+# check for tools needed by automake generated Makefiles
+# -Wall  : Turn all warnings on.
+# -Werror: report warings as errors.
+# foreign: relax some GNU standard requirements
+#AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AM_INIT_AUTOMAKE([-Wall foreign])
+AM_SILENT_RULES([yes])
+
+dnl ========================================================================
+# checks for programs
+dnl ========================================================================
+AC_PROG_CC
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+
+dnl ========================================================================
+# checks for libraries
+dnl ========================================================================
+
+dnl ========================================================================
+# checks for header files
+dnl ========================================================================
+#AC_HEADER_STDC
+AC_CHECK_HEADERS([math.h fcntl.h stdlib.h string.h unistd.h])
+
+dnl ========================================================================
+# checks for typedefs, structures, and compiler characteristics
+AC_C_CONST
+
+dnl ========================================================================
+# checks for library functions
+dnl ========================================================================
+#AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_CHECK_FUNCS([memset munmap strcasecmp strdup])
+
+dnl ========================================================================
+# checks for pkg-config
+dnl ========================================================================
+PKG_PROG_PKG_CONFIG
+
+
+dnl ========================================================================
+# checks for pkg-config
+dnl ========================================================================
+
+have_wayland_only=no
+AC_ARG_ENABLE([wayland-only],
+  AS_HELP_STRING([--enable-wayland-only],[enable wayland-only version of processmgr @<:@default=disabled@:>@]),
+  [have_wayland_only=$enableval],
+  [have_wayland_only=no])
+AC_MSG_CHECKING([whether wayland-only version is enabled])
+if test "x${have_wayland_only}" = "xyes"; then
+  AC_DEFINE_UNQUOTED([HAVE_WAYLAND_ONLY],[1],[enable wayland-only version of processmgr])
+fi
+AM_CONDITIONAL(HAVE_WAYLAND_ONLY, [test "x${have_wayland_only}" = xyes])
+
+if test "x${have_wayland_only}" = "xyes"; then
+       PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, dlog, edbus])
+else
+       PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, dlog, edbus, x11])
+       ENLIGHTENMENT_CFLAGS="${ENLIGHTENMENT_CFLAGS} -DNEED_X=1"
+fi
+
+AC_SUBST(ENLIGHTENMENT_CFLAGS)
+AC_SUBST(ENLIGHTENMENT_LIBS)
+
+dnl =======================================================================
+
+release=$(pkg-config --variable=release enlightenment)
+MODULE_ARCH="$host_os-$host_cpu-$release"
+AC_SUBST(MODULE_ARCH)
+AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
+
+datadir=$(pkg-config --variable=modules enlightenment)/${PACKAGE}
+AC_ARG_ENABLE(homedir-install,
+       AS_HELP_STRING([--enable-homedir-install], [Install module in homedir]),
+       [ datadir="${HOME}/.e/e/modules/${PACKAGE}" ]
+)
+
+dnl ========================================================================
+# output files
+dnl ========================================================================
+
+# create HEADER for all HEADER.in.
+# HEADERS contain definitions made with AC_DEFINE.
+# the following command will create config.h from config.h.in
+AC_CONFIG_HEADERS([config.h])
+
+AC_SYS_LARGEFILE
+
+# create FILE for all FILE.in.
+# FILES contains definitions made with AC_SUBST.
+AC_CONFIG_FILES([
+                Makefile
+                src/Makefile
+                ])
+
+AC_OUTPUT
+
+
diff --git a/packaging/e-mod-tizen-processmgr.spec b/packaging/e-mod-tizen-processmgr.spec
new file mode 100644 (file)
index 0000000..5732917
--- /dev/null
@@ -0,0 +1,54 @@
+%bcond_with x
+%bcond_with wayland
+
+Name: e-mod-tizen-processmgr
+Version: 0.0.1
+Release: 1
+Summary: The enlightenment processmgr module for Tizen
+Group: Graphics & UI Framework/Other
+Source0: %{name}-%{version}.tar.gz
+License: BSD-2-Clause
+BuildRequires: pkgconfig(enlightenment)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(edbus)
+%if %{with x}
+BuildRequires: pkgconfig(x11)
+Requires: libX11
+%endif
+
+%description
+This package is a processmgr module for enlightenment.
+
+%prep
+%setup -q
+
+%build
+export GC_SECTIONS_FLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections"
+export CFLAGS+=" -Wall -Werror-implicit-function-declaration -g -fPIC -rdynamic ${GC_SECTIONS_FLAGS} -DE_LOGGING=1"
+export LDFLAGS+=" -Wl,--hash-style=both -Wl,--as-needed -Wl,--rpath=/usr/lib"
+
+%if %{with wayland}
+%reconfigure --enable-wayland-only
+%else
+%reconfigure 
+%endif
+
+make
+
+%install
+rm -rf %{buildroot}
+
+# for license notification
+mkdir -p %{buildroot}/usr/share/license
+cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/usr/share/license/%{name}
+
+# install
+make install DESTDIR=%{buildroot}
+
+# clear useless textual files
+find  %{buildroot}%{_libdir}/enlightenment/modules/%{name} -name *.la | xargs rm
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/enlightenment/modules/e-mod-tizen-processmgr
+/usr/share/license/%{name}
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..adaee31
--- /dev/null
@@ -0,0 +1,18 @@
+MAINTAINERCLEANFILES = Makefile.in
+MODULE = e-mod-tizen-processmgr
+
+LDFLAGS +=
+
+pkgdir                 = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
+pkg_LTLIBRARIES        = module.la
+module_la_SOURCES      = \
+       e_mod_main.c \
+       e_mod_processmgr.c
+
+module_la_LIBADD       =
+module_la_CFLAGS       = @ENLIGHTENMENT_CFLAGS@
+module_la_LDFLAGS      = -module -avoid-version @ENLIGHTENMENT_LIBS@
+module_la_DEPENDENCIES = $(top_builddir)/config.h
+
+#uninstall:
+#  rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
new file mode 100644 (file)
index 0000000..42d4c3d
--- /dev/null
@@ -0,0 +1,28 @@
+#include "e.h"
+#include "e_mod_main.h"
+#include "e_mod_processmgr.h"
+
+EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Process Manager Module" };
+
+EAPI void *
+e_modapi_init(E_Module *m)
+{
+   if (!e_mod_processmgr_init())
+     return NULL;
+
+   return m;
+}
+EAPI int
+e_modapi_shutdown(E_Module *m EINA_UNUSED)
+{
+   e_mod_processmgr_shutdown();
+
+   return 1;
+}
+
+EAPI int
+e_modapi_save(E_Module *m EINA_UNUSED)
+{
+   /* Save something to be kept */
+   return 1;
+}
diff --git a/src/e_mod_main.h b/src/e_mod_main.h
new file mode 100644 (file)
index 0000000..474c1f2
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef E_MOD_MAIN_H
+#define E_MOD_MAIN_H
+
+/*** E Module ***/
+EAPI extern E_Module_Api e_modapi;
+
+EAPI void *e_modapi_init     (E_Module *m);
+EAPI int   e_modapi_shutdown (E_Module *m);
+EAPI int   e_modapi_save     (E_Module *m);
+
+#endif
diff --git a/src/e_mod_processmgr.c b/src/e_mod_processmgr.c
new file mode 100644 (file)
index 0000000..31af2b2
--- /dev/null
@@ -0,0 +1,489 @@
+#include "e.h"
+#include "e_mod_processmgr.h"
+#include "e_mod_processmgr_shared_types.h"
+
+
+static E_ProcessMgr *_pm = NULL;
+
+static Eina_List *handlers = NULL;
+static Eina_List *hooks_ec = NULL;
+
+
+static E_ProcessMgr *_e_processmgr_new(void);
+static void _e_processmgr_del(E_ProcessMgr *pm);
+
+static E_ProcessInfo *_e_processmgr_processinfo_find(E_ProcessMgr *pm, pid_t pid);
+static Eina_Bool _e_processmgr_processinfo_add(pid_t pid, E_Client *ec);
+static Eina_Bool _e_processmgr_processinfo_del(pid_t pid, E_Client *ec);
+
+static E_WindowInfo *_e_processmgr_client_info_find(E_ProcessMgr *pm, E_Client *ec);
+static Eina_Bool _e_processmgr_client_info_add(E_Client *ec);
+static void _e_processmgr_client_info_del(E_Client *ec);
+
+static Eina_Bool _e_processmgr_cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
+static Eina_Bool _e_processmgr_cb_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
+static Eina_Bool _e_processmgr_cb_client_iconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
+static Eina_Bool _e_processmgr_cb_client_uniconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
+static Eina_Bool _e_processmgr_cb_client_visibility_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
+
+static void _pol_cb_hook_client_visibility(void *d EINA_UNUSED, E_Client *ec);
+
+static Eina_Bool _e_processmgr_client_freeze_condition_check(E_Client *ec);
+static Eina_Bool _e_processmgr_client_freeze(E_Client *ec);
+static Eina_Bool _e_processmgr_client_thaw(E_Client *ec);
+
+static void _e_processmgr_send_pid_action(int pid, E_ProcessMgr_Action act);
+
+
+static E_ProcessMgr *
+_e_processmgr_new(void)
+{
+   E_ProcessMgr *pm;
+
+   pm = E_NEW(E_ProcessMgr, 1);
+   if (!pm) return NULL;
+
+   pm->pids_hash = eina_hash_pointer_new(NULL);
+   if (!pm->pids_hash) goto error;
+   pm->wins_hash = eina_hash_pointer_new(NULL);
+   if (!pm->wins_hash) goto error;
+
+   return pm;
+
+error:
+   if (pm->pids_hash)
+     eina_hash_free(pm->pids_hash);
+
+   E_FREE(pm);
+   return NULL;
+
+}
+
+static void
+_e_processmgr_del(E_ProcessMgr *pm)
+{
+   E_WindowInfo   *winfo = NULL;
+   E_ProcessInfo  *pinfo = NULL;
+
+   if (!pm) return;
+
+   while (pm->wins_list)
+     {
+        winfo = (E_WindowInfo *)(pm->wins_list);
+        eina_hash_del_by_key(pm->wins_hash, &winfo->win);
+        //eina_hash_del(pm->wins_hash, &winfo->win, winfo);
+        pm->wins_list = eina_inlist_remove(pm->wins_list, EINA_INLIST_GET(winfo));
+        E_FREE(winfo);
+     }
+
+   while (pm->pids_list)
+     {
+        pinfo = (E_ProcessInfo *)(pm->pids_list);
+        eina_hash_del_by_key(pm->pids_hash, &pinfo->pid);
+        //eina_hash_del(pm->pids_hash, &pinfo->pid, pinfo);
+        pm->pids_list = eina_inlist_remove(pm->pids_list, EINA_INLIST_GET(pinfo));
+        E_FREE(pinfo);
+     }
+
+   if (pm->pids_hash)
+     {
+        eina_hash_free(pm->pids_hash);
+        pm->pids_hash = NULL;
+     }
+
+   if (pm->wins_hash)
+     {
+        eina_hash_free(pm->wins_hash);
+        pm->wins_hash = NULL;
+     }
+
+   E_FREE(pm);
+}
+
+static E_ProcessInfo *
+_e_processmgr_processinfo_find(E_ProcessMgr *pm, pid_t pid)
+{
+   if (!pm) return NULL;
+   return eina_hash_find(pm->pids_hash, &pid);
+}
+
+static Eina_Bool
+_e_processmgr_processinfo_add(pid_t pid, E_Client *ec)
+{
+   E_ProcessInfo  *pinfo = NULL;
+
+   if (pid <= 0) return EINA_FALSE;
+   if (!ec) return EINA_FALSE;
+
+   pinfo = _e_processmgr_processinfo_find(_pm, pid);
+   if (!pinfo)
+     {
+        pinfo = E_NEW(E_ProcessInfo, 1);
+        if (!pinfo) return EINA_FALSE;
+
+        pinfo->pid = pid;
+        pinfo->state = PROCESS_STATE_UNKNOWN;
+
+        eina_hash_add(_pm->pids_hash, &pid, pinfo);
+        _pm->pids_list = eina_inlist_append(_pm->pids_list, EINA_INLIST_GET(pinfo));
+     }
+
+   pinfo->wins = eina_list_append(pinfo->wins, ec);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_e_processmgr_processinfo_del(pid_t pid, E_Client *ec)
+{
+   E_ProcessInfo *pinfo = NULL;
+   Eina_List *l;
+   E_Client *temp_ec;
+   Eina_Bool found = EINA_FALSE;
+
+   if (pid <= 0) return EINA_FALSE;
+   if (!ec) return EINA_FALSE;
+
+   pinfo = _e_processmgr_processinfo_find(_pm, pid);
+   if (!pinfo) return EINA_FALSE;
+
+   EINA_LIST_FOREACH(pinfo->wins, l, temp_ec)
+     {
+        if (temp_ec == ec)
+          {
+             found = EINA_TRUE;
+             break;
+          }
+     }
+
+   if (found)
+     pinfo->wins = eina_list_remove(pinfo->wins, ec);
+
+   if (!(pinfo->wins))
+     {
+        eina_hash_del_by_key(_pm->pids_hash, &pid);
+        //eina_hash_del(_pm->pids_hash, &pid, pinfo);
+        _pm->pids_list = eina_inlist_remove(_pm->pids_list, EINA_INLIST_GET(pinfo));
+        E_FREE(pinfo);
+     }
+
+   return EINA_TRUE;
+}
+
+
+static E_WindowInfo *
+_e_processmgr_client_info_find(E_ProcessMgr *pm, E_Client *ec)
+{
+   if (!pm) return NULL;
+   return eina_hash_find(pm->wins_hash, &ec);
+}
+
+static Eina_Bool
+_e_processmgr_client_info_add(E_Client *ec)
+{
+   E_WindowInfo *winfo = NULL;
+
+   if (!ec) return EINA_FALSE;
+
+   if (_e_processmgr_client_info_find(_pm, ec))
+     return EINA_TRUE;
+
+   winfo = E_NEW(E_WindowInfo, 1);
+   if (!winfo) return EINA_FALSE;
+
+   winfo->win = ec;
+   winfo->pid = ec->netwm.pid;
+
+   eina_hash_add(_pm->wins_hash, &ec, winfo);
+   _pm->wins_list = eina_inlist_append(_pm->wins_list, EINA_INLIST_GET(winfo));
+
+   _e_processmgr_processinfo_add(winfo->pid, ec);
+
+   return EINA_TRUE;
+}
+
+static void
+_e_processmgr_client_info_del(E_Client *ec)
+{
+   E_WindowInfo *winfo = NULL;
+
+   if (!ec) return;
+
+   winfo = _e_processmgr_client_info_find(_pm, ec);
+   if (!winfo) return;
+
+   _e_processmgr_processinfo_del(winfo->pid, ec);
+
+   eina_hash_del_by_key(_pm->wins_hash, &ec);
+   //eina_hash_del(_pm->wins_hash, &ec, winfo);
+   _pm->wins_list = eina_inlist_remove(_pm->wins_list, EINA_INLIST_GET(winfo));
+
+   E_FREE(winfo);
+
+   return;
+}
+
+static Eina_Bool
+_e_processmgr_cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+   _e_processmgr_client_info_add(ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_processmgr_cb_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+   _e_processmgr_client_info_del(ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_processmgr_cb_client_iconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+
+   // check all ECs of its pid, if yes, freeze
+   if (_e_processmgr_client_freeze_condition_check(ec))
+     _e_processmgr_client_freeze(ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_processmgr_cb_client_uniconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+   _e_processmgr_client_thaw(ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_processmgr_cb_client_visibility_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+   if (ec->visibility.obscured == E_VISIBILITY_UNOBSCURED)
+     _e_processmgr_client_thaw(ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_pol_cb_hook_client_visibility(void *d EINA_UNUSED, E_Client *ec)
+{
+   if (ec->visibility.changed)
+     {
+        if (ec->visibility.obscured == E_VISIBILITY_UNOBSCURED)
+          {
+             _e_processmgr_client_thaw(ec);
+          }
+     }
+}
+
+static Eina_Bool
+_e_processmgr_client_freeze_condition_check(E_Client *ec)
+{
+   E_WindowInfo *winfo  = NULL;
+   E_ProcessInfo *pinfo  = NULL;
+   E_Client *temp_ec = NULL;
+   Eina_Bool freeze = EINA_TRUE;
+   Eina_List *l;
+
+   if (!ec) return EINA_FALSE;
+
+   winfo = _e_processmgr_client_info_find(_pm, ec);
+   if (!winfo) return EINA_FALSE;
+
+   if (winfo->pid <= 0) return EINA_FALSE;
+
+   pinfo = _e_processmgr_processinfo_find(_pm, winfo->pid);
+   if (!pinfo) return EINA_FALSE;
+
+   if (pinfo->state == PROCESS_STATE_BACKGROUND) return EINA_FALSE;
+   if (!pinfo->wins) return EINA_FALSE;
+
+   EINA_LIST_FOREACH(pinfo->wins, l, temp_ec)
+     {
+        if (!temp_ec->iconic)
+          {
+             freeze = EINA_FALSE;
+             break;
+          }
+     }
+
+   return freeze;
+}
+
+static Eina_Bool
+_e_processmgr_client_freeze(E_Client *ec)
+{
+   E_WindowInfo   *winfo  = NULL;
+   E_ProcessInfo  *pinfo  = NULL;
+
+   if (!ec) return EINA_FALSE;
+
+   winfo = _e_processmgr_client_info_find(_pm, ec);
+   if (!winfo) return EINA_FALSE;
+
+   if (winfo->pid <= 0) return EINA_FALSE;
+
+   pinfo = _e_processmgr_processinfo_find(_pm, winfo->pid);
+   if (!pinfo) return EINA_FALSE;
+
+   if (pinfo->state != PROCESS_STATE_BACKGROUND)
+     {
+        ELOGF("PROCESSMGR STATE", "PROCESS_BACKGROUND. PID:%d", NULL, NULL, winfo->pid);
+        pinfo->state = PROCESS_STATE_BACKGROUND;
+        _e_processmgr_send_pid_action(winfo->pid, PROCESS_BACKGROUND);
+     }
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_e_processmgr_client_thaw(E_Client *ec)
+{
+   E_WindowInfo   *winfo  = NULL;
+   E_ProcessInfo  *pinfo  = NULL;
+
+   if (!ec) return EINA_FALSE;
+
+   winfo = _e_processmgr_client_info_find(_pm, ec);
+   if (!winfo) return EINA_FALSE;
+
+   if (winfo->pid <= 0) return EINA_FALSE;
+
+   pinfo = _e_processmgr_processinfo_find(_pm, winfo->pid);
+   if (!pinfo) return EINA_FALSE;
+
+   if (pinfo->state != PROCESS_STATE_FOREGROUND)
+     {
+        ELOGF("PROCESSMGR STATE", "PROCESS_FOREGROUND. PID:%d", NULL, NULL, winfo->pid);
+        pinfo->state = PROCESS_STATE_FOREGROUND;
+        _e_processmgr_send_pid_action(winfo->pid, PROCESS_FOREGROUND);
+     }
+
+   return EINA_TRUE;
+}
+
+static void
+_e_processmgr_send_pid_action(int pid, E_ProcessMgr_Action act)
+{
+   Eldbus_Connection *conn;
+   Eldbus_Message *msg;
+
+   int param_pid;
+   int param_act;
+
+   conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
+   if (!conn) return;
+
+   // set up msg for resourced
+   msg = eldbus_message_signal_new("/Org/Tizen/ResourceD/Process",
+                                   "org.tizen.resourced.process",
+                                   "ProcStatus");
+   if (!msg) return;
+
+   // append the action to do and the pid to do it to
+   param_pid = (int)pid;
+   param_act = (int)act;
+
+   if (!eldbus_message_arguments_append(msg, "ii", param_pid, param_act))
+     {
+        eldbus_message_unref(msg);
+        return;
+     }
+
+   // send the message
+   if (!eldbus_connection_send(conn, msg, NULL, NULL, -1))
+     {
+        eldbus_message_unref(msg);
+        return;
+     }
+
+   eldbus_message_unref(msg);
+}
+
+
+EAPI Eina_Bool
+e_mod_processmgr_init(void)
+{
+   E_ProcessMgr *pm;
+   E_Client_Hook *hook;
+
+   if (!eldbus_init())
+     return EINA_FALSE;
+
+   pm = _e_processmgr_new();
+   if (!pm)
+     {
+        eldbus_shutdown();
+        return EINA_FALSE;
+     }
+
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ADD, _e_processmgr_cb_client_add, NULL);
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE, _e_processmgr_cb_client_remove, NULL);
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ICONIFY, _e_processmgr_cb_client_iconify, NULL);
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_UNICONIFY, _e_processmgr_cb_client_uniconify, NULL);
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_VISIBILITY_CHANGE, _e_processmgr_cb_client_visibility_change, NULL);
+
+   hook = e_client_hook_add(E_CLIENT_HOOK_EVAL_VISIBILITY, _pol_cb_hook_client_visibility, NULL);
+   if (hook) hooks_ec = eina_list_append(hooks_ec, hook);
+
+   _pm = pm;
+
+   return EINA_TRUE;
+
+}
+
+EAPI void
+e_mod_processmgr_shutdown(void)
+{
+   E_Client_Hook *hook;
+
+   if (!_pm) return;
+
+   eldbus_shutdown();
+
+   E_FREE_LIST(handlers, ecore_event_handler_del);
+   EINA_LIST_FREE(hooks_ec, hook)
+     e_client_hook_del(hook);
+
+   _e_processmgr_del(_pm);
+   _pm = NULL;
+}
+
diff --git a/src/e_mod_processmgr.h b/src/e_mod_processmgr.h
new file mode 100644 (file)
index 0000000..e6d94ed
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef E_MOD_PROCESSMGR_H
+#define E_MOD_PROCESSMGR_H
+
+typedef struct _E_Processmgr_Info E_Processmgr_Info;
+
+struct _E_Processmgr_Info
+{
+   E_Comp *comp;
+
+   Eina_Hash *clients;
+};
+
+EAPI Eina_Bool e_mod_processmgr_init(void);
+EAPI void e_mod_processmgr_shutdown(void);
+
+#endif
+
diff --git a/src/e_mod_processmgr_shared_types.h b/src/e_mod_processmgr_shared_types.h
new file mode 100644 (file)
index 0000000..2ee88c4
--- /dev/null
@@ -0,0 +1,51 @@
+#ifdef E_TYPEDEFS
+#else
+#ifndef E_MOD_PROCESSMGR_SHARED_TYPES_H
+#define E_MOD_PROCESSMGR_SHARED_TYPES_H
+
+typedef struct _E_ProcessMgr  E_ProcessMgr;
+typedef struct _E_ProcessInfo E_ProcessInfo;
+typedef struct _E_WindowInfo  E_WindowInfo;
+
+typedef enum _E_ProcessMgr_Action
+{
+   PROCESS_LAUNCH = 0,
+   PROCESS_RESUME = 1,
+   PROCESS_TERMINATE = 2,
+   PROCESS_FOREGROUND = 3,
+   PROCESS_BACKGROUND = 4
+} E_ProcessMgr_Action;
+
+typedef enum _E_Process_State
+{
+   PROCESS_STATE_UNKNOWN,
+   PROCESS_STATE_BACKGROUND,
+   PROCESS_STATE_FOREGROUND,
+} E_Process_State;
+
+struct _E_ProcessMgr
+{
+   Eina_Hash         *pids_hash;
+   Eina_Hash         *wins_hash;
+   Eina_Inlist       *pids_list;
+   Eina_Inlist       *wins_list;
+};
+
+struct _E_ProcessInfo
+{
+   EINA_INLIST;
+   int              pid;
+   Eina_List       *wins;
+   E_Process_State  state;
+   Eina_Bool        launch;
+};
+
+struct _E_WindowInfo
+{
+   EINA_INLIST;
+   E_Client      *win;
+   pid_t          pid;
+};
+
+#endif
+#endif