+struct weston_output *
+get_default_output(struct weston_compositor *compositor)
+{
+ if (wl_list_empty(&compositor->output_list))
+ return NULL;
+
+ return container_of(compositor->output_list.next,
+ struct weston_output, link);
+}
+
+struct weston_output *
+get_focused_output(struct weston_compositor *compositor)
+{
+ struct weston_seat *seat;
+ struct weston_output *output = NULL;
+
+ wl_list_for_each(seat, &compositor->seat_list, link) {
+ struct weston_touch *touch = weston_seat_get_touch(seat);
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(seat);
+
+ if (touch && touch->focus)
+ output = touch->focus->output;
+ else if (pointer && pointer->focus)
+ output = pointer->focus->output;
+ else if (keyboard && keyboard->focus)
+ output = keyboard->focus->output;
+
+ if (output)
+ break;
+ }
+
+ return output;
+}
+
+void
+ivi_shell_activate_surface(struct ivi_surface *ivi_surf,
+ struct ivi_shell_seat *ivi_seat,
+ uint32_t flags)
+{
+ struct weston_desktop_surface *dsurface = ivi_surf->dsurface;
+ struct weston_surface *surface =
+ weston_desktop_surface_get_surface(dsurface);
+
+ weston_view_activate_input(ivi_surf->view, ivi_seat->seat, flags);
+
+ if (ivi_seat->focused_surface) {
+ struct ivi_surface *current_focus =
+ get_ivi_shell_surface(ivi_seat->focused_surface);
+ struct weston_desktop_surface *dsurface_focus;
+ assert(current_focus);
+
+ dsurface_focus = current_focus->dsurface;
+ if (--current_focus->focus_count == 0)
+ weston_desktop_surface_set_activated(dsurface_focus, false);
+ }
+
+ ivi_seat->focused_surface = surface;
+ if (ivi_surf->focus_count++ == 0)
+ weston_desktop_surface_set_activated(dsurface, true);
+}
+
+
+static void
+desktop_surface_added_configure(struct ivi_surface *surface,
+ struct ivi_output *ivi_output)
+{
+ enum ivi_surface_role role = IVI_SURFACE_ROLE_NONE;
+ struct weston_desktop_surface *dsurface = surface->dsurface;
+
+ ivi_check_pending_surface_desktop(surface, &role);
+ if ((role != IVI_SURFACE_ROLE_DESKTOP &&
+ role != IVI_SURFACE_ROLE_FULLSCREEN &&
+ role != IVI_SURFACE_ROLE_REMOTE) ||
+ role == IVI_SURFACE_ROLE_NONE)
+ return;
+
+ if (role == IVI_SURFACE_ROLE_FULLSCREEN) {
+ struct ivi_output *bg_output =
+ ivi_layout_find_bg_output(surface->ivi);
+ assert(bg_output);
+ weston_desktop_surface_set_fullscreen(dsurface, true);
+ weston_desktop_surface_set_size(dsurface,
+ bg_output->output->width,
+ bg_output->output->height);
+ return;
+ }
+
+ weston_desktop_surface_set_maximized(dsurface, true);
+ weston_desktop_surface_set_size(dsurface,
+ ivi_output->area.width,
+ ivi_output->area.height);
+}
+
+