Bug 1761435 [Wayland] Store only move-to-rect popup size r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D142048
This commit is contained in:
stransky 2022-03-28 10:13:40 +00:00
parent 7870caa83e
commit 9cac822f97
4 changed files with 20 additions and 31 deletions

View File

@ -1569,23 +1569,23 @@ nsresult nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame,
#ifdef MOZ_WAYLAND
if (IS_WAYLAND_DISPLAY()) {
if (nsIWidget* widget = GetWidget()) {
nsRect prefRect = LayoutDeviceIntRect::ToAppUnits(
widget->GetMoveToRectPopupRect(), presContext->AppUnitsPerDevPixel());
if (prefRect.width > 0 && mRect.width > prefRect.width) {
nsSize prefSize = LayoutDeviceIntRect::ToAppUnits(
widget->GetMoveToRectPopupSize(), presContext->AppUnitsPerDevPixel());
if (prefSize.width > 0 && mRect.width > prefSize.width) {
LOG_WAYLAND(
"nsMenuPopupFrame::SetPopupPosition [%p]: MoveToRect change "
"width from %d to %d",
widget, mRect.width / presContext->AppUnitsPerDevPixel(),
prefRect.width / presContext->AppUnitsPerDevPixel());
mRect.width = prefRect.width;
prefSize.width / presContext->AppUnitsPerDevPixel());
mRect.width = prefSize.width;
}
if (prefRect.height > 0 && mRect.height > prefRect.height) {
if (prefSize.height > 0 && mRect.height > prefSize.height) {
LOG_WAYLAND(
"nsMenuPopupFrame::SetPopupPosition [%p]: MoveToRect change "
"height from %d to %d",
widget, mRect.height / presContext->AppUnitsPerDevPixel(),
prefRect.height / presContext->AppUnitsPerDevPixel());
mRect.height = prefRect.height;
prefSize.height / presContext->AppUnitsPerDevPixel());
mRect.height = prefSize.height;
}
}
}

View File

@ -1030,19 +1030,8 @@ void nsWindow::Move(double aX, double aY) {
return;
}
if (IsWaylandPopup()) {
// TODO: Do we need this?
auto prefBounds = mMoveToRectPopupRect;
if (prefBounds.TopLeft() != mBounds.TopLeft()) {
NativeMoveResize(/* move */ true, /* resize */ false);
NotifyRollupGeometryChange();
} else {
LOG(" mBounds same as mMoveToRectPopupRect, no need to move");
}
} else {
NativeMoveResize(/* move */ true, /* resize */ false);
NotifyRollupGeometryChange();
}
NativeMoveResize(/* move */ true, /* resize */ false);
NotifyRollupGeometryChange();
}
bool nsWindow::IsPopup() const { return mWindowType == eWindowType_popup; }
@ -1928,13 +1917,13 @@ void nsWindow::NativeMoveResizeWaylandPopupCallback(
// Wayland compositor changed popup size request from layout.
// Set the constraints to use them in nsMenuPopupFrame::SetPopupPosition().
if (newBounds.width < mBounds.width) {
mMoveToRectPopupRect.width = newBounds.width;
mMoveToRectPopupSize.width = newBounds.width;
}
if (newBounds.height < mBounds.height) {
mMoveToRectPopupRect.height = newBounds.height;
mMoveToRectPopupSize.height = newBounds.height;
}
LOG(" mMoveToRectPopupRect set to [%d, %d]", mMoveToRectPopupRect.width,
mMoveToRectPopupRect.height);
LOG(" mMoveToRectPopupSize set to [%d, %d]", mMoveToRectPopupSize.width,
mMoveToRectPopupSize.height);
}
mBounds = newBounds;
WaylandPopupPropagateChangesToLayout(needsPositionUpdate, needsSizeUpdate);

View File

@ -406,8 +406,8 @@ class nsWindow final : public nsBaseWidget {
const LayoutDeviceIntPoint& aLockCenter) override;
void LockNativePointer() override;
void UnlockNativePointer() override;
LayoutDeviceIntRect GetMoveToRectPopupRect() const override {
return mMoveToRectPopupRect;
LayoutDeviceIntSize GetMoveToRectPopupSize() const override {
return mMoveToRectPopupSize;
};
#endif
@ -821,9 +821,9 @@ class nsWindow final : public nsBaseWidget {
RefPtr<nsWindow> mWaylandPopupPrev;
// When popup is resized by Gtk by move-to-rect callback,
// we store final popup size here. Then we use mMoveToRectPopupRect size
// we store final popup size here. Then we use mMoveToRectPopupSize size
// in following popup operations unless mLayoutPopupSizeCleared is set.
LayoutDeviceIntRect mMoveToRectPopupRect;
LayoutDeviceIntSize mMoveToRectPopupSize;
LayoutDeviceIntRect mNewBoundsAfterMoveToRect;

View File

@ -1710,9 +1710,9 @@ class nsIWidget : public nsISupports {
/**
* Wayland specific routines.
*/
virtual LayoutDeviceIntRect GetMoveToRectPopupRect() const {
virtual LayoutDeviceIntSize GetMoveToRectPopupSize() const {
NS_WARNING("GetLayoutPopupRect implemented only for wayland");
return LayoutDeviceIntRect();
return LayoutDeviceIntSize();
}
/**