+result<int> App::request_surface(char const *drawing_name) {
+ auto lid = this->layers.get_layer_id(std::string(drawing_name));
+ if (!lid) {
+ // XXX: to we need to put these applications on the App layer?
+ return Err<int>("Drawing name does not match any role");
+ }
+
+ auto rname = this->id_alloc[drawing_name];
+ if (! rname) {
+ // name does not exist yet, allocate surface id...
+ // XXX: how to allocate surface IDs?
+ // * allocate by running a counter for each layer?
+ // * allocate IDs globally, i.e. do not have layers contain
+ // ID ranges (only define the surfaces on the layer by
+ // role?)
+ 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 = id;
+ this->activate_surface(id);
+ logdebug("Set main_surface id to %u", id);
+ }
+
+ return Ok<int>(id);
+ }
+
+ // Check currently registered drawing names if it is already there.
+ return Err<int>("Surface already present");
+}
+
+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());
+ this->activate_surface(osid.value());
+ return nullptr;
+ }
+
+ logerror("surface %s unknown", drawing_name);
+ return "Surface unknown";
+}
+