KWin::RegionF Class

The RegionF type represents a collection of rectangles to specify the area for drawing or clipping. More...

Header: #include <core/region.h>
CMake: find_package(KWin REQUIRED)
target_link_libraries(mytarget PRIVATE KWin::kwin)

Public Functions

RegionF()
RegionF(const KWin::RectF &rect)
RegionF(const KWin::Region &other)
RegionF(const QRegion &region)
RegionF(qreal x, qreal y, qreal width, qreal height)
RegionF(const KWin::RegionF &other)
RegionF(KWin::RegionF &&other)
KWin::RectF boundingRect() const
bool contains(const KWin::RectF &rect) const
bool contains(const QPointF &point) const
KWin::RegionF grownBy(const QMarginsF &margins) const
KWin::RegionF intersected(const KWin::RegionF &other) const
KWin::RegionF intersected(const KWin::RectF &other) const
bool intersects(const KWin::RegionF &other) const
bool intersects(const KWin::RectF &rect) const
bool isEmpty() const
QSpan<const KWin::RectF> rects() const
KWin::Region rounded() const
KWin::Region roundedIn() const
KWin::Region roundedOut() const
void scale(qreal xScale, qreal yScale)
void scale(qreal scale)
KWin::RegionF scaled(qreal xScale, qreal yScale) const
KWin::RegionF scaled(qreal scale) const
KWin::RegionF subtracted(const KWin::RegionF &other) const
KWin::RegionF subtracted(const KWin::RectF &other) const
void translate(const QPointF &offset)
void translate(qreal x, qreal y)
KWin::RegionF translated(const QPointF &offset) const
KWin::RegionF translated(qreal x, qreal y) const
KWin::RegionF united(const KWin::RegionF &other) const
KWin::RegionF united(const KWin::RectF &other) const
KWin::RegionF xored(const KWin::RegionF &other) const
KWin::RegionF xored(const KWin::RectF &other) const
KWin::RegionF operator&(const KWin::RegionF &other) const
KWin::RegionF operator&(const KWin::RectF &other) const
KWin::RegionF &operator&=(const KWin::RegionF &other)
KWin::RegionF &operator&=(const KWin::RectF &other)
KWin::RegionF operator+(const KWin::RegionF &other) const
KWin::RegionF operator+(const KWin::RectF &other) const
KWin::RegionF &operator+=(const KWin::RegionF &other)
KWin::RegionF &operator+=(const KWin::RectF &other)
KWin::RegionF operator-(const KWin::RegionF &other) const
KWin::RegionF operator-(const KWin::RectF &other) const
KWin::RegionF &operator-=(const KWin::RegionF &other)
KWin::RegionF &operator-=(const KWin::RectF &other)
KWin::RegionF &operator=(KWin::RegionF &&other)
KWin::RegionF &operator=(const KWin::RegionF &other)
bool operator==(const KWin::RegionF &other) const
KWin::RegionF operator^(const KWin::RegionF &other) const
KWin::RegionF operator^(const KWin::RectF &other) const
KWin::RegionF &operator^=(const KWin::RegionF &other)
KWin::RegionF &operator^=(const KWin::RectF &other)
KWin::RegionF operator|(const KWin::RegionF &other) const
KWin::RegionF operator|(const KWin::RectF &other) const
KWin::RegionF &operator|=(const KWin::RegionF &other)
KWin::RegionF &operator|=(const KWin::RectF &other)

Static Public Members

KWin::RegionF fromRectsSortedByY(const QList<KWin::RectF> &rects)
KWin::RegionF fromSortedRects(const QList<KWin::RectF> &rects)
KWin::RegionF fromUnsortedRects(const QList<KWin::RectF> &rects)
KWin::RegionF infinite()

Detailed Description

The RegionF stores rectangles in the y-x lexicographical order. In other words, the rectangles are sorted by the top coordinate first, from top to bottom. If two rectangles have the same top coordinate, then they are also sorted by the left coordinate, from left to right.

The rectangles are split to form bands. A band is a collection of rectangles that share the same top and bottom coordinates. Rectangles in the same band cannot touch or overlap. For example, the following region with two rectangles

----------------- | | | | | | ----------------- | | | | | | | | | | | | ----------------- | | | | | | -----------------

will be stored as follows

----------------- | | | | |---------------| |---------------| ----------------- | | | | | | | | | | | | ----------------- |---------------| |---------------| | | | | -----------------

Note: The RegionF performs no fuzzy floating point number comparisons. You may need to use rounded() or roundedOut() to get rid of extremely small rectangles.

Member Function Documentation

RegionF::RegionF()

Constructs an empty region.

RegionF::RegionF(const KWin::RectF &rect)

Constructs a region with the given rect rectangle.

[explicit] RegionF::RegionF(const KWin::Region &other)

Constructs a copy of the given other region.

[explicit] RegionF::RegionF(const QRegion &region)

Constructs a region from the given QRegion region.

RegionF::RegionF(qreal x, qreal y, qreal width, qreal height)

Constructs a region with the given (x, y, width, and height) rectangle.

RegionF::RegionF(const KWin::RegionF &other)

Constructs a copy of the given other region.

RegionF::RegionF(KWin::RegionF &&other)

Move-constructs a region from the given other region. After the call, the other is empty.

KWin::RectF RegionF::boundingRect() const

Returns the bounding rectangle for this region. If the region is empty, this will return an empty rectangle.

bool RegionF::contains(const KWin::RectF &rect) const

Returns true if the rect is completely inside this region; otherwise returns false.

bool RegionF::contains(const QPointF &point) const

Returns true if the specified point is inside this region; otherwise returns false.

[static] KWin::RegionF RegionF::fromRectsSortedByY(const QList<KWin::RectF> &rects)

Constructs a region from the given list of partially sorted rectangles rects. The rectangles must be sorted by the top edge position, from top to bottom. The rectangles are allowed to overlap. The rectangles with the same top edge coordinate are not required to be sorted by the left edge coordinate and share the same bottom edge coordinate.

rects should not have any empty rectangles.

This can be more efficient than constructing a region by calling the united() function in a loop.

See also fromSortedRects() and fromUnsortedRects().

[static] KWin::RegionF RegionF::fromSortedRects(const QList<KWin::RectF> &rects)

Constructs a region from the given rects. The rectangles must be sorted in the y-x lexicographical order. In other words, the rectangles must be sorted by the top edge coordinate, from top to bottom. If two rectangles have the same top coordinate, they should be sorted by the left coordinate, from left to right. Rectangles with the same top edge coordinate must have the same bottom coordinate.

No rectangles are allowed to overlap. Furthermore, two rectangles cannot touch each other horizontally, a rectangle must occupy the horizontal space as much as possible.

rects() can be safely passed to this function.

rects should not have any empty rectangles.

See also rects(), fromUnsortedRects(), and fromRectsSortedByY().

[static] KWin::RegionF RegionF::fromUnsortedRects(const QList<KWin::RectF> &rects)

Constructs a region from the given list of unsorted rectangles rects. There are no concrete requirements for rectangles. They can overlap, there can be duplicate rectangles, they can be stored in any order in the list. However, the rects should not have any empty rectangles.

See also fromSortedRects() and fromRectsSortedByY().

KWin::RegionF RegionF::grownBy(const QMarginsF &margins) const

Returns a copy of the region grown by the given margins.

[static] KWin::RegionF RegionF::infinite()

Returns the infinite region.

KWin::RegionF RegionF::intersected(const KWin::RegionF &other) const

Returns a region that is the intersection of this region and the given other region.

KWin::RegionF RegionF::intersected(const KWin::RectF &other) const

Returns a region that is the intersection of this region and the given other rectangle.

This is an overloaded function.

bool RegionF::intersects(const KWin::RegionF &other) const

Returns true if the given other region and this region overlap; otherwise returns false.

bool RegionF::intersects(const KWin::RectF &rect) const

Returns true if the given rect and this region overlap; otherwise returns false.

This is an overloaded function.

bool RegionF::isEmpty() const

Returns true if the region is empty; otherwise returns false.

QSpan<const KWin::RectF> RegionF::rects() const

Returns the rectangles that this region is made of.

KWin::Region RegionF::rounded() const

Returns a copy of this region with rounded rectangles.

Note: This may make some rectangles disappear.

See also RectF::rounded().

KWin::Region RegionF::roundedIn() const

Returns a copy of this region with rounded in rectangles.

See also RectF::roundedIn().

KWin::Region RegionF::roundedOut() const

Returns a copy of this region with rounded out rectangles.

See also RectF::roundedOut().

void RegionF::scale(qreal xScale, qreal yScale)

Scales this region by the xScale factor along the X axis and the yScale along the Y axis.

void RegionF::scale(qreal scale)

Scales this region by the scale factor along both the X and Y axis. Equivalent to scale(scale, scale).

This is an overloaded function.

KWin::RegionF RegionF::scaled(qreal xScale, qreal yScale) const

Returns a copy of this region that is scaled by the xScale factor along the X axis and the yScale along the Y axis.

KWin::RegionF RegionF::scaled(qreal scale) const

Returns a copy of this region that is scaled by the scale factor along both the X and Y axis. Equivalent to scaled(scale, scale).

This is an overloaded function.

KWin::RegionF RegionF::subtracted(const KWin::RegionF &other) const

Returns a region that is the other region subtracted from this region.

KWin::RegionF RegionF::subtracted(const KWin::RectF &other) const

Returns a region that is the other rectangle subtracted from this region.

This is an overloaded function.

void RegionF::translate(const QPointF &offset)

Shifts the region by the offset.x() amount along the X axis, and the offset.y() amount along the Y axis.

void RegionF::translate(qreal x, qreal y)

Shifts the region by the x amount along the X axis, and the y amount along the Y axis.

This is an overloaded function.

KWin::RegionF RegionF::translated(const QPointF &offset) const

Returns a copy of this region that is shifted by the offset.x() amount along the X axis, and the offset.y() amount along the Y axis.

KWin::RegionF RegionF::translated(qreal x, qreal y) const

Returns a copy of this region that is shifted by the x amount along the X axis, and the y amount along the Y axis.

This is an overloaded function.

KWin::RegionF RegionF::united(const KWin::RegionF &other) const

Returns a region that is the union of this region and the given other region.

KWin::RegionF RegionF::united(const KWin::RectF &other) const

Returns a region that is the union of this region and the given other rectangle.

This is an overloaded function.

KWin::RegionF RegionF::xored(const KWin::RegionF &other) const

Returns a region that is the exclusive or of this region and the given other region.

KWin::RegionF RegionF::xored(const KWin::RectF &other) const

Returns a region that is the exclusive or of this region and the given other rectangle.

This is an overloaded function.

KWin::RegionF RegionF::operator&(const KWin::RegionF &other) const

Returns a region that is the intersection of this region and the given other region. Equivalent to intersected().

See also intersected() and operator&=().

KWin::RegionF RegionF::operator&(const KWin::RectF &other) const

Returns a region that is the intersection of this region and the given other rectangle. Equivalent to intersected().

This is an overloaded function.

See also intersected() and operator&=().

KWin::RegionF &RegionF::operator&=(const KWin::RegionF &other)

Intersects the other region with this region and assigns the result to this region. Equivalent to region = region.intersected(other).

See also intersected() and operator&().

KWin::RegionF &RegionF::operator&=(const KWin::RectF &other)

Intersects the other rectangle with this region and assigns the result to this region. Equivalent to region = region.intersected(other).

This is an overloaded function.

See also intersected() and operator&().

KWin::RegionF RegionF::operator+(const KWin::RegionF &other) const

Returns a region that is the union of this region and the given other region. Equivalent to united() and operator|().

See also united() and operator+=().

KWin::RegionF RegionF::operator+(const KWin::RectF &other) const

Returns a region that is the union of this region and the given other rectangle. Equivalent to united() and operator|().

This is an overloaded function.

See also united() and operator+=().

KWin::RegionF &RegionF::operator+=(const KWin::RegionF &other)

Unites the other region with this region and assigns the result to this region. Equivalent to region = region.united(other).

See also united() and operator+().

KWin::RegionF &RegionF::operator+=(const KWin::RectF &other)

Unites the other rectangle with this region and assigns the result to this region. Equivalent to region = region.united(other).

This is an overloaded function.

See also united() and operator+().

KWin::RegionF RegionF::operator-(const KWin::RegionF &other) const

Returns a region that is the other region subtracted from this region. Equivalent to subtracted().

See also subtracted() and operator-=().

KWin::RegionF RegionF::operator-(const KWin::RectF &other) const

Returns a region that is the other rectangle subtracted from this region. Equivalent to subtracted().

This is an overloaded function.

See also subtracted() and operator-=().

KWin::RegionF &RegionF::operator-=(const KWin::RegionF &other)

Subtracts the other region from this region and assigns the result to this region. Equivalent to region = region.subtracted(other).

See also subtracted() and operator-().

KWin::RegionF &RegionF::operator-=(const KWin::RectF &other)

Subtracts the other rectangle from this region and assigns the result to this region. Equivalent to region = region.subtracted(other).

This is an overloaded function.

See also subtracted() and operator-().

KWin::RegionF &RegionF::operator=(KWin::RegionF &&other)

Move-assigns the other region to this region.

KWin::RegionF &RegionF::operator=(const KWin::RegionF &other)

Copy-assigns the other region to this region.

bool RegionF::operator==(const KWin::RegionF &other) const

Returns true if this region is equal to the other region; otherwise returns false.

KWin::RegionF RegionF::operator^(const KWin::RegionF &other) const

Returns a region that is the exclusive or of this region and the given other region. Equivalent to xored().

See also xored() and operator^=().

KWin::RegionF RegionF::operator^(const KWin::RectF &other) const

Returns a region that is the exclusive or of this region and the given other rectangle. Equivalent to xored().

This is an overloaded function.

See also xored() and operator^=().

KWin::RegionF &RegionF::operator^=(const KWin::RegionF &other)

Applies the exclusive OR operation to the other region and this region and assigns the result to this region. Equivalent to region = region.xored(other).

See also xored() and operator^().

KWin::RegionF &RegionF::operator^=(const KWin::RectF &other)

Applies the exclusive OR operation to the other rectangle and this region and assigns the result to this region. Equivalent to region = region.xored(other).

This is an overloaded function.

See also xored() and operator^().

KWin::RegionF RegionF::operator|(const KWin::RegionF &other) const

Returns a region that is the union of this region and the given other region. Equivalent to united() and operator+().

See also united() and operator|=().

KWin::RegionF RegionF::operator|(const KWin::RectF &other) const

Returns a region that is the union of this region and the given other rectangle. Equivalent to united() and operator+().

This is an overloaded function.

See also united() and operator|=().

KWin::RegionF &RegionF::operator|=(const KWin::RegionF &other)

Unites the other region with this region and assigns the result to this region. Equivalent to region = region.united(other).

See also united() and operator|().

KWin::RegionF &RegionF::operator|=(const KWin::RectF &other)

Unites the other rectangle with this region and assigns the result to this region. Equivalent to region = region.united(other).

This is an overloaded function.

See also united() and operator|().