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 bool use_default_area = true;
156 ivi_background_init(ivi, output);
158 if (output->area_activation.width ||
159 output->area_activation.height ||
160 output->area_activation.x ||
161 output->area_activation.y) {
162 /* Sanity check target area is within output bounds */
163 if ((output->area_activation.x + output->area_activation.width) < output->output->width ||
164 (output->area_activation.y + output->area_activation.height) < output->output->height) {
165 weston_log("Using specified area for output %s, ignoring panels\n",
167 output->area.x = output->area_activation.x;
168 output->area.y = output->area_activation.y;
169 output->area.width = output->area_activation.width;
170 output->area.height = output->area_activation.height;
171 use_default_area = false;
173 weston_log("Invalid activation-area position for output %s, ignoring\n",
177 if (use_default_area) {
180 output->area.width = output->output->width;
181 output->area.height = output->output->height;
183 ivi_panel_init(ivi, output, output->top);
184 ivi_panel_init(ivi, output, output->bottom);
185 ivi_panel_init(ivi, output, output->left);
186 ivi_panel_init(ivi, output, output->right);
189 weston_compositor_schedule_repaint(ivi->compositor);
191 weston_log("Usable area: %dx%d+%d,%d\n",
192 output->area.width, output->area.height,
193 output->area.x, output->area.y);
197 ivi_find_app(struct ivi_compositor *ivi, const char *app_id)
199 struct ivi_surface *surf;
202 wl_list_for_each(surf, &ivi->surfaces, link) {
203 id = weston_desktop_surface_get_app_id(surf->dsurface);
204 if (id && strcmp(app_id, id) == 0)
212 ivi_layout_activate_complete(struct ivi_output *output,
213 struct ivi_surface *surf)
215 struct ivi_compositor *ivi = output->ivi;
216 struct weston_output *woutput = output->output;
217 struct weston_view *view = surf->view;
218 struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi);
219 struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
221 if (weston_view_is_mapped(view)) {
222 weston_layer_entry_remove(&view->layer_link);
224 weston_view_update_transform(view);
227 weston_view_set_output(view, woutput);
229 if (surf->role != IVI_SURFACE_ROLE_BACKGROUND)
230 weston_view_set_position(view,
231 woutput->x + output->area.x,
232 woutput->y + output->area.y);
234 view->is_mapped = true;
236 view->surface->is_mapped = true;
238 if (output->active) {
239 /* keep the background surface mapped at all times */
240 if (output->active->role != IVI_SURFACE_ROLE_BACKGROUND) {
241 output->active->view->is_mapped = false;
242 output->active->view->surface->is_mapped = false;
244 weston_layer_entry_remove(&output->active->view->layer_link);
247 output->previous_active = output->active;
248 output->active = surf;
250 weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
251 weston_view_geometry_dirty(view);
252 weston_surface_damage(view->surface);
255 ivi_shell_activate_surface(surf, ivi_seat, WESTON_ACTIVATE_FLAG_NONE);
258 * the 'remote' role now makes use of this part so make sure we don't
259 * trip the enum such that we might end up with a modified output for
262 if (surf->role == IVI_SURFACE_ROLE_DESKTOP) {
263 if (surf->desktop.pending_output)
264 surf->desktop.last_output = surf->desktop.pending_output;
265 surf->desktop.pending_output = NULL;
268 weston_log("Activation completed for app_id %s, role %s, output %s\n",
269 weston_desktop_surface_get_app_id(surf->dsurface),
270 ivi_layout_get_surface_role_name(surf), output->name);
274 ivi_layout_find_with_app_id(const char *app_id, struct ivi_compositor *ivi)
276 struct ivi_output *out;
281 wl_list_for_each(out, &ivi->outputs, link) {
285 if (!strcmp(app_id, out->app_id))
293 ivi_layout_find_bg_output(struct ivi_compositor *ivi)
295 struct ivi_output *out;
297 wl_list_for_each(out, &ivi->outputs, link) {
298 if (out->background &&
299 out->background->role == IVI_SURFACE_ROLE_BACKGROUND)
308 ivi_layout_add_to_hidden_layer(struct ivi_surface *surf,
309 struct ivi_output *ivi_output)
311 struct weston_desktop_surface *dsurf = surf->dsurface;
312 struct weston_view *ev = surf->view;
313 struct ivi_compositor *ivi = surf->ivi;
314 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
316 weston_desktop_surface_set_maximized(dsurf, true);
317 weston_desktop_surface_set_size(dsurf,
318 ivi_output->area.width,
319 ivi_output->area.height);
321 weston_log("Setting app_id %s, role %s, set to maximized (%dx%d)\n",
322 app_id, ivi_layout_get_surface_role_name(surf),
323 ivi_output->area.width, ivi_output->area.height);
325 * If the view isn't mapped, we put it onto the hidden layer so it will
326 * start receiving frame events, and will be able to act on our
329 if (!weston_view_is_mapped(ev)) {
330 ev->is_mapped = true;
331 ev->surface->is_mapped = true;
333 weston_view_set_output(ev, ivi_output->output);
334 weston_layer_entry_insert(&ivi->hidden.view_list, &ev->layer_link);
335 weston_log("Placed app_id %s, type %s in hidden layer\n",
336 app_id, ivi_layout_get_surface_role_name(surf));
341 ivi_layout_desktop_committed(struct ivi_surface *surf)
343 struct weston_desktop_surface *dsurf = surf->dsurface;
344 struct weston_geometry geom = weston_desktop_surface_get_geometry(dsurf);
345 struct ivi_policy *policy = surf->ivi->policy;
346 struct ivi_output *output;
347 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
349 assert(surf->role == IVI_SURFACE_ROLE_DESKTOP ||
350 surf->role == IVI_SURFACE_ROLE_REMOTE);
353 * we can't make use here of the ivi_layout_get_output_from_surface()
354 * due to the fact that we'll always land here when a surface performs
355 * a commit and pending_output will not bet set. This works in tandem
356 * with 'mapped' at this point to avoid tripping over
357 * to a surface that continuously updates its content
359 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
360 output = surf->desktop.pending_output;
362 output = surf->remote.output;
364 if (surf->role == IVI_SURFACE_ROLE_DESKTOP && !output) {
365 struct ivi_output *r_output;
367 if (policy && policy->api.surface_activate_by_default &&
368 !policy->api.surface_activate_by_default(surf, surf->ivi))
371 /* we can only activate it again by using the protocol */
375 /* check first if there aren't any outputs being set */
376 r_output = ivi_layout_find_with_app_id(app_id, surf->ivi);
379 struct weston_view *view = r_output->fullscreen_view.fs->view;
380 if (view->is_mapped || view->surface->is_mapped)
381 remove_black_surface(r_output);
385 /* try finding an output with a background and use that */
387 r_output = ivi_layout_find_bg_output(surf->ivi);
389 /* if we couldn't still find an output by this point, there's
390 * something wrong so we abort with a protocol error */
392 wl_resource_post_error(surf->ivi->shell_client.resource,
393 AGL_SHELL_ERROR_INVALID_ARGUMENT,
394 "No valid output found to activate surface by default");
398 if (!surf->ivi->activate_by_default) {
399 weston_log("Refusing to activate surface role %d, app_id %s\n",
402 if (!weston_desktop_surface_get_maximized(dsurf) ||
403 geom.width != r_output->area.width ||
404 geom.height != r_output->area.height)
405 ivi_layout_add_to_hidden_layer(surf, r_output);
410 /* use the output of the bg to activate the app on start-up by
412 if (surf->view && r_output) {
413 if (app_id && r_output) {
414 weston_log("Surface with app_id %s, role %s activating by default\n",
415 weston_desktop_surface_get_app_id(surf->dsurface),
416 ivi_layout_get_surface_role_name(surf));
417 ivi_layout_activate(r_output, app_id);
418 } else if (!app_id) {
420 * applications not setting an app_id, or
421 * setting an app_id but at a later point in
422 * time, might fall-back here so give them a
423 * chance to receive the configure event and
426 weston_log("Surface no app_id, role %s activating by default\n",
427 ivi_layout_get_surface_role_name(surf));
428 ivi_layout_activate_by_surf(r_output, surf);
435 if (surf->role == IVI_SURFACE_ROLE_REMOTE && output) {
436 if (policy && policy->api.surface_activate_by_default &&
437 !policy->api.surface_activate_by_default(surf, surf->ivi))
440 /* we can only activate it again by using the protocol, but
441 * additionally the output is not reset when
442 * ivi_layout_activate_complete() terminates so we use the
443 * current active surface to avoid hitting this again and again
445 if (surf->mapped && output->active == surf)
449 weston_log("Surface with app_id %s, role %s activating by default\n",
450 weston_desktop_surface_get_app_id(surf->dsurface),
451 ivi_layout_get_surface_role_name(surf));
452 ivi_layout_activate(output, app_id);
457 if (!weston_desktop_surface_get_maximized(dsurf) ||
458 geom.width != output->area.width ||
459 geom.height != output->area.height)
462 ivi_layout_activate_complete(output, surf);
466 ivi_layout_fullscreen_committed(struct ivi_surface *surface)
468 struct ivi_compositor *ivi = surface->ivi;
469 struct ivi_policy *policy = ivi->policy;
471 struct weston_desktop_surface *dsurface = surface->dsurface;
472 struct weston_surface *wsurface =
473 weston_desktop_surface_get_surface(dsurface);
474 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
476 struct ivi_output *output = surface->split.output;
477 struct weston_output *woutput = output->output;
478 struct ivi_output *bg_output = ivi_layout_find_bg_output(ivi);
480 struct weston_view *view = surface->view;
481 struct weston_geometry geom =
482 weston_desktop_surface_get_geometry(dsurface);
484 struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi);
485 struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
487 bool is_fullscreen = weston_desktop_surface_get_fullscreen(dsurface);
489 geom.width == bg_output->output->width &&
490 geom.height == bg_output->output->height;
492 if (policy && policy->api.surface_activate_by_default &&
493 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
497 assert(surface->role == IVI_SURFACE_ROLE_FULLSCREEN);
499 if (weston_view_is_mapped(view))
502 /* if we still get here but we haven't resized so far, send configure
504 if (surface->state != RESIZING && (!is_fullscreen || !is_dim_same)) {
505 struct ivi_output *bg_output =
506 ivi_layout_find_bg_output(surface->ivi);
508 weston_log("Placing fullscreen app_id %s, type %s in hidden layer\n",
509 app_id, ivi_layout_get_surface_role_name(surface));
510 weston_desktop_surface_set_fullscreen(dsurface, true);
511 weston_desktop_surface_set_size(dsurface,
512 bg_output->output->width,
513 bg_output->output->height);
515 surface->state = RESIZING;
516 weston_view_set_output(view, output->output);
517 weston_layer_entry_insert(&ivi->hidden.view_list, &view->layer_link);
521 /* eventually, we would set the surface fullscreen, but the client
522 * hasn't resized correctly by this point, so terminate connection */
523 if (surface->state == RESIZING && is_fullscreen && !is_dim_same) {
524 struct weston_desktop_client *desktop_client =
525 weston_desktop_surface_get_client(dsurface);
526 struct wl_client *client =
527 weston_desktop_client_get_client(desktop_client);
528 wl_client_post_implementation_error(client,
529 "can not display surface due to invalid geometry."
530 " Client should perform a geometry resize!");
534 /* this implies we resized correctly */
535 if (!weston_view_is_mapped(view)) {
536 weston_layer_entry_remove(&view->layer_link);
538 weston_view_set_output(view, woutput);
539 weston_view_set_position(view, woutput->x, woutput->y);
540 weston_layer_entry_insert(&ivi->fullscreen.view_list, &view->layer_link);
542 wsurface->is_mapped = true;
543 surface->view->is_mapped = true;
544 surface->state = FULLSCREEN;
546 weston_view_geometry_dirty(view);
547 weston_surface_damage(view->surface);
550 ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE);
552 shell_advertise_app_state(ivi, app_id,
553 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
555 weston_log("Activation completed for app_id %s, role %s, "
556 "output %s\n", app_id,
557 ivi_layout_get_surface_role_name(surface),
564 ivi_layout_desktop_resize(struct ivi_surface *surface,
565 struct weston_geometry area)
567 struct weston_desktop_surface *dsurf = surface->dsurface;
568 struct weston_view *view = surface->view;
572 int width = area.width;
573 int height = area.height;
575 weston_desktop_surface_set_size(dsurf,
578 weston_view_set_position(view, x, y);
580 weston_view_geometry_dirty(view);
581 weston_surface_damage(view->surface);
585 ivi_layout_split_committed(struct ivi_surface *surface)
587 struct ivi_compositor *ivi = surface->ivi;
588 struct ivi_policy *policy = ivi->policy;
590 struct weston_desktop_surface *dsurface = surface->dsurface;
591 struct weston_surface *wsurface =
592 weston_desktop_surface_get_surface(dsurface);
593 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
595 struct ivi_output *output = surface->split.output;
596 struct weston_output *woutput = output->output;
598 struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi);
599 struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
601 struct weston_view *view = surface->view;
602 struct weston_geometry geom;
610 if (policy && policy->api.surface_activate_by_default &&
611 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
615 if (surface->view->is_mapped)
618 geom = weston_desktop_surface_get_geometry(dsurface);
620 assert(surface->role == IVI_SURFACE_ROLE_SPLIT_H ||
621 surface->role == IVI_SURFACE_ROLE_SPLIT_V);
623 /* save the previous area in order to recover it back when if this kind
624 * of surface is being destroyed/removed */
625 output->area_saved = output->area;
627 switch (surface->role) {
628 case IVI_SURFACE_ROLE_SPLIT_V:
629 geom.width = (output->area.width / 2);
631 x += woutput->width - geom.width;
632 output->area.width -= geom.width;
634 width = woutput->width - x;
635 height = output->area.height;
639 case IVI_SURFACE_ROLE_SPLIT_H:
640 geom.height = (output->area.height / 2);
643 output->area.y += geom.height;
644 output->area.height -= geom.height;
646 width = output->area.width;
647 height = output->area.height;
653 assert(!"Invalid split orientation\n");
656 weston_desktop_surface_set_size(dsurface,
659 /* resize the active surface first, output->area already contains
660 * correct area to resize to */
662 ivi_layout_desktop_resize(output->active, output->area);
664 weston_view_set_output(view, woutput);
665 weston_view_set_position(view, x, y);
666 weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
668 weston_view_geometry_dirty(view);
669 weston_surface_damage(view->surface);
672 ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE);
674 wsurface->is_mapped = true;
675 surface->view->is_mapped = true;
677 shell_advertise_app_state(ivi, app_id,
678 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
680 weston_log("Activation completed for app_id %s, role %s, output %s\n",
681 app_id, ivi_layout_get_surface_role_name(surface), output->name);
685 ivi_compute_popup_position(const struct weston_output *output, struct weston_view *view,
686 int initial_x, int initial_y, int *new_x, int *new_y)
688 *new_x = output->x + initial_x;
689 *new_y = output->y + initial_y;
694 ivi_layout_popup_committed(struct ivi_surface *surface)
696 struct ivi_compositor *ivi = surface->ivi;
697 struct ivi_policy *policy = ivi->policy;
699 struct weston_desktop_surface *dsurface = surface->dsurface;
700 struct weston_surface *wsurface =
701 weston_desktop_surface_get_surface(dsurface);
702 const char *app_id = weston_desktop_surface_get_app_id(dsurface);
706 struct ivi_output *output = surface->popup.output;
707 struct weston_output *woutput = output->output;
709 struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi);
710 struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
712 struct weston_view *view = surface->view;
714 if (policy && policy->api.surface_activate_by_default &&
715 !policy->api.surface_activate_by_default(surface, surface->ivi) &&
719 if (surface->view->is_mapped || surface->state == HIDDEN)
722 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
724 weston_view_set_output(view, woutput);
726 ivi_compute_popup_position(woutput, view,
727 surface->popup.x, surface->popup.y, &new_x, &new_y);
728 weston_view_set_position(view, new_x, new_y);
729 weston_view_update_transform(view);
731 /* only clip the pop-up dialog window if we have a valid
732 * width and height being passed on. Users might not want to have one
733 * set-up so only enfore it is really passed on. */
734 if (surface->popup.bb.width > 0 && surface->popup.bb.height > 0)
735 weston_view_set_mask(view, surface->popup.bb.x, surface->popup.bb.y,
736 surface->popup.bb.width, surface->popup.bb.height);
738 weston_layer_entry_insert(&ivi->popup.view_list, &view->layer_link);
740 weston_view_geometry_dirty(view);
741 weston_surface_damage(view->surface);
744 ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE);
746 wsurface->is_mapped = true;
747 surface->view->is_mapped = true;
749 shell_advertise_app_state(ivi, app_id,
750 NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
752 weston_log("Activation completed for app_id %s, role %s, output %s\n",
753 app_id, ivi_layout_get_surface_role_name(surface), output->name);
757 ivi_layout_popup_re_add(struct ivi_surface *surface)
759 assert(surface->role == IVI_SURFACE_ROLE_POPUP);
760 struct weston_view *view = surface->view;
762 if (weston_view_is_mapped(view)) {
763 struct weston_desktop_surface *dsurface = surface->dsurface;
764 struct weston_surface *wsurface =
765 weston_desktop_surface_get_surface(dsurface);
767 weston_layer_entry_remove(&view->layer_link);
769 wsurface->is_mapped = false;
770 view->is_mapped = false;
773 /* reset the activate by default in order to (still) allow the surface
774 * to be activaved using the request */
775 if (!surface->mapped)
776 surface->mapped = true;
778 surface->state = NORMAL;
779 ivi_layout_popup_committed(surface);
783 ivi_layout_surface_is_split_or_fullscreen(struct ivi_surface *surf)
785 struct ivi_compositor *ivi = surf->ivi;
786 struct ivi_surface *is;
788 if (surf->role != IVI_SURFACE_ROLE_SPLIT_H &&
789 surf->role != IVI_SURFACE_ROLE_SPLIT_V &&
790 surf->role != IVI_SURFACE_ROLE_FULLSCREEN)
793 /* reset the activate by default in order to (still) allow the surface
794 * to be activaved using the request */
798 wl_list_for_each(is, &ivi->surfaces, link)
806 ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
808 struct ivi_compositor *ivi = output->ivi;
809 struct weston_desktop_surface *dsurf;
810 struct weston_geometry geom;
811 struct ivi_policy *policy = output->ivi->policy;
813 dsurf = surf->dsurface;
815 const char *app_id = weston_desktop_surface_get_app_id(dsurf);
820 if (policy && policy->api.surface_activate &&
821 !policy->api.surface_activate(surf, surf->ivi)) {
825 #ifdef AGL_COMP_DEBUG
826 weston_log("Activating app_id %s, type %s\n", app_id,
827 ivi_layout_get_surface_role_name(surf));
830 if (surf->role == IVI_SURFACE_ROLE_POPUP) {
831 ivi_layout_popup_re_add(surf);
835 /* do not 're'-activate surfaces that are split or active */
836 if (surf == output->active ||
837 ivi_layout_surface_is_split_or_fullscreen(surf))
840 if (surf->role == IVI_SURFACE_ROLE_REMOTE) {
841 struct ivi_output *remote_output =
842 ivi_layout_find_with_app_id(app_id, ivi);
844 /* if already active on a remote output do not
845 * attempt to activate it again */
846 if (remote_output && remote_output->active == surf)
851 geom = weston_desktop_surface_get_geometry(dsurf);
853 if (surf->role == IVI_SURFACE_ROLE_DESKTOP)
854 surf->desktop.pending_output = output;
855 if (weston_desktop_surface_get_maximized(dsurf) &&
856 geom.width == output->area.width &&
857 geom.height == output->area.height) {
858 ivi_layout_activate_complete(output, surf);
862 /* the background surface is already "maximized" so we don't need to
863 * add to the hidden layer */
864 if (surf->role == IVI_SURFACE_ROLE_BACKGROUND) {
865 ivi_layout_activate_complete(output, surf);
869 ivi_layout_add_to_hidden_layer(surf, output);
873 ivi_layout_activate(struct ivi_output *output, const char *app_id)
875 struct ivi_surface *surf;
876 struct ivi_compositor *ivi = output->ivi;
881 surf = ivi_find_app(ivi, app_id);
885 ivi_layout_activate_by_surf(output, surf);
889 ivi_layout_get_output_from_surface(struct ivi_surface *surf)
891 struct ivi_output *ivi_output = NULL;
893 switch (surf->role) {
894 case IVI_SURFACE_ROLE_DESKTOP:
895 if (surf->desktop.pending_output)
896 ivi_output = surf->desktop.pending_output;
898 ivi_output = surf->desktop.last_output;
900 case IVI_SURFACE_ROLE_POPUP:
901 ivi_output = surf->popup.output;
903 case IVI_SURFACE_ROLE_BACKGROUND:
904 ivi_output = surf->bg.output;
906 case IVI_SURFACE_ROLE_PANEL:
907 ivi_output = surf->panel.output;
909 case IVI_SURFACE_ROLE_FULLSCREEN:
910 ivi_output = surf->fullscreen.output;
912 case IVI_SURFACE_ROLE_SPLIT_H:
913 case IVI_SURFACE_ROLE_SPLIT_V:
914 ivi_output = surf->split.output;
916 case IVI_SURFACE_ROLE_REMOTE:
917 ivi_output = surf->remote.output;
919 case IVI_SURFACE_ROLE_NONE:
928 ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
930 struct ivi_surface *surf;
931 struct ivi_output *ivi_output;
932 struct ivi_policy *policy = ivi->policy;
937 surf = ivi_find_app(ivi, app_id);
941 if (policy && policy->api.surface_deactivate &&
942 !policy->api.surface_deactivate(surf, surf->ivi)) {
946 ivi_output = ivi_layout_get_output_from_surface(surf);
947 weston_log("Deactiving %s, role %s\n", app_id,
948 ivi_layout_get_surface_role_name(surf));
950 if (surf->role == IVI_SURFACE_ROLE_DESKTOP) {
951 struct ivi_surface *previous_active;
953 previous_active = ivi_output->previous_active;
954 if (!previous_active) {
955 /* we don't have a previous active it means we should
957 if (ivi_output->active) {
958 struct weston_view *view;
960 view = ivi_output->active->view;
961 view->is_mapped = false;
962 view->surface->is_mapped = false;
964 weston_layer_entry_remove(&view->layer_link);
965 weston_view_geometry_dirty(view);
966 weston_surface_damage(view->surface);
967 ivi_output->active = NULL;
970 struct weston_desktop_surface *dsurface;
971 const char *previous_active_app_id;
973 dsurface = previous_active->dsurface;
974 previous_active_app_id =
975 weston_desktop_surface_get_app_id(dsurface);
976 ivi_layout_activate(ivi_output, previous_active_app_id);
978 } else if (surf->role == IVI_SURFACE_ROLE_POPUP) {
979 struct weston_view *view = surf->view;
981 weston_view_unmap(view);
982 surf->state = HIDDEN;
984 weston_layer_entry_remove(&view->layer_link);
985 weston_view_geometry_dirty(view);
986 weston_surface_damage(view->surface);