From cb43847cd07ba3d2b3e1f34aff3d6c98325c1c20 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 31 Jul 2023 14:53:47 +0300 Subject: [PATCH] Add SetAppScale example support This adds support for set_app_scale request to demonstrate the equivalence of surface_set_destination_rectangle from ivi-shell. Bug-AGL: SPEC-4862 Signed-off-by: Marius Vlad Change-Id: I59cf316f7304135a8f8520ca61333c1e549363a9 --- src/AglShellGrpcClient.cpp | 16 ++++++++++++++++ src/AglShellGrpcClient.h | 1 + src/agl_shell.proto | 10 ++++++++++ src/main.cpp | 14 +++++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/AglShellGrpcClient.cpp b/src/AglShellGrpcClient.cpp index 058c051..804ab79 100644 --- a/src/AglShellGrpcClient.cpp +++ b/src/AglShellGrpcClient.cpp @@ -120,6 +120,22 @@ GrpcClient::SetAppPosition(const std::string& app_id, int32_t x, int32_t y) return status.ok(); } +bool +GrpcClient::SetAppScale(const std::string& app_id, int32_t width, int32_t height) +{ + agl_shell_ipc::AppScaleRequest request; + + request.set_app_id(app_id); + request.set_width(width); + request.set_height(height); + + grpc::ClientContext context; + ::agl_shell_ipc::AppScaleResponse reply; + + grpc::Status status = m_stub->SetAppScale(&context, request, &reply); + return status.ok(); +} + grpc::Status GrpcClient::Wait(void) { diff --git a/src/AglShellGrpcClient.h b/src/AglShellGrpcClient.h index bc246d9..844ece5 100644 --- a/src/AglShellGrpcClient.h +++ b/src/AglShellGrpcClient.h @@ -95,6 +95,7 @@ public: bool SetAppFullscreen(const std::string& app_id); bool SetAppOnOutput(const std::string& app_id, const std::string& output); bool SetAppPosition(const std::string& app_id, int32_t x, int32_t y); + bool SetAppScale(const std::string& app_id, int32_t width, int32_t height); std::vector GetOutputs(); void GetAppState(); void AppStatusState(Callback callback); diff --git a/src/agl_shell.proto b/src/agl_shell.proto index 74ea958..1aa3dd4 100644 --- a/src/agl_shell.proto +++ b/src/agl_shell.proto @@ -14,6 +14,7 @@ service AglShellManagerService { rpc SetAppNormal(NormalRequest) returns (NormalResponse) {} rpc SetAppOnOutput(AppOnOutputRequest) returns (AppOnOutputResponse) {} rpc SetAppPosition(AppPositionRequest) returns (AppPositionResponse) {} + rpc SetAppScale(AppScaleRequest) returns (AppScaleResponse) {} } message ActivateRequest { @@ -98,3 +99,12 @@ message AppPositionRequest { message AppPositionResponse { }; + +message AppScaleRequest { + string app_id = 1; + int32 width = 2; + int32 height = 3; +}; + +message AppScaleResponse { +}; diff --git a/src/main.cpp b/src/main.cpp index ed809fe..6ab9530 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,7 @@ enum mode { FULLSCREEN_QT = 3, // rather than use rpc, use Qt API ON_OTHER_OUTPUTS = 4, SET_FLOAT_POS = 5, + SCALE = 6, }; static QWindow * @@ -84,10 +85,14 @@ int main(int argc, char *argv[]) mmode = FULLSCREEN_QT; else if (strcmp(argv[1], "position") == 0) mmode = SET_FLOAT_POS; + else if (strcmp(argv[1], "scale") == 0) + mmode = SCALE; else assert(!"Invalid mode"); - if (mmode != FLOAT && mmode != FULLSCREEN && mmode != ON_OTHER_OUTPUTS && mmode != SET_FLOAT_POS) { + if (mmode != FLOAT && mmode != FULLSCREEN && + mmode != ON_OTHER_OUTPUTS && mmode != SET_FLOAT_POS && + mmode != SCALE) { fprintf(stderr, "Will not use rpc\n"); goto skip; } @@ -128,6 +133,13 @@ int main(int argc, char *argv[]) client->SetAppPosition(myname.toStdString(), 550, 550); exit(EXIT_SUCCESS); break; + case SCALE: + // this assumes the window is already running and + // floating; uses the same application so this needs + // to be first started as float. + client->SetAppScale(myname.toStdString(), 200, 200); + exit(EXIT_SUCCESS); + break; default: break; } -- 2.16.6