diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h index 395a9758..34ab1f4d 100644 --- a/ivi-shell/ivi-layout-export.h +++ b/ivi-shell/ivi-layout-export.h @@ -330,6 +330,18 @@ struct ivi_layout_interface { int32_t (*surface_set_id)(struct ivi_layout_surface *ivisurf, uint32_t id_surface); + /** + * \brief activate ivi_layout_surface + * + * The surface must be added to a layer before it can be activated. + */ + void (*surface_activate)(struct ivi_layout_surface *ivisurf); + + /** + * \brief check if ivi_layout_surface is active + */ + bool (*surface_is_active)(struct ivi_layout_surface *ivisurf); + /** * layer controller interface */ diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h index 21261e54..02331647 100644 --- a/ivi-shell/ivi-layout-private.h +++ b/ivi-shell/ivi-layout-private.h @@ -55,6 +55,8 @@ struct ivi_layout_surface { struct weston_surface *surface; struct weston_desktop_surface *weston_desktop_surface; + int focus_count; + struct ivi_layout_view *ivi_view; struct ivi_layout_surface_properties prop; diff --git a/ivi-shell/ivi-layout-shell.h b/ivi-shell/ivi-layout-shell.h index 83762fc0..4cec0604 100644 --- a/ivi-shell/ivi-layout-shell.h +++ b/ivi-shell/ivi-layout-shell.h @@ -76,6 +76,11 @@ void ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf, int32_t width, int32_t height); +void +ivi_layout_surface_activate_with_seat(struct ivi_layout_surface *ivisurf, + struct weston_seat *seat, + uint32_t activate_flags); + struct ivi_layout_surface* ivi_layout_surface_create(struct weston_surface *wl_surface, uint32_t id_surface); diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index 91f862c0..1c654798 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -1776,6 +1776,67 @@ ivi_layout_surface_set_id(struct ivi_layout_surface *ivisurf, return IVI_SUCCEEDED; } +static void +deactivate_current_surface(struct weston_seat *seat) +{ + struct ivi_layout_surface *ivisurf = + shell_get_focused_ivi_layout_surface(seat); + struct weston_desktop_surface *desktop_surface; + + if (!ivisurf) + return; + + shell_set_focused_ivi_layout_surface(NULL, seat); + desktop_surface = ivisurf->weston_desktop_surface; + if (--ivisurf->focus_count == 0 && desktop_surface) + weston_desktop_surface_set_activated(desktop_surface, false); +} + +static void +surface_activate(struct ivi_layout_surface *ivisurf, struct weston_seat *seat) +{ + struct weston_desktop_surface *dsurf = ivisurf->weston_desktop_surface; + + deactivate_current_surface(seat); + + shell_set_focused_ivi_layout_surface(ivisurf, seat); + if (ivisurf->focus_count++ == 0 && dsurf) + weston_desktop_surface_set_activated(dsurf, true); +} + +static void +ivi_layout_surface_activate(struct ivi_layout_surface *ivisurf) +{ + struct weston_seat *seat; + + assert(ivisurf->ivi_view); + + wl_list_for_each(seat, &ivisurf->surface->compositor->seat_list, link) { + weston_view_activate_input(ivisurf->ivi_view->view, seat, + WESTON_ACTIVATE_FLAG_NONE); + surface_activate(ivisurf, seat); + } +} + +static bool +ivi_layout_surface_is_active(struct ivi_layout_surface *ivisurf) +{ + assert(ivisurf); + + return (ivisurf->focus_count > 0); +} + +void +ivi_layout_surface_activate_with_seat(struct ivi_layout_surface *ivisurf, + struct weston_seat *seat, + uint32_t activate_flags) +{ + weston_view_activate_input(ivisurf->ivi_view->view, + seat, activate_flags); + + surface_activate(ivisurf, seat); +} + static void ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf, enum ivi_layout_transition_type type, @@ -2123,6 +2184,8 @@ static struct ivi_layout_interface ivi_layout_interface = { .surface_set_transition = ivi_layout_surface_set_transition, .surface_set_transition_duration = ivi_layout_surface_set_transition_duration, .surface_set_id = ivi_layout_surface_set_id, + .surface_activate = ivi_layout_surface_activate, + .surface_is_active = ivi_layout_surface_is_active, /** * layer controller interfaces diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c index 79d460e0..66658b8c 100644 --- a/ivi-shell/ivi-shell.c +++ b/ivi-shell/ivi-shell.c @@ -98,6 +98,7 @@ struct ivi_input_panel_surface struct ivi_shell_seat { struct weston_seat *seat; struct wl_listener seat_destroy_listener; + struct ivi_layout_surface *focused_ivisurf; struct wl_list link; /** ivi_shell::seat_list */ }; @@ -135,6 +136,43 @@ shell_get_ivi_layout_surface(struct weston_surface *surface) return shsurf->layout_surface; } +static void +ivi_shell_seat_handle_destroy(struct wl_listener *listener, void *data); + +static struct ivi_shell_seat * +get_ivi_shell_seat(struct weston_seat *seat) +{ + struct wl_listener *listener; + + if (!seat) + return NULL; + + listener = wl_signal_get(&seat->destroy_signal, + ivi_shell_seat_handle_destroy); + if (!listener) + return NULL; + + return container_of(listener, struct ivi_shell_seat, + seat_destroy_listener); +} + +struct ivi_layout_surface * +shell_get_focused_ivi_layout_surface(struct weston_seat *seat) +{ + struct ivi_shell_seat *shseat = get_ivi_shell_seat(seat); + + return shseat->focused_ivisurf; +} + +void +shell_set_focused_ivi_layout_surface(struct ivi_layout_surface *ivisurf, + struct weston_seat *seat) +{ + struct ivi_shell_seat *shseat = get_ivi_shell_seat(seat); + + shseat->focused_ivisurf = ivisurf; +} + void shell_surface_send_configure(struct weston_surface *surface, int32_t width, int32_t height) @@ -523,9 +561,8 @@ activate_binding(struct weston_seat *seat, return; } - /* FIXME: need to activate the surface like - kiosk_shell_surface_activate() */ - weston_view_activate_input(focus_view, seat, flags); + ivi_layout_surface_activate_with_seat(ivisurf->layout_surface, seat, + flags); } static void diff --git a/ivi-shell/ivi-shell.h b/ivi-shell/ivi-shell.h index 4b613582..bb90dfe3 100644 --- a/ivi-shell/ivi-shell.h +++ b/ivi-shell/ivi-shell.h @@ -66,6 +66,13 @@ struct ivi_layout_surface; struct ivi_layout_surface * shell_get_ivi_layout_surface(struct weston_surface *surface); +struct ivi_layout_surface * +shell_get_focused_ivi_layout_surface(struct weston_seat *seat); + +void +shell_set_focused_ivi_layout_surface(struct ivi_layout_surface *ivisurface, + struct weston_seat *seat); + void shell_ensure_text_input(struct ivi_shell *shell); bool