homescreenhandler: Handle dynamic movement of windows 25/28725/1
authorMarius Vlad <marius.vlad@collabora.com>
Thu, 27 Apr 2023 19:01:38 +0000 (22:01 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Thu, 27 Apr 2023 20:23:21 +0000 (23:23 +0300)
Between different outputs. This works in connection with the
changes from the compositor.

Bug-AGL: SPEC-4673
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ia2842f40f39bd09dfb4781b52cc6750cd73fe0f5

homescreen/src/homescreenhandler.cpp
homescreen/src/homescreenhandler.h
homescreen/src/main.cpp

index 918237a..b1244c1 100644 (file)
@@ -156,5 +156,7 @@ void HomescreenHandler::processAppStatusEvent(const QString &app_id, const QStri
        } else if (status == "terminated") {
                HMI_DEBUG("HomeScreen", "Application %s terminated, activating last app", app_id.toStdString().c_str());
                deactivateApp(app_id);
+       } else if (status == "deactivated") {
+               HMI_DEBUG("HomeScreen", "Application %s deactivated, activating last app", app_id.toStdString().c_str());
        }
 }
index e014192..9a659a6 100644 (file)
@@ -30,6 +30,7 @@ public:
        void activateApp(const QString& app_id);
        void deactivateApp(const QString& app_id);
 
+       QStringList apps_stack;
        std::list<std::pair<const QString, const QString>> pending_app_list;
 signals:
        void showNotification(QString application_id, QString icon_path, QString text);
@@ -44,7 +45,6 @@ private:
 
        Shell *aglShell;
 
-       QStringList apps_stack;
 };
 
 #endif // HOMESCREENHANDLER_H
index d2967ca..d0bd2c3 100644 (file)
@@ -102,6 +102,10 @@ agl_shell_app_state(void *data, struct agl_shell *agl_shell,
                qDebug() << "Got AGL_SHELL_APP_STATE_ACTIVATED for app_id " << app_id;
                homescreenHandler->addAppToStack(app_id);
                break;
+       case AGL_SHELL_APP_STATE_DEACTIVATED:
+               qDebug() << "Got AGL_SHELL_APP_STATE_DEACTIVATED for app_id " << app_id;
+               homescreenHandler->processAppStatusEvent(app_id, "deactivated");
+               break;
        default:
                break;
        }
@@ -117,9 +121,28 @@ agl_shell_app_on_output(void *data, struct agl_shell *agl_shell,
        if (!homescreenHandler)
                return;
 
+       // a couple of use-cases, if there is no app_id in the app_list then it
+       // means this is a request to map the application, from the start to a
+       // different output that the default one. We'd get an
+       // AGL_SHELL_APP_STATE_STARTED which will handle activation.
+       //
+       // if there's an app_id then it means we might have gotten an event to
+       // move the application to another output; so we'd need to process it
+       // by explicitly calling processAppStatusEvent() which would ultimately
+       // activate the application on other output. We'd have to pick-up the
+       // last activated window and activate the default output.
+       //
+       // finally if the outputs are identical probably that's an user-error -
+       // but the compositor won't activate it again, so we don't handle that.
        std::pair new_pending_app = std::pair(QString(app_id),
                                              QString(output_name));
        homescreenHandler->pending_app_list.push_back(new_pending_app);
+
+       if (homescreenHandler->apps_stack.contains(QString(app_id))) {
+               qDebug() << "Gove event to move " << app_id <<
+                       " to another output " << output_name;
+               homescreenHandler->processAppStatusEvent(app_id, "started");
+       }
 }