X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=sample%2Fapp%2Feventhandler.cpp;h=17decc41d1440b4820cdc7e7e4b06e2678eed53b;hb=ff66bdf313d0695aa8042c3f707282fa68b0ead3;hp=388291fc54fd9bd8bb2077eb77437bdde7f03d28;hpb=85a1f5f0305fda98d7077bab78070456bcd680ac;p=apps%2Fonscreenapp.git diff --git a/sample/app/eventhandler.cpp b/sample/app/eventhandler.cpp index 388291f..17decc4 100644 --- a/sample/app/eventhandler.cpp +++ b/sample/app/eventhandler.cpp @@ -74,13 +74,24 @@ application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop, return; qInfo() << "app_id: " << app_id; +} - if (strcmp(app_id, "onescreenapp") == 0) - emit ev_handler->signalOnReplyShowWindow(app_id); +static void +application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop, + const char *app_id, const char *app_data, uint32_t app_state, uint32_t app_role) +{ + /* unused */ + (void) data; + (void) app_id; + (void) app_data; + (void) app_role; + (void) app_state; + (void) agl_shell_desktop; } static const struct agl_shell_desktop_listener agl_shell_desk_listener = { application_id_event, + application_state_event, }; static struct agl_shell_desktop * @@ -137,6 +148,11 @@ void EventHandler::init(int port, const char *token) if (shell_desktop) agl_shell_desktop_add_listener(shell_desktop, &agl_shell_desk_listener, this); + + m_launcher = new Launcher(DEFAULT_AFM_UNIX_SOCK, nullptr); + if (m_launcher->setup_pws_connection() != 0) + HMI_DEBUG("onscreen", "EventHandler::init failed to set-up connection to afm-system-daemon"); + #if 0 myThis = this; mp_wm = new QLibWindowmanager(); @@ -197,7 +213,11 @@ void EventHandler::showWindow(QString id, QString json) { if (shell_desktop) { struct wl_output *output = getWlOutput(qApp->screens().first()); - agl_shell_desktop_activate_app(shell_desktop, id.toStdString().c_str(), output); + qInfo() << "sending activate_app"; + agl_shell_desktop_activate_app(shell_desktop, + id.toStdString().c_str(), + json.toStdString().c_str(), + output); } qInfo() << "data from json: " << json.toStdString().c_str(); @@ -217,3 +237,34 @@ void EventHandler::hideWindow(QString id) mp_hs->hideWindow(id.toStdString().c_str()); #endif } + +int +EventHandler::start(const QString &app_id) +{ + int pid = -1; + + if (m_launcher && m_launcher->connection_is_set()) + pid = m_launcher->start(app_id); + + return pid; +} + +bool +EventHandler::is_running(const QString &app_id) +{ + if (m_launcher && m_launcher->connection_is_set()) + return m_launcher->is_running(app_id); + + return false; +} + +void +EventHandler::set_window_popup(const QString &app_id, int x, int y) +{ + struct wl_output *output = getWlOutput(qApp->screens().first()); + + if (shell_desktop) + agl_shell_desktop_set_app_property(shell_desktop, + app_id.toStdString().c_str(), + AGL_SHELL_DESKTOP_APP_ROLE_POPUP, x, y, output); +}