From: Sung-Jin Park Date: Mon, 22 Apr 2019 10:44:06 +0000 (+0900) Subject: headless input: add APIs to set focus/top view, add init/deinit (input) modules X-Git-Tag: submit/tizen/20190530.092249~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f25c23a7875a5f873a574caea2d93493b1bf0b85;p=platform%2Fcore%2Fuifw%2Fpepper.git headless input: add APIs to set focus/top view, add init/deinit (input) modules Change-Id: If5c09e81dda7ff52f9a2cfb43a6a62a06795dd51 Signed-off-by: Sung-Jin Park --- diff --git a/configure.ac b/configure.ac index bb66dac..86491f1 100644 --- a/configure.ac +++ b/configure.ac @@ -309,8 +309,9 @@ AC_SUBST(SAMPLES_LIBS) # headless server HEADLESS_SERVER_REQUIRES="wayland-server capi-system-peripheral-io xdg-shell-unstable-v6-server tizen-extension-server" PKG_CHECK_MODULES(HEADLESS_SERVER, $[HEADLESS_SERVER_REQUIRES]) -HEADLESS_SERVER_CFLAGS="$PEPPER_DIR $PEPPER_EVDEV_DIR $HEADLESS_SERVER_CFLAGS" +HEADLESS_SERVER_CFLAGS="$PEPPER_DIR $PEPPER_KEYROUTER_DIR $PEPPER_EVDEV_DIR $HEADLESS_SERVER_CFLAGS" HEADLESS_SERVER_LIBS="$PEPPER_LIB $PEPPER_LIBS $PEPPER_EVDEV_LIB $PEPPER_EVDEV_LIBS $HEADLESS_SERVER_LIBS" +HEADLESS_SERVER_LIBS="$PEPPER_KEYROUTER_LIB $PEPPER_KEYROUTER_LIBS $HEADLESS_SERVER_LIBS" AC_SUBST(HEADLESS_SERVER_CFLAGS) AC_SUBST(HEADLESS_SERVER_LIBS) diff --git a/src/bin/headless/headless_server.h b/src/bin/headless/headless_server.h index 63b29f4..2fcf4fe 100644 --- a/src/bin/headless/headless_server.h +++ b/src/bin/headless/headless_server.h @@ -34,7 +34,13 @@ PEPPER_API pepper_bool_t pepper_output_led_init(pepper_compositor_t *compositor) PEPPER_API void pepper_output_led_deinit(pepper_compositor_t *compositor); PEPPER_API pepper_bool_t headless_shell_init(pepper_compositor_t *compositor); + +/* APIs for headless_input */ PEPPER_API pepper_bool_t headless_input_init(pepper_compositor_t *compositor); +PEPPER_API void *headless_input_get(void); +PEPPER_API void headless_input_set_focus_view(void *input, pepper_view_t *view); +PEPPER_API void headless_input_set_top_view(void *input, pepper_view_t *view); + #ifdef __cplusplus } #endif diff --git a/src/bin/headless/input.c b/src/bin/headless/input.c index 5f36a4d..27d2fcd 100644 --- a/src/bin/headless/input.c +++ b/src/bin/headless/input.c @@ -22,12 +22,19 @@ */ #include #include +#include typedef struct { pepper_compositor_t *compositor; - pepper_evdev_t *evdev; pepper_seat_t *seat; + pepper_evdev_t *evdev; + pepper_keyboard_t *keyboard; + + pepper_view_t *focus_view; + pepper_view_t *top_view; + + pepper_keyrouter_t *keyrouter; pepper_event_listener_t *listener_seat_keyboard_key; pepper_event_listener_t *listener_seat_keyboard_add; @@ -38,6 +45,7 @@ typedef struct uint32_t ndevices; } headless_input_t; +headless_input_t *input = NULL; const static int KEY_INPUT = 0xdeadbeaf; static void init_event_listeners(headless_input_t *hi); @@ -78,6 +86,7 @@ _handle_seat_keyboard_add(pepper_event_listener_t *listener, pepper_object_t *ob 0, _handle_keyboard_key, hi); PEPPER_CHECK(h, goto end, "Failed to add keyboard key listener.\n"); hi->listener_seat_keyboard_key = h; + hi->keyboard = keyboard; return; @@ -140,6 +149,45 @@ end: deinit_event_listeners(hi); } +void +headless_input_set_focus_view(void *input, pepper_view_t *focus_view) +{ + headless_input_t *hi = (headless_input_t *)input; + + PEPPER_CHECK(hi, return, "Invalid headless input.\n"); + + if (hi->focus_view != focus_view) + { + if (hi->focus_view) + pepper_keyboard_send_leave(hi->keyboard, hi->focus_view); + pepper_keyboard_set_focus(hi->keyboard, focus_view); + pepper_keyboard_send_enter(hi->keyboard, focus_view); + hi->focus_view = focus_view; + } + + if (hi->keyrouter) + pepper_keyrouter_set_focus_view(hi->keyrouter, focus_view); +} + +void +headless_input_set_top_view(void *input, pepper_view_t *top_view) +{ + headless_input_t *hi = (headless_input_t *)input; + + PEPPER_CHECK(hi, return, "Invalid headless input.\n"); + + hi->top_view = top_view; + + if (hi->keyrouter) + pepper_keyrouter_set_top_view(hi->keyrouter, top_view); +} + +headless_input_t * +headless_input_get(void) +{ + return input; +} + static void init_event_listeners(headless_input_t *hi) { @@ -241,6 +289,35 @@ end: return PEPPER_FALSE; } +static void +init_modules(headless_input_t *hi) +{ + pepper_keyrouter_t *keyrouter = NULL; + + PEPPER_TRACE("[%s] ... begin\n", __FUNCTION); + + /* create pepper keyrouter */ + keyrouter = pepper_keyrouter_create(hi->compositor); + PEPPER_CHECK(keyrouter, goto end, "Failed to create keyrouter !\n"); + + hi->keyrouter = keyrouter; + + PEPPER_TRACE("[%s] ... done\n", __FUNCTION); + +end: + if (keyrouter) + pepper_keyrouter_destroy(keyrouter); +} + +static void +deinit_modules(headless_input_t *hi) +{ + if (hi->keyrouter) + pepper_keyrouter_destroy(hi->keyrouter); + + hi->keyrouter = NULL; +} + static void headless_input_deinit(void *data) { @@ -249,10 +326,13 @@ headless_input_deinit(void *data) if (!hi) return; deinit_event_listeners(hi); + deinit_modules(hi); input_deinit(hi); pepper_object_set_user_data((pepper_object_t *)hi->compositor, &KEY_INPUT, NULL, NULL); free(hi); + + input = hi = NULL; } pepper_bool_t @@ -266,9 +346,11 @@ headless_input_init(pepper_compositor_t *compositor) hi->compositor = compositor; init_event_listeners(hi); + init_modules(hi); init = input_init(hi); PEPPER_CHECK(init, goto error, "input_init() failed\n"); + input = hi; pepper_object_set_user_data((pepper_object_t *)compositor, &KEY_INPUT, NULL, headless_input_deinit); return PEPPER_TRUE;