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 ivi_layout_find_bg_output(struct ivi_compositor *ivi)
259 struct ivi_output *out;
261 wl_list_for_each(out, &ivi->outputs, link) {
262 if (out->background &&
263 out->background->role == IVI_SURFACE_ROLE_BACKGROUND)
271 ivi_layout_desktop_committed(struct ivi_surface *surf)
273 struct weston_desktop_surface *dsurf = surf->dsurface;
274 struct weston_geometry geom = weston_desktop_surface_get_geometry(dsurf);
275 struct ivi_policy *policy = surf->ivi->policy;
276 struct ivi_output *output;
277 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
279 assert(surf->role == IVI_SURFACE_ROLE_DESKTOP ||
280 surf->role == IVI_SURFACE_ROLE_REMOTE);
283 * we can't make use here of the ivi_layout_get_output_from_surface()
284 * due to the fact that we'll always land here when a surface performs
285 * a commit and pending_output will not bet set. This works in tandem
286 * with 'activated_by_default' at this point to avoid tripping over
287 * to a surface that continuously updates its content
289 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
290 output = surf->desktop.pending_output;
292 output = surf->remote.output;
294 if (surf->role == IVI_SURFACE_ROLE_DESKTOP && !output) {
295 struct ivi_output *r_output;
297 if (policy && policy->api.surface_activate_by_default &&
298 !policy->api.surface_activate_by_default(surf, surf->ivi))
301 /* we can only activate it again by using the protocol */
302 if (surf->activated_by_default)
305 /* check first if there aren't any outputs being set */
306 r_output = ivi_layout_find_with_app_id(app_id, surf->ivi);
309 struct weston_view *view = r_output->fullscreen_view.fs->view;
310 if (view->is_mapped || view->surface->is_mapped)
311 remove_black_surface(r_output);
315 /* try finding an output with a background and use that */
317 r_output = ivi_layout_find_bg_output(surf->ivi);
319 /* if we couldn't still find an output by this point, there's
320 * something wrong so we abort with a protocol error */
322 wl_resource_post_error(surf->ivi->shell_client.resource,
323 AGL_SHELL_ERROR_INVALID_ARGUMENT,
324 "No valid output found to activate surface by default");
328 if (!surf->ivi->activate_by_default) {
329 weston_log("Refusing to activate surface role %d, app_id %s\n",
334 /* use the output of the bg to activate the app on start-up by
336 if (surf->view && r_output) {
337 if (app_id && r_output) {
338 weston_log("Surface with app_id %s, role %s activating by default\n",
339 weston_desktop_surface_get_app_id(surf->dsurface),
340 ivi_layout_get_surface_role_name(surf));
341 ivi_layout_activate(r_output, app_id);
342 surf->activated_by_default = true;
343 } else if (!app_id) {
345 * applications not setting an app_id, or
346 * setting an app_id but at a later point in
347 * time, might fall-back here so give them a
348 * chance to receive the configure event and
351 weston_log("Surface no app_id, role %s activating by default\n",
352 ivi_layout_get_surface_role_name(surf));
353 ivi_layout_activate_by_surf(r_output, surf);
354 surf->activated_by_default = true;
361 if (surf->role == IVI_SURFACE_ROLE_REMOTE && output) {
362 if (policy && policy->api.surface_activate_by_default &&
363 !policy->api.surface_activate_by_default(surf, surf->ivi))
366 /* we can only activate it again by using the protocol, but
367 * additionally the output is not reset when
368 * ivi_layout_activate_complete() terminates so we use the
369 * current active surface to avoid hitting this again and again
371 if (surf->activated_by_default && output->active == surf)
375 weston_log("Surface with app_id %s, role %s activating by default\n",
376 weston_desktop_surface_get_app_id(surf->dsurface),
377 ivi_layout_get_surface_role_name(surf));
378 ivi_layout_activate(output, app_id);
379 surf->activated_by_default = true;
384 if (!weston_desktop_surface_get_maximized(dsurf) ||
385 geom.width != output->area.width ||
386 geom.height != output->area.height)
389 ivi_layout_activate_complete(output, surf);
393 ivi_layout_fullscreen_committed(struct ivi_surface *surface)
395 struct ivi_compositor *ivi = surface->ivi;
396 struct ivi_policy *policy = ivi->policy;
398 struct weston_desktop_surface *dsurface = surface->dsurface;
399 struct weston_surface *wsurface =
400 weston_desktop_surface_get_surface(dsurface);
401 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
403 struct ivi_output *output = surface->split.output;
404 struct weston_output *woutput = output->output;
405 struct ivi_output *bg_output = ivi_layout_find_bg_output(ivi);
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 assert(surface->role == IVI_SURFACE_ROLE_FULLSCREEN);
421 if (!weston_desktop_surface_get_fullscreen(dsurface) ||
422 geom.width != bg_output->output->width ||
423 geom.height != bg_output->output->height) {
424 struct weston_desktop_client *desktop_client =
425 weston_desktop_surface_get_client(dsurface);
426 struct wl_client *client =
427 weston_desktop_client_get_client(desktop_client);
428 wl_client_post_implementation_error(client,
429 "Can not display surface due to invalid geometry");
433 weston_view_set_output(view, woutput);
434 weston_view_set_position(view, woutput->x, woutput->y);
435 weston_layer_entry_insert(&ivi->fullscreen.view_list, &view->layer_link);
437 weston_view_geometry_dirty(view);
438 weston_surface_damage(view->surface);
440 wsurface->is_mapped = true;
441 surface->view->is_mapped = true;
443 shell_advertise_app_state(ivi, app_id,
444 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
446 weston_log("Activation completed for app_id %s, role %s, output %s\n",
447 app_id, ivi_layout_get_surface_role_name(surface), output->name);
451 ivi_layout_desktop_resize(struct ivi_surface *surface,
452 struct weston_geometry area)
454 struct weston_desktop_surface *dsurf = surface->dsurface;
455 struct weston_view *view = surface->view;
459 int width = area.width;
460 int height = area.height;
462 weston_desktop_surface_set_size(dsurf,
465 weston_view_set_position(view, x, y);
467 weston_view_geometry_dirty(view);
468 weston_surface_damage(view->surface);
472 ivi_layout_split_committed(struct ivi_surface *surface)
474 struct ivi_compositor *ivi = surface->ivi;
475 struct ivi_policy *policy = ivi->policy;
477 struct weston_desktop_surface *dsurface = surface->dsurface;
478 struct weston_surface *wsurface =
479 weston_desktop_surface_get_surface(dsurface);
480 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
482 struct ivi_output *output = surface->split.output;
483 struct weston_output *woutput = output->output;
485 struct weston_view *view = surface->view;
486 struct weston_geometry geom;
494 if (policy && policy->api.surface_activate_by_default &&
495 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
496 !surface->activated_by_default)
499 if (surface->view->is_mapped)
502 geom = weston_desktop_surface_get_geometry(dsurface);
504 assert(surface->role == IVI_SURFACE_ROLE_SPLIT_H ||
505 surface->role == IVI_SURFACE_ROLE_SPLIT_V);
507 /* save the previous area in order to recover it back when if this kind
508 * of surface is being destroyed/removed */
509 output->area_saved = output->area;
511 switch (surface->role) {
512 case IVI_SURFACE_ROLE_SPLIT_V:
513 geom.width = (output->area.width / 2);
515 x += woutput->width - geom.width;
516 output->area.width -= geom.width;
518 width = woutput->width - x;
519 height = output->area.height;
523 case IVI_SURFACE_ROLE_SPLIT_H:
524 geom.height = (output->area.height / 2);
527 output->area.y += geom.height;
528 output->area.height -= geom.height;
530 width = output->area.width;
531 height = output->area.height;
537 assert(!"Invalid split orientation\n");
540 weston_desktop_surface_set_size(dsurface,
543 /* resize the active surface first, output->area already contains
544 * correct area to resize to */
546 ivi_layout_desktop_resize(output->active, output->area);
548 weston_view_set_output(view, woutput);
549 weston_view_set_position(view, x, y);
550 weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
552 weston_view_geometry_dirty(view);
553 weston_surface_damage(view->surface);
555 wsurface->is_mapped = true;
556 surface->view->is_mapped = true;
558 shell_advertise_app_state(ivi, app_id,
559 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
561 weston_log("Activation completed for app_id %s, role %s, output %s\n",
562 app_id, ivi_layout_get_surface_role_name(surface), output->name);
566 ivi_compute_popup_position(const struct weston_output *output, struct weston_view *view,
567 int initial_x, int initial_y, int *new_x, int *new_y)
569 *new_x = output->x + initial_x;
570 *new_y = output->y + initial_y;
575 ivi_layout_popup_committed(struct ivi_surface *surface)
577 struct ivi_compositor *ivi = surface->ivi;
578 struct ivi_policy *policy = ivi->policy;
580 struct weston_desktop_surface *dsurface = surface->dsurface;
581 struct weston_surface *wsurface =
582 weston_desktop_surface_get_surface(dsurface);
583 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
587 struct ivi_output *output = surface->popup.output;
588 struct weston_output *woutput = output->output;
590 struct weston_view *view = surface->view;
592 if (policy && policy->api.surface_activate_by_default &&
593 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
594 !surface->activated_by_default)
597 if (surface->view->is_mapped)
600 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
602 weston_view_set_output(view, woutput);
604 ivi_compute_popup_position(woutput, view,
605 surface->popup.x, surface->popup.y, &new_x, &new_y);
606 weston_view_set_position(view, new_x, new_y);
608 /* only clip the pop-up dialog window if we have a valid
609 * width and height being passed on. Users might not want to have one
610 * set-up so only enfore it is really passed on. */
611 if (surface->popup.bb.width > 0 && surface->popup.bb.height > 0)
612 weston_view_set_mask(view, surface->popup.bb.x, surface->popup.bb.y,
613 surface->popup.bb.width, surface->popup.bb.height);
615 weston_layer_entry_insert(&ivi->popup.view_list, &view->layer_link);
617 weston_view_geometry_dirty(view);
618 weston_surface_damage(view->surface);
620 wsurface->is_mapped = true;
621 surface->view->is_mapped = true;
623 shell_advertise_app_state(ivi, app_id,
624 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
626 weston_log("Activation completed for app_id %s, role %s, output %s\n",
627 app_id, ivi_layout_get_surface_role_name(surface), output->name);
631 ivi_layout_popup_re_add(struct ivi_surface *surface)
633 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
634 struct weston_view *view = surface->view;
636 if (weston_view_is_mapped(view)) {
637 struct weston_desktop_surface *dsurface = surface->dsurface;
638 struct weston_surface *wsurface =
639 weston_desktop_surface_get_surface(dsurface);
641 weston_layer_entry_remove(&view->layer_link);
643 wsurface->is_mapped = false;
644 view->is_mapped = false;
647 /* reset the activate by default in order to (still) allow the surface
648 * to be activaved using the request */
649 if (!surface->activated_by_default)
650 surface->activated_by_default = true;
652 ivi_layout_popup_committed(surface);
656 ivi_layout_surface_is_split_or_fullscreen(struct ivi_surface *surf)
658 struct ivi_compositor *ivi = surf->ivi;
659 struct ivi_surface *is;
661 if (surf->role != IVI_SURFACE_ROLE_SPLIT_H &&
662 surf->role != IVI_SURFACE_ROLE_SPLIT_V &&
663 surf->role != IVI_SURFACE_ROLE_FULLSCREEN)
666 /* reset the activate by default in order to (still) allow the surface
667 * to be activaved using the request */
668 if (!surf->activated_by_default)
669 surf->activated_by_default = true;
671 wl_list_for_each(is, &ivi->surfaces, link)
679 ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
681 struct ivi_compositor *ivi = output->ivi;
682 struct weston_desktop_surface *dsurf;
683 struct weston_view *view;
684 struct weston_geometry geom;
685 struct ivi_policy *policy = output->ivi->policy;
687 dsurf = surf->dsurface;
690 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
695 if (policy && policy->api.surface_activate &&
696 !policy->api.surface_activate(surf, surf->ivi)) {
700 #ifdef AGL_COMP_DEBUG
701 weston_log("Activating app_id %s, type %s\n", app_id,
702 ivi_layout_get_surface_role_name(surf));
705 if (surf->role == IVI_SURFACE_ROLE_POPUP) {
706 ivi_layout_popup_re_add(surf);
710 /* do not 're'-activate surfaces that are split or active */
711 if (surf == output->active ||
712 ivi_layout_surface_is_split_or_fullscreen(surf))
715 if (surf->role == IVI_SURFACE_ROLE_REMOTE) {
716 struct ivi_output *remote_output =
717 ivi_layout_find_with_app_id(app_id, ivi);
719 /* if already active on a remote output do not
720 * attempt to activate it again */
721 if (remote_output && remote_output->active == surf)
726 geom = weston_desktop_surface_get_geometry(dsurf);
728 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
729 surf->desktop.pending_output = output;
730 if (weston_desktop_surface_get_maximized(dsurf) &&
731 geom.width == output->area.width &&
732 geom.height == output->area.height) {
733 ivi_layout_activate_complete(output, surf);
737 weston_desktop_surface_set_maximized(dsurf, true);
738 weston_desktop_surface_set_size(dsurf,
740 output->area.height);
742 weston_log("Setting app_id %s, role %s, set to maximized (%dx%d)\n",
743 app_id, ivi_layout_get_surface_role_name(surf),
744 output->area.width, output->area.height);
746 * If the view isn't mapped, we put it onto the hidden layer so it will
747 * start receiving frame events, and will be able to act on our
750 if (!weston_view_is_mapped(view)) {
751 view->is_mapped = true;
752 view->surface->is_mapped = true;
754 weston_view_set_output(view, output->output);
755 weston_layer_entry_insert(&ivi->hidden.view_list, &view->layer_link);
756 weston_log("Placed app_id %s, type %s in hidden layer\n",
757 app_id, ivi_layout_get_surface_role_name(surf));
762 ivi_layout_activate(struct ivi_output *output, const char *app_id)
764 struct ivi_surface *surf;
765 struct ivi_compositor *ivi = output->ivi;
770 surf = ivi_find_app(ivi, app_id);
774 ivi_layout_activate_by_surf(output, surf);
778 ivi_layout_get_output_from_surface(struct ivi_surface *surf)
780 struct ivi_output *ivi_output = NULL;
782 switch (surf->role) {
783 case IVI_SURFACE_ROLE_DESKTOP:
784 if (surf->desktop.pending_output)
785 ivi_output = surf->desktop.pending_output;
787 ivi_output = surf->desktop.last_output;
789 case IVI_SURFACE_ROLE_POPUP:
790 ivi_output = surf->popup.output;
792 case IVI_SURFACE_ROLE_BACKGROUND:
793 ivi_output = surf->bg.output;
795 case IVI_SURFACE_ROLE_PANEL:
796 ivi_output = surf->panel.output;
798 case IVI_SURFACE_ROLE_FULLSCREEN:
799 ivi_output = surf->fullscreen.output;
801 case IVI_SURFACE_ROLE_SPLIT_H:
802 case IVI_SURFACE_ROLE_SPLIT_V:
803 ivi_output = surf->split.output;
805 case IVI_SURFACE_ROLE_REMOTE:
806 ivi_output = surf->remote.output;
808 case IVI_SURFACE_ROLE_NONE:
817 ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
819 struct ivi_surface *surf;
820 struct ivi_output *ivi_output;
821 struct ivi_policy *policy = ivi->policy;
826 surf = ivi_find_app(ivi, app_id);
830 if (policy && policy->api.surface_deactivate &&
831 !policy->api.surface_deactivate(surf, surf->ivi)) {
835 ivi_output = ivi_layout_get_output_from_surface(surf);
836 weston_log("Deactiving %s, role %s\n", app_id,
837 ivi_layout_get_surface_role_name(surf));
839 if (surf->role == IVI_SURFACE_ROLE_DESKTOP) {
840 struct ivi_surface *previous_active;
842 previous_active = ivi_output->previous_active;
843 if (!previous_active) {
844 /* we don't have a previous active it means we should
846 if (ivi_output->active) {
847 struct weston_view *view;
849 view = ivi_output->active->view;
850 view->is_mapped = false;
851 view->surface->is_mapped = false;
853 weston_layer_entry_remove(&view->layer_link);
854 weston_view_geometry_dirty(view);
855 weston_surface_damage(view->surface);
856 ivi_output->active = NULL;
859 struct weston_desktop_surface *dsurface;
860 const char *previous_active_app_id;
862 dsurface = previous_active->dsurface;
863 previous_active_app_id =
864 weston_desktop_surface_get_app_id(dsurface);
865 ivi_layout_activate(ivi_output, previous_active_app_id);
867 } else if (surf->role == IVI_SURFACE_ROLE_POPUP) {
868 struct weston_view *view = surf->view;
870 weston_layer_entry_remove(&view->layer_link);
871 weston_view_geometry_dirty(view);
872 weston_surface_damage(view->surface);