downstream: ivi-shell: add get_wl_shell_info() function
authorJanos Kovacs <jankovac503@gmail.com>
Mon, 21 Jul 2014 21:05:54 +0000 (00:05 +0300)
committerJanos Kovacs <jankovac503@gmail.com>
Wed, 10 Dec 2014 14:28:04 +0000 (16:28 +0200)
get_wl_shell_info() is meant to be used by controllers
to access shell related data such as pid of the surface
creator and the title of the surface.

Change-Id: I8aa9090ba9e655e87d02d07e8f6bad2792db3149
Signed-off-by: Janos Kovacs <jankovac503@gmail.com>
ivi-shell/ivi-shell.c
ivi-shell/ivi-shell.h

index 5e016f1..9b1741a 100644 (file)
@@ -42,6 +42,8 @@
 #include <limits.h>
 #include <assert.h>
 
+#include <wayland-server.h>
+
 #include "ivi-shell.h"
 #include "ivi-shell-ext.h"
 #include "ivi-application-server-protocol.h"
@@ -580,6 +582,42 @@ send_wl_shell_info(int32_t pid, const char *window_title, struct weston_surface
        }
 }
 
+WL_EXPORT void
+get_wl_shell_info(struct ivi_layout_surface *layout_surface, uint32_t id_surface,
+                  int32_t *pid_ret, const char **window_title_ret)
+{
+    struct weston_surface *surface;
+    struct wl_array shsurflist;
+    struct shell_surface **shsurface;
+    pid_t pid;
+    uid_t uid;
+    gid_t gid;
+
+    *pid_ret = 0;
+    *window_title_ret = "";
+
+    if (layout_surface != NULL && id_surface > 0) {
+      surface = get_shell_instance()->ivi_layout->get_weston_surface(layout_surface);
+
+        if (surface != NULL && surface->resource != NULL && surface->resource->client != NULL) {
+            wl_client_get_credentials(surface->resource->client, &pid, &uid, &gid);
+
+            *pid_ret = pid;
+
+            ivi_shell_get_shell_surfaces(&shsurflist);
+
+            wl_array_for_each(shsurface, &shsurflist) {
+                if (surface == shell_surface_get_surface(*shsurface)) {
+                    *window_title_ret = shell_surface_get_title(*shsurface);
+                    break;
+                }
+            }
+
+            wl_array_release(&shsurflist);
+        }
+    }
+}
+
 /*
  * Initialization of ivi-shell.
  */
index 5d15175..e47264a 100644 (file)
@@ -68,3 +68,7 @@ input_panel_destroy(struct ivi_shell *shell);
 
 WL_EXPORT void
 send_wl_shell_info(int32_t pid, const char *window_title, struct weston_surface *surface);
+
+WL_EXPORT void
+get_wl_shell_info(struct ivi_layout_surface *layout_surface, uint32_t id_surface,
+                  int32_t *pid_ret, const char **window_title_ret);