summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2023-07-31 14:48:49 +0300
committerMarius Vlad <marius.vlad@collabora.com>2023-08-31 07:21:53 +0000
commit21772bfc2d482248e2df5438039a70d5231bc993 (patch)
tree8ade3504cc90b868598aab0a9e36b7618f3f45ff
parentad0d2072c885d5ef6065ea5039536fe0d01a6871 (diff)
Add SetAppPosition example usage
This adds support for set_app_position to allow dynamic positioning of windows, as requested in SPEC-4863. Bug-AGL: SPEC-4863 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I9ef1c52ef0de6bb250291cfbb561d58418cd0ee2
-rw-r--r--src/AglShellGrpcClient.cpp16
-rw-r--r--src/AglShellGrpcClient.h1
-rw-r--r--src/agl_shell.proto11
-rw-r--r--src/main.cpp12
4 files changed, 39 insertions, 1 deletions
diff --git a/src/AglShellGrpcClient.cpp b/src/AglShellGrpcClient.cpp
index ee2fe48..058c051 100644
--- a/src/AglShellGrpcClient.cpp
+++ b/src/AglShellGrpcClient.cpp
@@ -104,6 +104,22 @@ 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();
+}
+
grpc::Status
GrpcClient::Wait(void)
{
diff --git a/src/AglShellGrpcClient.h b/src/AglShellGrpcClient.h
index 7c30fe6..bc246d9 100644
--- a/src/AglShellGrpcClient.h
+++ b/src/AglShellGrpcClient.h
@@ -94,6 +94,7 @@ public:
bool SetAppFloat(const std::string& app_id, int32_t x_pos, int32_t y_pos);
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);
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..74ea958 100644
--- a/src/agl_shell.proto
+++ b/src/agl_shell.proto
@@ -13,6 +13,7 @@ service AglShellManagerService {
rpc GetOutputs(OutputRequest) returns (ListOutputResponse) {}
rpc SetAppNormal(NormalRequest) returns (NormalResponse) {}
rpc SetAppOnOutput(AppOnOutputRequest) returns (AppOnOutputResponse) {}
+ rpc SetAppPosition(AppPositionRequest) returns (AppPositionResponse) {}
}
message ActivateRequest {
@@ -23,6 +24,7 @@ message ActivateRequest {
message ActivateResponse {
};
+
message DeactivateRequest {
string app_id = 1;
}
@@ -87,3 +89,12 @@ message AppOnOutputRequest {
message AppOnOutputResponse {
};
+
+message AppPositionRequest {
+ string app_id = 1;
+ int32 x = 2;
+ int32 y = 3;
+};
+
+message AppPositionResponse {
+};
diff --git a/src/main.cpp b/src/main.cpp
index 727bd27..ed809fe 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -46,6 +46,7 @@ enum mode {
FULLSCREEN = 2,
FULLSCREEN_QT = 3, // rather than use rpc, use Qt API
ON_OTHER_OUTPUTS = 4,
+ SET_FLOAT_POS = 5,
};
static QWindow *
@@ -81,10 +82,12 @@ int main(int argc, char *argv[])
mmode = ON_OTHER_OUTPUTS;
else if (strcmp(argv[1], "full_qt") == 0)
mmode = FULLSCREEN_QT;
+ else if (strcmp(argv[1], "position") == 0)
+ mmode = SET_FLOAT_POS;
else
assert(!"Invalid mode");
- if (mmode != FLOAT && mmode != FULLSCREEN && mmode != ON_OTHER_OUTPUTS) {
+ if (mmode != FLOAT && mmode != FULLSCREEN && mmode != ON_OTHER_OUTPUTS && mmode != SET_FLOAT_POS) {
fprintf(stderr, "Will not use rpc\n");
goto skip;
}
@@ -118,6 +121,13 @@ int main(int argc, char *argv[])
client->SetAppOnOutput(myname.toStdString(),
std::string(output_name));
break;
+ case SET_FLOAT_POS:
+ // this assumes the window is already running and
+ // floating; uses the same application so this needs
+ // to be first started as float.
+ client->SetAppPosition(myname.toStdString(), 550, 550);
+ exit(EXIT_SUCCESS);
+ break;
default:
break;
}