Fix #374127 misplacement of popups from dock wins

--the dialogs shown from dock type windows when
the dock uses masking are placed far from the
the element that triggered them. This patch
fixes this bug and provide also an auto test.
This commit is contained in:
Michail Vourlakos 2016-12-25 13:15:35 +02:00
parent 2e944d53a3
commit 6aedda94b2
3 changed files with 23 additions and 1 deletions

View File

@ -38,14 +38,24 @@ void DialogNativeTest::initTestCase()
m_panel2->setGeometry(100, 0, 50, 50);
m_panel2->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus);
m_panel3 = new QQuickView;
m_panel3->setGeometry(200, 0, 50, 50);
m_panel3->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus);
m_content = new QQuickItem;
m_content->setWidth(100);
m_content->setHeight(100);
m_dialog->setMainItem(m_content);
m_content2 = new QQuickItem(m_panel3->contentItem());
m_content2->setWidth(50);
m_content2->setHeight(25);
m_panel->show();
m_panel2->show();
m_panel3->show();
KWindowSystem::setType(m_panel->winId(), NET::Dock);
KWindowSystem::setType(m_panel3->winId(), NET::Dock);
m_dialog->setVisualParent(m_panel->contentItem());
m_dialog->show();
}
@ -55,6 +65,7 @@ void DialogNativeTest::cleanupTestCase()
delete m_dialog;
delete m_panel;
delete m_panel2;
delete m_panel3;
m_cacheDir.removeRecursively();
}
@ -68,6 +79,9 @@ void DialogNativeTest::size()
QCOMPARE(m_dialog->width(), 112);
QCOMPARE(m_dialog->height(), 112);
QCOMPARE(m_content2->width(), (qreal)50);
QCOMPARE(m_content2->height(), (qreal)25);
QCOMPARE(m_dialog->margins()->property("left").value<qreal>(), (qreal)6.0);
QCOMPARE(m_dialog->margins()->property("top").value<qreal>(), (qreal)6.0);
QCOMPARE(m_dialog->margins()->property("right").value<qreal>(), (qreal)6.0);
@ -85,6 +99,11 @@ void DialogNativeTest::position()
m_dialog->setVisualParent(m_panel2->contentItem());
QCOMPARE(m_dialog->x(), 69);
QCOMPARE(m_dialog->y(), 49);
m_panel3->setMask(QRect(0, 0, 50, 25));
m_dialog->setVisualParent(m_content2);
QCOMPARE(m_dialog->x(), 169);
QCOMPARE(m_dialog->y(), 24);
#endif
}

View File

@ -42,7 +42,9 @@ private Q_SLOTS:
private:
QQuickView *m_panel;
QQuickView *m_panel2;
QQuickView *m_panel3;
QQuickItem *m_content;
QQuickItem *m_content2;
PlasmaQuick::Dialog *m_dialog;
QDir m_cacheDir;
};

View File

@ -873,7 +873,8 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size)
//if the item is in a dock or in a window that ignores WM we want to position the popups outside of the dock
const KWindowInfo winInfo = KWindowSystem::windowInfo(item->window()->winId(), NET::WMWindowType);
const bool outsideParentWindow = (winInfo.windowType(NET::AllTypesMask) == NET::Dock) || (item->window()->flags() & Qt::X11BypassWindowManagerHint);
const bool outsideParentWindow = ((winInfo.windowType(NET::AllTypesMask) == NET::Dock) || (item->window()->flags() & Qt::X11BypassWindowManagerHint))
&& item->window()->mask().isNull();
QRect parentGeometryBounds;
if (outsideParentWindow) {