shell: Provide a better explanation for terminating the connection
[src/agl-compositor.git] / src / shell.c
index 2f8a722..c089bec 100644 (file)
@@ -1108,8 +1108,8 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res)
            ivi->shell_client.status == BOUND_FAILED) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
-                                      "agl_shell has already been bound. "
-                                      "Check out bound_fail event");
+                                      "agl_shell (ready quest) has already "
+                                      "been bound. Check out bound_fail event");
                return;
        }
 
@@ -1165,8 +1165,8 @@ shell_set_background(struct wl_client *client,
            ivi->shell_client.resource_ext == shell_res) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
-                                      "agl_shell has already been bound. "
-                                      "Check out bound_fail event");
+                                      "agl_shell (set_background) has already "
+                                      "been bound. Check out bound_fail event");
                return;
        }
 
@@ -1230,7 +1230,7 @@ shell_set_panel(struct wl_client *client,
            ivi->shell_client.resource_ext == shell_res) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
-                                      "agl_shell has already been bound. "
+                                      "agl_shell (set_panel) has already been bound. "
                                       "Check out bound_fail event");
                return;
        }
@@ -1622,9 +1622,8 @@ shell_set_app_output(struct wl_client *client, struct wl_resource *res,
        struct weston_output *woutput = weston_head_get_output(head);
        struct ivi_output *ioutput = to_ivi_output(woutput);
        struct ivi_surface *surf = ivi_find_app(ivi, app_id);
-       struct ivi_output *desktop_last_output = surf->desktop.last_output;
-       struct ivi_output *current_completed_output =
-               surf->current_completed_output;
+       struct ivi_output *desktop_last_output;
+       struct ivi_output *current_completed_output;
 
        if (!app_id || !ioutput)
                return;
@@ -1636,6 +1635,9 @@ shell_set_app_output(struct wl_client *client, struct wl_resource *res,
                return;
        }
 
+       desktop_last_output = surf->desktop.last_output;
+       current_completed_output = surf->current_completed_output;
+
        if (surf->remote.output)
                surf->hidden_layer_output = surf->remote.output;
        else
@@ -1664,6 +1666,35 @@ shell_set_app_output(struct wl_client *client, struct wl_resource *res,
        shell_send_app_on_output(ivi, app_id, woutput->name);
 }
 
+static void
+shell_set_app_position(struct wl_client *client, struct wl_resource *res,
+                   const char *app_id, int32_t x, int32_t y)
+{
+       struct ivi_compositor *ivi = wl_resource_get_user_data(res);
+       struct ivi_surface *surf = ivi_find_app(ivi, app_id);
+
+       if (!surf || !app_id || surf->role != IVI_SURFACE_ROLE_POPUP)
+               return;
+
+       weston_view_set_position(surf->view, x, y);
+       weston_compositor_schedule_repaint(ivi->compositor);
+}
+
+static void
+shell_set_app_scale(struct wl_client *client, struct wl_resource *res,
+                   const char *app_id, int32_t width, int32_t height)
+{
+
+       struct ivi_compositor *ivi = wl_resource_get_user_data(res);
+       struct ivi_surface *surf = ivi_find_app(ivi, app_id);
+
+       if (!surf || !app_id || surf->role != IVI_SURFACE_ROLE_POPUP)
+               return;
+
+       weston_desktop_surface_set_size(surf->dsurface, width, height);
+       weston_compositor_schedule_repaint(ivi->compositor);
+}
+
 static void
 shell_ext_destroy(struct wl_client *client, struct wl_resource *res)
 {
@@ -1692,6 +1723,8 @@ static const struct agl_shell_interface agl_shell_implementation = {
        .set_app_normal = shell_set_app_normal,
        .set_app_fullscreen = shell_set_app_fullscreen,
        .set_app_output = shell_set_app_output,
+       .set_app_position = shell_set_app_position,
+       .set_app_scale = shell_set_app_scale,
 };
 
 static const struct agl_shell_ext_interface agl_shell_ext_implementation = {
@@ -1795,18 +1828,20 @@ unbind_agl_shell(struct wl_resource *resource)
        }
 
        wl_list_for_each(output, &ivi->outputs, link) {
-               struct weston_geometry area = {};
 
                /* reset the active surf if there's one present */
                if (output->active) {
+                       struct weston_geometry area = {};
+
                        output->active->view->is_mapped = false;
                        output->active->view->surface->is_mapped = false;
 
                        weston_layer_entry_remove(&output->active->view->layer_link);
                        output->active = NULL;
+
+                       output->area_activation = area;
                }
 
-               output->area_activation = area;
                insert_black_curtain(output);
        }
 
@@ -1825,6 +1860,7 @@ unbind_agl_shell(struct wl_resource *resource)
 
        ivi->shell_client.ready = false;
        ivi->shell_client.resource = NULL;
+       ivi->shell_client.resource_ext = NULL;
        ivi->shell_client.client = NULL;
 }
 
@@ -1834,6 +1870,7 @@ unbind_agl_shell_ext(struct wl_resource *resource)
        struct ivi_compositor *ivi = wl_resource_get_user_data(resource);
 
        ivi->shell_client_ext.resource = NULL;
+       ivi->shell_client.resource_ext = NULL;
 }
 
 static void
@@ -1991,7 +2028,7 @@ int
 ivi_shell_create_global(struct ivi_compositor *ivi)
 {
        ivi->agl_shell = wl_global_create(ivi->compositor->wl_display,
-                                         &agl_shell_interface, 8,
+                                         &agl_shell_interface, 10,
                                          ivi, bind_agl_shell);
        if (!ivi->agl_shell) {
                weston_log("Failed to create wayland global.\n");