+ uint32_t layer_id = o_layer_id.value();
+ 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;
+ auto &s = this->controller->surfaces[surface_id];
+ auto &ss = this->controller->surfaces[sub_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 = this->controller->output_size.w + 1 + w;
+ }
+ if (h < 0) {
+ h = this->controller->output_size.h + 1 + h;
+ }
+
+ int x_off = 0;
+ int y_off = 0;
+
+ // split along major axis
+ if (w > h) {
+ w /= 2;
+ x_off = w;
+ } else {
+ h /= 2;
+ y_off = h;
+ }
+
+ // configure surface to wxh dimensions
+ s->set_configuration(w, h);
+ // set source reactangle, even if we should not need to set it.
+ s->set_source_rectangle(0, 0, w, h);
+ // set destination to the display rectangle
+ s->set_destination_rectangle(x, y, w, h);
+
+ // configure surface to wxh dimensions
+ ss->set_configuration(w, h);
+ // set source reactangle, even if we should not need to set it.
+ ss->set_source_rectangle(0, 0, w, h);
+ // set destination to the display rectangle
+ ss->set_destination_rectangle(x + x_off, y + y_off, w, h);
+
+ // redraw_fix(this, s, x, y, w, h);
+ // redraw_fix(this, ss, x+x_off, y+y_off, w, h);
+