2 * Copyright © 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "ivi-compositor.h"
28 #include "shared/helpers.h"
33 #include <libweston/libweston.h>
34 #include <libweston-desktop/libweston-desktop.h>
36 #include "agl-shell-desktop-server-protocol.h"
38 #define AGL_COMP_DEBUG
40 static const char *ivi_roles_as_string[] = {
41 [IVI_SURFACE_ROLE_NONE] = "NONE",
42 [IVI_SURFACE_ROLE_BACKGROUND] = "BACKGROUND",
43 [IVI_SURFACE_ROLE_PANEL] = "PANEL",
44 [IVI_SURFACE_ROLE_DESKTOP] = "DESKTOP",
45 [IVI_SURFACE_ROLE_POPUP] = "POPUP",
46 [IVI_SURFACE_ROLE_SPLIT_H] = "SPLIT_H",
47 [IVI_SURFACE_ROLE_SPLIT_V] = "SPLIT_V",
48 [IVI_SURFACE_ROLE_FULLSCREEN] = "FULLSCREEN",
49 [IVI_SURFACE_ROLE_REMOTE] = "REMOTE",
53 ivi_layout_get_surface_role_name(struct ivi_surface *surf)
55 if (surf->role < 0 || surf->role >= ARRAY_LENGTH(ivi_roles_as_string))
56 return " unknown surface role";
58 return ivi_roles_as_string[surf->role];
62 ivi_background_init(struct ivi_compositor *ivi, struct ivi_output *output)
64 struct weston_output *woutput = output->output;
65 struct ivi_surface *bg = output->background;
66 struct weston_view *view;
69 weston_log("WARNING: Output does not have a background\n");
73 assert(bg->role == IVI_SURFACE_ROLE_BACKGROUND);
77 weston_view_set_output(view, woutput);
78 weston_view_set_position(view, woutput->x, woutput->y);
80 weston_log("(background) position view %p, x %d, y %d, on output %s\n", view,
81 woutput->x, woutput->y, output->name);
83 view->is_mapped = true;
84 view->surface->is_mapped = true;
86 weston_layer_entry_insert(&ivi->background.view_list, &view->layer_link);
90 ivi_panel_init(struct ivi_compositor *ivi, struct ivi_output *output,
91 struct ivi_surface *panel)
93 struct weston_output *woutput = output->output;
94 struct weston_desktop_surface *dsurface;
95 struct weston_view *view;
96 struct weston_geometry geom;
103 assert(panel->role == IVI_SURFACE_ROLE_PANEL);
104 dsurface = panel->dsurface;
106 geom = weston_desktop_surface_get_geometry(dsurface);
108 weston_log("(panel) geom.width %d, geom.height %d, geom.x %d, geom.y %d\n",
109 geom.width, geom.height, geom.x, geom.y);
111 switch (panel->panel.edge) {
112 case AGL_SHELL_EDGE_TOP:
113 output->area.y += geom.height;
114 output->area.height -= geom.height;
116 case AGL_SHELL_EDGE_BOTTOM:
117 y += woutput->height - geom.height;
118 output->area.height -= geom.height;
120 case AGL_SHELL_EDGE_LEFT:
121 output->area.x += geom.width;
122 output->area.width -= geom.width;
124 case AGL_SHELL_EDGE_RIGHT:
125 x += woutput->width - geom.width;
126 output->area.width -= geom.width;
133 weston_view_set_output(view, woutput);
134 weston_view_set_position(view, x, y);
136 weston_log("(panel) edge %d position view %p, x %d, y %d\n",
137 panel->panel.edge, view, x, y);
139 view->is_mapped = true;
140 view->surface->is_mapped = true;
142 weston_log("panel type %d inited on output %s\n", panel->panel.edge,
145 weston_layer_entry_insert(&ivi->panel.view_list, &view->layer_link);
149 * Initializes all static parts of the layout, i.e. the background and panels.
152 ivi_layout_init(struct ivi_compositor *ivi, struct ivi_output *output)
154 ivi_background_init(ivi, output);
158 output->area.width = output->output->width;
159 output->area.height = output->output->height;
161 ivi_panel_init(ivi, output, output->top);
162 ivi_panel_init(ivi, output, output->bottom);
163 ivi_panel_init(ivi, output, output->left);
164 ivi_panel_init(ivi, output, output->right);
166 weston_compositor_schedule_repaint(ivi->compositor);
168 weston_log("Usable area: %dx%d+%d,%d\n",
169 output->area.width, output->area.height,
170 output->area.x, output->area.y);
174 ivi_find_app(struct ivi_compositor *ivi, const char *app_id)
176 struct ivi_surface *surf;
179 wl_list_for_each(surf, &ivi->surfaces, link) {
180 id = weston_desktop_surface_get_app_id(surf->dsurface);
181 if (id && strcmp(app_id, id) == 0)
189 ivi_layout_activate_complete(struct ivi_output *output,
190 struct ivi_surface *surf)
192 struct ivi_compositor *ivi = output->ivi;
193 struct weston_output *woutput = output->output;
194 struct weston_view *view = surf->view;
196 if (weston_view_is_mapped(view)) {
197 weston_layer_entry_remove(&view->layer_link);
200 weston_view_set_output(view, woutput);
201 weston_view_set_position(view,
202 woutput->x + output->area.x,
203 woutput->y + output->area.y);
205 view->is_mapped = true;
206 view->surface->is_mapped = true;
208 if (output->active) {
209 output->active->view->is_mapped = false;
210 output->active->view->surface->is_mapped = false;
212 weston_layer_entry_remove(&output->active->view->layer_link);
214 output->previous_active = output->active;
215 output->active = surf;
217 weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
218 weston_view_geometry_dirty(view);
219 weston_surface_damage(view->surface);
222 * the 'remote' role now makes use of this part so make sure we don't
223 * trip the enum such that we might end up with a modified output for
226 if (surf->role == IVI_SURFACE_ROLE_DESKTOP) {
227 if (surf->desktop.pending_output)
228 surf->desktop.last_output = surf->desktop.pending_output;
229 surf->desktop.pending_output = NULL;
232 weston_log("Activation completed for app_id %s, role %s, output %s\n",
233 weston_desktop_surface_get_app_id(surf->dsurface),
234 ivi_layout_get_surface_role_name(surf), output->name);
238 ivi_layout_find_with_app_id(const char *app_id, struct ivi_compositor *ivi)
240 struct ivi_output *out;
245 wl_list_for_each(out, &ivi->outputs, link) {
249 if (!strcmp(app_id, out->app_id))
257 static struct ivi_output *
258 ivi_layout_find_bg_output(struct ivi_compositor *ivi)
260 struct ivi_output *out;
262 wl_list_for_each(out, &ivi->outputs, link) {
263 if (out->background &&
264 out->background->role == IVI_SURFACE_ROLE_BACKGROUND)
272 ivi_layout_desktop_committed(struct ivi_surface *surf)
274 struct weston_desktop_surface *dsurf = surf->dsurface;
275 struct weston_geometry geom = weston_desktop_surface_get_geometry(dsurf);
276 struct ivi_policy *policy = surf->ivi->policy;
277 struct ivi_output *output;
278 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
280 assert(surf->role == IVI_SURFACE_ROLE_DESKTOP ||
281 surf->role == IVI_SURFACE_ROLE_REMOTE);
284 * we can't make use here of the ivi_layout_get_output_from_surface()
285 * due to the fact that we'll always land here when a surface performs
286 * a commit and pending_output will not bet set. This works in tandem
287 * with 'activated_by_default' at this point to avoid tripping over
288 * to a surface that continuously updates its content
290 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
291 output = surf->desktop.pending_output;
293 output = surf->remote.output;
295 if (surf->role == IVI_SURFACE_ROLE_DESKTOP && !output) {
296 struct ivi_output *r_output;
298 if (policy && policy->api.surface_activate_by_default &&
299 !policy->api.surface_activate_by_default(surf, surf->ivi))
302 /* we can only activate it again by using the protocol */
303 if (surf->activated_by_default)
306 /* check first if there aren't any outputs being set */
307 r_output = ivi_layout_find_with_app_id(app_id, surf->ivi);
310 struct weston_view *view = r_output->fullscreen_view.fs->view;
311 if (view->is_mapped || view->surface->is_mapped)
312 remove_black_surface(r_output);
316 /* try finding an output with a background and use that */
318 r_output = ivi_layout_find_bg_output(surf->ivi);
320 /* if we couldn't still find an output by this point, there's
321 * something wrong so we abort with a protocol error */
323 wl_resource_post_error(surf->ivi->shell_client.resource,
324 AGL_SHELL_ERROR_INVALID_ARGUMENT,
325 "No valid output found to activate surface by default");
329 if (!surf->ivi->activate_by_default) {
330 weston_log("Refusing to activate surface role %d, app_id %s\n",
335 /* use the output of the bg to activate the app on start-up by
337 if (surf->view && r_output) {
338 if (app_id && r_output) {
339 weston_log("Surface with app_id %s, role %s activating by default\n",
340 weston_desktop_surface_get_app_id(surf->dsurface),
341 ivi_layout_get_surface_role_name(surf));
342 ivi_layout_activate(r_output, app_id);
343 surf->activated_by_default = true;
344 } else if (!app_id) {
346 * applications not setting an app_id, or
347 * setting an app_id but at a later point in
348 * time, might fall-back here so give them a
349 * chance to receive the configure event and
352 weston_log("Surface no app_id, role %s activating by default\n",
353 ivi_layout_get_surface_role_name(surf));
354 ivi_layout_activate_by_surf(r_output, surf);
355 surf->activated_by_default = true;
362 if (surf->role == IVI_SURFACE_ROLE_REMOTE && output) {
363 if (policy && policy->api.surface_activate_by_default &&
364 !policy->api.surface_activate_by_default(surf, surf->ivi))
367 /* we can only activate it again by using the protocol, but
368 * additionally the output is not reset when
369 * ivi_layout_activate_complete() terminates so we use the
370 * current active surface to avoid hitting this again and again
372 if (surf->activated_by_default && output->active == surf)
376 weston_log("Surface with app_id %s, role %s activating by default\n",
377 weston_desktop_surface_get_app_id(surf->dsurface),
378 ivi_layout_get_surface_role_name(surf));
379 ivi_layout_activate(output, app_id);
380 surf->activated_by_default = true;
385 if (!weston_desktop_surface_get_maximized(dsurf) ||
386 geom.width != output->area.width ||
387 geom.height != output->area.height)
390 ivi_layout_activate_complete(output, surf);
394 ivi_layout_fullscreen_committed(struct ivi_surface *surface)
396 struct ivi_compositor *ivi = surface->ivi;
397 struct ivi_policy *policy = ivi->policy;
399 struct weston_desktop_surface *dsurface = surface->dsurface;
400 struct weston_surface *wsurface =
401 weston_desktop_surface_get_surface(dsurface);
402 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
404 struct ivi_output *output = surface->split.output;
405 struct weston_output *woutput = output->output;
407 struct weston_view *view = surface->view;
408 struct weston_geometry geom;
410 if (policy && policy->api.surface_activate_by_default &&
411 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
412 !surface->activated_by_default)
415 if (surface->view->is_mapped)
418 geom = weston_desktop_surface_get_geometry(dsurface);
419 weston_log("(fs) geom x %d, y %d, width %d, height %d\n", geom.x, geom.y,
420 geom.width, geom.height);
422 assert(surface->role == IVI_SURFACE_ROLE_FULLSCREEN);
424 weston_desktop_surface_set_fullscreen(dsurface, true);
426 weston_view_set_output(view, woutput);
427 weston_view_set_position(view, woutput->x, woutput->y);
428 weston_layer_entry_insert(&ivi->fullscreen.view_list, &view->layer_link);
430 weston_view_update_transform(view);
431 weston_view_damage_below(view);
433 wsurface->is_mapped = true;
434 surface->view->is_mapped = true;
436 shell_advertise_app_state(ivi, app_id,
437 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
439 weston_log("Activation completed for app_id %s, role %s, output %s\n",
440 app_id, ivi_layout_get_surface_role_name(surface), output->name);
444 ivi_layout_desktop_resize(struct ivi_surface *surface,
445 struct weston_geometry area)
447 struct weston_desktop_surface *dsurf = surface->dsurface;
448 struct weston_view *view = surface->view;
452 int width = area.width;
453 int height = area.height;
455 weston_desktop_surface_set_size(dsurf,
458 weston_view_set_position(view, x, y);
459 weston_view_update_transform(view);
460 weston_view_damage_below(view);
464 ivi_layout_split_committed(struct ivi_surface *surface)
466 struct ivi_compositor *ivi = surface->ivi;
467 struct ivi_policy *policy = ivi->policy;
469 struct weston_desktop_surface *dsurface = surface->dsurface;
470 struct weston_surface *wsurface =
471 weston_desktop_surface_get_surface(dsurface);
472 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
474 struct ivi_output *output = surface->split.output;
475 struct weston_output *woutput = output->output;
477 struct weston_view *view = surface->view;
478 struct weston_geometry geom;
486 if (policy && policy->api.surface_activate_by_default &&
487 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
488 !surface->activated_by_default)
491 if (surface->view->is_mapped)
494 geom = weston_desktop_surface_get_geometry(dsurface);
496 assert(surface->role == IVI_SURFACE_ROLE_SPLIT_H ||
497 surface->role == IVI_SURFACE_ROLE_SPLIT_V);
499 /* save the previous area in order to recover it back when if this kind
500 * of surface is being destroyed/removed */
501 output->area_saved = output->area;
503 switch (surface->role) {
504 case IVI_SURFACE_ROLE_SPLIT_V:
505 geom.width = (output->area.width / 2);
507 x += woutput->width - geom.width;
508 output->area.width -= geom.width;
510 width = woutput->width - x;
511 height = output->area.height;
515 case IVI_SURFACE_ROLE_SPLIT_H:
516 geom.height = (output->area.height / 2);
519 output->area.y += geom.height;
520 output->area.height -= geom.height;
522 width = output->area.width;
523 height = output->area.height;
529 assert(!"Invalid split orientation\n");
532 weston_desktop_surface_set_size(dsurface,
535 /* resize the active surface first, output->area already contains
536 * correct area to resize to */
538 ivi_layout_desktop_resize(output->active, output->area);
540 weston_view_set_output(view, woutput);
541 weston_view_set_position(view, x, y);
542 weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
544 weston_view_update_transform(view);
545 weston_view_damage_below(view);
547 wsurface->is_mapped = true;
548 surface->view->is_mapped = true;
550 shell_advertise_app_state(ivi, app_id,
551 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
553 weston_log("Activation completed for app_id %s, role %s, output %s\n",
554 app_id, ivi_layout_get_surface_role_name(surface), output->name);
558 ivi_compute_popup_position(const struct weston_output *output, struct weston_view *view,
559 int initial_x, int initial_y, int *new_x, int *new_y)
561 *new_x = output->x + initial_x;
562 *new_y = output->y + initial_y;
567 ivi_layout_popup_committed(struct ivi_surface *surface)
569 struct ivi_compositor *ivi = surface->ivi;
570 struct ivi_policy *policy = ivi->policy;
572 struct weston_desktop_surface *dsurface = surface->dsurface;
573 struct weston_surface *wsurface =
574 weston_desktop_surface_get_surface(dsurface);
575 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
579 struct ivi_output *output = surface->popup.output;
580 struct weston_output *woutput = output->output;
582 struct weston_view *view = surface->view;
584 if (policy && policy->api.surface_activate_by_default &&
585 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
586 !surface->activated_by_default)
589 if (surface->view->is_mapped)
592 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
594 weston_view_set_output(view, woutput);
596 ivi_compute_popup_position(woutput, view,
597 surface->popup.x, surface->popup.y, &new_x, &new_y);
598 weston_view_set_position(view, new_x, new_y);
600 /* only clip the pop-up dialog window if we have a valid
601 * width and height being passed on. Users might not want to have one
602 * set-up so only enfore it is really passed on. */
603 if (surface->popup.bb.width > 0 && surface->popup.bb.height > 0)
604 weston_view_set_mask(view, surface->popup.bb.x, surface->popup.bb.y,
605 surface->popup.bb.width, surface->popup.bb.height);
607 weston_layer_entry_insert(&ivi->popup.view_list, &view->layer_link);
609 weston_view_update_transform(view);
610 weston_view_damage_below(view);
612 wsurface->is_mapped = true;
613 surface->view->is_mapped = true;
615 shell_advertise_app_state(ivi, app_id,
616 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
618 weston_log("Activation completed for app_id %s, role %s, output %s\n",
619 app_id, ivi_layout_get_surface_role_name(surface), output->name);
623 ivi_layout_popup_re_add(struct ivi_surface *surface)
625 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
626 struct weston_view *view = surface->view;
628 if (weston_view_is_mapped(view)) {
629 struct weston_desktop_surface *dsurface = surface->dsurface;
630 struct weston_surface *wsurface =
631 weston_desktop_surface_get_surface(dsurface);
633 weston_layer_entry_remove(&view->layer_link);
635 wsurface->is_mapped = false;
636 view->is_mapped = false;
639 /* reset the activate by default in order to (still) allow the surface
640 * to be activaved using the request */
641 if (!surface->activated_by_default)
642 surface->activated_by_default = true;
644 ivi_layout_popup_committed(surface);
648 ivi_layout_surface_is_split_or_fullscreen(struct ivi_surface *surf)
650 struct ivi_compositor *ivi = surf->ivi;
651 struct ivi_surface *is;
653 if (surf->role != IVI_SURFACE_ROLE_SPLIT_H &&
654 surf->role != IVI_SURFACE_ROLE_SPLIT_V &&
655 surf->role != IVI_SURFACE_ROLE_FULLSCREEN)
658 /* reset the activate by default in order to (still) allow the surface
659 * to be activaved using the request */
660 if (!surf->activated_by_default)
661 surf->activated_by_default = true;
663 wl_list_for_each(is, &ivi->surfaces, link)
671 ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
673 struct ivi_compositor *ivi = output->ivi;
674 struct weston_desktop_surface *dsurf;
675 struct weston_view *view;
676 struct weston_geometry geom;
677 struct ivi_policy *policy = output->ivi->policy;
679 dsurf = surf->dsurface;
682 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
687 if (policy && policy->api.surface_activate &&
688 !policy->api.surface_activate(surf, surf->ivi)) {
692 #ifdef AGL_COMP_DEBUG
693 weston_log("Activating app_id %s, type %s\n", app_id,
694 ivi_layout_get_surface_role_name(surf));
697 if (surf->role == IVI_SURFACE_ROLE_POPUP) {
698 ivi_layout_popup_re_add(surf);
702 /* do not 're'-activate surfaces that are split or active */
703 if (surf == output->active ||
704 ivi_layout_surface_is_split_or_fullscreen(surf))
707 if (surf->role == IVI_SURFACE_ROLE_REMOTE) {
708 struct ivi_output *remote_output =
709 ivi_layout_find_with_app_id(app_id, ivi);
711 /* if already active on a remote output do not
712 * attempt to activate it again */
713 if (remote_output && remote_output->active == surf)
718 geom = weston_desktop_surface_get_geometry(dsurf);
720 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
721 surf->desktop.pending_output = output;
722 if (weston_desktop_surface_get_maximized(dsurf) &&
723 geom.width == output->area.width &&
724 geom.height == output->area.height) {
725 ivi_layout_activate_complete(output, surf);
729 weston_desktop_surface_set_maximized(dsurf, true);
730 weston_desktop_surface_set_size(dsurf,
732 output->area.height);
734 weston_log("Setting app_id %s, role %s, set to maximized (%dx%d)\n",
735 app_id, ivi_layout_get_surface_role_name(surf),
736 output->area.width, output->area.height);
738 * If the view isn't mapped, we put it onto the hidden layer so it will
739 * start receiving frame events, and will be able to act on our
742 if (!weston_view_is_mapped(view)) {
743 view->is_mapped = true;
744 view->surface->is_mapped = true;
746 weston_view_set_output(view, output->output);
747 weston_layer_entry_insert(&ivi->hidden.view_list, &view->layer_link);
748 weston_log("Placed app_id %s, type %s in hidden layer\n",
749 app_id, ivi_layout_get_surface_role_name(surf));
754 ivi_layout_activate(struct ivi_output *output, const char *app_id)
756 struct ivi_surface *surf;
757 struct ivi_compositor *ivi = output->ivi;
762 surf = ivi_find_app(ivi, app_id);
766 ivi_layout_activate_by_surf(output, surf);
770 ivi_layout_get_output_from_surface(struct ivi_surface *surf)
772 struct ivi_output *ivi_output = NULL;
774 switch (surf->role) {
775 case IVI_SURFACE_ROLE_DESKTOP:
776 if (surf->desktop.pending_output)
777 ivi_output = surf->desktop.pending_output;
779 ivi_output = surf->desktop.last_output;
781 case IVI_SURFACE_ROLE_POPUP:
782 ivi_output = surf->popup.output;
784 case IVI_SURFACE_ROLE_BACKGROUND:
785 ivi_output = surf->bg.output;
787 case IVI_SURFACE_ROLE_PANEL:
788 ivi_output = surf->panel.output;
790 case IVI_SURFACE_ROLE_FULLSCREEN:
791 ivi_output = surf->fullscreen.output;
793 case IVI_SURFACE_ROLE_SPLIT_H:
794 case IVI_SURFACE_ROLE_SPLIT_V:
795 ivi_output = surf->split.output;
797 case IVI_SURFACE_ROLE_REMOTE:
798 ivi_output = surf->remote.output;
800 case IVI_SURFACE_ROLE_NONE:
809 ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
811 struct ivi_surface *surf;
812 struct ivi_output *ivi_output;
813 struct ivi_policy *policy = ivi->policy;
818 surf = ivi_find_app(ivi, app_id);
822 if (policy && policy->api.surface_deactivate &&
823 !policy->api.surface_deactivate(surf, surf->ivi)) {
827 ivi_output = ivi_layout_get_output_from_surface(surf);
828 weston_log("Deactiving %s, role %s\n", app_id,
829 ivi_layout_get_surface_role_name(surf));
831 if (surf->role == IVI_SURFACE_ROLE_DESKTOP) {
832 struct ivi_surface *previous_active;
834 previous_active = ivi_output->previous_active;
835 if (!previous_active) {
836 /* we don't have a previous active it means we should
838 if (ivi_output->active) {
839 struct weston_view *view;
841 view = ivi_output->active->view;
842 view->is_mapped = false;
843 view->surface->is_mapped = false;
845 weston_layer_entry_remove(&view->layer_link);
846 weston_view_damage_below(view);
847 ivi_output->active = NULL;
850 struct weston_desktop_surface *dsurface;
851 const char *previous_active_app_id;
853 dsurface = previous_active->dsurface;
854 previous_active_app_id =
855 weston_desktop_surface_get_app_id(dsurface);
856 ivi_layout_activate(ivi_output, previous_active_app_id);
858 } else if (surf->role == IVI_SURFACE_ROLE_POPUP) {
859 struct weston_view *view = surf->view;
861 weston_layer_entry_remove(&view->layer_link);
862 weston_view_damage_below(view);