diff --git a/repos/base/include/util/geometry.h b/repos/base/include/util/geometry.h index 0266ef6be9..4f362ef239 100644 --- a/repos/base/include/util/geometry.h +++ b/repos/base/include/util/geometry.h @@ -224,10 +224,26 @@ struct Genode::Rect */ Point center(Area const area) const { - return Point((CT(w()) - CT(area.w))/2, - (CT(h()) - CT(area.h))/2) + at; + return Point { .x = (CT(w()) - CT(area.w))/2, + .y = (CT(h()) - CT(area.h))/2 } + at; } + Point clamp(Point const p) const + { + return Point { .x = max(x1(), min(x2(), p.x)), + .y = max(y1(), min(y2(), p.y)) }; + } + + /** + * Operator for testing non-equality of two rectangled + */ + bool operator != (Rect const &r) const { return r.at != at || r.area != area; } + + /** + * Operator for testing equality of two rectangles + */ + bool operator == (Rect const &r) const { return r.at == at && r.area == area; } + /** * Print rectangle coordinates *