From: jeon Date: Fri, 10 May 2019 09:32:08 +0000 (+0900) Subject: headless-server: enable inotify to support hot-plugged devices X-Git-Tag: submit/tizen/20190530.092249~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F207194%2F1;p=platform%2Fcore%2Fuifw%2Fpepper.git headless-server: enable inotify to support hot-plugged devices Change-Id: I7d42716cc306129d8a670aa6f8a10c94bebcf034 --- diff --git a/configure.ac b/configure.ac index 611ca80..8593417 100644 --- a/configure.ac +++ b/configure.ac @@ -319,10 +319,12 @@ HEADLESS_SERVER_REQUIRES="wayland-server capi-system-peripheral-io xdg-shell-uns PKG_CHECK_MODULES(HEADLESS_SERVER, $[HEADLESS_SERVER_REQUIRES]) HEADLESS_SERVER_CFLAGS="$PEPPER_DIR $PEPPER_KEYROUTER_DIR $PEPPER_DEVICEMGR_DIR $PEPPER_EVDEV_DIR $HEADLESS_SERVER_CFLAGS $TBM_CFLAGS" HEADLESS_SERVER_CFLAGS="$PEPPER_XKB_DIR $HEADLESS_SERVER_CFLAGS" +HEADLESS_SERVER_CFLAGS="$PEPPER_INOTIFY_DIR $HEADLESS_SERVER_CFLAGS" HEADLESS_SERVER_LIBS="$PEPPER_LIB $PEPPER_LIBS $PEPPER_EVDEV_LIB $PEPPER_EVDEV_LIBS $HEADLESS_SERVER_LIBS $TBM_LIBS" HEADLESS_SERVER_LIBS="$PEPPER_KEYROUTER_LIB $PEPPER_KEYROUTER_LIBS $HEADLESS_SERVER_LIBS" HEADLESS_SERVER_LIBS="$PEPPER_DEVICEMGR_LIB $PEPPER_DEVICEMGR_LIBS $HEADLESS_SERVER_LIBS" HEADLESS_SERVER_LIBS="$PEPPER_XKB_LIB $PEPPER_XKB_LIBS $HEADLESS_SERVER_LIBS" +HEADLESS_SERVER_LIBS="$PEPPER_INOTIFY_LIB $PEPPER_INOTIFY_LIBS $HEADLESS_SERVER_LIBS" AC_SUBST(HEADLESS_SERVER_CFLAGS) AC_SUBST(HEADLESS_SERVER_LIBS) diff --git a/src/bin/headless/input.c b/src/bin/headless/input.c index 494b0a6..9257267 100644 --- a/src/bin/headless/input.c +++ b/src/bin/headless/input.c @@ -25,6 +25,7 @@ #include #include #include +#include typedef struct { @@ -33,6 +34,7 @@ typedef struct pepper_evdev_t *evdev; pepper_keyboard_t *keyboard; pepper_input_device_t *default_device; + pepper_inotify_t *inotify; pepper_view_t *focus_view; pepper_view_t *top_view; @@ -119,6 +121,30 @@ end: headless_input_deinit_event_listeners(hi); } +static void +_cb_handle_inotify_event(uint32_t type, pepper_inotify_event_t *ev, void *data) +{ + headless_input_t *hi = data; + + PEPPER_CHECK(hi, return, "Invalid headless input\n"); + + switch (type) + { + case PEPPER_INOTIFY_EVENT_TYPE_CREATE: + pepper_evdev_device_path_add(hi->evdev, pepper_inotify_event_name_get(ev)); + break; + case PEPPER_INOTIFY_EVENT_TYPE_REMOVE: + pepper_evdev_device_path_remove(hi->evdev, pepper_inotify_event_name_get(ev)); + break; + case PEPPER_INOTIFY_EVENT_TYPE_MODIFY: + pepper_evdev_device_path_remove(hi->evdev, pepper_inotify_event_name_get(ev)); + pepper_evdev_device_path_add(hi->evdev, pepper_inotify_event_name_get(ev)); + break; + default: + break; + } +} + void headless_input_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *focus_view) { @@ -194,6 +220,12 @@ headless_input_deinit_event_listeners(headless_input_t *hi) static void headless_input_deinit_input(headless_input_t *hi) { + if (hi->inotify) + { + pepper_inotify_destroy(hi->inotify); + hi->inotify = NULL; + } + if (hi->default_device) { pepper_input_device_destroy(hi->default_device); @@ -230,6 +262,7 @@ headless_input_init_input(headless_input_t *hi) uint32_t probed = 0; pepper_bool_t res = PEPPER_FALSE; pepper_evdev_t *evdev = NULL; + pepper_inotify_t *inotify = NULL; /* create pepper evdev */ evdev = pepper_evdev_create(hi->compositor); @@ -255,6 +288,13 @@ headless_input_init_input(headless_input_t *hi) PEPPER_TRACE("%d evdev device(s) has been found.\n", probed); + inotify = pepper_inotify_create(hi->compositor, _cb_handle_inotify_event, hi); + PEPPER_CHECK(inotify, goto end, "Failed to create inotify\n"); + + pepper_inotify_add(inotify, "/dev/input/"); + + hi->inotify = inotify; + return PEPPER_TRUE; end: