desktop-shell: Implement set_title, set_class, set_appid
authorJaehoon Jeong <jh01.j@samsung.com>
Wed, 8 Jul 2015 05:10:15 +0000 (14:10 +0900)
committerJaehoon Jeong <jh01.j@samsung.com>
Thu, 16 Jul 2015 06:06:56 +0000 (15:06 +0900)
    - In wl_shell_surface.set_class(), the surface class identifies the general
      class of applications to which the surface belongs.
      So we can use it for xdg_surface's app_id as application identifier.

Change-Id: I31a4362d0da141cc06f971736c79aa7e680ff6ad

desktop-shell/src/desktop-shell-internal.h
desktop-shell/src/shell-surface.c
desktop-shell/src/wl-shell.c
desktop-shell/src/xdg-shell.c

index 940ced8..38a345b 100644 (file)
@@ -124,6 +124,12 @@ get_shsurf_from_surface(pepper_surface_t *surface, desktop_shell_t *shell);
 void
 set_shsurf_to_surface(pepper_surface_t *surface, shell_surface_t *shsurf);
 
+pepper_bool_t
+shell_surface_set_title(shell_surface_t *shsurf, const char* title);
+
+pepper_bool_t
+shell_surface_set_class(shell_surface_t *shsurf, const char* class_);
+
 void
 shell_surface_set_toplevel(shell_surface_t *shsurf);
 
index fa8f38d..5859a4c 100644 (file)
@@ -309,3 +309,31 @@ shell_surface_set_parent(shell_surface_t *shsurf, pepper_surface_t *parent)
             wl_list_insert(&parent_shsurf->child_list, &shsurf->parent_link);
     }
 }
+
+pepper_bool_t
+shell_surface_set_title(shell_surface_t *shsurf, const char* title)
+{
+    if (shsurf->title)
+        free(shsurf->title);
+
+    shsurf->title = strdup(title);
+
+    if (!shsurf->title)
+        return PEPPER_FALSE;
+
+    return PEPPER_TRUE;
+}
+
+pepper_bool_t
+shell_surface_set_class(shell_surface_t *shsurf, const char* class_)
+{
+    if (shsurf->class_)
+        free(shsurf->class_);
+
+    shsurf->class_ = strdup(class_);
+
+    if (!shsurf->class_)
+        return PEPPER_FALSE;
+
+    return PEPPER_TRUE;
+}
index e3b5b3e..b109d82 100644 (file)
@@ -65,13 +65,7 @@ wl_shell_surface_set_title(struct wl_client *client, struct wl_resource *resourc
 {
     shell_surface_t *shsurf = wl_resource_get_user_data(resource);
 
-    if (shsurf->title)
-        free(shsurf->title);
-
-    shsurf->title = strdup(title);
-
-    if (!shsurf->title)
-        wl_client_post_no_memory(client);
+    shell_surface_set_title(shsurf, title);
 }
 
 static void
@@ -80,13 +74,7 @@ wl_shell_surface_set_class(struct wl_client *client, struct wl_resource *resourc
 {
     shell_surface_t *shsurf = wl_resource_get_user_data(resource);
 
-    if (shsurf->class_)
-        free(shsurf->class_);
-
-    shsurf->class_ = strdup(class_);
-
-    if (!shsurf->class_)
-        wl_client_post_no_memory(client);
+    shell_surface_set_class(shsurf, class_);
 }
 
 static const struct wl_shell_surface_interface shell_surface_implementation =
index 3374829..4c4f13c 100644 (file)
@@ -21,7 +21,9 @@ xdg_surface_set_app_id(struct wl_client     *client,
                        struct wl_resource   *resource,
                        const char           *app_id)
 {
-    /* TODO: */
+    shell_surface_t *shsurf = wl_resource_get_user_data(resource);
+
+    shell_surface_set_class(shsurf, app_id);
 }
 
 static void
@@ -40,7 +42,9 @@ xdg_surface_set_title(struct wl_client      *client,
                       struct wl_resource    *resource,
                       const char            *title)
 {
-    /* TODO: */
+    shell_surface_t *shsurf = wl_resource_get_user_data(resource);
+
+    shell_surface_set_title(shsurf, title);
 }
 
 static void