From fc41fa6da7f64262a7bbc4313b920762e1a31d15 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 29 May 2020 13:30:15 +0300 Subject: homescreenhandler: Add the ability to specify the output based on the screen Pass the output when activing the surface in Launcher.qml Bug-AGL: SPEC-3447 Signed-off-by: Marius Vlad Change-Id: I4b8f03c90712290f580a570cd2644a4bc44687c5 --- launcher/qml/Launcher.qml | 8 +++++++- launcher/src/homescreenhandler.cpp | 7 +++++-- launcher/src/homescreenhandler.h | 2 +- launcher/src/shell-desktop.cpp | 25 +++++++++++++++++++++++++ launcher/src/shell-desktop.h | 3 +++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/launcher/qml/Launcher.qml b/launcher/qml/Launcher.qml index f7f1c1b..27b0d3d 100644 --- a/launcher/qml/Launcher.qml +++ b/launcher/qml/Launcher.qml @@ -82,6 +82,7 @@ ApplicationWindow { property string currentId: '' property int newIndex: -1 property int index: grid.indexAt(loc.mouseX, loc.mouseY) + property string output_screen: '' x: 62 y: 264 onPressAndHold: currentId = applicationModel.id(newIndex = index) @@ -89,8 +90,13 @@ ApplicationWindow { if(loc.index < 0) { return } + + //if (applicationModel.appid(loc.index) === 'tbtnavi' || + // applicationModel.appid(loc.index) === 'hvac') { + // output_screen = 'Virtual-1' + //} if (currentId === '') { - homescreenHandler.tapShortcut(applicationModel.appid(loc.index)) + homescreenHandler.tapShortcut(applicationModel.appid(loc.index), output_screen) } else { currentId = '' } diff --git a/launcher/src/homescreenhandler.cpp b/launcher/src/homescreenhandler.cpp index 3c16c23..4d98414 100644 --- a/launcher/src/homescreenhandler.cpp +++ b/launcher/src/homescreenhandler.cpp @@ -172,7 +172,7 @@ void HomescreenHandler::init(int port, const char *token, QString myname) }); } -void HomescreenHandler::tapShortcut(QString application_id) +void HomescreenHandler::tapShortcut(QString application_id, QString output_name) { HMI_DEBUG("Launcher","tapShortcut %s", application_id.toStdString().c_str()); struct json_object* j_json = json_object_new_object(); @@ -181,7 +181,10 @@ void HomescreenHandler::tapShortcut(QString application_id) json_object_object_add(j_json, "area", value); mp_hs->showWindow(application_id.toStdString().c_str(), j_json); - aglShell->activate_app(nullptr, application_id, nullptr); + if (output_name.isEmpty()) + aglShell->activate_app(nullptr, application_id, nullptr); + else + aglShell->activate_app_by_screen(output_name, application_id, nullptr); } void HomescreenHandler::onRep_static(struct json_object* reply_contents) diff --git a/launcher/src/homescreenhandler.h b/launcher/src/homescreenhandler.h index ac490ce..471a663 100644 --- a/launcher/src/homescreenhandler.h +++ b/launcher/src/homescreenhandler.h @@ -35,7 +35,7 @@ public: void init(int port, const char* token, QString myname); - Q_INVOKABLE void tapShortcut(QString application_id); + Q_INVOKABLE void tapShortcut(QString application_id, QString output_name); Q_INVOKABLE void getRunnables(void); void onRep(struct json_object* reply_contents); diff --git a/launcher/src/shell-desktop.cpp b/launcher/src/shell-desktop.cpp index 42cc6d1..b8e6ef0 100644 --- a/launcher/src/shell-desktop.cpp +++ b/launcher/src/shell-desktop.cpp @@ -51,6 +51,31 @@ Shell::activate_app(QWindow *win, const QString &app_id, app_data.toStdString().c_str(), output); } +void +Shell::activate_app_by_screen(const QString &screen_name, const QString &app_id, + const QString &app_data) +{ + QScreen *qscreen_to_put = nullptr; + for (auto &ss: qApp->screens()) { + if (ss->name() == screen_name) { + qscreen_to_put = ss; + break; + } + } + + /* use the primary one */ + if (!qscreen_to_put) { + qscreen_to_put = qApp->screens().first(); + } + + struct wl_output *output = getWlOutput(qscreen_to_put); + qDebug() << "will activate app: " << app_id << " on output " << + qscreen_to_put->name(); + agl_shell_desktop_activate_app(this->shell.get(), + app_id.toStdString().c_str(), + app_data.toStdString().c_str(), output); +} + void Shell::deactivate_app(const QString &app_id) { diff --git a/launcher/src/shell-desktop.h b/launcher/src/shell-desktop.h index a8f3326..f65e67d 100644 --- a/launcher/src/shell-desktop.h +++ b/launcher/src/shell-desktop.h @@ -56,6 +56,9 @@ public: public slots: // calls out of qml into CPP void activate_app(QWindow *win, const QString &app_id, const QString &app_data); + void activate_app_by_screen(const QString &screen_name, + const QString &app_id, + const QString &app_data); void deactivate_app(const QString &app_id); void set_window_props(QWindow *win, const QString &app_id, uint32_t props, int x, int y); -- cgit 1.2.3-korg