File 0180-window-role.diff of Package libqt4
--- src/corelib/kernel/qobject.cpp
+++ src/corelib/kernel/qobject.cpp
@@ -1099,10 +1099,19 @@ void QObject::setObjectName(const QStrin
d->objectName = name;
+#if defined(Q_WS_X11)
+ d->checkWindowRole();
+#endif
+
if (objectNameChanged)
d->declarativeData->objectNameChanged(d->declarativeData, this);
}
+#if defined(Q_WS_X11)
+void QObjectPrivate::checkWindowRole()
+{
+}
+#endif
#ifdef QT3_SUPPORT
/*! \internal
--- src/corelib/kernel/qobject_p.h
+++ src/corelib/kernel/qobject_p.h
@@ -156,6 +156,9 @@ public:
void sendPendingChildInsertedEvents();
void removePendingChildInsertedEvents(QObject *child);
#endif
+#if defined(Q_WS_X11)
+ virtual void checkWindowRole();
+#endif
static inline Sender *setCurrentSender(QObject *receiver,
Sender *sender);
--- src/gui/kernel/qwidget_p.h
+++ src/gui/kernel/qwidget_p.h
@@ -762,6 +762,7 @@ public:
static QWidget *keyboardGrabber;
void setWindowRole();
+ virtual void checkWindowRole();
void sendStartupMessage(const char *message) const;
void setNetWmWindowTypes();
void x11UpdateIsOpaque();
--- src/gui/kernel/qwidget_x11.cpp
+++ src/gui/kernel/qwidget_x11.cpp
@@ -837,13 +837,17 @@ void QWidgetPrivate::create_sys(WId wind
// declare the widget's window role
+ QByteArray windowRole;
if (QTLWExtra *topData = maybeTopData()) {
- if (!topData->role.isEmpty()) {
- QByteArray windowRole = topData->role.toUtf8();
- XChangeProperty(dpy, id,
- ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
- (unsigned char *)windowRole.constData(), windowRole.length());
- }
+ if (!topData->role.isEmpty())
+ windowRole = topData->role.toUtf8();
+ }
+ if (windowRole.isEmpty()) // use object name as a fallback
+ windowRole = objectName.toUtf8();
+ if (!windowRole.isEmpty()) {
+ XChangeProperty(dpy, id,
+ ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
+ (unsigned char *)windowRole.constData(), windowRole.length());
}
// set client leader property
@@ -2957,6 +2961,17 @@ void QWidgetPrivate::setWindowRole()
XChangeProperty(X11->display, q->internalWinId(),
ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
(unsigned char *)windowRole.constData(), windowRole.length());
+}
+
+void QWidgetPrivate::checkWindowRole()
+{
+ Q_Q(QWidget);
+ if( !q->windowRole().isEmpty() || !q->internalWinId())
+ return;
+ QByteArray windowRole = objectName.toUtf8(); // use as a fallback
+ XChangeProperty(X11->display, q->internalWinId(),
+ ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
+ (unsigned char *)windowRole.constData(), windowRole.length());
}
Q_GLOBAL_STATIC(QX11PaintEngine, qt_widget_paintengine)