diff options
-rw-r--r-- | homescreen/src/homescreenhandler.cpp | 35 | ||||
-rw-r--r-- | homescreen/src/homescreenhandler.h | 1 | ||||
-rw-r--r-- | homescreen/src/main.cpp | 51 |
3 files changed, 69 insertions, 18 deletions
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp index e7d6a39..918237a 100644 --- a/homescreen/src/homescreenhandler.cpp +++ b/homescreen/src/homescreenhandler.cpp @@ -11,6 +11,8 @@ #include "homescreenhandler.h" #include "hmi-debug.h" +QScreen *find_screen(const char *output); + // defined by meson build file #include QT_QPA_HEADER @@ -98,8 +100,39 @@ void HomescreenHandler::activateApp(const QString& app_id) if (mp_launcher) { mp_launcher->setCurrent(app_id); } + HMI_DEBUG("HomeScreen", "Activating app_id %s by default output %p\n", + app_id.toStdString().c_str(), mm_output); + + // search for a pending application which might have a different output + auto iter = pending_app_list.begin(); + bool found_pending_app = false; + while (iter != pending_app_list.end()) { + const QString &app_to_search = iter->first; + + if (app_to_search == app_id) { + found_pending_app = true; + break; + } + + iter++; + } + + if (found_pending_app) { + const QString &output_name = iter->second; + QScreen *screen = + ::find_screen(output_name.toStdString().c_str()); + + mm_output = getWlOutput(native, screen); + pending_app_list.erase(iter); + + HMI_DEBUG("HomeScreen", "For application %s found another " + "output to activate %s\n", + app_id.toStdString().c_str(), + output_name.toStdString().c_str()); + } - HMI_DEBUG("HomeScreen", "Activating application %s", app_id.toStdString().c_str()); + HMI_DEBUG("HomeScreen", "Activating application %s", + app_id.toStdString().c_str()); agl_shell_activate_app(agl_shell, app_id.toStdString().c_str(), mm_output); } diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h index a2baeb2..e014192 100644 --- a/homescreen/src/homescreenhandler.h +++ b/homescreen/src/homescreenhandler.h @@ -30,6 +30,7 @@ public: void activateApp(const QString& app_id); void deactivateApp(const QString& app_id); + std::list<std::pair<const QString, const QString>> pending_app_list; signals: void showNotification(QString application_id, QString icon_path, QString text); void showInformation(QString info); diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 5d7e36d..d2967ca 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -36,6 +36,23 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif +QScreen * +find_screen(const char *screen_name) +{ + QList<QScreen *> screens = qApp->screens(); + QScreen *found = nullptr; + QString qstr_name = QString::fromUtf8(screen_name, -1); + + for (QScreen *xscreen : screens) { + if (qstr_name == xscreen->name()) { + found = xscreen; + break; + } + } + + return found; +} + struct shell_data { struct agl_shell *shell; HomescreenHandler *homescreenHandler; @@ -90,12 +107,28 @@ agl_shell_app_state(void *data, struct agl_shell *agl_shell, } } +static void +agl_shell_app_on_output(void *data, struct agl_shell *agl_shell, + const char *app_id, const char *output_name) +{ + struct shell_data *shell_data = static_cast<struct shell_data *>(data); + HomescreenHandler *homescreenHandler = shell_data->homescreenHandler; + + if (!homescreenHandler) + return; + + std::pair new_pending_app = std::pair(QString(app_id), + QString(output_name)); + homescreenHandler->pending_app_list.push_back(new_pending_app); +} + #ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION static const struct agl_shell_listener shell_listener = { agl_shell_bound_ok, agl_shell_bound_fail, agl_shell_app_state, + agl_shell_app_on_output, }; #endif @@ -112,7 +145,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t name, if (ver >= 2) { shell_data->shell = static_cast<struct agl_shell *>( - wl_registry_bind(reg, name, &agl_shell_interface, MIN(4, ver))); + wl_registry_bind(reg, name, &agl_shell_interface, MIN(8, ver))); #ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION agl_shell_add_listener(shell_data->shell, &shell_listener, data); #endif @@ -192,22 +225,6 @@ create_component(QPlatformNativeInterface *native, QQmlComponent *comp, return getWlSurface(native, win); } -static QScreen * -find_screen(const char *screen_name) -{ - QList<QScreen *> screens = qApp->screens(); - QScreen *found = nullptr; - QString qstr_name = QString::fromUtf8(screen_name, -1); - - for (QScreen *xscreen : screens) { - if (qstr_name == xscreen->name()) { - found = xscreen; - break; - } - } - - return found; -} static void load_agl_shell(QPlatformNativeInterface *native, QQmlApplicationEngine *engine, |