Skip to content

Draft: scene: Change decoration item origin

Vlad Zahorodnii requested to merge work/zzag/decoration-item-origin into master

The main goal of this change is to address the problem of having gaps between the surface item and the decoration item in the device pixels.

At the heart of problem is the fact that:

std::round(a + b) != std::round(a) + std::round(b)

Consider the x coordinate of the right edge of the surface item in the device pixels:

std::round(window_item_x * scale) + std::round(surface_item_x * scale)
    + std::round(surface_item_width * scale) =>

given, surface_item_x == borderLeft

std::round(window_item_x * scale) + std::round(borderLeft * scale)
    + std::round(surface_item_width * scale)

The x coordinate of the right border of the decoration item:

std::round(window_item_x * scale) + std::round(decoration_item_x * scale)
    + std::round((borderLeft + surface_item_width) * scale) =>
std::round(window_item_x * scale) + std::round((borderLeft + surface_item_width) * scale)

By changing the origin, it's possible to match the math when computing the coordinates of surface item borders and inner decoration item borders.

Merge request reports