From 5c7c48e38d5eded67079f44ab6879f845a029aa6 Mon Sep 17 00:00:00 2001 From: Jaehoon Jeong Date: Wed, 8 Jul 2015 14:10:15 +0900 Subject: [PATCH] desktop-shell: Implement set_title, set_class, set_appid - 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 | 6 ++++++ desktop-shell/src/shell-surface.c | 28 ++++++++++++++++++++++++++++ desktop-shell/src/wl-shell.c | 16 ++-------------- desktop-shell/src/xdg-shell.c | 8 ++++++-- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/desktop-shell/src/desktop-shell-internal.h b/desktop-shell/src/desktop-shell-internal.h index 940ced8..38a345b 100644 --- a/desktop-shell/src/desktop-shell-internal.h +++ b/desktop-shell/src/desktop-shell-internal.h @@ -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); diff --git a/desktop-shell/src/shell-surface.c b/desktop-shell/src/shell-surface.c index fa8f38d..5859a4c 100644 --- a/desktop-shell/src/shell-surface.c +++ b/desktop-shell/src/shell-surface.c @@ -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; +} diff --git a/desktop-shell/src/wl-shell.c b/desktop-shell/src/wl-shell.c index e3b5b3e..b109d82 100644 --- a/desktop-shell/src/wl-shell.c +++ b/desktop-shell/src/wl-shell.c @@ -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 = diff --git a/desktop-shell/src/xdg-shell.c b/desktop-shell/src/xdg-shell.c index 3374829..4c4f13c 100644 --- a/desktop-shell/src/xdg-shell.c +++ b/desktop-shell/src/xdg-shell.c @@ -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 -- 2.7.4