summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2023-07-31 15:40:09 +0300
committerMarius Vlad <marius.vlad@collabora.com>2023-08-29 17:15:51 +0300
commit3a93f33ba5fc7f2e5863173a77a09daa15b37d40 (patch)
tree62d10a68db817b78863ad4a3becbc94c6a2d6d53
parent3caa714ffa288d51dd5b7bc1e8ad5c17d2dbc8b7 (diff)
Add support for positioning and scaling
This adds support for dynamic positioning and scalling of windows, using the gRPC interface. This can used to manipulate other's windows, wheareas the window management client gRPC will do so with its own window. Bug-AGL: SPEC-4862, SPEC-4863 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I8f5cc40a929ae55dbf4b287833c473c8db64a1c3
-rw-r--r--src/AglShellGrpcClient.cpp33
-rw-r--r--src/AglShellGrpcClient.h2
-rw-r--r--src/agl_shell.proto39
-rw-r--r--src/main.cpp22
4 files changed, 86 insertions, 10 deletions
diff --git a/src/AglShellGrpcClient.cpp b/src/AglShellGrpcClient.cpp
index e1dad57..6f4ff24 100644
--- a/src/AglShellGrpcClient.cpp
+++ b/src/AglShellGrpcClient.cpp
@@ -119,6 +119,39 @@ GrpcClient::SetAppOnOutput(const std::string& app_id, const std::string &output)
return status.ok();
}
+bool
+GrpcClient::SetAppPosition(const std::string& app_id, int32_t x, int32_t y)
+{
+ agl_shell_ipc::AppPositionRequest request;
+
+ request.set_app_id(app_id);
+ request.set_x(x);
+ request.set_y(y);
+
+ grpc::ClientContext context;
+ ::agl_shell_ipc::AppPositionResponse reply;
+
+ grpc::Status status = m_stub->SetAppPosition(&context, request, &reply);
+ 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 4b33469..ff190f7 100644
--- a/src/AglShellGrpcClient.h
+++ b/src/AglShellGrpcClient.h
@@ -96,6 +96,8 @@ public:
bool SetAppFullscreen(const std::string& app_id);
bool SetAppOnOutput(const std::string& app_id, const std::string& output);
bool SetAppNormal(const std::string& app_id);
+ 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<std::string> GetOutputs();
void GetAppState();
void AppStatusState(Callback callback);
diff --git a/src/agl_shell.proto b/src/agl_shell.proto
index aac35f4..c4f3dfe 100644
--- a/src/agl_shell.proto
+++ b/src/agl_shell.proto
@@ -4,15 +4,17 @@ syntax = "proto3";
package agl_shell_ipc;
service AglShellManagerService {
- rpc ActivateApp(ActivateRequest) returns (ActivateResponse) {}
- rpc DeactivateApp(DeactivateRequest) returns (DeactivateResponse) {}
- rpc SetAppSplit(SplitRequest) returns (SplitResponse) {}
- rpc SetAppFloat(FloatRequest) returns (FloatResponse) {}
- rpc SetAppFullscreen(FullscreenRequest) returns (FullscreenResponse) {}
- rpc AppStatusState(AppStateRequest) returns (stream AppStateResponse) {}
- rpc GetOutputs(OutputRequest) returns (ListOutputResponse) {}
- rpc SetAppNormal(NormalRequest) returns (NormalResponse) {}
- rpc SetAppOnOutput(AppOnOutputRequest) returns (AppOnOutputResponse) {}
+ rpc ActivateApp(ActivateRequest) returns (ActivateResponse) {}
+ rpc DeactivateApp(DeactivateRequest) returns (DeactivateResponse) {}
+ rpc SetAppSplit(SplitRequest) returns (SplitResponse) {}
+ rpc SetAppFloat(FloatRequest) returns (FloatResponse) {}
+ rpc SetAppFullscreen(FullscreenRequest) returns (FullscreenResponse) {}
+ rpc AppStatusState(AppStateRequest) returns (stream AppStateResponse) {}
+ rpc GetOutputs(OutputRequest) returns (ListOutputResponse) {}
+ rpc SetAppNormal(NormalRequest) returns (NormalResponse) {}
+ rpc SetAppOnOutput(AppOnOutputRequest) returns (AppOnOutputResponse) {}
+ rpc SetAppPosition(AppPositionRequest) returns (AppPositionResponse) {}
+ rpc SetAppScale(AppScaleRequest) returns (AppScaleResponse) {}
}
message ActivateRequest {
@@ -23,6 +25,7 @@ message ActivateRequest {
message ActivateResponse {
};
+
message DeactivateRequest {
string app_id = 1;
}
@@ -87,3 +90,21 @@ message AppOnOutputRequest {
message AppOnOutputResponse {
};
+
+message AppPositionRequest {
+ string app_id = 1;
+ int32 x = 2;
+ int32 y = 3;
+};
+
+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 8f50b5e..43e0ced 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -50,6 +50,8 @@ enum action_state {
GETOUTPUTS,
SET_FULLSCREEN,
SET_APP_ON_OUTPUT,
+ SET_APP_POS,
+ SET_APP_SCALE,
};
static struct action {
@@ -63,6 +65,8 @@ static struct action {
{ SET_NORMAL, "NORMAL" },
{ SET_FULLSCREEN, "FULLSCREEN" },
{ SET_APP_ON_OUTPUT, "ON_OUTPUT" },
+ { SET_APP_POS, "POSITION" },
+ { SET_APP_SCALE, "SCALE" },
};
static int
@@ -89,7 +93,7 @@ help(char **argv)
{
fprintf(stderr, "Usage: %s [-a action] [-p app_id] [-o output_name] [-l]\n",
argv[0]);
- fprintf(stderr, "\t-a -- action activate|deactivate|float|normal|getoutputs|fullscreen|on_output\n");
+ fprintf(stderr, "\t-a -- action activate|deactivate|float|normal|getoutputs|fullscreen|on_output|position|scale\n");
fprintf(stderr, "\t-p -- app_id application_id\n");
fprintf(stderr, "\t-o -- output_name one of the outputs from getoutputs action\n");
fprintf(stderr, "\t-l -- continuously listen for window state events\n");
@@ -219,6 +223,22 @@ int main(int argc, char *argv[])
case GETOUTPUTS:
read_outputs(client);
break;
+ case SET_APP_POS:
+ if (!app_id) {
+ fprintf(stderr, "Positioning require an app_id\n");
+ help(argv);
+ }
+ fprintf(stderr, "Set app position for application '%s'\n", app_id);
+ client->SetAppPosition(std::string(app_id), 550, 550);
+ break;
+ case SET_APP_SCALE:
+ if (!app_id) {
+ fprintf(stderr, "Scale require an app_id\n");
+ help(argv);
+ }
+ fprintf(stderr, "Set scale for application '%s'\n", app_id);
+ client->SetAppScale(std::string(app_id), 200, 200);
+ break;
default:
// allow listen flag to be passed
if (listen_flag)