xcb: Add support for Qt::WA_ShowWithoutActivating
Also re-enable and update the tst_showWithoutActivating test. Change-Id: Ic7fa9b1bf7637e4661c593aaeabb3220cd4204ff Task-number: QTBUG-46098 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>bb10
parent
275f5347ef
commit
04e8d72a64
|
|
@ -775,6 +775,13 @@ void QXcbWindow::setVisible(bool visible)
|
|||
hide();
|
||||
}
|
||||
|
||||
static inline bool testShowWithoutActivating(const QWindow *window)
|
||||
{
|
||||
// QWidget-attribute Qt::WA_ShowWithoutActivating.
|
||||
const QVariant showWithoutActivating = window->property("_q_showWithoutActivating");
|
||||
return showWithoutActivating.isValid() && showWithoutActivating.toBool();
|
||||
}
|
||||
|
||||
void QXcbWindow::show()
|
||||
{
|
||||
if (window()->isTopLevel()) {
|
||||
|
|
@ -822,7 +829,9 @@ void QXcbWindow::show()
|
|||
updateNetWmStateBeforeMap();
|
||||
}
|
||||
|
||||
if (connection()->time() != XCB_TIME_CURRENT_TIME)
|
||||
if (testShowWithoutActivating(window()))
|
||||
updateNetWmUserTime(0);
|
||||
else if (connection()->time() != XCB_TIME_CURRENT_TIME)
|
||||
updateNetWmUserTime(connection()->time());
|
||||
|
||||
if (window()->objectName() == QLatin1String("QSystemTrayIconSysWindow"))
|
||||
|
|
@ -1329,7 +1338,11 @@ void QXcbWindow::updateNetWmStateBeforeMap()
|
|||
void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp)
|
||||
{
|
||||
xcb_window_t wid = m_window;
|
||||
connection()->setNetWmUserTime(timestamp);
|
||||
// If timestamp == 0, then it means that the window should not be
|
||||
// initially activated. Don't update global user time for this
|
||||
// special case.
|
||||
if (timestamp != 0)
|
||||
connection()->setNetWmUserTime(timestamp);
|
||||
|
||||
const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW));
|
||||
if (m_netWmUserTimeWindow || isSupportedByWM) {
|
||||
|
|
|
|||
|
|
@ -338,30 +338,30 @@ void tst_QWidget_window::tst_windowFilePath()
|
|||
|
||||
void tst_QWidget_window::tst_showWithoutActivating()
|
||||
{
|
||||
#ifndef Q_DEAD_CODE_FROM_QT4_X11
|
||||
QSKIP("This test is X11-only.");
|
||||
#else
|
||||
QWidget w;
|
||||
w.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&w));
|
||||
QApplication::processEvents();
|
||||
QString platformName = QGuiApplication::platformName().toLower();
|
||||
if (platformName == "cocoa")
|
||||
QSKIP("Cocoa: This fails. Figure out why.");
|
||||
else if (platformName != QStringLiteral("xcb")
|
||||
&& platformName != QStringLiteral("windows")
|
||||
&& platformName != QStringLiteral("ios"))
|
||||
QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios platforms.");
|
||||
|
||||
QApplication::clipboard();
|
||||
QLineEdit *lineEdit = new QLineEdit;
|
||||
lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, true);
|
||||
lineEdit->show();
|
||||
lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, false);
|
||||
lineEdit->raise();
|
||||
lineEdit->activateWindow();
|
||||
QWidget w1;
|
||||
w1.setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
w1.show();
|
||||
QVERIFY(!QTest::qWaitForWindowActive(&w1));
|
||||
|
||||
Window window;
|
||||
int revertto;
|
||||
QTRY_COMPARE(lineEdit->winId(),
|
||||
(XGetInputFocus(QX11Info::display(), &window, &revertto), window) );
|
||||
// Note the use of the , before window because we want the XGetInputFocus to be re-executed
|
||||
// in each iteration of the inside loop of the QTRY_COMPARE macro
|
||||
QWidget w2;
|
||||
w2.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&w2));
|
||||
|
||||
#endif // Q_DEAD_CODE_FROM_QT4_X11
|
||||
QWidget w3;
|
||||
w3.setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
w3.show();
|
||||
QVERIFY(!QTest::qWaitForWindowActive(&w3));
|
||||
|
||||
w3.activateWindow();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&w3));
|
||||
}
|
||||
|
||||
void tst_QWidget_window::tst_paintEventOnSecondShow()
|
||||
|
|
|
|||
Loading…
Reference in New Issue