From 020464e433a3811399ecc4497626003130a1f17e Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 16 Apr 2019 21:12:41 +0900 Subject: [PATCH] headless-client: add basic implementation Change-Id: I2f0fe96c7779532c469614027e2828e57fd9dcd4 Signed-off-by: Sung-Jin Park --- configure.ac | 8 ++ packaging/pepper.spec | 2 + src/samples/headless_client.c | 196 ++++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+) diff --git a/configure.ac b/configure.ac index 20f1b68..6f37bf1 100644 --- a/configure.ac +++ b/configure.ac @@ -334,6 +334,14 @@ DOCTOR_CLIENT_LIBS="$DOCTOR_CLIENT_LIBS" AC_SUBST(DOCTOR_CLIENT_CFLAGS) AC_SUBST(DOCTOR_CLIENT_LIBS) +HEADLESS_CLIENT_REQUIRES="wayland-client tizen-extension-client ecore-wl2 capi-ui-efl-util" +PKG_CHECK_MODULES(HEADLESS_CLIENT, $[HEADLESS_CLIENT_REQUIRES]) +HEADLESS_CLIENT_CFLAGS="$HEADLESS_CLIENT_CFLAGS -DEFL_BETA_API_SUPPORT" +HEADLESS_CLIENT_LIBS="$HEADLESS_CLIENT_LIBS" + +AC_SUBST(HEADLESS_CLIENT_CFLAGS) +AC_SUBST(HEADLESS_CLIENT_LIBS) + # sample client SAMPLE_CLIENT_REQUIRES="wayland-client tizen-extension-client xkbcommon" PKG_CHECK_MODULES(SAMPLE_CLIENT, $[SAMPLE_CLIENT_REQUIRES]) diff --git a/packaging/pepper.spec b/packaging/pepper.spec index 5973111..d47d0d9 100644 --- a/packaging/pepper.spec +++ b/packaging/pepper.spec @@ -30,6 +30,8 @@ BuildRequires: pkgconfig(wayland-tbm-server) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(tizen-extension-server) BuildRequires: pkgconfig(tizen-extension-client) +BuildRequires: pkgconfig(ecore-wl2) +BuildRequires: pkgconfig(capi-ui-efl-util) %if "%{ENABLE_TDM}" == "1" BuildRequires: pkgconfig(libtdm) %endif diff --git a/src/samples/headless_client.c b/src/samples/headless_client.c index 4be0df7..32c681c 100644 --- a/src/samples/headless_client.c +++ b/src/samples/headless_client.c @@ -1,7 +1,203 @@ +#include #include +#include +#include + +#define DISPLAY_NAME "headless-0" + +#define DEBUG +#ifdef DEBUG +#define TRACE(fmt, ...) \ + do { \ + printf("[headless-client : %s] "fmt, __FUNCTION__, ##__VA_ARGS__); \ + } while (0) +#else +#define TRACE(fmt, ...) + do { \ + ; + } while (0) +#endif + +#define ERROR_CHECK(exp, action, fmt, ...) \ + do { \ + if (!(exp)) \ + { \ + printf(fmt, ##__VA_ARGS__); \ + action; \ + } \ + } while (0) + +typedef struct app_data app_data_t; +struct app_data +{ + Ecore_Wl2_Display *ewd; + Ecore_Wl2_Window *win; +}; + +static Eina_Array *_ecore_event_hdls; + +static Eina_Bool +_cb_focus_in(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Focus_In *ev = (Ecore_Wl2_Event_Focus_In *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_focus_out(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Focus_Out *ev = (Ecore_Wl2_Event_Focus_Out *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_window_show(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Window_Show *ev = (Ecore_Wl2_Event_Window_Show *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_window_lower(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Window_Lower *ev = (Ecore_Wl2_Event_Window_Lower *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_window_activate(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Window_Activate *ev = (Ecore_Wl2_Event_Window_Activate *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_window_deactivate(void *data, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Wl2_Event_Window_Deactivate *ev = (Ecore_Wl2_Event_Window_Deactivate *)event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Event_Key *ev = event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + app_data_t *client = (app_data_t *)data; + Ecore_Event_Key *ev = event; + + TRACE(""); + + /* TODO */ + + return ECORE_CALLBACK_PASS_ON; +} + +static void _event_handlers_init(app_data_t *client) +{ + Ecore_Event_Handler *h = NULL; + + _ecore_event_hdls = eina_array_new(10); + h = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, _cb_focus_in, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, _cb_focus_out, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW, _cb_window_show, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_LOWER, _cb_window_lower, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE, _cb_window_activate, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_DEACTIVATE, _cb_window_deactivate, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _cb_key_down, client); + eina_array_push(_ecore_event_hdls, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _cb_key_up, client); + eina_array_push(_ecore_event_hdls, h); +} int main(int argc, char **argv) { + int x, y, w, h; + app_data_t *client = NULL; + + client = (app_data_t *)calloc(1, sizeof(app_data_t)); + ERROR_CHECK(client, goto shutdown, "Failed to allocate memory for app_data_t"); + + if (!ecore_wl2_init()) + { + TRACE("Failed to initialize ecore_wl2"); + goto shutdown; + } + + client->ewd = ecore_wl2_display_connect(DISPLAY_NAME); + ERROR_CHECK(client->ewd, goto shutdown, "Failed to connect to wayland display %s", DISPLAY_NAME); + + _event_handlers_init(client); + + x = y = 0; + w = h = 1; + client->win = ecore_wl2_window_new(client->ewd, NULL, x, y, w, h); + + /* TODO */ + return EXIT_SUCCESS; + +shutdown: + return EXIT_FAILURE; } -- 2.34.1