From 404f7128b1589fa3bfbb5ea55c0a51a5fef91bb0 Mon Sep 17 00:00:00 2001 From: Marius Vlad <marius.vlad@collabora.com> Date: Wed, 27 Nov 2024 11:55:13 +0200 Subject: app: Add a way to retireve output name to place tbtnavi This is identical to what cluster-receiver is doing so let's do the same thing here to have some consistency between them. An /etc/xdg/AGL.conf file containing [tbtnavi] output=XXXX Would pass 'XXXX' to the compositor to move the application to. Bug-AGL: SPEC-5310 Change-Id: I4bd52b87b50f90606c5ba5e93f93d58f76af1ace Signed-off-by: Marius Vlad <marius.vlad@collabora.com> --- app/main.cpp | 37 ++++++++++++++++++++++++++++++++++++- app/meson.build | 3 ++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/main.cpp b/app/main.cpp index b3fd47a..41773f0 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -9,6 +9,7 @@ #include <QtQuick/QQuickWindow> #include <navigation.h> #include <vehiclesignals.h> +#include <glib.h> #include "navigation_client.h" #include "qcheapruler.hpp" @@ -16,6 +17,34 @@ #include "AglShellGrpcClient.h" +std::string +read_config_and_get_output(void) +{ + GKeyFile *conf_file; + gchar *value; + GError *err = NULL; + + bool ret; + int n; + unsigned width, height, x, y; + + // Load settings from configuration file if it exists + conf_file = g_key_file_new(); + + ret = g_key_file_load_from_dirs(conf_file, "AGL.conf", + (const gchar**) g_get_system_config_dirs(), + NULL, G_KEY_FILE_KEEP_COMMENTS, NULL); + if (!ret) + return std::string(""); + + value = g_key_file_get_string(conf_file, "tbtnavi", "output", &err); + if (!value) { + return std::string(""); + } + + return std::string(value); +} + int main(int argc, char *argv[]) { std::string our_name = "tbtnavi"; @@ -30,8 +59,14 @@ int main(int argc, char *argv[]) QCoreApplication::setApplicationVersion("0.1.0"); app.setDesktopFileName(graphic_role); + // grab the output to put the application on + std::string output = read_config_and_get_output(); + GrpcClient *client = new GrpcClient(); - client->SetAppOnOutput(our_name, "remoting-remote-1"); + if (!output.empty()) + client->SetAppOnOutput(our_name, output); + else + client->SetAppOnOutput(our_name, "pipewire"); // Load qml QQmlApplicationEngine engine; diff --git a/app/meson.build b/app/meson.build index b2ee673..cad087e 100644 --- a/app/meson.build +++ b/app/meson.build @@ -36,7 +36,8 @@ dep_qtappfw = [ tbtnavi_dep = [ qt_dep, dep_qtappfw, - grpc_deps + grpc_deps, + dependency('glib-2.0'), ] tbtnavi_headers = [ -- cgit