From 7f526e6bcd0255ef0900509b4f6721eaeb1fbda5 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 12 Sep 2017 11:08:25 +0900 Subject: [PATCH] doctor: use doctor as a reference implementation of headless server Change-Id: I81a19fc3162787a3a6868c3f76adef7d43078ede Signed-off-by: Sung-Jin Park --- configure.ac | 42 +++------ packaging/pepper.spec | 4 +- src/bin/doctor/Makefile.am | 16 +++- .../doctor/doctor-client.c} | 28 ++++-- .../headless-server.c => bin/doctor/doctor.c} | 0 src/bin/doctor/server.c | 93 ------------------- src/samples/Makefile.am | 12 --- 7 files changed, 51 insertions(+), 144 deletions(-) rename src/{samples/headless-client.c => bin/doctor/doctor-client.c} (92%) rename src/{samples/headless-server.c => bin/doctor/doctor.c} (100%) delete mode 100644 src/bin/doctor/server.c diff --git a/configure.ac b/configure.ac index 8494b0e..104672a 100644 --- a/configure.ac +++ b/configure.ac @@ -240,18 +240,6 @@ if test x$enable_x11 = xyes; then AC_SUBST(PEPPER_X11_REQUIRES) fi -# doctor -DOCTOR_REQUIRES="wayland-server pixman-1 libudev" -PKG_CHECK_MODULES(DOCTOR, [$DOCTOR_REQUIRES]) - -DOCTOR_CFLAGS="$PEPPER_DIR $PEPPER_DRM_DIR $PEPPER_DESKTOP_SHELL_DIR $DOCTOR_CFLAGS" -DOCTOR_CFLAGS="$PEPPER_LIBINPUT_DIR $DOCTOR_CFLAGS" -DOCTOR_LIBS="$PEPPER_LIB $PEPPER_DRM_LIB $PEPPER_DESKTOP_SHELL_LIB $DOCTOR_LIBS" -DOCTOR_LIBS="$PEPPER_LIBINPUT_LIB $PEPPER_LIBINPUT_LIBS $DOCTOR_LIBS" - -AC_SUBST(DOCTOR_CFLAGS) -AC_SUBST(DOCTOR_LIBS) - # shell client SHELL_CLIENT_REQUIRES="wayland-client pixman-1" PKG_CHECK_MODULES(SHELL_CLIENT, [$SHELL_CLIENT_REQUIRES]) @@ -285,24 +273,24 @@ SAMPLES_LIBS="$PEPPER_X11_LIB $PEPPER_X11_LIBS $SAMPLES_LIBS" AC_SUBST(SAMPLES_CFLAGS) AC_SUBST(SAMPLES_LIBS) -# headless server and headless client samples -HEADLESS_SERVER_REQUIRES="wayland-server" -PKG_CHECK_MODULES(HEADLESS_SERVER, $[HEADLESS_SERVER_REQUIRES]) -HEADLESS_SERVER_CFLAGS="$PEPPER_DIR $PEPPER_EVDEV_DIR $PEPPER_KEYROUTER_DIR $HEADLESS_SERVER_CFLAGS" -HEADLESS_SERVER_LIBS="$PEPPER_LIB $PEPPER_LIBS $HEADLESS_SERVER_LIBS" -HEADLESS_SERVER_LIBS="$PEPPER_EVDEV_LIB $PEPPER_EVDEV_LIBS $HEADLESS_SERVER_LIBS" -HEADLESS_SERVER_LIBS="$PEPPER_KEYROUTER_LIB $PEPPER_KEYROUTER_LIBS $HEADLESS_SERVER_LIBS" +# doctor (headless server) and headless client samples +DOCTOR_SERVER_REQUIRES="wayland-server" +PKG_CHECK_MODULES(DOCTOR_SERVER, $[DOCTOR_SERVER_REQUIRES]) +DOCTOR_SERVER_CFLAGS="$PEPPER_DIR $PEPPER_EVDEV_DIR $PEPPER_KEYROUTER_DIR $DOCTOR_SERVER_CFLAGS" +DOCTOR_SERVER_LIBS="$PEPPER_LIB $PEPPER_LIBS $DOCTOR_SERVER_LIBS" +DOCTOR_SERVER_LIBS="$PEPPER_EVDEV_LIB $PEPPER_EVDEV_LIBS $DOCTOR_SERVER_LIBS" +DOCTOR_SERVER_LIBS="$PEPPER_KEYROUTER_LIB $PEPPER_KEYROUTER_LIBS $DOCTOR_SERVER_LIBS" -AC_SUBST(HEADLESS_SERVER_CFLAGS) -AC_SUBST(HEADLESS_SERVER_LIBS) +AC_SUBST(DOCTOR_SERVER_CFLAGS) +AC_SUBST(DOCTOR_SERVER_LIBS) -HEADLESS_CLIENT_REQUIRES="wayland-client tizen-extension-client" -PKG_CHECK_MODULES(HEADLESS_CLIENT, $[HEADLESS_CLIENT_REQUIRES]) -HEADLESS_CLIENT_CFLAGS="$HEADLESS_CLIENT_CFLAGS" -HEADLESS_CLIENT_LIBS="$HEADLESS_CLIENT_LIBS" +DOCTOR_CLIENT_REQUIRES="wayland-client tizen-extension-client" +PKG_CHECK_MODULES(DOCTOR_CLIENT, $[DOCTOR_CLIENT_REQUIRES]) +DOCTOR_CLIENT_CFLAGS="$DOCTOR_CLIENT_CFLAGS" +DOCTOR_CLIENT_LIBS="$DOCTOR_CLIENT_LIBS" -AC_SUBST(HEADLESS_CLIENT_CFLAGS) -AC_SUBST(HEADLESS_CLIENT_LIBS) +AC_SUBST(DOCTOR_CLIENT_CFLAGS) +AC_SUBST(DOCTOR_CLIENT_LIBS) # sample client SAMPLE_CLIENT_REQUIRES="wayland-client tizen-extension-client xkbcommon" diff --git a/packaging/pepper.spec b/packaging/pepper.spec index 8ac4213..b09b649 100644 --- a/packaging/pepper.spec +++ b/packaging/pepper.spec @@ -198,6 +198,7 @@ This package includes wayland backend development module files. ###### doctor server %package doctor Summary: Doctor server for pepper package +Requires: pepper pepper-keyrouter pepper-evdev %description doctor This package includes doctor server files. @@ -421,11 +422,10 @@ make %{?_smp_mflags} %manifest %{name}.manifest %defattr(-,root,root,-) %license COPYING -%{_bindir}/doctor +%{_bindir}/doctor* %files samples %manifest %{name}.manifest %defattr(-,root,root,-) %{_bindir}/*-backend -%{_bindir}/headless* %{_bindir}/sample-* diff --git a/src/bin/doctor/Makefile.am b/src/bin/doctor/Makefile.am index e08aec6..3c6dcfa 100644 --- a/src/bin/doctor/Makefile.am +++ b/src/bin/doctor/Makefile.am @@ -1,6 +1,14 @@ -bin_PROGRAMS = doctor +bin_PROGRAMS = -doctor_CFLAGS = $(DOCTOR_CFLAGS) -doctor_LDADD = $(DOCTOR_LIBS) +bin_PROGRAMS += doctor doctor-client + +doctor_CFLAGS = $(DOCTOR_SERVER_CFLAGS) +doctor_LDADD = $(DOCTOR_SERVER_LIBS) + +doctor_SOURCES = doctor.c + +doctor_client_CFLAGS = $(DOCTOR_CLIENT_CFLAGS) +doctor_client_LDADD = $(DOCTOR_CLIENT_LIBS) + +doctor_client_SOURCES = doctor-client.c -doctor_SOURCES = server.c diff --git a/src/samples/headless-client.c b/src/bin/doctor/doctor-client.c similarity index 92% rename from src/samples/headless-client.c rename to src/bin/doctor/doctor-client.c index 17f940f..b739e01 100644 --- a/src/samples/headless-client.c +++ b/src/bin/doctor/doctor-client.c @@ -327,25 +327,41 @@ grab_keys(headless_info_t *headless) wl_array_init(&keygrab_array); - //grab informa key(100), mode(OR_EXCLUSIVE) and error + //grab information : key(169), mode(OR_EXCLUSIVE) and error uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); - *uint_ptr = 169;//menu key in mobile + *uint_ptr = 169;//menu key uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); *uint_ptr = TIZEN_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE; uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); *uint_ptr = 0; - //grab informa key(200), mode(OR_EXCLUSIVE) and error + //grab information : key(139), mode(OR_EXCLUSIVE) and error uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); - *uint_ptr = 139;//home key in mobile + *uint_ptr = 139;//home key uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); *uint_ptr = TIZEN_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE; uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); *uint_ptr = 0; - //grab informa key(300), mode(OR_EXCLUSIVE) and error + //grab information : key(158), mode(OR_EXCLUSIVE) and error uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); - *uint_ptr = 158;//back key in mobile + *uint_ptr = 158;//back key + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = TIZEN_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE; + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = 0; + + //grab information : key(28), mode(OR_EXCLUSIVE) and error + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = 28;//enter key on a keyboard + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = TIZEN_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE; + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = 0; + + //grab information : key(57), mode(OR_EXCLUSIVE) and error + uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); + *uint_ptr = 57;//space bar on a keyboard uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); *uint_ptr = TIZEN_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE; uint_ptr = wl_array_add(&keygrab_array, sizeof(unsigned int)); diff --git a/src/samples/headless-server.c b/src/bin/doctor/doctor.c similarity index 100% rename from src/samples/headless-server.c rename to src/bin/doctor/doctor.c diff --git a/src/bin/doctor/server.c b/src/bin/doctor/server.c deleted file mode 100644 index 165f87a..0000000 --- a/src/bin/doctor/server.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -* Copyright © 2008-2012 Kristian Høgsberg -* Copyright © 2010-2012 Intel Corporation -* Copyright © 2011 Benjamin Franzke -* Copyright © 2012 Collabora, Ltd. -* Copyright © 2015 S-Core Corporation -* Copyright © 2015-2016 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include - -#include -#include -#include - -int -main(int argc, char **argv) -{ - struct udev *udev = NULL; - pepper_libinput_t *input = NULL; - - struct wl_display *display; - pepper_compositor_t *compositor; - const char* socket_name = NULL; - - if (!getenv("XDG_RUNTIME_DIR")) - setenv("XDG_RUNTIME_DIR", "/run", 1); - - socket_name = getenv("WAYLAND_DISPLAY"); - - if (!socket_name) - socket_name = "wayland-0"; - - compositor = pepper_compositor_create(socket_name); - - if (!compositor) - return -1; - - display = pepper_compositor_get_display(compositor); - - if (!display) - { - pepper_compositor_destroy(compositor); - return -1; - } - - udev = udev_new(); - PEPPER_CHECK(udev, goto shutdown_on_failure, "Failed to get udev !\n"); - - input = pepper_libinput_create(compositor, udev); - PEPPER_CHECK(input, goto shutdown_on_failure, "Failed to create pepepr libinput !\n"); - - if (!pepper_desktop_shell_init(compositor)) - { - PEPPER_ERROR("Failed to initialize pepper desktop shell !\n"); - goto shutdown_on_failure; - } - - /* Enter main loop. */ - wl_display_run(display); - -shutdown_on_failure: - - if (input) - pepper_libinput_destroy(input); - - if (udev) - udev_unref(udev); - - if (compositor) - pepper_compositor_destroy(compositor); - - return 0; -} diff --git a/src/samples/Makefile.am b/src/samples/Makefile.am index 29ac394..bd63fb5 100644 --- a/src/samples/Makefile.am +++ b/src/samples/Makefile.am @@ -44,18 +44,6 @@ x11_backend_LDADD = $(SAMPLES_LIBS) x11_backend_SOURCES = x11-backend.c endif -bin_PROGRAMS += headless-server headless-client - -headless_server_CFLAGS = $(HEADLESS_SERVER_CFLAGS) -headless_server_LDADD = $(HEADLESS_SERVER_LIBS) - -headless_server_SOURCES = headless-server.c - -headless_client_CFLAGS = $(HEADLESS_CLIENT_CFLAGS) -headless_client_LDADD = $(HEADLESS_CLIENT_LIBS) - -headless_client_SOURCES = headless-client.c - bin_PROGRAMS += sample-server sample-client sample_server_CFLAGS = $(SAMPLE_SERVER_CFLAGS) -- 2.34.1