#include <linux/input.h>
#include <cairo.h>
-#include "compositor.h"
+#include "weston/compositor.h"
#include "ivi-controller-server-protocol.h"
-#include "weston-layout.h"
+#include "ivi-layout-export.h"
struct ivishell;
struct ivilayer;
struct wl_client *client;
struct ivishell *shell;
uint32_t update_count;
- struct weston_layout_surface *layout_surface;
+ struct ivi_layout_surface *layout_surface;
struct wl_listener surface_destroy_listener;
struct wl_list list_layer;
+ uint32_t controller_surface_count;
+ int can_be_removed;
};
struct ivilayer {
struct wl_list link;
struct ivishell *shell;
- struct weston_layout_layer *layout_layer;
+ struct ivi_layout_layer *layout_layer;
struct wl_list list_screen;
+ uint32_t controller_layer_count;
+ int layer_canbe_removed;
};
struct iviscreen {
struct wl_list link;
struct ivishell *shell;
- struct weston_layout_screen *layout_screen;
+ struct ivi_layout_screen *layout_screen;
struct weston_output *output;
};
int previous_state;
int event_restriction;
};
+static void surface_event_remove(struct ivi_layout_surface *, void *);
static void
destroy_ivicontroller_surface(struct wl_resource *resource)
struct ivishell *shell = ivisurf->shell;
struct ivicontroller_surface *ctrlsurf = NULL;
struct ivicontroller_surface *next = NULL;
- uint32_t id_surface = 0;
-
- id_surface = weston_layout_getIdOfSurface(ivisurf->layout_surface);
+ int is_removed = 0;
wl_list_for_each_safe(ctrlsurf, next,
&shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
+
+ if (resource != ctrlsurf->resource) {
continue;
}
- wl_list_remove(&ctrlsurf->link);
+ if (!wl_list_empty(&ctrlsurf->link)) {
+ wl_list_remove(&ctrlsurf->link);
+ }
+
+ is_removed = 1;
free(ctrlsurf);
ctrlsurf = NULL;
+ --ivisurf->controller_surface_count;
break;
}
+
+ if ((is_removed) && (ivisurf->controller_surface_count == 0)) {
+ if (ivisurf->can_be_removed) {
+ free(ivisurf);
+ }
+ else {
+ ivisurf->can_be_removed = 1;
+ }
+ }
}
static void
struct ivicontroller_layer *next = NULL;
uint32_t id_layer = 0;
- id_layer = weston_layout_getIdOfLayer(ivilayer->layout_layer);
+ id_layer = ivi_layout_getIdOfLayer(ivilayer->layout_layer);
wl_list_for_each_safe(ctrllayer, next,
&shell->list_controller_layer, link) {
- if (id_layer != ctrllayer->id_layer) {
+
+ if (resource != ctrllayer->resource) {
continue;
}
wl_list_remove(&ctrllayer->link);
+ --ivilayer->controller_layer_count;
+ ivi_controller_layer_send_destroyed(ctrllayer->resource);
free(ctrllayer);
ctrllayer = NULL;
break;
}
+
+ if ((ivilayer->layout_layer != NULL) &&
+ (ivilayer->controller_layer_count == 0) &&
+ (ivilayer->layer_canbe_removed == 1)) {
+ ivi_layout_layerRemove(ivilayer->layout_layer);
+ }
}
static void
continue;
}
#endif
+
+ if (resource != ctrlscrn->resource) {
+ continue;
+ }
+
wl_list_remove(&ctrlscrn->link);
free(ctrlscrn);
ctrlscrn = NULL;
uint32_t ivisurf_id = 0;
wl_list_for_each(ivisurf, list_surf, link) {
- ivisurf_id = weston_layout_getIdOfSurface(ivisurf->layout_surface);
+ ivisurf_id = ivi_layout_getIdOfSurface(ivisurf->layout_surface);
if (ivisurf_id == id_surface) {
return ivisurf;
}
uint32_t ivilayer_id = 0;
wl_list_for_each(ivilayer, list_layer, link) {
- ivilayer_id = weston_layout_getIdOfLayer(ivilayer->layout_layer);
+ ivilayer_id = ivi_layout_getIdOfLayer(ivilayer->layout_layer);
if (ivilayer_id == id_layer) {
return ivilayer;
}
static void
send_surface_add_event(struct ivisurface *ivisurf,
- struct wl_resource *resource)
+ struct wl_resource *resource,
+ enum ivi_layout_notification_mask mask)
{
- weston_layout_layer_ptr *pArray = NULL;
+ struct ivi_layout_layer **pArray = NULL;
uint32_t length = 0;
int32_t ans = 0;
int i = 0;
struct ivilayer *ivilayer = NULL;
struct ivishell *shell = ivisurf->shell;
uint32_t id_layout_layer = 0;
+ struct wl_client *surface_client = wl_resource_get_client(resource);
int found = 0;
- ans = weston_layout_getLayersUnderSurface(ivisurf->layout_surface,
+ ans = ivi_layout_getLayersUnderSurface(ivisurf->layout_surface,
&length, &pArray);
if (0 != ans) {
weston_log("failed to get layers at send_surface_add_event\n");
}
/* Send Null to cancel added surface */
- wl_list_for_each_safe(link_layer, next, &ivisurf->list_layer, link) {
- for (i = 0, found = 0; i < (int)length; i++) {
- if (pArray[i] == link_layer->layer->layout_layer) {
- /* No need to send event, if new layer doesn't be added. */
- found = 1;
- break;
- }
- }
- if (found != 0) {
- continue;
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ wl_list_for_each_safe(link_layer, next, &ivisurf->list_layer, link) {
+ ivi_controller_surface_send_layer(resource, NULL);
}
-
- ivi_controller_surface_send_layer(resource, NULL);
- wl_list_remove(&link_layer->link);
- free(link_layer);
- link_layer = NULL;
}
-
- for (i = 0; i < (int)length; i++) {
- found = 0;
- wl_list_for_each(link_layer, &ivisurf->list_layer, link) {
- if (pArray[i] == link_layer->layer->layout_layer) {
- /* No need to send event, if new layer doesn't be added. */
- found = 1;
- break;
+ else if (mask & IVI_NOTIFICATION_ADD) {
+ for (i = 0; i < (int)length; i++) {
+ /* Send new surface event */
+ ivilayer = NULL;
+ wl_list_for_each(ivilayer, &shell->list_layer, link) {
+ if (ivilayer->layout_layer == pArray[i]) {
+ break;
+ }
}
- }
- if (found != -1) {
- continue;
- }
- /* Create list_layer */
- link_layer = calloc(1, sizeof(*link_layer));
- if (NULL == link_layer) {
- continue;
- }
- wl_list_init(&link_layer->link);
- link_layer->layer = NULL;
- wl_list_for_each(ivilayer, &shell->list_layer, link) {
- if (ivilayer->layout_layer == pArray[i]) {
- link_layer->layer = ivilayer;
- break;
+ if (ivilayer == NULL) {
+ continue;
}
- }
- if (link_layer->layer == NULL) {
- free(link_layer);
- link_layer = NULL;
- continue;
- }
- wl_list_insert(&ivisurf->list_layer, &link_layer->link);
+ id_layout_layer =
+ ivi_layout_getIdOfLayer(ivilayer->layout_layer);
+ wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
+ if (id_layout_layer != ctrllayer->id_layer) {
+ continue;
+ }
- /* Send new surface event */
- id_layout_layer =
- weston_layout_getIdOfLayer(link_layer->layer->layout_layer);
- wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
- if (id_layout_layer != ctrllayer->id_layer) {
- continue;
+ struct wl_client *layer_client = wl_resource_get_client(ctrllayer->resource);
+ if (surface_client != layer_client) {
+ continue;
+ }
+
+ ivi_controller_surface_send_layer(resource, ctrllayer->resource);
}
- ivi_controller_surface_send_layer(resource, ctrllayer->resource);
}
}
static void
send_surface_event(struct wl_resource *resource,
struct ivisurface *ivisurf,
- struct weston_layout_SurfaceProperties *prop,
+ struct ivi_layout_SurfaceProperties *prop,
uint32_t mask)
{
if (mask & IVI_NOTIFICATION_OPACITY) {
ivi_controller_surface_send_pixelformat(resource,
prop->pixelformat);
}
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ send_surface_add_event(ivisurf, resource, IVI_NOTIFICATION_REMOVE);
+ }
+ if (mask & IVI_NOTIFICATION_ADD) {
+ send_surface_add_event(ivisurf, resource, IVI_NOTIFICATION_ADD);
+ }
+}
+
+static void
+update_surface_prop(struct ivisurface *ivisurf,
+ uint32_t mask)
+{
+ struct ivi_layout_layer **pArray = NULL;
+ uint32_t length = 0;
+ int32_t ans = 0;
+ int i = 0;
+ struct ivishell *shell = ivisurf->shell;
+
+ ans = ivi_layout_getLayersUnderSurface(ivisurf->layout_surface,
+ &length, &pArray);
+ if (0 != ans) {
+ weston_log("failed to get layers at send_surface_add_event\n");
+ return;
+ }
+
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ struct link_layer *link_layer = NULL;
+ struct link_layer *next = NULL;
+
+ wl_list_for_each_safe(link_layer, next, &ivisurf->list_layer, link) {
+ wl_list_remove(&link_layer->link);
+ free(link_layer);
+ link_layer = NULL;
+ }
+ }
if (mask & IVI_NOTIFICATION_ADD) {
- send_surface_add_event(ivisurf, resource);
+ for (i = 0; i < (int)length; ++i) {
+ /* Create list_layer */
+ struct ivilayer *ivilayer = NULL;
+ struct link_layer *link_layer = calloc(1, sizeof(*link_layer));
+ if (NULL == link_layer) {
+ continue;
+ }
+ wl_list_init(&link_layer->link);
+ link_layer->layer = NULL;
+ wl_list_for_each(ivilayer, &shell->list_layer, link) {
+ if (ivilayer->layout_layer == pArray[i]) {
+ link_layer->layer = ivilayer;
+ break;
+ }
+ }
+
+ if (link_layer->layer == NULL) {
+ free(link_layer);
+ link_layer = NULL;
+ continue;
+ }
+
+ wl_list_insert(&ivisurf->list_layer, &link_layer->link);
+ }
}
}
static void
-send_surface_prop(struct weston_layout_surface *layout_surface,
- struct weston_layout_SurfaceProperties *prop,
- enum weston_layout_notification_mask mask,
+send_surface_prop(struct ivi_layout_surface *layout_surface,
+ struct ivi_layout_SurfaceProperties *prop,
+ enum ivi_layout_notification_mask mask,
void *userdata)
{
struct ivisurface *ivisurf = userdata;
struct ivicontroller_surface *ctrlsurf = NULL;
uint32_t id_surface = 0;
- id_surface = weston_layout_getIdOfSurface(layout_surface);
+ id_surface = ivi_layout_getIdOfSurface(layout_surface);
wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
if (id_surface != ctrlsurf->id_surface) {
}
send_surface_event(ctrlsurf->resource, ivisurf, prop, mask);
}
+
+ update_surface_prop(ivisurf, mask);
}
static void
send_layer_add_event(struct ivilayer *ivilayer,
- struct wl_resource *resource)
+ struct wl_resource *resource,
+ enum ivi_layout_notification_mask mask)
{
- weston_layout_screen_ptr *pArray = NULL;
+ struct ivi_layout_screen **pArray = NULL;
uint32_t length = 0;
int32_t ans = 0;
int i = 0;
struct link_screen *next = NULL;
struct iviscreen *iviscrn = NULL;
struct ivishell *shell = ivilayer->shell;
- int found = 0;
struct wl_client *client = wl_resource_get_client(resource);
struct wl_resource *resource_output = NULL;
- ans = weston_layout_getScreensUnderLayer(ivilayer->layout_layer,
+ ans = ivi_layout_getScreensUnderLayer(ivilayer->layout_layer,
&length, &pArray);
if (0 != ans) {
weston_log("failed to get screens at send_layer_add_event\n");
}
/* Send Null to cancel added layer */
- wl_list_for_each_safe(link_scrn, next, &ivilayer->list_screen, link) {
- for (i = 0, found = 0; i < (int)length; i++) {
- if (pArray[i] == link_scrn->screen->layout_screen) {
- /* No need to send event, if new layer doesn't be added. */
- found = 1;
- break;
- }
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ wl_list_for_each_safe(link_scrn, next, &ivilayer->list_screen, link) {
+ ivi_controller_layer_send_screen(resource, NULL);
}
- if (found != 0) {
- continue;
- }
-
- ivi_controller_layer_send_screen(resource, NULL);
- wl_list_remove(&link_scrn->link);
- free(link_scrn);
- link_scrn = NULL;
}
-
- for (i = 0; i < (int)length; i++) {
- found = 0;
- wl_list_for_each(link_scrn, &ivilayer->list_screen, link) {
- if (pArray[i] == link_scrn->screen->layout_screen) {
- /* No need to send event, if new screen doesn't be added. */
- found = 1;
- break;
+ else if (mask & IVI_NOTIFICATION_ADD) {
+ for (i = 0; i < (int)length; i++) {
+ /* Send new layer event */
+ iviscrn = NULL;
+ wl_list_for_each(iviscrn, &shell->list_screen, link) {
+ if (iviscrn->layout_screen == pArray[i]) {
+ break;
+ }
}
- }
- if (found != 0) {
- continue;
- }
- /* Create list_screen */
- link_scrn = calloc(1, sizeof(*link_scrn));
- if (NULL == link_scrn) {
- continue;
- }
- wl_list_init(&link_scrn->link);
- link_scrn->screen = NULL;
- wl_list_for_each(iviscrn, &shell->list_screen, link) {
- if (iviscrn->layout_screen == pArray[i]) {
- link_scrn->screen = iviscrn;
- break;
+ if (iviscrn == NULL) {
+ continue;
}
- }
- if (link_scrn->screen == NULL) {
- free(link_scrn);
- link_scrn = NULL;
- continue;
- }
- wl_list_insert(&ivilayer->list_screen, &link_scrn->link);
-
- /* Send new layer event */
- resource_output =
- wl_resource_find_for_client(&iviscrn->output->resource_list,
- client);
- if (resource_output != NULL) {
- ivi_controller_layer_send_screen(resource, resource_output);
+ resource_output =
+ wl_resource_find_for_client(&iviscrn->output->resource_list,
+ client);
+ if (resource_output != NULL) {
+ ivi_controller_layer_send_screen(resource, resource_output);
+ }
}
}
static void
send_layer_event(struct wl_resource *resource,
struct ivilayer *ivilayer,
- struct weston_layout_LayerProperties *prop,
+ struct ivi_layout_LayerProperties *prop,
uint32_t mask)
{
if (mask & IVI_NOTIFICATION_OPACITY) {
ivi_controller_layer_send_visibility(resource,
prop->visibility);
}
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ send_layer_add_event(ivilayer, resource, IVI_NOTIFICATION_REMOVE);
+ }
if (mask & IVI_NOTIFICATION_ADD) {
- send_layer_add_event(ivilayer, resource);
+ send_layer_add_event(ivilayer, resource, IVI_NOTIFICATION_ADD);
}
}
static void
-send_layer_prop(struct weston_layout_layer *layer,
- struct weston_layout_LayerProperties *prop,
- enum weston_layout_notification_mask mask,
+update_layer_prop(struct ivilayer *ivilayer,
+ enum ivi_layout_notification_mask mask)
+{
+ struct ivi_layout_screen **pArray = NULL;
+ uint32_t length = 0;
+ int32_t ans = 0;
+ struct link_screen *link_scrn = NULL;
+ struct link_screen *next = NULL;
+
+ ans = ivi_layout_getScreensUnderLayer(ivilayer->layout_layer,
+ &length, &pArray);
+ if (0 != ans) {
+ weston_log("failed to get screens at send_layer_add_event\n");
+ return;
+ }
+
+ /* Send Null to cancel added layer */
+ if (mask & IVI_NOTIFICATION_REMOVE) {
+ wl_list_for_each_safe(link_scrn, next, &ivilayer->list_screen, link) {
+ wl_list_remove(&link_scrn->link);
+ free(link_scrn);
+ link_scrn = NULL;
+ }
+ }
+ if (mask & IVI_NOTIFICATION_ADD) {
+ int i = 0;
+ for (i = 0; i < (int)length; i++) {
+ struct ivishell *shell = ivilayer->shell;
+ struct iviscreen *iviscrn = NULL;
+ /* Create list_screen */
+ link_scrn = calloc(1, sizeof(*link_scrn));
+ if (NULL == link_scrn) {
+ continue;
+ }
+ wl_list_init(&link_scrn->link);
+ link_scrn->screen = NULL;
+ wl_list_for_each(iviscrn, &shell->list_screen, link) {
+ if (iviscrn->layout_screen == pArray[i]) {
+ link_scrn->screen = iviscrn;
+ break;
+ }
+ }
+
+ if (link_scrn->screen == NULL) {
+ free(link_scrn);
+ link_scrn = NULL;
+ continue;
+ }
+ wl_list_insert(&ivilayer->list_screen, &link_scrn->link);
+ }
+ }
+
+ free(pArray);
+ pArray = NULL;
+}
+
+static void
+send_layer_prop(struct ivi_layout_layer *layer,
+ struct ivi_layout_LayerProperties *prop,
+ enum ivi_layout_notification_mask mask,
void *userdata)
{
struct ivilayer *ivilayer = userdata;
struct ivishell *shell = ivilayer->shell;
uint32_t id_layout_layer = 0;
- id_layout_layer = weston_layout_getIdOfLayer(layer);
+ id_layout_layer = ivi_layout_getIdOfLayer(layer);
wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
if (id_layout_layer != ctrllayer->id_layer) {
continue;
}
send_layer_event(ctrllayer->resource, ivilayer, prop, mask);
}
+
+ update_layer_prop(ivilayer, mask);
}
static void
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_surfaceSetOpacity(ivisurf->layout_surface, (float)opacity);
+ ivi_layout_surfaceSetOpacity(ivisurf->layout_surface, (float)opacity);
}
static void
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_surfaceSetSourceRectangle(ivisurf->layout_surface,
+ ivi_layout_surfaceSetSourceRectangle(ivisurf->layout_surface,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_surfaceSetDestinationRectangle(ivisurf->layout_surface,
+ ivi_layout_surfaceSetDestinationRectangle(ivisurf->layout_surface,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_surfaceSetVisibility(ivisurf->layout_surface, visibility);
+ ivi_layout_surfaceSetVisibility(ivisurf->layout_surface, visibility);
}
static void
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_surfaceSetOrientation(ivisurf->layout_surface, (uint32_t)orientation);
+ ivi_layout_surfaceSetOrientation(ivisurf->layout_surface, (uint32_t)orientation);
}
static void
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_takeSurfaceScreenshot(filename, ivisurf->layout_surface);
+ ivi_layout_takeSurfaceScreenshot(filename, ivisurf->layout_surface);
}
static void
struct wl_resource *resource,
int32_t destroy_scene_object)
{
- struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
- struct ivishell *shell = ivisurf->shell;
- struct ivicontroller_surface *ctrlsurf = NULL;
- uint32_t id_surface = weston_layout_getIdOfSurface(ivisurf->layout_surface);
(void)client;
(void)destroy_scene_object;
-
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (ctrlsurf->id_surface != id_surface) {
- continue;
- }
-
- if (!wl_list_empty(&ctrlsurf->link)) {
- wl_list_remove(&ctrlsurf->link);
- }
- wl_resource_destroy(resource);
- break;
- }
+ wl_resource_destroy(resource);
}
static void
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetSourceRectangle(ivilayer->layout_layer,
+ ivi_layout_layerSetSourceRectangle(ivilayer->layout_layer,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetDestinationRectangle(ivilayer->layout_layer,
+ ivi_layout_layerSetDestinationRectangle(ivilayer->layout_layer,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetVisibility(ivilayer->layout_layer, visibility);
+ ivi_layout_layerSetVisibility(ivilayer->layout_layer, visibility);
}
static void
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetOpacity(ivilayer->layout_layer, (float)opacity);
+ ivi_layout_layerSetOpacity(ivilayer->layout_layer, (float)opacity);
}
static void
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetOrientation(ivilayer->layout_layer, (uint32_t)orientation);
+ ivi_layout_layerSetOrientation(ivilayer->layout_layer, (uint32_t)orientation);
}
static void
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_layerSetRenderOrder(ivilayer->layout_layer, NULL, 0);
+ ivi_layout_layerSetRenderOrder(ivilayer->layout_layer, NULL, 0);
}
static void
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
struct ivisurface *ivisurf = wl_resource_get_user_data(surface);
(void)client;
- weston_layout_layerAddSurface(ivilayer->layout_layer, ivisurf->layout_surface);
+ ivi_layout_layerAddSurface(ivilayer->layout_layer, ivisurf->layout_surface);
}
static void
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
struct ivisurface *ivisurf = wl_resource_get_user_data(surface);
(void)client;
- weston_layout_layerRemoveSurface(ivilayer->layout_layer, ivisurf->layout_surface);
+ ivi_layout_layerRemoveSurface(ivilayer->layout_layer, ivisurf->layout_surface);
}
static void
struct wl_array *id_surfaces)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
- struct weston_layout_surface **layoutsurf_array = NULL;
+ struct ivi_layout_surface **layoutsurf_array = NULL;
struct ivisurface *ivisurf = NULL;
uint32_t *id_surface = NULL;
uint32_t id_layout_surface = 0;
wl_array_for_each(id_surface, id_surfaces) {
wl_list_for_each(ivisurf, &ivilayer->shell->list_surface, link) {
- id_layout_surface = weston_layout_getIdOfSurface(ivisurf->layout_surface);
+ id_layout_surface = ivi_layout_getIdOfSurface(ivisurf->layout_surface);
if (*id_surface == id_layout_surface) {
layoutsurf_array[i] = ivisurf->layout_surface;
i++;
}
}
- weston_layout_layerSetRenderOrder(ivilayer->layout_layer,
+ ivi_layout_layerSetRenderOrder(ivilayer->layout_layer,
layoutsurf_array, id_surfaces->size);
free(layoutsurf_array);
}
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
struct ivishell *shell = ivilayer->shell;
struct ivicontroller_layer *ctrllayer = NULL;
- uint32_t id_layer = weston_layout_getIdOfLayer(ivilayer->layout_layer);
+ struct ivicontroller_layer *next = NULL;
+ uint32_t id_layer = ivi_layout_getIdOfLayer(ivilayer->layout_layer);
(void)client;
(void)destroy_scene_object;
- wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
+ ivilayer->layer_canbe_removed = 1;
+ wl_list_for_each_safe(ctrllayer, next, &shell->list_controller_layer, link) {
if (ctrllayer->id_layer != id_layer) {
continue;
}
- if (!wl_list_empty(&ctrllayer->link)) {
- wl_list_remove(&ctrllayer->link);
- }
- wl_resource_destroy(resource);
- break;
+ wl_resource_destroy(ctrllayer->resource);
}
-
- weston_layout_layerRemove(ivilayer->layout_layer);
}
static const
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
struct ivicontroller_screen *ctrlscrn = NULL;
struct ivicontroller_screen *next = NULL;
-// uint32_t id_screen = weston_layout_getIdOfScreen(iviscrn->layout_screen);
+// uint32_t id_screen = ivi_layout_getIdOfScreen(iviscrn->layout_screen);
(void)client;
wl_list_for_each_safe(ctrlscrn, next,
&iviscrn->shell->list_controller_screen, link) {
-// TODO : Only Single display
- destroy_ivicontroller_screen(ctrlscrn->resource);
+ if (resource != ctrlscrn->resource) {
+ continue;
+ }
+
+ wl_list_remove(&ctrlscrn->link);
+ free(ctrlscrn);
+ ctrlscrn = NULL;
wl_resource_destroy(ctrlscrn->resource);
break;
}
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_screenSetRenderOrder(iviscrn->layout_screen, NULL, 0);
+ ivi_layout_screenSetRenderOrder(iviscrn->layout_screen, NULL, 0);
}
static void
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
struct ivilayer *ivilayer = wl_resource_get_user_data(layer);
(void)client;
- weston_layout_screenAddLayer(iviscrn->layout_screen, ivilayer->layout_layer);
+ ivi_layout_screenAddLayer(iviscrn->layout_screen, ivilayer->layout_layer);
}
static void
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
(void)client;
- weston_layout_takeScreenshot(iviscrn->layout_screen, filename);
+ ivi_layout_takeScreenshot(iviscrn->layout_screen, filename);
}
static void
struct wl_array *id_layers)
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
- struct weston_layout_layer **layoutlayer_array = NULL;
+ struct ivi_layout_layer **layoutlayer_array = NULL;
struct ivilayer *ivilayer = NULL;
uint32_t *id_layer = NULL;
uint32_t id_layout_layer = 0;
int i = 0;
(void)client;
- *layoutlayer_array = (struct weston_layout_layer*)calloc(
+ *layoutlayer_array = (struct ivi_layout_layer*)calloc(
id_layers->size, sizeof(void*));
wl_array_for_each(id_layer, id_layers) {
wl_list_for_each(ivilayer, &iviscrn->shell->list_layer, link) {
- id_layout_layer = weston_layout_getIdOfLayer(ivilayer->layout_layer);
+ id_layout_layer = ivi_layout_getIdOfLayer(ivilayer->layout_layer);
if (*id_layer == id_layout_layer) {
layoutlayer_array[i] = ivilayer->layout_layer;
i++;
}
}
- weston_layout_screenSetRenderOrder(iviscrn->layout_screen,
+ ivi_layout_screenSetRenderOrder(iviscrn->layout_screen,
layoutlayer_array, id_layers->size);
free(layoutlayer_array);
}
(void)client;
(void)resource;
- ans = weston_layout_commitChanges();
+ ans = ivi_layout_commitChanges();
if (ans < 0) {
weston_log("Failed to commit changes at controller_commit_changes\n");
}
{
struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
struct ivishell *shell = ctrl->shell;
- struct weston_layout_layer *layout_layer = NULL;
+ struct ivi_layout_layer *layout_layer = NULL;
struct ivicontroller_layer *ctrllayer = NULL;
struct ivilayer *ivilayer = NULL;
- struct weston_layout_LayerProperties prop;
+ struct ivi_layout_LayerProperties prop;
ivilayer = get_layer(&shell->list_layer, id_layer);
if (ivilayer == NULL) {
- layout_layer = weston_layout_layerCreateWithDimension(id_layer,
+ layout_layer = ivi_layout_layerCreateWithDimension(id_layer,
(uint32_t)width, (uint32_t)height);
if (layout_layer == NULL) {
weston_log("id_layer is already created\n");
return;
}
+ ++ivilayer->controller_layer_count;
+ ivilayer->layer_canbe_removed = 0;
+
ctrllayer->shell = shell;
ctrllayer->client = client;
ctrllayer->id = id;
memset(&prop, 0, sizeof prop);
- weston_layout_getPropertiesOfLayer(ivilayer->layout_layer, &prop);
+ ivi_layout_getPropertiesOfLayer(ivilayer->layout_layer, &prop);
+ send_layer_event(ctrllayer->resource, ivilayer,
+ &prop, IVI_NOTIFICATION_ALL);
+}
- wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
- if (id_layer != ctrllayer->id_layer) {
- continue;
- }
- send_layer_event(ctrllayer->resource, ivilayer,
- &prop, IVI_NOTIFICATION_ALL);
+static void
+surface_event_content(struct ivi_layout_surface *layout_surface, int32_t content, void *userdata)
+{
+ struct ivishell *shell = userdata;
+ struct ivicontroller_surface *ctrlsurf = NULL;
+ uint32_t id_surface = 0;
+
+ if (content == 0) {
+ surface_event_remove(layout_surface, userdata);
}
}
struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
struct ivishell *shell = ctrl->shell;
struct ivicontroller_surface *ctrlsurf = NULL;
- struct weston_layout_SurfaceProperties prop;
+ struct ivi_layout_SurfaceProperties prop;
struct ivisurface *ivisurf = NULL;
ctrlsurf = calloc(1, sizeof *ctrlsurf);
return;
}
+ ++ivisurf->controller_surface_count;
+
wl_resource_set_implementation(ctrlsurf->resource,
&controller_surface_implementation,
ivisurf, destroy_ivicontroller_surface);
memset(&prop, 0, sizeof prop);
- weston_layout_getPropertiesOfSurface(ivisurf->layout_surface, &prop);
+ ivi_layout_getPropertiesOfSurface(ivisurf->layout_surface, &prop);
+ ivi_layout_surfaceSetContentObserver(ivisurf->layout_surface, surface_event_content, shell);
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
- }
- send_surface_event(ctrlsurf->resource, ivisurf,
- &prop, IVI_NOTIFICATION_ALL);
- }
+ send_surface_event(ctrlsurf->resource, ivisurf,
+ &prop, IVI_NOTIFICATION_ALL);
}
static const struct ivi_controller_interface controller_implementation = {
uint32_t id_layout_surface = 0;
uint32_t id_layout_layer = 0;
- wl_list_for_each(ivisurf, &shell->list_surface, link) {
- id_layout_surface =
- weston_layout_getIdOfSurface(ivisurf->layout_surface);
-
- ivi_controller_send_surface(controller->resource,
- id_layout_surface);
- }
-
- wl_list_for_each(ivilayer, &shell->list_layer, link) {
- id_layout_layer =
- weston_layout_getIdOfLayer(ivilayer->layout_layer);
-
- ivi_controller_send_layer(controller->resource,
- id_layout_layer);
- }
-
wl_list_for_each(iviscrn, &shell->list_screen, link) {
resource_output = wl_resource_find_for_client(
&iviscrn->output->resource_list, client);
wl_resource_get_id(resource_output),
ctrlscrn->resource);
}
+ wl_list_for_each_reverse(ivilayer, &shell->list_layer, link) {
+ id_layout_layer =
+ ivi_layout_getIdOfLayer(ivilayer->layout_layer);
+
+ ivi_controller_send_layer(controller->resource,
+ id_layout_layer);
+ }
+ wl_list_for_each_reverse(ivisurf, &shell->list_surface, link) {
+ id_layout_surface =
+ ivi_layout_getIdOfSurface(ivisurf->layout_surface);
+
+ ivi_controller_send_surface(controller->resource,
+ id_layout_surface);
+ }
}
static void
iviscrn->output = output;
// TODO : Only Single display
- iviscrn->layout_screen = weston_layout_getScreenFromId(0);
+ iviscrn->layout_screen = ivi_layout_getScreenFromId(0);
wl_list_init(&iviscrn->link);
return iviscrn;
}
-static void
-layer_event_create(struct weston_layout_layer *layout_layer,
- void *userdata)
+static struct ivilayer*
+create_layer(struct ivishell *shell,
+ struct ivi_layout_layer *layout_layer,
+ uint32_t id_layer)
{
- struct ivishell *shell = userdata;
- struct ivicontroller *controller = NULL;
struct ivilayer *ivilayer = NULL;
- uint32_t id_layer = 0;
+ struct ivicontroller *controller = NULL;
- id_layer = weston_layout_getIdOfLayer(layout_layer);
+ ivilayer = get_layer(&shell->list_layer, id_layer);
+ if (ivilayer != NULL) {
+ weston_log("id_layer is already created\n");
+ return NULL;
+ }
ivilayer = calloc(1, sizeof *ivilayer);
- if (!ivilayer) {
+ if (NULL == ivilayer) {
weston_log("no memory to allocate client layer\n");
- return;
+ return NULL;
}
ivilayer->shell = shell;
wl_list_insert(&shell->list_layer, &ivilayer->link);
ivilayer->layout_layer = layout_layer;
- weston_layout_layerAddNotification(layout_layer, send_layer_prop, ivilayer);
+ ivi_layout_layerAddNotification(layout_layer, send_layer_prop, ivilayer);
wl_list_for_each(controller, &shell->list_controller, link) {
ivi_controller_send_layer(controller->resource, id_layer);
}
- return;
+ return ivilayer;
+}
+
+static struct ivisurface*
+create_surface(struct ivishell *shell,
+ struct ivi_layout_surface *layout_surface,
+ uint32_t id_surface)
+{
+ struct ivisurface *ivisurf = NULL;
+ struct ivicontroller *controller = NULL;
+
+ ivisurf = get_surface(&shell->list_surface, id_surface);
+ if (ivisurf != NULL) {
+ weston_log("id_surface is already created\n");
+ return NULL;
+ }
+
+ ivisurf = calloc(1, sizeof *ivisurf);
+ if (ivisurf == NULL) {
+ weston_log("no memory to allocate client surface\n");
+ return NULL;
+ }
+
+ ivisurf->shell = shell;
+ ivisurf->layout_surface = layout_surface;
+ wl_list_init(&ivisurf->list_layer);
+ wl_list_init(&ivisurf->link);
+ wl_list_insert(&shell->list_surface, &ivisurf->link);
+
+ wl_list_for_each(controller, &shell->list_controller, link) {
+ ivi_controller_send_surface(controller->resource,
+ id_surface);
+ }
+
+ ivi_layout_surfaceAddNotification(layout_surface,
+ send_surface_prop, ivisurf);
+
+ return ivisurf;
+}
+
+static void
+layer_event_create(struct ivi_layout_layer *layout_layer,
+ void *userdata)
+{
+ struct ivishell *shell = userdata;
+ struct ivilayer *ivilayer = NULL;
+ uint32_t id_layer = 0;
+
+ id_layer = ivi_layout_getIdOfLayer(layout_layer);
+
+ ivilayer = create_layer(shell, layout_layer, id_layer);
+ if (ivilayer == NULL) {
+ weston_log("failed to create layer");
+ return;
+ }
}
static void
-layer_event_remove(struct weston_layout_layer *layout_layer,
+layer_event_remove(struct ivi_layout_layer *layout_layer,
void *userdata)
{
struct ivishell *shell = userdata;
struct ivilayer *ivilayer = NULL;
struct ivilayer *next = NULL;
uint32_t id_layer = 0;
+ int is_removed = 0;
wl_list_for_each_safe(ivilayer, next, &shell->list_layer, link) {
if (layout_layer != ivilayer->layout_layer) {
}
wl_list_remove(&ivilayer->link);
+
+ is_removed = 1;
free(ivilayer);
ivilayer = NULL;
break;
}
- id_layer = weston_layout_getIdOfLayer(layout_layer);
+ if (is_removed) {
+ id_layer = ivi_layout_getIdOfLayer(layout_layer);
- wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
- if (id_layer != ctrllayer->id_layer) {
- continue;
+ wl_list_for_each(ctrllayer, &shell->list_controller_layer, link) {
+ if (id_layer != ctrllayer->id_layer) {
+ continue;
+ }
+ ivi_controller_layer_send_destroyed(ctrllayer->resource);
}
- ivi_controller_layer_send_destroyed(ctrllayer->resource);
}
}
static void
-surface_event_create(struct weston_layout_surface *layout_surface,
+surface_event_create(struct ivi_layout_surface *layout_surface,
void *userdata)
{
struct ivishell *shell = userdata;
struct ivisurface *ivisurf = NULL;
- struct ivicontroller *controller = NULL;
uint32_t id_surface = 0;
- id_surface = weston_layout_getIdOfSurface(layout_surface);
+ id_surface = ivi_layout_getIdOfSurface(layout_surface);
- ivisurf = get_surface(&shell->list_surface, id_surface);
- if (ivisurf != NULL)
- {
- weston_log("id_surface is already created\n");
- return;
- }
-
- ivisurf = calloc(1, sizeof *ivisurf);
+ ivisurf = create_surface(shell, layout_surface, id_surface);
if (ivisurf == NULL) {
- weston_log("no memory to allocate client surface\n");
+ weston_log("failed to create surface");
return;
}
-
- ivisurf->shell = shell;
- ivisurf->layout_surface = layout_surface;
- wl_list_init(&ivisurf->list_layer);
- wl_list_init(&ivisurf->link);
- wl_list_insert(&shell->list_surface, &ivisurf->link);
-
- wl_list_for_each(controller, &shell->list_controller, link) {
- ivi_controller_send_surface(controller->resource,
- id_surface);
- }
-
- weston_layout_surfaceAddNotification(layout_surface,
- &send_surface_prop, ivisurf);
-
}
static void
-surface_event_remove(struct weston_layout_surface *layout_surface,
+surface_event_remove(struct ivi_layout_surface *layout_surface,
void *userdata)
{
struct ivishell *shell = userdata;
struct ivisurface *ivisurf = NULL;
struct ivisurface *next = NULL;
uint32_t id_surface = 0;
+ int is_removed = 0;
wl_list_for_each_safe(ivisurf, next, &shell->list_surface, link) {
if (layout_surface != ivisurf->layout_surface) {
}
wl_list_remove(&ivisurf->link);
- free(ivisurf);
- ivisurf = NULL;
+ is_removed = 1;
+
+ if (ivisurf->controller_surface_count == 0) {
+ free(ivisurf);
+ }
+ else {
+ ivisurf->can_be_removed = 1;
+ }
+
break;
}
- id_surface = weston_layout_getIdOfSurface(layout_surface);
+ if (is_removed) {
+ id_surface = ivi_layout_getIdOfSurface(layout_surface);
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
+ wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
+ if (id_surface != ctrlsurf->id_surface) {
+ continue;
+ }
+ ivi_controller_surface_send_destroyed(ctrlsurf->resource);
}
- ivi_controller_surface_send_destroyed(ctrlsurf->resource);
}
}
static void
-surface_event_configure(struct weston_layout_surface *layout_surface,
+surface_event_configure(struct ivi_layout_surface *layout_surface,
void *userdata)
{
struct ivishell *shell = userdata;
struct ivisurface *ivisurf = NULL;
struct ivicontroller_surface *ctrlsurf = NULL;
- struct weston_layout_SurfaceProperties prop;
+ struct ivi_layout_SurfaceProperties prop;
uint32_t id_surface = 0;
- id_surface = weston_layout_getIdOfSurface(layout_surface);
+ id_surface = ivi_layout_getIdOfSurface(layout_surface);
ivisurf = get_surface(&shell->list_surface, id_surface);
if (ivisurf == NULL) {
}
memset(&prop, 0, sizeof prop);
- weston_layout_getPropertiesOfSurface(layout_surface, &prop);
+ ivi_layout_getPropertiesOfSurface(layout_surface, &prop);
wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
if (id_surface != ctrlsurf->id_surface) {
}
}
+static int32_t
+check_layout_layers(struct ivishell *shell)
+{
+ struct ivi_layout_layer **pArray = NULL;
+ struct ivilayer *ivilayer = NULL;
+ uint32_t id_layer = 0;
+ uint32_t length = 0;
+ uint32_t i = 0;
+ int32_t ret = 0;
+
+ ret = ivi_layout_getLayers(&length, &pArray);
+ if(ret != 0) {
+ weston_log("failed to get layers at check_layout_layers\n");
+ return -1;
+ }
+
+ if (length == 0) {
+ /* if length is 0, pArray doesn't need to free.*/
+ return 0;
+ }
+
+ for (i = 0; i < length; i++) {
+ id_layer = ivi_layout_getIdOfLayer(pArray[i]);
+ ivilayer = create_layer(shell, pArray[i], id_layer);
+ if (ivilayer == NULL) {
+ weston_log("failed to create layer");
+ }
+ }
+
+ free(pArray);
+ pArray = NULL;
+
+ return 0;
+}
+
+static int32_t
+check_layout_surfaces(struct ivishell *shell)
+{
+ struct ivi_layout_surface **pArray = NULL;
+ struct ivisurface *ivisurf = NULL;
+ uint32_t id_surface = 0;
+ uint32_t length = 0;
+ uint32_t i = 0;
+ int32_t ret = 0;
+
+ ret = ivi_layout_getSurfaces(&length, &pArray);
+ if(ret != 0) {
+ weston_log("failed to get surfaces at check_layout_surfaces\n");
+ return -1;
+ }
+
+ if (length == 0) {
+ /* if length is 0, pArray doesn't need to free.*/
+ return 0;
+ }
+
+ for (i = 0; i < length; i++) {
+ id_surface = ivi_layout_getIdOfSurface(pArray[i]);
+ ivisurf = create_surface(shell, pArray[i], id_surface);
+ if (ivisurf == NULL) {
+ weston_log("failed to create surface");
+ }
+ }
+
+ free(pArray);
+ pArray = NULL;
+
+ return 0;
+}
+
static void
init_ivi_shell(struct weston_compositor *ec, struct ivishell *shell)
{
struct weston_output *output = NULL;
struct iviscreen *iviscrn = NULL;
+ int32_t ret = 0;
+
shell->compositor = ec;
- wl_list_init(&ec->layer_list);
wl_list_init(&shell->list_surface);
wl_list_init(&shell->list_layer);
wl_list_init(&shell->list_screen);
}
}
- weston_layout_setNotificationCreateLayer(layer_event_create, shell);
- weston_layout_setNotificationRemoveLayer(layer_event_remove, shell);
+ ret = check_layout_layers(shell);
+ if (ret != 0) {
+ weston_log("failed to check_layout_layers");
+ }
+
+ ret = check_layout_surfaces(shell);
+ if (ret != 0) {
+ weston_log("failed to check_layout_surfaces");
+ }
+
+ ivi_layout_addNotificationCreateLayer(layer_event_create, shell);
+ ivi_layout_addNotificationRemoveLayer(layer_event_remove, shell);
- weston_layout_setNotificationCreateSurface(surface_event_create, shell);
- weston_layout_setNotificationRemoveSurface(surface_event_remove, shell);
- weston_layout_setNotificationConfigureSurface(surface_event_configure, shell);
+ ivi_layout_addNotificationCreateSurface(surface_event_create, shell);
+ ivi_layout_addNotificationRemoveSurface(surface_event_remove, shell);
+ ivi_layout_addNotificationConfigureSurface(surface_event_configure, shell);
}
WL_EXPORT int