diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2014-10-24 10:41:48 +0000 |
---|---|---|
committer | Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp> | 2014-11-06 17:09:37 +0900 |
commit | da782dd73eb23b384aa7861053f9910b7b39bdc1 (patch) | |
tree | 88c23d18aa1608b36d3700223e38ad73095b7cc2 | |
parent | 382d91bc7897363ae52cec27d975018ee3a2f81d (diff) | |
download | weston-da782dd73eb23b384aa7861053f9910b7b39bdc1.tar.gz |
ivi-shell: Add keyboard grab
This commit does not specify what the keyboard grabs do. That
is implemented in a later commit.
Signed-off-by: James Thomas <james.thomas@codethink.co.uk>
-rw-r--r-- | ivi-shell/ivi-layout-private.h | 2 | ||||
-rw-r--r-- | ivi-shell/ivi-layout.c | 80 |
2 files changed, 82 insertions, 0 deletions
diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h index 812a3d49..387de9e1 100644 --- a/ivi-shell/ivi-layout-private.h +++ b/ivi-shell/ivi-layout-private.h @@ -178,6 +178,8 @@ struct ivi_layout { struct ivi_layout_transition_set* transitions; struct wl_list pending_transition_list; + + struct wl_listener seat_create_listener; }; /* struct ivi_layout { diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index 5a46d479..17a9a742 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -115,6 +115,12 @@ struct ivi_layout_screen { } order; }; +struct seat_ctx { + struct weston_keyboard_grab grab; + struct wl_listener updated_caps_listener; + struct wl_listener destroy_listener; +}; + struct ivi_layout_notificationCallback { void *callback; void *data; @@ -3157,6 +3163,70 @@ ivi_layout_surfaceCreate(struct weston_surface *wl_surface, } static void +keyboard_grab_key(struct weston_keyboard_grab *grab, uint32_t time, + uint32_t key, uint32_t state) +{ +} + +static void +keyboard_grab_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, + uint32_t mods_depressed, uint32_t mods_latched, + uint32_t mods_locked, uint32_t group) +{ +} + +static void +keyboard_grab_cancel(struct weston_keyboard_grab *grab) +{ +} + +static struct weston_keyboard_grab_interface keyboard_grab_interface = { + keyboard_grab_key, + keyboard_grab_modifiers, + keyboard_grab_cancel +}; + +static void +handle_seat_updated_caps(struct wl_listener *listener, void *data) +{ + struct weston_seat *seat = data; + struct seat_ctx *ctx = wl_container_of(listener, ctx, + updated_caps_listener); + if (seat->keyboard && seat->keyboard != ctx->grab.keyboard) + weston_keyboard_start_grab(seat->keyboard, &ctx->grab); +} + +static void +handle_seat_destroy(struct wl_listener *listener, void *data) +{ + struct seat_ctx *ctx = wl_container_of(listener, ctx, destroy_listener); + if (ctx->grab.keyboard) + keyboard_grab_cancel(&ctx->grab); + + free(ctx); +} + +static void +handle_seat_create(struct wl_listener *listener, void *data) +{ + struct weston_seat *seat = data; + + struct seat_ctx *ctx = calloc(1, sizeof *ctx); + if (ctx == NULL) { + weston_log("%s: failed to allocate memory\n", __FUNCTION__); + return; + } + + ctx->grab.interface = &keyboard_grab_interface; + + ctx->destroy_listener.notify = &handle_seat_destroy; + wl_signal_add(&seat->destroy_signal, &ctx->destroy_listener); + + ctx->updated_caps_listener.notify = &handle_seat_updated_caps; + wl_signal_add(&seat->updated_caps_signal, &ctx->updated_caps_listener); +} + +static void ivi_layout_initWithCompositor(struct weston_compositor *ec) { struct ivi_layout *layout = get_instance(); @@ -3197,6 +3267,16 @@ ivi_layout_initWithCompositor(struct weston_compositor *ec) layout->transitions = ivi_layout_transition_set_create(ec); wl_list_init(&layout->pending_transition_list); + /* Listen to seat creation, for grab purposes */ + layout->seat_create_listener.notify = &handle_seat_create; + wl_signal_add(&ec->seat_created_signal, &layout->seat_create_listener); + + /* Handle existing seats */ + struct weston_seat *seat; + wl_list_for_each(seat, &ec->seat_list, link) { + handle_seat_create(NULL, seat); + wl_signal_emit(&seat->updated_caps_signal, seat); + } } |