sample/app: Allow to set-up the onscreenapp as pop-up
authorMarius Vlad <marius.vlad@collabora.com>
Fri, 10 Apr 2020 16:41:16 +0000 (19:41 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Mon, 13 Apr 2020 14:25:03 +0000 (17:25 +0300)
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
sample/app/eventhandler.cpp
sample/app/eventhandler.h
sample/app/main.qml

index 58f99fc..3a61887 100644 (file)
@@ -242,3 +242,14 @@ EventHandler::is_running(const QString &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);
+}
index 77e01e6..96e44ae 100644 (file)
@@ -59,6 +59,7 @@ public:
     Q_INVOKABLE void hideWindow(QString id);
     Q_INVOKABLE int start(const QString &app_id);
     Q_INVOKABLE bool is_running(const QString &app_id);
+    Q_INVOKABLE void set_window_popup(const QString &app_id, int x, int y);
 
 signals:
     void signalOnReplyShowWindow(QVariant val);
index f0a65e9..2979d88 100644 (file)
@@ -20,6 +20,7 @@ ApplicationWindow {
     property string postmsg: qsTr("")
     property string btndata: qsTr("")
     property int pid: -1
+    property bool onscreen_role_set: false
 
     Label {
         id: title
@@ -340,6 +341,11 @@ ApplicationWindow {
         else
             postmsg += "}"
 
+       if (!onscreen_role_set) {
+               eventHandler.set_window_poup(onsId, 0, 218)
+               onscreen_role_set = true
+       }
+
        // if the application is not already started, start it
        if (pid == -1) {
                // if the application is not started, then the first time