From 831dc2946ce773ce2ed944ea9253350e5dd081bb Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 10 Apr 2020 19:41:16 +0300 Subject: [PATCH] sample/app: Allow to set-up the onscreenapp as pop-up Signed-off-by: Marius Vlad --- sample/app/eventhandler.cpp | 11 +++++++++++ sample/app/eventhandler.h | 1 + sample/app/main.qml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/sample/app/eventhandler.cpp b/sample/app/eventhandler.cpp index 58f99fc..3a61887 100644 --- a/sample/app/eventhandler.cpp +++ b/sample/app/eventhandler.cpp @@ -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); +} diff --git a/sample/app/eventhandler.h b/sample/app/eventhandler.h index 77e01e6..96e44ae 100644 --- a/sample/app/eventhandler.h +++ b/sample/app/eventhandler.h @@ -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); diff --git a/sample/app/main.qml b/sample/app/main.qml index f0a65e9..2979d88 100644 --- a/sample/app/main.qml +++ b/sample/app/main.qml @@ -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 -- 2.16.6