KWin::Region Class
The Region 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
| Region() | |
| Region(const KWin::Rect &rect) | |
| Region(const QRegion ®ion) | |
| Region(int x, int y, int width, int height) | |
| Region(const KWin::Region &other) | |
| Region(KWin::Region &&other) | |
| KWin::Rect | boundingRect() const |
| bool | contains(const KWin::Rect &rect) const |
| bool | contains(const QPoint &point) const |
| KWin::Region | grownBy(const QMargins &margins) const |
| KWin::Region | intersected(const KWin::Region &other) const |
| KWin::Region | intersected(const KWin::Rect &other) const |
| bool | intersects(const KWin::Region &other) const |
| bool | intersects(const KWin::Rect &rect) const |
| bool | isEmpty() const |
| QSpan<const KWin::Rect> | rects() const |
| KWin::RegionF | scaled(qreal xScale, qreal yScale) const |
| KWin::RegionF | scaled(qreal scale) const |
| KWin::Region | scaledAndRoundedOut(qreal xScale, qreal yScale) const |
| KWin::Region | scaledAndRoundedOut(qreal scale) const |
| KWin::Region | subtracted(const KWin::Region &other) const |
| KWin::Region | subtracted(const KWin::Rect &other) const |
| void | translate(const QPoint &offset) |
| void | translate(int x, int y) |
| KWin::Region | translated(const QPoint &offset) const |
| KWin::Region | translated(int x, int y) const |
| KWin::Region | united(const KWin::Region &other) const |
| KWin::Region | united(const KWin::Rect &other) const |
| KWin::Region | xored(const KWin::Region &other) const |
| KWin::Region | xored(const KWin::Rect &other) const |
| operator QRegion() const | |
| KWin::Region | operator&(const KWin::Region &other) const |
| KWin::Region | operator&(const KWin::Rect &other) const |
| KWin::Region & | operator&=(const KWin::Region &other) |
| KWin::Region & | operator&=(const KWin::Rect &other) |
| KWin::Region | operator+(const KWin::Region &other) const |
| KWin::Region | operator+(const KWin::Rect &other) const |
| KWin::Region & | operator+=(const KWin::Region &other) |
| KWin::Region & | operator+=(const KWin::Rect &other) |
| KWin::Region | operator-(const KWin::Region &other) const |
| KWin::Region | operator-(const KWin::Rect &other) const |
| KWin::Region & | operator-=(const KWin::Region &other) |
| KWin::Region & | operator-=(const KWin::Rect &other) |
| KWin::Region & | operator=(KWin::Region &&other) |
| KWin::Region & | operator=(const KWin::Region &other) |
| bool | operator==(const KWin::Region &other) const |
| KWin::Region | operator^(const KWin::Region &other) const |
| KWin::Region | operator^(const KWin::Rect &other) const |
| KWin::Region & | operator^=(const KWin::Region &other) |
| KWin::Region & | operator^=(const KWin::Rect &other) |
| KWin::Region | operator|(const KWin::Region &other) const |
| KWin::Region | operator|(const KWin::Rect &other) const |
| KWin::Region & | operator|=(const KWin::Region &other) |
| KWin::Region & | operator|=(const KWin::Rect &other) |
Static Public Members
| KWin::Region | fromRectsSortedByY(const QList<KWin::Rect> &rects) |
| KWin::Region | fromSortedRects(const QList<KWin::Rect> &rects) |
| KWin::Region | fromUnsortedRects(const QList<KWin::Rect> &rects) |
| KWin::Region | infinite() |
Detailed Description
The Region 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
----------------- | | | | |---------------| |---------------| ----------------- | | | | | | | | | | | | ----------------- |---------------| |---------------| | | | | -----------------
Member Function Documentation
Region::Region()
Constructs an empty region.
Region::Region(const KWin::Rect &rect)
Constructs a region with the given rect rectangle.
[explicit] Region::Region(const QRegion ®ion)
Constructs a region from the given QRegion region.
Region::Region(int x, int y, int width, int height)
Constructs a region with the given (x, y, width, and height) rectangle.
Region::Region(const KWin::Region &other)
Constructs a copy of the given other region.
Region::Region(KWin::Region &&other)
Move-constructs a region from the given other region. After the call, the other is empty.
KWin::Rect Region::boundingRect() const
Returns the bounding rectangle for this region. If the region is empty, this will return an empty rectangle.
bool Region::contains(const KWin::Rect &rect) const
Returns true if the rect is completely inside this region; otherwise returns false.
bool Region::contains(const QPoint &point) const
Returns true if the specified point is inside this region; otherwise returns false.
[static] KWin::Region Region::fromRectsSortedByY(const QList<KWin::Rect> &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::Region Region::fromSortedRects(const QList<KWin::Rect> &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::Region Region::fromUnsortedRects(const QList<KWin::Rect> &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::Region Region::grownBy(const QMargins &margins) const
Returns a copy of the region grown by the given margins.
[static] KWin::Region Region::infinite()
Returns the infinite region.
KWin::Region Region::intersected(const KWin::Region &other) const
Returns a region that is the intersection of this region and the given other region.
KWin::Region Region::intersected(const KWin::Rect &other) const
Returns a region that is the intersection of this region and the given other rectangle.
This is an overloaded function.
bool Region::intersects(const KWin::Region &other) const
Returns true if the given other region and this region overlap; otherwise returns false.
bool Region::intersects(const KWin::Rect &rect) const
Returns true if the given rect and this region overlap; otherwise returns false.
This is an overloaded function.
bool Region::isEmpty() const
Returns true if the region is empty; otherwise returns false.
QSpan<const KWin::Rect> Region::rects() const
Returns the rectangles that this region is made of.
KWin::RegionF Region::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 Region::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::Region Region::scaledAndRoundedOut(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 and then rounded out.
KWin::Region Region::scaledAndRoundedOut(qreal scale) const
Returns a copy of this region that is scaled by the scale factor along both the X and Y axis and then rounded out. Equivalent to scaledAndRoundedOut(scale, scale).
This is an overloaded function.
KWin::Region Region::subtracted(const KWin::Region &other) const
Returns a region that is the other region subtracted from this region.
KWin::Region Region::subtracted(const KWin::Rect &other) const
Returns a region that is the other rectangle subtracted from this region.
This is an overloaded function.
void Region::translate(const QPoint &offset)
Shifts the region by the offset.x() amount along the X axis, and the offset.y() amount along the Y axis.
void Region::translate(int x, int 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::Region Region::translated(const QPoint &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::Region Region::translated(int x, int 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::Region Region::united(const KWin::Region &other) const
Returns a region that is the union of this region and the given other region.
KWin::Region Region::united(const KWin::Rect &other) const
Returns a region that is the union of this region and the given other rectangle.
This is an overloaded function.
KWin::Region Region::xored(const KWin::Region &other) const
Returns a region that is the exclusive or of this region and the given other region.
KWin::Region Region::xored(const KWin::Rect &other) const
Returns a region that is the exclusive or of this region and the given other rectangle.
This is an overloaded function.
[explicit] Region::operator QRegion() const
Converts this region to a QRegion.
KWin::Region Region::operator&(const KWin::Region &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::Region Region::operator&(const KWin::Rect &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::Region &Region::operator&=(const KWin::Region &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::Region &Region::operator&=(const KWin::Rect &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::Region Region::operator+(const KWin::Region &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::Region Region::operator+(const KWin::Rect &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::Region &Region::operator+=(const KWin::Region &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::Region &Region::operator+=(const KWin::Rect &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::Region Region::operator-(const KWin::Region &other) const
Returns a region that is the other region subtracted from this region. Equivalent to subtracted().
See also subtracted() and operator-=().
KWin::Region Region::operator-(const KWin::Rect &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::Region &Region::operator-=(const KWin::Region &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::Region &Region::operator-=(const KWin::Rect &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::Region &Region::operator=(KWin::Region &&other)
Move-assigns the other region to this region.
KWin::Region &Region::operator=(const KWin::Region &other)
Copy-assigns the other region to this region.
bool Region::operator==(const KWin::Region &other) const
Returns true if this region is equal to the other region; otherwise returns false.
KWin::Region Region::operator^(const KWin::Region &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::Region Region::operator^(const KWin::Rect &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::Region &Region::operator^=(const KWin::Region &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::Region &Region::operator^=(const KWin::Rect &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::Region Region::operator|(const KWin::Region &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::Region Region::operator|(const KWin::Rect &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::Region &Region::operator|=(const KWin::Region &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::Region &Region::operator|=(const KWin::Rect &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.