Add a helper function to convert QPointF to QPoint using floor instead of round
In a bunch of cases, we want to floor when converting to QPoint rather than rounding. As it gets tedious to repeat the same code over and over, add a helper function.
This commit is contained in:
parent
a1191bea18
commit
2f900d84ab
1 changed files with 11 additions and 0 deletions
|
@ -206,6 +206,17 @@ KWINEFFECTS_EXPORT inline QVector2D roundVector(const QVector2D &input)
|
|||
return QVector2D(std::round(input.x()), std::round(input.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a QPointF to a QPoint by flooring instead of rounding.
|
||||
*
|
||||
* By default, QPointF::toPoint() rounds which can cause problems in certain
|
||||
* cases.
|
||||
*/
|
||||
KWINEFFECTS_EXPORT inline QPoint flooredPoint(const QPointF &point)
|
||||
{
|
||||
return QPoint(std::floor(point.x()), std::floor(point.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @short Base class for all KWin effects
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue