From 68adbfd5174f21830d7ddea2c102cb69d527a3c1 Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Sat, 10 Nov 2018 17:53:32 +0000 Subject: Add example:weston-terminal Example of launching weston-terminal Issue: 1. --fullscreen doesn't work 2. scaled, not dot-by-dot Change-Id: I0c3034bc9584228de4f0eb68723ea3f000344843 Signed-off-by: Tadao Tanikawa --- CMakeLists.txt | 5 ++ package/weston-terminal/bin/runxdg | 2 + package/weston-terminal/config.xml | 17 ++++++ package/weston-terminal/icon.svg | 114 ++++++++++++++++++++++++++++++++++++ package/weston-terminal/runxdg.toml | 25 ++++++++ src/runxdg.cpp | 28 ++++++--- src/runxdg.hpp | 7 ++- 7 files changed, 187 insertions(+), 11 deletions(-) create mode 100755 package/weston-terminal/bin/runxdg create mode 100644 package/weston-terminal/config.xml create mode 100644 package/weston-terminal/icon.svg create mode 100644 package/weston-terminal/runxdg.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index af5e6b7..67bd88f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(PkgConfig REQUIRED) pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(GIO REQUIRED gio-2.0) pkg_check_modules(ILMCONTROL REQUIRED ilmControl) +pkg_check_modules(ILMINPUT REQUIRED ilmInput) # No configuration # configure_file ( @@ -22,6 +23,7 @@ pkg_check_modules(ILMCONTROL REQUIRED ilmControl) include_directories( "include" "${ILMCONTROL_INCLUDE_DIRS}" + "${ILMINPUT_INCLUDE_DIRS}" "${GLIB_INCLUDE_DIRS}" "${GIO_INCLUDE_DIRS}" ) @@ -34,6 +36,7 @@ SET(LIBRARIES windowmanager homescreen ${ILMCONTROL_LIBRARIES} + ${ILMINPUT_LIBRARIES} afbwsc json-c pthread @@ -64,4 +67,6 @@ add_custom_target(widget # test for webbrowser COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/webbrowser.wgt ${PROJECT_BINARY_DIR}/package/webbrowser + # test for weston-terminal + COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/weston-terminal.wgt ${PROJECT_BINARY_DIR}/package/weston-terminal ) diff --git a/package/weston-terminal/bin/runxdg b/package/weston-terminal/bin/runxdg new file mode 100755 index 0000000..dac903c --- /dev/null +++ b/package/weston-terminal/bin/runxdg @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/runxdg $@ diff --git a/package/weston-terminal/config.xml b/package/weston-terminal/config.xml new file mode 100644 index 0000000..619f682 --- /dev/null +++ b/package/weston-terminal/config.xml @@ -0,0 +1,17 @@ + + + weston-terminal + + + Launcher for XDG application on AGL HomeScreen 2017 + Panasonic Corporation + MIT + + + + + + + + + diff --git a/package/weston-terminal/icon.svg b/package/weston-terminal/icon.svg new file mode 100644 index 0000000..882e3c4 --- /dev/null +++ b/package/weston-terminal/icon.svg @@ -0,0 +1,114 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/package/weston-terminal/runxdg.toml b/package/weston-terminal/runxdg.toml new file mode 100644 index 0000000..abd7c14 --- /dev/null +++ b/package/weston-terminal/runxdg.toml @@ -0,0 +1,25 @@ +[application] +# role: identifier for WindowManager (used in layers.json) +# e.g. role = "WebBrowser" +role = "weston-terminal" + +# launch by "POSIX"(fork/exec), "AFM_DBUS"(afm via dbus), "AFM_WEBSOCKET"(afm via websockt) +method = "POSIX" + +# path: path to the executable +# e.g. +# path = "/usr/bin/chromium" +path = "/usr/bin/weston-terminal" + +# params: arguments of the excecutable +# e.g. +# params = [ +# "--mus", +# "--no-sandbox", +# "--window-size=1080,1488", +# "--ozone-platform=wayland", +# "" +# ] +params = [ + "--fullscreen" +] diff --git a/src/runxdg.cpp b/src/runxdg.cpp index 3ff942c..1ce3881 100644 --- a/src/runxdg.cpp +++ b/src/runxdg.cpp @@ -83,7 +83,8 @@ void RunXDG::notify_ivi_control_cb (ilmObjectType object, t_ilm_uint id, m_launcher->register_surfpid(surf_pid); if (m_launcher->m_rid && surf_pid == m_launcher->find_surfpid_by_rid(m_launcher->m_rid)) { - setup_surface(id); + m_ivi_id = id; + setup_surface(); } m_surfaces[surf_pid] = id; } else if (object == ILM_LAYER) { @@ -279,12 +280,16 @@ int RunXDG::init_wm (void) return -1; } - std::function< void(json_object*) > h_active = [](json_object* object) { + std::function< void(json_object*) > h_active = [this](json_object* object) { AGL_DEBUG("Got Event_Active"); + t_ilm_surface s_ids[1] = { this->m_ivi_id }; + ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_TRUE); }; - std::function< void(json_object*) > h_inactive = [](json_object* object) { + std::function< void(json_object*) > h_inactive = [this](json_object* object) { AGL_DEBUG("Got Event_Inactive"); + t_ilm_surface s_ids[1] = { this->m_ivi_id }; + ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_FALSE); }; std::function< void(json_object*) > h_visible = [](json_object* object) { @@ -332,9 +337,13 @@ int RunXDG::init_hs (void) if (json_object_object_get_ex(object, "application_name", &val)) { const char *name = json_object_get_string(val); - AGL_DEBUG("Event_TapShortcut <%s>", name); + const char *app_id = this->m_id.c_str(); + int len = strlen(name); - if (strcmp(name, this->m_role.c_str()) == 0) { + AGL_DEBUG("Event_TapShortcut ", name, app_id, len); + + if (strcmp(name, app_id) == 0 || + (strncmp(name, app_id, len) == 0 && ('@' == app_id[len]))) { // check app exist and re-launch if needed AGL_DEBUG("Activesurface %s ", this->m_role.c_str()); @@ -454,7 +463,7 @@ RunXDG::RunXDG (int port, const char* token, const char* id) AGL_FATAL("Error in config"); } - AGL_DEBUG("id=[%s], name=[%s], path=[%s], port=%lu, token=[%s]", + AGL_DEBUG("id=[%s], role=[%s], path=[%s], port=%lu, token=[%s]", m_id.c_str(), m_role.c_str(), m_path.c_str(), m_port, m_token.c_str()); @@ -471,9 +480,9 @@ RunXDG::RunXDG (int port, const char* token, const char* id) AGL_DEBUG("RunXDG created."); } -void RunXDG::setup_surface (int id) +void RunXDG::setup_surface (void) { - std::string sid = std::to_string(id); + std::string sid = std::to_string(m_ivi_id); // This surface is mine, register pair app_name and ivi id. json_object *obj = json_object_new_object(); @@ -599,7 +608,8 @@ void RunXDG::start (void) int id = itr->second; AGL_DEBUG("surface %d for <%s> already exists", id, m_role.c_str()); - setup_surface(id); + m_ivi_id = id; + setup_surface(); } } } diff --git a/src/runxdg.hpp b/src/runxdg.hpp index ce0c016..3a51c58 100644 --- a/src/runxdg.hpp +++ b/src/runxdg.hpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -149,7 +150,9 @@ class RunXDG LibHomeScreen *m_hs; ILMControl *m_ic; - std::map m_surfaces; // pair of + t_ilm_surface m_ivi_id; + + std::map m_surfaces; // pair of bool m_pending_create = false; @@ -158,7 +161,7 @@ class RunXDG int parse_config(const char *file); - void setup_surface(int id); + void setup_surface(void); }; #endif // RUNXDG_HPP -- cgit 1.2.3-korg