-struct shell_data {
- struct wl_display *wl_display;
- struct agl_shell *shell;
- struct agl_shell_ext *shell_ext;
- Shell *aglShell;
-
- bool wait_for_bound;
- bool wait_for_doas;
-
- bool bound_ok;
- bool doas_ok;
-
- uint32_t version;
- struct wl_list output_list; /** window_output::link */
-};
-
-struct window_output {
- struct shell_data *shell_data;
- struct wl_output *output;
- char *name;
- struct wl_list link; /** display::output_list */
-};
-
-static struct shell_data *sh = nullptr;
-
-grpc::ServerUnaryReactor *
-GrpcServiceImpl::ActivateApp(grpc::CallbackServerContext *context,
- const ::agl_shell_ipc::ActivateRequest* request,
- google::protobuf::Empty* /*response*/)
-{
- fprintf(stderr, "activating app %s on output %s\n",
- request->app_id().c_str(),
- request->output_name().c_str());
-
- sh->aglShell->ActivateApp(request->app_id(), request->output_name());
-
- grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
- reactor->Finish(grpc::Status::OK);
- return reactor;
-}
-
-grpc::ServerUnaryReactor *
-GrpcServiceImpl::DeactivateApp(grpc::CallbackServerContext *context,
- const ::agl_shell_ipc::DeactivateRequest* request,
- google::protobuf::Empty* /*response*/)
-{
- sh->aglShell->DeactivateApp(request->app_id());
-
- grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
- reactor->Finish(grpc::Status::OK);
- return reactor;
-}
-
-grpc::ServerUnaryReactor *
-GrpcServiceImpl::SetAppFloat(grpc::CallbackServerContext *context,
- const ::agl_shell_ipc::FloatRequest* request,
- google::protobuf::Empty* /* response */)
-{
- sh->aglShell->SetAppFloat(request->app_id());
-
- grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
- reactor->Finish(grpc::Status::OK);
- return reactor;
-}
-
-grpc::ServerUnaryReactor *
-GrpcServiceImpl::SetAppSplit(grpc::CallbackServerContext *context,
- const ::agl_shell_ipc::SplitRequest* request,
- google::protobuf::Empty* /*response*/)
-{
- sh->aglShell->SetAppSplit(request->app_id(), request->tile_orientation());
-
- grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
- reactor->Finish(grpc::Status::OK);
- return reactor;
-}
-
-void
-Shell::ActivateApp(const std::string &app_id, const std::string &output_name)
-{
- struct window_output *woutput, *w_output;
-
- woutput = nullptr;
- w_output = nullptr;
-
- wl_list_for_each(woutput, &sh->output_list, link) {
- if (woutput->name && !strcmp(woutput->name, output_name.c_str())) {
- w_output = woutput;
- break;
- }
- }
-
- // else, get the first one available
- if (!w_output)
- w_output = wl_container_of(sh->output_list.prev, w_output, link);
-
- agl_shell_activate_app(this->m_shell.get(), app_id.c_str(), w_output->output);
- wl_display_flush(sh->wl_display);
-}
-
-void
-Shell::DeactivateApp(const std::string &app_id)
-{
- (void) app_id;
-}
-
-void
-Shell::SetAppFloat(const std::string &app_id)
-{
- (void) app_id;
-}
-
-void
-Shell::SetAppSplit(const std::string &app_id, uint32_t orientation)
-{
- (void) app_id;
- (void) orientation;
-}
-
-static void
-start_grpc_server(void)
-{
- // instantiante the grpc server
- std::string server_address(kDefaultGrpcServiceAddress);
- GrpcServiceImpl service;
-
- grpc::EnableDefaultHealthCheckService(true);
- grpc::reflection::InitProtoReflectionServerBuilderPlugin();
-
- grpc::ServerBuilder builder;
- builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
- builder.RegisterService(&service);
-
- std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
- fprintf(stderr, "Server listening on %s\n", server_address.c_str());
-
- server->Wait();
-}