+ int layer_id = this->layers.get_layer_id(surface_id).value_or(-1);
+ if (layer_id == -1) {
+ logerror("Surface %d (0x%x) is not part of any layer!", surface_id,
+ surface_id);
+ } else {
+ auto rect = this->layers.get_layer_rect(surface_id).value();
+ this->controller->add_task(
+ "fullscreen surface",
+ [layer_id, surface_id, rect](struct genivi::controller *c) {
+ auto &s = c->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) {
+ w = c->output_size.w + 1 + w;
+ }
+ if (h < 0) {
+ h = c->output_size.h + 1 + h;
+ }
+ logdebug("Computed rect={ %d, %d, %d, %d }", x, y, w, h);
+
+ // configure surface to wxh dimensions
+ s->set_configuration(w, h);
+ // set source rect to "entire surface"
+ s->set_source_rectangle(0, 0, w, h);
+ // set destination to the display rectangle
+ s->set_destination_rectangle(x, y, w, h);
+
+ s->set_visibility(1);
+ c->layers[layer_id]->add_surface(s.get());
+ logdebug("Surface %u now on layer %u", surface_id, layer_id);
+ });
+ }