Fix QWidget::setWindowRole()
Introduce QXcbWindowFunctions::setWmWindowRole() and call it either from the implementation of QWidget::setWindowRole() or after the creation of the corresponding QWidgetWindow. Change-Id: I143450f4673dd707bb491c1d0f0e8b61d564283d Task-number: QTBUG-45484 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Ivan Čukić <ivan.cukic@kde.org>bb10
parent
ccccdbaf74
commit
d13d81eb01
|
|
@ -69,6 +69,14 @@ public:
|
|||
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
|
||||
}
|
||||
|
||||
typedef void (*SetWmWindowRole)(QWindow *window, const QByteArray &role);
|
||||
static const QByteArray setWmWindowRoleIdentifier() { return QByteArrayLiteral("XcbSetWmWindowRole"); }
|
||||
|
||||
static void setWmWindowRole(QWindow *window, const QByteArray &role)
|
||||
{
|
||||
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowRole, QWindow *, const QByteArray &>(setWmWindowRoleIdentifier(), window, role);
|
||||
}
|
||||
|
||||
typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
|
||||
static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
|
||||
static void setWmWindowIconText(QWindow *window, const QString &text)
|
||||
|
|
|
|||
|
|
@ -350,6 +350,9 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio
|
|||
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier())
|
||||
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic));
|
||||
|
||||
if (function == QXcbWindowFunctions::setWmWindowRoleIdentifier())
|
||||
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowRole(QXcbWindow::setWmWindowRoleStatic));
|
||||
|
||||
if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier())
|
||||
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic));
|
||||
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ static QWindow *childWindowAt(QWindow *win, const QPoint &p)
|
|||
}
|
||||
|
||||
static const char *wm_window_type_property_id = "_q_xcb_wm_window_type";
|
||||
static const char *wm_window_role_property_id = "_q_xcb_wm_window_role";
|
||||
|
||||
QXcbWindow::QXcbWindow(QWindow *window)
|
||||
: QPlatformWindow(window)
|
||||
|
|
@ -610,6 +611,11 @@ void QXcbWindow::create()
|
|||
setOpacity(opacity);
|
||||
if (window()->isTopLevel())
|
||||
setWindowIcon(window()->icon());
|
||||
|
||||
if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) {
|
||||
QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray();
|
||||
setWmWindowRole(wmWindowRole);
|
||||
}
|
||||
}
|
||||
|
||||
QXcbWindow::~QXcbWindow()
|
||||
|
|
@ -1733,6 +1739,14 @@ void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text)
|
|||
static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text);
|
||||
}
|
||||
|
||||
void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role)
|
||||
{
|
||||
if (window->handle())
|
||||
static_cast<QXcbWindow *>(window->handle())->setWmWindowRole(role);
|
||||
else
|
||||
window->setProperty(wm_window_role_property_id, role);
|
||||
}
|
||||
|
||||
uint QXcbWindow::visualIdStatic(QWindow *window)
|
||||
{
|
||||
if (window && window->handle())
|
||||
|
|
@ -1898,6 +1912,13 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
|
|||
xcb_flush(xcb_connection());
|
||||
}
|
||||
|
||||
void QXcbWindow::setWmWindowRole(const QByteArray &role)
|
||||
{
|
||||
Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
|
||||
atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8,
|
||||
role.size(), role.constData()));
|
||||
}
|
||||
|
||||
void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window)
|
||||
{
|
||||
if (window->handle())
|
||||
|
|
|
|||
|
|
@ -145,10 +145,12 @@ public:
|
|||
void updateNetWmUserTime(xcb_timestamp_t timestamp);
|
||||
|
||||
static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
|
||||
static void setWmWindowRoleStatic(QWindow *window, const QByteArray &role);
|
||||
static uint visualIdStatic(QWindow *window);
|
||||
|
||||
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
|
||||
void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
|
||||
void setWmWindowRole(const QByteArray &role);
|
||||
|
||||
static void setWindowIconTextStatic(QWindow *window, const QString &text);
|
||||
|
||||
|
|
|
|||
|
|
@ -1473,6 +1473,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
|
|||
|
||||
data.window_flags = win->flags();
|
||||
|
||||
if (!topData()->role.isNull())
|
||||
QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1());
|
||||
|
||||
QBackingStore *store = q->backingStore();
|
||||
|
||||
if (!store) {
|
||||
|
|
@ -6329,13 +6332,11 @@ QString QWidget::windowRole() const
|
|||
*/
|
||||
void QWidget::setWindowRole(const QString &role)
|
||||
{
|
||||
#if defined(Q_DEAD_CODE_FROM_QT4_X11)
|
||||
Q_D(QWidget);
|
||||
d->createTLExtra();
|
||||
d->topData()->role = role;
|
||||
d->setWindowRole();
|
||||
#else
|
||||
Q_UNUSED(role)
|
||||
#endif
|
||||
if (windowHandle())
|
||||
QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue