homescreenhandler: Add the ability to specify the output based on the 23/24823/1
authorMarius Vlad <marius.vlad@collabora.com>
Fri, 29 May 2020 10:30:15 +0000 (13:30 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Wed, 24 Jun 2020 14:05:32 +0000 (17:05 +0300)
screen

Pass the output when activing the surface in Launcher.qml

Bug-AGL: SPEC-3447

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I4b8f03c90712290f580a570cd2644a4bc44687c5

launcher/qml/Launcher.qml
launcher/src/homescreenhandler.cpp
launcher/src/homescreenhandler.h
launcher/src/shell-desktop.cpp
launcher/src/shell-desktop.h

index f7f1c1b..27b0d3d 100644 (file)
@@ -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 = ''
                 }
index 3c16c23..4d98414 100644 (file)
@@ -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)
index ac490ce..471a663 100644 (file)
@@ -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);
index 42cc6d1..b8e6ef0 100644 (file)
@@ -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)
 {
index a8f3326..f65e67d 100644 (file)
@@ -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);