Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
GeometryHelpers.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <QRect>
7#include <QRectF>
8
9#include <algorithm>
10
11namespace PhosphorCompositor {
12
18namespace GeometryHelpers {
19
29inline QRect snapToRect(const QRectF& rf)
30{
31 const int left = qRound(rf.x());
32 const int top = qRound(rf.y());
33 const int right = qRound(rf.x() + rf.width());
34 const int bottom = qRound(rf.y() + rf.height());
35 return QRect(left, top, std::max(0, right - left), std::max(0, bottom - top));
36}
37
38} // namespace GeometryHelpers
39} // namespace PhosphorCompositor
QRect snapToRect(const QRectF &rf)
Convert QRectF to QRect with edge-consistent rounding.
Definition GeometryHelpers.h:29
Definition AutotileState.h:16