aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AglShellGrpcClient.cpp19
-rw-r--r--src/AglShellGrpcClient.h2
-rw-r--r--src/agl_shell.proto3
-rw-r--r--src/main.cpp63
4 files changed, 84 insertions, 3 deletions
diff --git a/src/AglShellGrpcClient.cpp b/src/AglShellGrpcClient.cpp
index 6f4ff24..20a960f 100644
--- a/src/AglShellGrpcClient.cpp
+++ b/src/AglShellGrpcClient.cpp
@@ -152,6 +152,25 @@ GrpcClient::SetAppScale(const std::string& app_id, int32_t width, int32_t height
}
+bool
+GrpcClient::SetAppSplit(const std::string& app_id, uint32_t orientation,
+ int32_t width, int32_t sticky, const std::string& output_name)
+{
+ agl_shell_ipc::SplitRequest request;
+
+ request.set_app_id(app_id);
+ request.set_output_name(output_name);
+ request.set_tile_orientation(orientation);
+ request.set_width(width);
+ request.set_sticky(sticky);
+
+ grpc::ClientContext context;
+ ::agl_shell_ipc::SplitResponse reply;
+
+ grpc::Status status = m_stub->SetAppSplit(&context, request, &reply);
+ return status.ok();
+}
+
grpc::Status
GrpcClient::Wait(void)
{
diff --git a/src/AglShellGrpcClient.h b/src/AglShellGrpcClient.h
index ff190f7..e7aa934 100644
--- a/src/AglShellGrpcClient.h
+++ b/src/AglShellGrpcClient.h
@@ -98,6 +98,8 @@ public:
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);
+ bool SetAppSplit(const std::string& app_id, uint32_t orientation,
+ int32_t width, int32_t sticky, const std::string& output_name);
std::vector<std::string> GetOutputs();
void GetAppState();
void AppStatusState(Callback callback);
diff --git a/src/agl_shell.proto b/src/agl_shell.proto
index c4f3dfe..d38d896 100644
--- a/src/agl_shell.proto
+++ b/src/agl_shell.proto
@@ -36,6 +36,9 @@ message DeactivateResponse {
message SplitRequest {
string app_id = 1;
int32 tile_orientation = 2;
+ int32 width = 3;
+ int32 sticky = 4;
+ string output_name = 5;
}
message SplitResponse {
diff --git a/src/main.cpp b/src/main.cpp
index 43e0ced..555e5a3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -52,6 +52,7 @@ enum action_state {
SET_APP_ON_OUTPUT,
SET_APP_POS,
SET_APP_SCALE,
+ SET_APP_SPLIT,
};
static struct action {
@@ -67,6 +68,7 @@ static struct action {
{ SET_APP_ON_OUTPUT, "ON_OUTPUT" },
{ SET_APP_POS, "POSITION" },
{ SET_APP_SCALE, "SCALE" },
+ { SET_APP_SPLIT, "SPLIT" },
};
static int
@@ -91,12 +93,15 @@ run_in_thread(GrpcClient *client)
static void
help(char **argv)
{
- fprintf(stderr, "Usage: %s [-a action] [-p app_id] [-o output_name] [-l]\n",
+ fprintf(stderr, "Usage: %s [-a action] [-p app_id] [-o output_name] [-l] [-r] [-s]\n",
argv[0]);
- fprintf(stderr, "\t-a -- action activate|deactivate|float|normal|getoutputs|fullscreen|on_output|position|scale\n");
+ fprintf(stderr, "\t-a -- action activate|deactivate|float|normal|getoutputs|fullscreen|on_output|position|scale|split\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");
+ fprintf(stderr, "\t-r -- orientation for split\n");
+ fprintf(stderr, "\t-w -- width of the window (if not specified defaults t0) for split\n");
+ fprintf(stderr, "\t-s -- sticky window for split\n");
exit(EXIT_FAILURE);
}
@@ -122,17 +127,36 @@ read_outputs(GrpcClient *client)
fprintf(stderr, "\n");
}
+static uint32_t orientation_trans(char *orientation)
+{
+ if (strcmp(orientation, "left") == 0)
+ return 1;
+ else if (strcmp(orientation, "right") == 0)
+ return 2;
+ else if (strcmp(orientation, "top") == 0)
+ return 3;
+ else if (strcmp(orientation, "bottom") == 0)
+ return 4;
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
char *output = NULL;
char *action = NULL;
char *app_id = NULL;
+ char *orientation = NULL;
+ // none, by default
+ uint32_t orientation_translate = 0;
int opt;
bool listen_flag = false;
+ int width = 0;
+ int32_t sticky = 0;
std::thread th;
// app_id, output p[0] -> name, p[1] action, p[2] app_id, p[3] -> output
- while ((opt = getopt(argc, argv, "a:p:o:lsh")) != -1) {
+ while ((opt = getopt(argc, argv, "a:p:o:r:lshw:")) != -1) {
switch (opt) {
case 'p':
app_id = optarg;
@@ -143,9 +167,18 @@ int main(int argc, char *argv[])
case 'o':
output = optarg;
break;
+ case 'r':
+ orientation = optarg;
+ break;
case 'l':
listen_flag = true;
break;
+ case 's':
+ sticky = 1;
+ break;
+ case 'w':
+ width = strtoul(optarg, NULL, 10);
+ break;
case 'h':
default: /* '?' */
help(argv);
@@ -239,6 +272,30 @@ int main(int argc, char *argv[])
fprintf(stderr, "Set scale for application '%s'\n", app_id);
client->SetAppScale(std::string(app_id), 200, 200);
break;
+ case SET_APP_SPLIT:
+ if (!orientation) {
+ fprintf(stderr, "split require orientation\n");
+ help(argv);
+ }
+
+ orientation_translate = orientation_trans(orientation);
+
+ if (!app_id) {
+ fprintf(stderr, "Split require an app_id\n");
+ help(argv);
+ }
+
+ if (!output) {
+ fprintf(stderr, "split require an output\n");
+ help(argv);
+ }
+
+
+ fprintf(stderr, "Set split orientation '%s' for application '%s' on output '%s'\n",
+ orientation, app_id, output);
+ client->SetAppSplit(std::string(app_id),
+ orientation_translate, width, sticky, std::string(output));
+ break;
default:
// allow listen flag to be passed
if (listen_flag)