Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37725784
en ru br
ALT Linux repos
S:4.8.7-alt25
5.0: 4.5.2-alt1.M50.1
4.1: 4.4.3-alt1.M41.1
4.0: 4.3.4-alt5.M40.1
3.0: 4.0.1-alt1
+updates:4.0.1-alt2
+backports:4.2.3-alt7.1.M30

Group :: System/Libraries
RPM: qt4

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: 0180-window-role.diff
Download


Index: src/corelib/kernel/qobject.cpp
===================================================================
--- src/corelib/kernel/qobject.cpp.orig
+++ src/corelib/kernel/qobject.cpp
@@ -1074,10 +1074,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
Index: src/corelib/kernel/qobject_p.h
===================================================================
--- src/corelib/kernel/qobject_p.h.orig
+++ src/corelib/kernel/qobject_p.h
@@ -160,6 +160,9 @@ public:
 #ifdef QT3_SUPPORT
     void sendPendingChildInsertedEvents();
 #endif
+#if defined(Q_WS_X11)
+    virtual void checkWindowRole();
+#endif
 
     static inline Sender *setCurrentSender(QObject *receiver,
                                     Sender *sender);
Index: src/gui/kernel/qwidget_p.h
===================================================================
--- src/gui/kernel/qwidget_p.h.orig
+++ src/gui/kernel/qwidget_p.h
@@ -781,6 +781,7 @@ public:
     static QWidget *keyboardGrabber;
 
     void setWindowRole();
+    virtual void checkWindowRole();
     void sendStartupMessage(const char *message) const;
     void setNetWmWindowTypes();
     void x11UpdateIsOpaque();
Index: src/gui/kernel/qwidget_x11.cpp
===================================================================
--- src/gui/kernel/qwidget_x11.cpp.orig
+++ src/gui/kernel/qwidget_x11.cpp
@@ -843,13 +843,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
@@ -3027,6 +3031,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)
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin