From 3e58f01b27b293717ce081ea094294890843eb06 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 25 Jun 2018 19:32:46 +0900 Subject: Clean: sort source code according to the order of header file Sort API order written in source code according to the order in header file to improve readability. Change-Id: I6606590ce2ad9c285b3cfd83dc6c0741890b105f Signed-off-by: Kazumasa Mitsunari --- src/window_manager.cpp | 682 +++++++++++++++++++++++++------------------------ 1 file changed, 343 insertions(+), 339 deletions(-) (limited to 'src/window_manager.cpp') diff --git a/src/window_manager.cpp b/src/window_manager.cpp index c66d4cf..28ef868 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -208,142 +208,98 @@ int WindowManager::dispatch_pending_events() return -1; } -bool WindowManager::pop_pending_events() -{ - bool x{true}; - return this->pending_events.compare_exchange_strong( - x, false, std::memory_order_consume); -} - void WindowManager::set_pending_events() { this->pending_events.store(true, std::memory_order_release); } -optional WindowManager::lookup_id(char const *name) -{ - return this->id_alloc.lookup(std::string(name)); -} -optional WindowManager::lookup_name(int id) -{ - return this->id_alloc.lookup(id); -} - -/** - * init_layers() - */ -int WindowManager::init_layers() +result WindowManager::api_request_surface(char const *appid, char const *drawing_name) { - if (!this->controller) + auto lid = this->layers.get_layer_id(std::string(drawing_name)); + if (!lid) { - HMI_ERROR("wm", "ivi_controller global not available"); - return -1; + /** + * register drawing_name as fallback and make it displayed. + */ + lid = this->layers.get_layer_id(std::string("Fallback")); + HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", drawing_name); + if (!lid) + { + return Err("Drawing name does not match any role, Fallback is disabled"); + } } - if (this->outputs.empty()) + auto rname = this->lookup_id(drawing_name); + if (!rname) { - HMI_ERROR("wm", "no output was set up!"); - return -1; - } - - auto &c = this->controller; - - auto &o = this->outputs.front(); - auto &s = c->screens.begin()->second; - auto &layers = c->layers; - - // Write output dimensions to ivi controller... - c->output_size = compositor::size{uint32_t(o->width), uint32_t(o->height)}; - c->physical_size = compositor::size{uint32_t(o->physical_width), - uint32_t(o->physical_height)}; + // name does not exist yet, allocate surface id... + auto id = int(this->id_alloc.generate_id(drawing_name)); + this->layers.add_surface(id, *lid); - // Clear scene - layers.clear(); + // set the main_surface[_name] here and now + if (!this->layers.main_surface_name.empty() && + this->layers.main_surface_name == drawing_name) + { + this->layers.main_surface = id; + HMI_DEBUG("wm", "Set main_surface id to %u", id); + } - // Clear screen - s->clear(); + // add client into the db + std::string appid_str(appid); + std::string role(drawing_name); + g_app_list.addClient(appid_str, *lid, id, role); - // Quick and dirty setup of layers - for (auto const &i : this->layers.mapping) - { - c->layer_create(i.second.layer_id, o->width, o->height); - auto &l = layers[i.second.layer_id]; - l->set_destination_rectangle(0, 0, o->width, o->height); - l->set_visibility(1); - HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"", - i.second.name.c_str(), i.second.layer_id, i.second.role.c_str()); + return Ok(id); } - // Add layers to screen - s->set_render_order(this->layers.layers); - - this->layout_commit(); - - this->layers.setupArea(o->width, o->height); - - return 0; + // Check currently registered drawing names if it is already there. + return Err("Surface already present"); } -void WindowManager::surface_set_layout(int surface_id, const std::string& area) +char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name, + char const *ivi_id) { - if (!this->controller->surface_exists(surface_id)) - { - HMI_ERROR("wm", "Surface %d does not exist", surface_id); - return; - } + ST(); - auto o_layer_id = this->layers.get_layer_id(surface_id); + auto lid = this->layers.get_layer_id(std::string(drawing_name)); + unsigned sid = std::stol(ivi_id); - if (!o_layer_id) + if (!lid) { - HMI_ERROR("wm", "Surface %d is not associated with any layer!", surface_id); - return; + /** + * register drawing_name as fallback and make it displayed. + */ + lid = this->layers.get_layer_id(std::string("Fallback")); + HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", drawing_name); + if (!lid) + { + return "Drawing name does not match any role, Fallback is disabled"; + } } - uint32_t layer_id = *o_layer_id; - - auto const &layer = this->layers.get_layer(layer_id); - auto rect = this->layers.getAreaSize(area); - HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "%s : x:%d y:%d w:%d h:%d", area.c_str(), - rect.x, rect.y, rect.w, rect.h); - auto &s = this->controller->surfaces[surface_id]; - - int x = rect.x; - int y = rect.y; - int w = rect.w; - int h = rect.h; + auto rname = this->lookup_id(drawing_name); - // less-than-0 values refer to MAX + 1 - $VALUE - // e.g. MAX is either screen width or height - if (w < 0) - { - w = this->controller->output_size.w + 1 + w; - } - if (h < 0) + if (rname) { - h = this->controller->output_size.h + 1 + h; + return "Surface already present"; } - HMI_DEBUG("wm", "surface_set_layout for surface %u on layer %u", surface_id, - layer_id); + // register pair drawing_name and ivi_id + this->id_alloc.register_name_id(drawing_name, sid); + this->layers.add_surface(sid, *lid); - // set destination to the display rectangle - s->set_destination_rectangle(x, y, w, h); + // this surface is already created + HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", sid, *lid); - // update area information - this->area_info[surface_id].x = x; - this->area_info[surface_id].y = y; - this->area_info[surface_id].w = w; - this->area_info[surface_id].h = h; + this->controller->layers[*lid]->add_surface(sid); + this->layout_commit(); - HMI_DEBUG("wm", "Surface %u now on layer %u with rect { %d, %d, %d, %d }", - surface_id, layer_id, x, y, w, h); -} + // add client into the db + std::string appid_str(appid); + std::string role(drawing_name); + g_app_list.addClient(appid_str, *lid, sid, role); -void WindowManager::layout_commit() -{ - this->controller->commit_changes(); - this->display->flush(); + return nullptr; } void WindowManager::api_activate_surface(char const *appid, char const *drawing_name, @@ -471,6 +427,72 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) } } +result WindowManager::api_get_display_info() +{ + // Check controller + if (!this->controller) + { + return Err("ivi_controller global not available"); + } + + // Set display info + compositor::size o_size = this->controller->output_size; + compositor::size p_size = this->controller->physical_size; + + json_object *object = json_object_new_object(); + json_object_object_add(object, kKeyWidthPixel, json_object_new_int(o_size.w)); + json_object_object_add(object, kKeyHeightPixel, json_object_new_int(o_size.h)); + json_object_object_add(object, kKeyWidthMm, json_object_new_int(p_size.w)); + json_object_object_add(object, kKeyHeightMm, json_object_new_int(p_size.h)); + + return Ok(object); +} + +result WindowManager::api_get_area_info(char const *drawing_name) +{ + HMI_DEBUG("wm", "called"); + + // Check drawing name, surface/layer id + auto const &surface_id = this->lookup_id(drawing_name); + if (!surface_id) + { + return Err("Surface does not exist"); + } + + if (!this->controller->surface_exists(*surface_id)) + { + return Err("Surface does not exist in controller!"); + } + + auto layer_id = this->layers.get_layer_id(*surface_id); + if (!layer_id) + { + return Err("Surface is not on any layer!"); + } + + auto o_state = *this->layers.get_layout_state(*surface_id); + if (o_state == nullptr) + { + return Err("Could not find layer for surface"); + } + + struct LayoutState &state = *o_state; + if ((state.main != *surface_id) && (state.sub != *surface_id)) + { + return Err("Surface is inactive"); + } + + // Set area rectangle + compositor::rect area_info = this->area_info[*surface_id]; + json_object *object = json_object_new_object(); + json_object_object_add(object, kKeyX, json_object_new_int(area_info.x)); + json_object_object_add(object, kKeyY, json_object_new_int(area_info.y)); + json_object_object_add(object, kKeyWidth, json_object_new_int(area_info.w)); + json_object_object_add(object, kKeyHeight, json_object_new_int(area_info.h)); + + return Ok(object); +} + void WindowManager::api_ping() { this->dispatch_pending_events(); } void WindowManager::send_event(char const *evname, char const *label) @@ -560,198 +582,268 @@ void WindowManager::timerHandler() this->processNextRequest(); } -void WindowManager::emit_activated(char const *label) -{ - this->send_event(kListEventName[Event_Active], label); -} +/* + ******* Private Functions ******* + */ -void WindowManager::emit_deactivated(char const *label) +bool WindowManager::pop_pending_events() { - this->send_event(kListEventName[Event_Inactive], label); + bool x{true}; + return this->pending_events.compare_exchange_strong( + x, false, std::memory_order_consume); } -void WindowManager::emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h) +optional WindowManager::lookup_id(char const *name) { - this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h); + return this->id_alloc.lookup(std::string(name)); } - -void WindowManager::emit_syncdraw(const std::string &role, const std::string &area) +optional WindowManager::lookup_name(int id) { - compositor::rect rect = this->layers.getAreaSize(area); - this->send_event(kListEventName[Event_SyncDraw], - role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h); + return this->id_alloc.lookup(id); } -void WindowManager::emit_flushdraw(char const *label) +/** + * init_layers() + */ +int WindowManager::init_layers() { - this->send_event(kListEventName[Event_FlushDraw], label); -} + if (!this->controller) + { + HMI_ERROR("wm", "ivi_controller global not available"); + return -1; + } -void WindowManager::emit_visible(char const *label, bool is_visible) -{ - this->send_event(is_visible ? kListEventName[Event_Visible] : kListEventName[Event_Invisible], label); -} + if (this->outputs.empty()) + { + HMI_ERROR("wm", "no output was set up!"); + return -1; + } -void WindowManager::emit_invisible(char const *label) -{ - return emit_visible(label, false); -} + auto &c = this->controller; -void WindowManager::emit_visible(char const *label) { return emit_visible(label, true); } + auto &o = this->outputs.front(); + auto &s = c->screens.begin()->second; + auto &layers = c->layers; -result WindowManager::api_request_surface(char const *appid, char const *drawing_name) -{ - auto lid = this->layers.get_layer_id(std::string(drawing_name)); - if (!lid) - { - /** - * register drawing_name as fallback and make it displayed. - */ - lid = this->layers.get_layer_id(std::string("Fallback")); - HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", drawing_name); - if (!lid) - { - return Err("Drawing name does not match any role, Fallback is disabled"); - } - } + // Write output dimensions to ivi controller... + c->output_size = compositor::size{uint32_t(o->width), uint32_t(o->height)}; + c->physical_size = compositor::size{uint32_t(o->physical_width), + uint32_t(o->physical_height)}; - auto rname = this->lookup_id(drawing_name); - if (!rname) + // Clear scene + layers.clear(); + + // Clear screen + s->clear(); + + // Quick and dirty setup of layers + for (auto const &i : this->layers.mapping) { - // name does not exist yet, allocate surface id... - auto id = int(this->id_alloc.generate_id(drawing_name)); - this->layers.add_surface(id, *lid); + c->layer_create(i.second.layer_id, o->width, o->height); + auto &l = layers[i.second.layer_id]; + l->set_destination_rectangle(0, 0, o->width, o->height); + l->set_visibility(1); + HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"", + i.second.name.c_str(), i.second.layer_id, i.second.role.c_str()); + } - // set the main_surface[_name] here and now - if (!this->layers.main_surface_name.empty() && - this->layers.main_surface_name == drawing_name) - { - this->layers.main_surface = id; - HMI_DEBUG("wm", "Set main_surface id to %u", id); - } + // Add layers to screen + s->set_render_order(this->layers.layers); - // add client into the db - std::string appid_str(appid); - std::string role(drawing_name); - g_app_list.addClient(appid_str, *lid, id, role); + this->layout_commit(); - return Ok(id); - } + this->layers.setupArea(o->width, o->height); - // Check currently registered drawing names if it is already there. - return Err("Surface already present"); + return 0; } -char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name, - char const *ivi_id) +void WindowManager::surface_set_layout(int surface_id, const std::string& area) { - ST(); + if (!this->controller->surface_exists(surface_id)) + { + HMI_ERROR("wm", "Surface %d does not exist", surface_id); + return; + } - auto lid = this->layers.get_layer_id(std::string(drawing_name)); - unsigned sid = std::stol(ivi_id); + auto o_layer_id = this->layers.get_layer_id(surface_id); - if (!lid) + if (!o_layer_id) { - /** - * register drawing_name as fallback and make it displayed. - */ - lid = this->layers.get_layer_id(std::string("Fallback")); - HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", drawing_name); - if (!lid) - { - return "Drawing name does not match any role, Fallback is disabled"; - } + HMI_ERROR("wm", "Surface %d is not associated with any layer!", surface_id); + return; } - auto rname = this->lookup_id(drawing_name); + uint32_t layer_id = *o_layer_id; - if (rname) + auto const &layer = this->layers.get_layer(layer_id); + auto rect = this->layers.getAreaSize(area); + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "%s : x:%d y:%d w:%d h:%d", area.c_str(), + rect.x, rect.y, rect.w, rect.h); + auto &s = this->controller->surfaces[surface_id]; + + int x = rect.x; + int y = rect.y; + int w = rect.w; + int h = rect.h; + + // less-than-0 values refer to MAX + 1 - $VALUE + // e.g. MAX is either screen width or height + if (w < 0) { - return "Surface already present"; + w = this->controller->output_size.w + 1 + w; + } + if (h < 0) + { + h = this->controller->output_size.h + 1 + h; } - // register pair drawing_name and ivi_id - this->id_alloc.register_name_id(drawing_name, sid); - this->layers.add_surface(sid, *lid); + HMI_DEBUG("wm", "surface_set_layout for surface %u on layer %u", surface_id, + layer_id); + + // set destination to the display rectangle + s->set_destination_rectangle(x, y, w, h); + + // update area information + this->area_info[surface_id].x = x; + this->area_info[surface_id].y = y; + this->area_info[surface_id].w = w; + this->area_info[surface_id].h = h; + + HMI_DEBUG("wm", "Surface %u now on layer %u with rect { %d, %d, %d, %d }", + surface_id, layer_id, x, y, w, h); +} + +void WindowManager::layout_commit() +{ + this->controller->commit_changes(); + this->display->flush(); +} + +void WindowManager::emit_activated(char const *label) +{ + this->send_event(kListEventName[Event_Active], label); +} + +void WindowManager::emit_deactivated(char const *label) +{ + this->send_event(kListEventName[Event_Inactive], label); +} - // this surface is already created - HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", sid, *lid); +void WindowManager::emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h) +{ + this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h); +} - this->controller->layers[*lid]->add_surface(sid); - this->layout_commit(); +void WindowManager::emit_syncdraw(const std::string &role, const std::string &area) +{ + compositor::rect rect = this->layers.getAreaSize(area); + this->send_event(kListEventName[Event_SyncDraw], + role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h); +} - // add client into the db - std::string appid_str(appid); - std::string role(drawing_name); - g_app_list.addClient(appid_str, *lid, sid, role); +void WindowManager::emit_flushdraw(char const *label) +{ + this->send_event(kListEventName[Event_FlushDraw], label); +} - return nullptr; +void WindowManager::emit_visible(char const *label, bool is_visible) +{ + this->send_event(is_visible ? kListEventName[Event_Visible] : kListEventName[Event_Invisible], label); } -result WindowManager::api_get_display_info() +void WindowManager::emit_invisible(char const *label) { - // Check controller - if (!this->controller) + return emit_visible(label, false); +} + +void WindowManager::emit_visible(char const *label) { return emit_visible(label, true); } + +void WindowManager::activate(int id) +{ + auto ip = this->controller->sprops.find(id); + if (ip != this->controller->sprops.end()) { - return Err("ivi_controller global not available"); - } + this->controller->surfaces[id]->set_visibility(1); + char const *label = + this->lookup_name(id).value_or("unknown-name").c_str(); - // Set display info - compositor::size o_size = this->controller->output_size; - compositor::size p_size = this->controller->physical_size; + // FOR CES DEMO >>> + if ((0 == strcmp(label, "Radio")) || + (0 == strcmp(label, "MediaPlayer")) || + (0 == strcmp(label, "Music")) || + (0 == strcmp(label, "Navigation"))) + { + for (auto i = surface_bg.begin(); i != surface_bg.end(); ++i) + { + if (id == *i) + { + // Remove id + this->surface_bg.erase(i); - json_object *object = json_object_new_object(); - json_object_object_add(object, kKeyWidthPixel, json_object_new_int(o_size.w)); - json_object_object_add(object, kKeyHeightPixel, json_object_new_int(o_size.h)); - json_object_object_add(object, kKeyWidthMm, json_object_new_int(p_size.w)); - json_object_object_add(object, kKeyHeightMm, json_object_new_int(p_size.h)); + // Remove from BG layer (999) + HMI_DEBUG("wm", "Remove %s(%d) from BG layer", label, id); + this->controller->layers[999]->remove_surface(id); - return Ok(object); -} + // Add to FG layer (1001) + HMI_DEBUG("wm", "Add %s(%d) to FG layer", label, id); + this->controller->layers[1001]->add_surface(id); -result WindowManager::api_get_area_info(char const *drawing_name) -{ - HMI_DEBUG("wm", "called"); + for (int j : this->surface_bg) + { + HMI_DEBUG("wm", "Stored id:%d", j); + } + break; + } + } + } + // <<< FOR CES DEMO + this->layout_commit(); - // Check drawing name, surface/layer id - auto const &surface_id = this->lookup_id(drawing_name); - if (!surface_id) - { - return Err("Surface does not exist"); + this->emit_visible(label); + this->emit_activated(label); } +} - if (!this->controller->surface_exists(*surface_id)) +void WindowManager::deactivate(int id) +{ + auto ip = this->controller->sprops.find(id); + if (ip != this->controller->sprops.end()) { - return Err("Surface does not exist in controller!"); - } + char const *label = + this->lookup_name(id).value_or("unknown-name").c_str(); - auto layer_id = this->layers.get_layer_id(*surface_id); - if (!layer_id) - { - return Err("Surface is not on any layer!"); - } + // FOR CES DEMO >>> + if ((0 == strcmp(label, "Radio")) || + (0 == strcmp(label, "MediaPlayer")) || + (0 == strcmp(label, "Music")) || + (0 == strcmp(label, "Navigation"))) + { - auto o_state = *this->layers.get_layout_state(*surface_id); - if (o_state == nullptr) - { - return Err("Could not find layer for surface"); - } + // Store id + this->surface_bg.push_back(id); - struct LayoutState &state = *o_state; - if ((state.main != *surface_id) && (state.sub != *surface_id)) - { - return Err("Surface is inactive"); - } + // Remove from FG layer (1001) + HMI_DEBUG("wm", "Remove %s(%d) from FG layer", label, id); + this->controller->layers[1001]->remove_surface(id); - // Set area rectangle - compositor::rect area_info = this->area_info[*surface_id]; - json_object *object = json_object_new_object(); - json_object_object_add(object, kKeyX, json_object_new_int(area_info.x)); - json_object_object_add(object, kKeyY, json_object_new_int(area_info.y)); - json_object_object_add(object, kKeyWidth, json_object_new_int(area_info.w)); - json_object_object_add(object, kKeyHeight, json_object_new_int(area_info.h)); + // Add to BG layer (999) + HMI_DEBUG("wm", "Add %s(%d) to BG layer", label, id); + this->controller->layers[999]->add_surface(id); - return Ok(object); + for (int j : surface_bg) + { + HMI_DEBUG("wm", "Stored id:%d", j); + } + } + else + { + this->controller->surfaces[id]->set_visibility(0); + } + // <<< FOR CES DEMO + + this->emit_deactivated(label); + this->emit_invisible(label); + } } WMError WindowManager::setRequest(const std::string& appid, const std::string &role, const std::string &area, @@ -1150,13 +1242,6 @@ WMError WindowManager::doEndDraw(unsigned req_num) return ret; } -WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area) -{ - this->surface_set_layout(surface, area); - - return WMError::SUCCESS; -} - WMError WindowManager::layoutChange(const WMAction &action) { if (action.visible == TaskVisible::INVISIBLE) @@ -1203,6 +1288,13 @@ WMError WindowManager::visibilityChange(const WMAction &action) return WMError::SUCCESS; } +WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area) +{ + this->surface_set_layout(surface, area); + + return WMError::SUCCESS; +} + WMError WindowManager::changeCurrentState(unsigned req_num) { HMI_SEQ_DEBUG(req_num, "Change current layout state"); @@ -1354,94 +1446,6 @@ const char *WindowManager::check_surface_exist(const char *drawing_name) return nullptr; } -void WindowManager::activate(int id) -{ - auto ip = this->controller->sprops.find(id); - if (ip != this->controller->sprops.end()) - { - this->controller->surfaces[id]->set_visibility(1); - char const *label = - this->lookup_name(id).value_or("unknown-name").c_str(); - - // FOR CES DEMO >>> - if ((0 == strcmp(label, "Radio")) || - (0 == strcmp(label, "MediaPlayer")) || - (0 == strcmp(label, "Music")) || - (0 == strcmp(label, "Navigation"))) - { - for (auto i = surface_bg.begin(); i != surface_bg.end(); ++i) - { - if (id == *i) - { - // Remove id - this->surface_bg.erase(i); - - // Remove from BG layer (999) - HMI_DEBUG("wm", "Remove %s(%d) from BG layer", label, id); - this->controller->layers[999]->remove_surface(id); - - // Add to FG layer (1001) - HMI_DEBUG("wm", "Add %s(%d) to FG layer", label, id); - this->controller->layers[1001]->add_surface(id); - - for (int j : this->surface_bg) - { - HMI_DEBUG("wm", "Stored id:%d", j); - } - break; - } - } - } - // <<< FOR CES DEMO - this->layout_commit(); - - this->emit_visible(label); - this->emit_activated(label); - } -} - -void WindowManager::deactivate(int id) -{ - auto ip = this->controller->sprops.find(id); - if (ip != this->controller->sprops.end()) - { - char const *label = - this->lookup_name(id).value_or("unknown-name").c_str(); - - // FOR CES DEMO >>> - if ((0 == strcmp(label, "Radio")) || - (0 == strcmp(label, "MediaPlayer")) || - (0 == strcmp(label, "Music")) || - (0 == strcmp(label, "Navigation"))) - { - - // Store id - this->surface_bg.push_back(id); - - // Remove from FG layer (1001) - HMI_DEBUG("wm", "Remove %s(%d) from FG layer", label, id); - this->controller->layers[1001]->remove_surface(id); - - // Add to BG layer (999) - HMI_DEBUG("wm", "Add %s(%d) to BG layer", label, id); - this->controller->layers[999]->add_surface(id); - - for (int j : surface_bg) - { - HMI_DEBUG("wm", "Stored id:%d", j); - } - } - else - { - this->controller->surfaces[id]->set_visibility(0); - } - // <<< FOR CES DEMO - - this->emit_deactivated(label); - this->emit_invisible(label); - } -} - bool WindowManager::can_split(struct LayoutState const &state, int new_id) { if (state.main != -1 && state.main != new_id) -- cgit 1.2.3-korg