From 42f7dfd87b7192ecd326598d627e32a5feddf43b Mon Sep 17 00:00:00 2001 From: Marcus Fritzsch Date: Thu, 17 Aug 2017 17:03:00 +0200 Subject: [PATCH] clang-format Signed-off-by: Marcus Fritzsch --- src/app.cpp | 20 ++++++++++---------- src/app.hpp | 3 ++- src/layers.cpp | 29 +++++++++++++---------------- src/layers.hpp | 14 ++++++-------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index c38a7f4..fbeb4fd 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -28,10 +28,10 @@ #include +#include #include #include #include -#include #include namespace wm { @@ -129,8 +129,7 @@ App::App(wl::display *d) layers(), pending(), name_mapping(), - id_alloc{} -{ + id_alloc{} { assert(g_app == nullptr); g_app = this; @@ -284,7 +283,8 @@ void App::surface_set_layout(uint32_t surface_id) { } uint32_t layer_id = o_layer_id.value(); - logdebug("surface_set_layout for surface %u on layer %u", surface_id, layer_id); + logdebug("surface_set_layout for surface %u on layer %u", surface_id, + layer_id); auto const &layer = this->layers.get_layer(layer_id); auto rect = layer.value().rect; @@ -390,7 +390,7 @@ result App::request_surface(char const *drawing_name) { } auto rname = this->id_alloc[drawing_name]; - if (! rname) { + if (!rname) { // name does not exist yet, allocate surface id... // XXX: how to allocate surface IDs? // * allocate by running a counter for each layer? @@ -400,10 +400,9 @@ result App::request_surface(char const *drawing_name) { auto id = int(this->id_alloc(drawing_name)); this->layers.add_surface(id, lid.value()); - // XXX: setup the main_surface id if we registered HomeScreen // XXX: you should fix this! if (!this->layers.main_surface_name.empty() && - this->layers.main_surface_name == drawing_name) { + this->layers.main_surface_name == drawing_name) { this->layers.main_surface = id; this->activate_surface(id); logdebug("Set main_surface id to %u", id); @@ -416,11 +415,12 @@ result App::request_surface(char const *drawing_name) { return Err("Surface already present"); } -char const* App::activate_surface(char const *drawing_name) { +char const *App::activate_surface(char const *drawing_name) { auto osid = this->id_alloc[drawing_name]; if (osid) { - logdebug("ativate surface with name %s and id %u", drawing_name, osid.value()); + logdebug("ativate surface with name %s and id %u", drawing_name, + osid.value()); this->activate_surface(osid.value()); return nullptr; } @@ -439,7 +439,7 @@ binding_api::result_type binding_api::request_surface( char const *drawing_name) { auto r = this->app->request_surface(drawing_name); if (r.is_err()) { - return Err(r.unwrap_err()); + return Err(r.unwrap_err()); } return Ok(json_object_new_int(r.unwrap())); } diff --git a/src/app.hpp b/src/app.hpp index 12d26b4..a35be27 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -71,7 +71,8 @@ struct id_allocator { optional operator[](unsigned id) { auto i = this->surfaces.find(id); - return i == this->surfaces.end() ? nullopt : optional(i->second); + return i == this->surfaces.end() ? nullopt + : optional(i->second); } }; diff --git a/src/layers.cpp b/src/layers.cpp index 464e20b..931fd5e 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -39,8 +39,7 @@ layer::layer(nlohmann::json const &j) { if (j["area"]["type"] == "rect") { auto jr = j["area"]["rect"]; this->rect = genivi::rect{ - jr["width"], jr["height"], - jr["x"], jr["y"], + jr["width"], jr["height"], jr["x"], jr["y"], }; } } @@ -52,21 +51,19 @@ struct result to_layer_map(nlohmann::json const &j) { std::transform(std::cbegin(m), std::cend(m), std::inserter(stl.mapping, stl.mapping.end()), - [](nlohmann::json const &j) { - return layer(j); - }); + [](nlohmann::json const &j) { return layer(j); }); // XXX: add sanity checks here? // * check for double IDs // * check for double names/roles stl.layers.reserve(m.size()); - std::transform(std::cbegin(stl.mapping), std::cend(stl.mapping), - std::back_inserter(stl.layers), - [&stl](struct layer const &k) { - stl.roles.emplace_back(std::make_pair(k.role, k.layer_id)); - return unsigned(k.layer_id); - }); + std::transform( + std::cbegin(stl.mapping), std::cend(stl.mapping), + std::back_inserter(stl.layers), [&stl](struct layer const &k) { + stl.roles.emplace_back(std::make_pair(k.role, k.layer_id)); + return unsigned(k.layer_id); + }); // XXX need to sort layers? for (auto i : stl.mapping) { @@ -80,8 +77,9 @@ struct result to_layer_map(nlohmann::json const &j) { auto msi = j.find("main_surface"); if (msi != j.end()) { - stl.main_surface = (*msi)["surface_id"]; stl.main_surface_name = msi->value("surface_role", ""); + stl.main_surface = + stl.main_surface_name.empty() ? int((*msi)["surface_id"]) : -1; } // Check lookup @@ -93,9 +91,8 @@ struct result to_layer_map(nlohmann::json const &j) { tests.reserve(jtests.size()); std::transform(std::cbegin(jtests), std::cend(jtests), std::back_inserter(tests), [](json const &j) { - return std::make_pair( - j["surface_id"], - j["expect_layer_id"]); + return std::make_pair(j["surface_id"], + j["expect_layer_id"]); }); for (auto sid : tests) { @@ -139,7 +136,7 @@ optional get_surface_id_to_layer(struct layer_map const *s2l, optional layer_map::get_layer_id(int surface_id) { auto e = get_surface_id_to_layer(this, surface_id); - if (! e) { + if (!e) { auto i = this->surfaces.find(surface_id); if (i != this->surfaces.end()) { return optional(int(i->second)); diff --git a/src/layers.hpp b/src/layers.hpp index ae609fc..a33f24a 100644 --- a/src/layers.hpp +++ b/src/layers.hpp @@ -69,21 +69,19 @@ struct layer_map { // make this the primary map, and the surface_id->layer a // secondary map. - storage_type mapping; // map surface_id to layer - layers_type layers; // the actual layer IDs we have + storage_type mapping; // map surface_id to layer + layers_type layers; // the actual layer IDs we have int main_surface; std::string main_surface_name; role_to_layer_map roles; - addsurf_layer_map surfaces; // additional surfaces on layers + addsurf_layer_map surfaces; // additional surfaces on layers optional get_layer_id(int surface_id); optional get_layer_id(std::string const &role); optional get_layer(int layer_id) { - auto i = std::find_if(std::cbegin(this->mapping), - std::cend(this->mapping), - [layer_id](struct layer const &l) { - return layer_id == l.layer_id; - }); + auto i = std::find_if( + std::cbegin(this->mapping), std::cend(this->mapping), + [layer_id](struct layer const &l) { return layer_id == l.layer_id; }); return i == this->mapping.end() ? nullopt : optional(*i); } -- 2.16.6