aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--windowmanager/src/windowmanager.cpp68
-rw-r--r--windowmanager/src/windowmanager.hpp5
2 files changed, 73 insertions, 0 deletions
diff --git a/windowmanager/src/windowmanager.cpp b/windowmanager/src/windowmanager.cpp
index 1f5e4c9..2768816 100644
--- a/windowmanager/src/windowmanager.cpp
+++ b/windowmanager/src/windowmanager.cpp
@@ -205,6 +205,7 @@ t_ilm_layer WindowManager::getAppLayerID(pid_t pid)
return layer_id;
}
+
void WindowManager::addSurface(t_ilm_surface surfaceId)
{
struct ilmSurfaceProperties surfaceProperties;
@@ -212,6 +213,9 @@ void WindowManager::addSurface(t_ilm_surface surfaceId)
ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
pid = surfaceProperties.creatorPid;
+#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION)
+ pid = surfPid2AppPid(pid);
+#endif
QMap<pid_t, t_ilm_surface>::const_iterator i = m_appSurfaces.find(pid);
if (i != m_appSurfaces.end() && i.value() == 0) {
@@ -238,6 +242,9 @@ t_ilm_layer WindowManager::addSurfaceToAppLayer(pid_t pid, int surfaceId)
if (pid < 0)
return 0;
+#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION)
+ pid = surfPid2AppPid(pid);
+#endif
QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(pid);
if (i == m_appLayers.end()) {
qDebug("No layer found, create new for app(pid=%d)", pid);
@@ -820,3 +827,64 @@ void WindowManager::showAppLayer(int pid)
renderLayers();
#endif
}
+
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
+
+#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION)
+bool WindowManager::otherPids(pid_t pid, pid_t &gpid, pid_t &spid)
+{
+ char buffer[60];
+ int rc;
+ FILE *f;
+
+ // get the filename
+ rc = snprintf(buffer, sizeof buffer, "/proc/%d/stat", (int)pid);
+ if (rc < 0 || rc >= (int)(sizeof buffer)) {
+ qDebug("internal unexpected error %d", rc);
+ return false;
+ }
+ // open the status file
+ f = fopen(buffer, "r");
+ if (f == NULL) {
+ qDebug("failed to open %s: %m", buffer);
+ return false;
+ }
+ // read and parse the status file
+ rc = fscanf(f, "%*d %*s %*c %*d %d %d", &gpid, &spid);
+ fclose(f);
+ if (rc != 2) {
+ qDebug("failed to parse %s: %d", buffer, rc);
+ return false;
+ }
+ qDebug("retrieved for pid=%d gpid=%d spid=%d", (int)pid, (int)gpid, (int)spid);
+ return true;
+}
+
+pid_t WindowManager::surfPid2AppPid(pid_t pid)
+{
+ pid_t gpid, spid;
+ QMap<pid_t, t_ilm_surface>::const_iterator i;
+
+ i = m_appSurfaces.find(pid);
+ if (i == m_appSurfaces.end() && otherPids(pid, gpid, spid)) {
+#if !defined(NO_PROCESS_GROUP)
+ i = m_appSurfaces.find(gpid);
+ if (i != m_appSurfaces.end()) {
+ qDebug("translate pid %d to Gpid %d", pid, gpid);
+ return gpid;
+ }
+#endif
+#if !defined(NO_PROCESS_SESSION)
+ i = m_appSurfaces.find(spid);
+ if (i != m_appSurfaces.end()) {
+ qDebug("translate pid %d to Spid %d", pid, spid);
+ return spid;
+ }
+#endif
+ }
+ return pid;
+}
+
+#endif
+
+#endif
diff --git a/windowmanager/src/windowmanager.hpp b/windowmanager/src/windowmanager.hpp
index 8b70349..7a9b297 100644
--- a/windowmanager/src/windowmanager.hpp
+++ b/windowmanager/src/windowmanager.hpp
@@ -67,6 +67,11 @@ private:
void configureHomeScreenMainSurface(const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
void configureAppSurface(const pid_t pid, const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
void renderLayers();
+
+#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION)
+ bool otherPids(pid_t pid, pid_t &gpid, pid_t &spid);
+ pid_t surfPid2AppPid(pid_t pid);
+#endif
#endif
void updateScreen();