Fix window extents terminology
Extents is a synonym of size but we're setting not window size.
This commit is contained in:
parent
2dd3add5b3
commit
bcf88b9065
8 changed files with 61 additions and 61 deletions
|
|
@ -467,7 +467,7 @@ std::optional<bool> IsOverlapped(
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool WindowExtentsSupported() {
|
||||
bool WindowMarginsSupported() {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
using namespace QNativeInterface::Private;
|
||||
QWindow window;
|
||||
|
|
@ -490,25 +490,25 @@ bool WindowExtentsSupported() {
|
|||
return false;
|
||||
}
|
||||
|
||||
void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
||||
void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
using namespace QNativeInterface::Private;
|
||||
if (const auto native = not_null(widget->windowHandle())
|
||||
->nativeInterface<QWaylandWindow>()) {
|
||||
native->setCustomMargins(extents);
|
||||
native->setCustomMargins(margins);
|
||||
return;
|
||||
}
|
||||
#endif // Qt >= 6.5.0
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||
if (::Platform::IsX11()) {
|
||||
SetXCBFrameExtents(widget, extents);
|
||||
SetXCBFrameExtents(widget, margins);
|
||||
return;
|
||||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||
}
|
||||
|
||||
void UnsetWindowExtents(not_null<QWidget*> widget) {
|
||||
void UnsetWindowMargins(not_null<QWidget*> widget) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
using namespace QNativeInterface::Private;
|
||||
if (const auto native = not_null(widget->windowHandle())
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ inline constexpr bool UseMainQueueGeneric() {
|
|||
return ::Platform::IsMacStoreBuild();
|
||||
}
|
||||
|
||||
inline bool WindowExtentsSupported() {
|
||||
inline bool WindowMarginsSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
||||
inline void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) {
|
||||
}
|
||||
|
||||
inline void UnsetWindowExtents(not_null<QWidget*> widget) {
|
||||
inline void UnsetWindowMargins(not_null<QWidget*> widget) {
|
||||
}
|
||||
|
||||
inline void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ void DisableSystemWindowResize(not_null<QWidget*> widget, QSize ratio);
|
|||
[[nodiscard]] constexpr bool UseMainQueueGeneric();
|
||||
void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false.
|
||||
|
||||
[[nodiscard]] bool WindowExtentsSupported();
|
||||
void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents);
|
||||
void UnsetWindowExtents(not_null<QWidget*> widget);
|
||||
[[nodiscard]] bool WindowMarginsSupported();
|
||||
void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins);
|
||||
void UnsetWindowMargins(not_null<QWidget*> widget);
|
||||
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
||||
|
||||
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ DefaultWindowHelper::DefaultWindowHelper(not_null<RpWidget*> window)
|
|||
}
|
||||
|
||||
void DefaultWindowHelper::init() {
|
||||
if (WindowExtentsSupported()) {
|
||||
if (WindowMarginsSupported()) {
|
||||
window()->setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ void DefaultWindowHelper::init() {
|
|||
bool titleShown,
|
||||
Qt::WindowStates windowState) {
|
||||
window()->windowHandle()->setFlag(Qt::FramelessWindowHint, titleShown);
|
||||
updateWindowExtents();
|
||||
updateWindowMargins();
|
||||
}, window()->lifetime());
|
||||
|
||||
window()->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
|
|
@ -437,7 +437,7 @@ QMargins DefaultWindowHelper::frameMargins() {
|
|||
}
|
||||
|
||||
bool DefaultWindowHelper::hasShadow() const {
|
||||
return WindowExtentsSupported() && TranslucentWindowsSupported();
|
||||
return WindowMarginsSupported() && TranslucentWindowsSupported();
|
||||
}
|
||||
|
||||
QMargins DefaultWindowHelper::resizeArea() const {
|
||||
|
|
@ -588,13 +588,13 @@ void DefaultWindowHelper::paintBorders(QPainter &p) {
|
|||
borderColor);
|
||||
}
|
||||
|
||||
void DefaultWindowHelper::updateWindowExtents() {
|
||||
void DefaultWindowHelper::updateWindowMargins() {
|
||||
if (hasShadow() && !_title->isHidden()) {
|
||||
SetWindowExtents(window(), resizeArea());
|
||||
_extentsSet = true;
|
||||
} else if (_extentsSet) {
|
||||
UnsetWindowExtents(window());
|
||||
_extentsSet = false;
|
||||
SetWindowMargins(window(), resizeArea());
|
||||
_marginsSet = true;
|
||||
} else if (_marginsSet) {
|
||||
UnsetWindowMargins(window());
|
||||
_marginsSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ private:
|
|||
[[nodiscard]] QMargins resizeArea() const;
|
||||
[[nodiscard]] Qt::Edges edgesFromPos(const QPoint &pos) const;
|
||||
void paintBorders(QPainter &p);
|
||||
void updateWindowExtents();
|
||||
void updateWindowMargins();
|
||||
void updateCursor(Qt::Edges edges);
|
||||
[[nodiscard]] int titleHeight() const;
|
||||
[[nodiscard]] QMargins bodyPadding() const;
|
||||
|
|
@ -118,7 +118,7 @@ private:
|
|||
std::array<QImage, 4> _sides;
|
||||
std::array<QImage, 4> _corners;
|
||||
object_ptr<RpWidget> _roundingOverlay = { nullptr };
|
||||
bool _extentsSet = false;
|
||||
bool _marginsSet = false;
|
||||
rpl::variable<Qt::WindowStates> _windowState = Qt::WindowNoState;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ inline constexpr bool UseMainQueueGeneric() {
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool WindowExtentsSupported() {
|
||||
inline bool WindowMarginsSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
||||
inline void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) {
|
||||
}
|
||||
|
||||
inline void UnsetWindowExtents(not_null<QWidget*> widget) {
|
||||
inline void UnsetWindowMargins(not_null<QWidget*> widget) {
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
|||
|
|
@ -314,19 +314,19 @@ void PopupMenu::validateCompositingSupport() {
|
|||
std::max(line, additional.top()),
|
||||
std::max(line, additional.right()),
|
||||
std::max(line, additional.bottom()));
|
||||
_extents = QMargins();
|
||||
_margins = QMargins();
|
||||
} else {
|
||||
_padding = QMargins(
|
||||
std::max(_st.shadow.extend.left(), additional.left()),
|
||||
std::max(_st.shadow.extend.top(), additional.top()),
|
||||
std::max(_st.shadow.extend.right(), additional.right()),
|
||||
std::max(_st.shadow.extend.bottom(), additional.bottom()));
|
||||
_extents = _padding - (additional - _additionalMenuExtents);
|
||||
_margins = _padding - (additional - _additionalMenuMargins);
|
||||
}
|
||||
if (_extents.isNull()) {
|
||||
Platform::UnsetWindowExtents(this);
|
||||
if (_margins.isNull()) {
|
||||
Platform::UnsetWindowMargins(this);
|
||||
} else {
|
||||
Platform::SetWindowExtents(this, _extents);
|
||||
Platform::SetWindowMargins(this, _margins);
|
||||
}
|
||||
_scroll->moveToLeft(_padding.left(), _padding.top());
|
||||
handleMenuResize();
|
||||
|
|
@ -722,16 +722,16 @@ void PopupMenu::setForcedVerticalOrigin(VerticalOrigin origin) {
|
|||
|
||||
void PopupMenu::setAdditionalMenuPadding(
|
||||
QMargins padding,
|
||||
QMargins extents) {
|
||||
Expects(padding.left() >= extents.left()
|
||||
&& padding.right() >= extents.right()
|
||||
&& padding.top() >= extents.top()
|
||||
&& padding.bottom() >= extents.bottom());
|
||||
QMargins margins) {
|
||||
Expects(padding.left() >= margins.left()
|
||||
&& padding.right() >= margins.right()
|
||||
&& padding.top() >= margins.top()
|
||||
&& padding.bottom() >= margins.bottom());
|
||||
|
||||
if (_additionalMenuPadding != padding
|
||||
|| _additionalMenuExtents != extents) {
|
||||
|| _additionalMenuMargins != margins) {
|
||||
_additionalMenuPadding = padding;
|
||||
_additionalMenuExtents = extents;
|
||||
_additionalMenuMargins = margins;
|
||||
_roundingOverlay = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -937,8 +937,8 @@ QMargins PopupMenu::preparedPadding() const {
|
|||
return _padding;
|
||||
}
|
||||
|
||||
QMargins PopupMenu::preparedExtents() const {
|
||||
return _extents;
|
||||
QMargins PopupMenu::preparedMargins() const {
|
||||
return _margins;
|
||||
}
|
||||
|
||||
bool PopupMenu::useTransparency() const {
|
||||
|
|
@ -1010,21 +1010,21 @@ bool PopupMenu::prepareGeometryFor(const QPoint &p, PopupMenu *parent) {
|
|||
auto r = screen ? screen->availableGeometry() : QRect();
|
||||
const auto parentWidth = _parent ? _parent->inner().width() : 0;
|
||||
if (style::RightToLeft()) {
|
||||
const auto badLeft = !r.isNull() && w.x() - width() < r.x() - _extents.left();
|
||||
const auto badLeft = !r.isNull() && w.x() - width() < r.x() - _margins.left();
|
||||
if (forceRight || (badLeft && !forceLeft)) {
|
||||
if (_parent && (r.isNull() || w.x() + parentWidth - _extents.left() - _extents.right() + width() - _extents.right() <= r.x() + r.width())) {
|
||||
w.setX(w.x() + parentWidth - _extents.left() - _extents.right());
|
||||
if (_parent && (r.isNull() || w.x() + parentWidth - _margins.left() - _margins.right() + width() - _margins.right() <= r.x() + r.width())) {
|
||||
w.setX(w.x() + parentWidth - _margins.left() - _margins.right());
|
||||
} else {
|
||||
w.setX(r.x() - _extents.left());
|
||||
w.setX(r.x() - _margins.left());
|
||||
}
|
||||
} else {
|
||||
w.setX(w.x() - width());
|
||||
}
|
||||
} else {
|
||||
const auto badLeft = !r.isNull() && w.x() + width() - _extents.right() > r.x() + r.width();
|
||||
const auto badLeft = !r.isNull() && w.x() + width() - _margins.right() > r.x() + r.width();
|
||||
if (forceRight || (badLeft && !forceLeft)) {
|
||||
if (_parent && (r.isNull() || w.x() - parentWidth + _extents.left() + _extents.right() - width() + _extents.right() >= r.x() - _extents.left())) {
|
||||
w.setX(w.x() + _extents.left() + _extents.right() - parentWidth - width() + _extents.left() + _extents.right());
|
||||
if (_parent && (r.isNull() || w.x() - parentWidth + _margins.left() + _margins.right() - width() + _margins.right() >= r.x() - _margins.left())) {
|
||||
w.setX(w.x() + _margins.left() + _margins.right() - parentWidth - width() + _margins.left() + _margins.right());
|
||||
} else {
|
||||
w.setX(p.x() - width() + std::max(
|
||||
_additionalMenuPadding.right() - _st.shadow.extend.right(),
|
||||
|
|
@ -1033,29 +1033,29 @@ bool PopupMenu::prepareGeometryFor(const QPoint &p, PopupMenu *parent) {
|
|||
origin = PanelAnimation::Origin::TopRight;
|
||||
}
|
||||
}
|
||||
const auto badTop = !r.isNull() && w.y() + height() - _extents.bottom() > r.y() + r.height();
|
||||
const auto badTop = !r.isNull() && w.y() + height() - _margins.bottom() > r.y() + r.height();
|
||||
if (forceBottom || (badTop && !forceTop)) {
|
||||
if (_parent) {
|
||||
w.setY(r.y() + r.height() - height() + _extents.bottom());
|
||||
w.setY(r.y() + r.height() - height() + _margins.bottom());
|
||||
} else {
|
||||
w.setY(p.y() - height() + _extents.bottom());
|
||||
w.setY(p.y() - height() + _margins.bottom());
|
||||
origin = (origin == PanelAnimation::Origin::TopRight)
|
||||
? PanelAnimation::Origin::BottomRight
|
||||
: PanelAnimation::Origin::BottomLeft;
|
||||
}
|
||||
}
|
||||
if (!r.isNull()) {
|
||||
if (w.x() + width() - _extents.right() > r.x() + r.width()) {
|
||||
w.setX(r.x() + r.width() + _extents.right() - width());
|
||||
if (w.x() + width() - _margins.right() > r.x() + r.width()) {
|
||||
w.setX(r.x() + r.width() + _margins.right() - width());
|
||||
}
|
||||
if (w.x() + _extents.left() < r.x()) {
|
||||
w.setX(r.x() - _extents.left());
|
||||
if (w.x() + _margins.left() < r.x()) {
|
||||
w.setX(r.x() - _margins.left());
|
||||
}
|
||||
if (w.y() + height() - _extents.bottom() > r.y() + r.height()) {
|
||||
w.setY(r.y() + r.height() + _extents.bottom() - height());
|
||||
if (w.y() + height() - _margins.bottom() > r.y() + r.height()) {
|
||||
w.setY(r.y() + r.height() + _margins.bottom() - height());
|
||||
}
|
||||
if (w.y() + _extents.top() < r.y()) {
|
||||
w.setY(r.y() - _extents.top());
|
||||
if (w.y() + _margins.top() < r.y()) {
|
||||
w.setY(r.y() - _margins.top());
|
||||
}
|
||||
}
|
||||
move(w);
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ public:
|
|||
void setForceWidth(int forceWidth);
|
||||
void setForcedOrigin(PanelAnimation::Origin origin);
|
||||
void setForcedVerticalOrigin(VerticalOrigin origin);
|
||||
void setAdditionalMenuPadding(QMargins padding, QMargins extents);
|
||||
void setAdditionalMenuPadding(QMargins padding, QMargins margins);
|
||||
|
||||
[[nodiscard]] PanelAnimation::Origin preparedOrigin() const;
|
||||
[[nodiscard]] QMargins preparedPadding() const;
|
||||
[[nodiscard]] QMargins preparedExtents() const;
|
||||
[[nodiscard]] QMargins preparedMargins() const;
|
||||
[[nodiscard]] bool useTransparency() const;
|
||||
|
||||
[[nodiscard]] int scrollTop() const;
|
||||
|
|
@ -197,9 +197,9 @@ private:
|
|||
|
||||
QRect _inner;
|
||||
QMargins _padding;
|
||||
QMargins _extents;
|
||||
QMargins _margins;
|
||||
QMargins _additionalMenuPadding;
|
||||
QMargins _additionalMenuExtents;
|
||||
QMargins _additionalMenuMargins;
|
||||
|
||||
QPointer<PopupMenu> _activeSubmenu;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue