2016-02-29 05:59:46 +08:00
|
|
|
From 8651fafdc958cfd040fc69a084fc7090e5987682 Mon Sep 17 00:00:00 2001
|
2016-01-22 16:08:08 +08:00
|
|
|
From: Alexander Volkov <a.volkov@rusbitech.ru>
|
|
|
|
Date: Mon, 8 Jun 2015 14:35:22 +0300
|
|
|
|
Subject: [PATCH] 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
|
|
|
|
---
|
2016-02-29 05:59:46 +08:00
|
|
|
.../xcbfunctions/qxcbwindowfunctions.h | 8 ++++++++
|
2016-01-22 16:08:08 +08:00
|
|
|
src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 3 +++
|
|
|
|
src/plugins/platforms/xcb/qxcbwindow.cpp | 21 +++++++++++++++++++++
|
|
|
|
src/plugins/platforms/xcb/qxcbwindow.h | 2 ++
|
2016-02-29 05:59:46 +08:00
|
|
|
src/widgets/kernel/qwidget.cpp | 11 ++++++-----
|
|
|
|
5 files changed, 40 insertions(+), 5 deletions(-)
|
2016-01-22 16:08:08 +08:00
|
|
|
|
|
|
|
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
|
2016-02-29 05:59:46 +08:00
|
|
|
index 0db2e2a..97e0e1c 100644
|
2016-01-22 16:08:08 +08:00
|
|
|
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
|
|
|
|
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -69,6 +69,14 @@ public:
|
|
|
|
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
|
2016-01-22 16:08:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
+ typedef void (*SetWmWindowRole)(QWindow *window, const QByteArray &role);
|
|
|
|
+ static const QByteArray setWmWindowRoleIdentifier() { return QByteArrayLiteral("XcbSetWmWindowRole"); }
|
|
|
|
+
|
|
|
|
+ static void setWmWindowRole(QWindow *window, const QByteArray &role)
|
|
|
|
+ {
|
2016-02-29 05:59:46 +08:00
|
|
|
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowRole, QWindow *, const QByteArray &>(setWmWindowRoleIdentifier(), window, role);
|
2016-01-22 16:08:08 +08:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 05:59:46 +08:00
|
|
|
typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
|
|
|
|
static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
|
|
|
|
static void setWmWindowIconText(QWindow *window, const QString &text)
|
2016-01-22 16:08:08 +08:00
|
|
|
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
index dfb0a12..3685d5c 100644
|
2016-01-22 16:08:08 +08:00
|
|
|
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
|
|
|
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -349,6 +349,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));
|
|
|
|
|
2016-01-22 16:08:08 +08:00
|
|
|
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
index d751c6d..557f143 100644
|
2016-01-22 16:08:08 +08:00
|
|
|
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
|
|
|
|
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -262,6 +262,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
|
2016-01-22 16:08:08 +08:00
|
|
|
#endif // XCB_USE_XLIB
|
|
|
|
|
|
|
|
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)
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -594,6 +595,11 @@ void QXcbWindow::create()
|
2016-01-22 16:08:08 +08:00
|
|
|
setOpacity(opacity);
|
|
|
|
if (window()->isTopLevel())
|
|
|
|
setWindowIcon(window()->icon());
|
|
|
|
+
|
2016-02-29 05:59:46 +08:00
|
|
|
+ if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) {
|
|
|
|
+ QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray();
|
2016-01-22 16:08:08 +08:00
|
|
|
+ setWmWindowRole(wmWindowRole);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
QXcbWindow::~QXcbWindow()
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -1640,6 +1646,14 @@ void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text)
|
|
|
|
static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text);
|
2016-01-22 16:08:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
+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())
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -1805,6 +1819,13 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
|
2016-01-22 16:08:08 +08:00
|
|
|
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()));
|
|
|
|
+}
|
|
|
|
+
|
2016-02-29 05:59:46 +08:00
|
|
|
void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window)
|
2016-01-22 16:08:08 +08:00
|
|
|
{
|
2016-02-29 05:59:46 +08:00
|
|
|
if (window->handle())
|
2016-01-22 16:08:08 +08:00
|
|
|
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
|
2016-02-29 05:59:46 +08:00
|
|
|
index 8968664..ebbe5e2 100644
|
2016-01-22 16:08:08 +08:00
|
|
|
--- a/src/plugins/platforms/xcb/qxcbwindow.h
|
|
|
|
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -141,10 +141,12 @@ public:
|
2016-01-22 16:08:08 +08:00
|
|
|
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);
|
|
|
|
|
2016-02-29 05:59:46 +08:00
|
|
|
static void setWindowIconTextStatic(QWindow *window, const QString &text);
|
2016-01-22 16:08:08 +08:00
|
|
|
|
|
|
|
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
index 2c9cc5c..29f2b1c 100644
|
2016-01-22 16:08:08 +08:00
|
|
|
--- a/src/widgets/kernel/qwidget.cpp
|
|
|
|
+++ b/src/widgets/kernel/qwidget.cpp
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -1459,6 +1459,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
|
2016-01-22 16:08:08 +08:00
|
|
|
|
|
|
|
data.window_flags = win->flags();
|
|
|
|
|
|
|
|
+ if (!topData()->role.isNull())
|
|
|
|
+ QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1());
|
|
|
|
+
|
|
|
|
QBackingStore *store = q->backingStore();
|
|
|
|
|
|
|
|
if (!store) {
|
2016-02-29 05:59:46 +08:00
|
|
|
@@ -6284,13 +6287,11 @@ QString QWidget::windowRole() const
|
2016-01-22 16:08:08 +08:00
|
|
|
*/
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
--
|
2016-02-29 05:59:46 +08:00
|
|
|
2.6.2.2.g1b5ffa3
|