Respond to the _NET_WM_CONTEXT_HELP WM_PROTOCOLS message

This change restores a proper function of the "(?)" button in the window
decorations which is used as a clue for the user to check what a particular
widget is supposed to do. The change is only implemented for QtWidgets because
the underlying QWhatsThis is inherently widget-specific -- which is why it sends
an event to QGuiApplication, but only processes it in the QtWidget-specific
QApplication.

Thanks to Alberto Mardegan and Gunnar Sletta for their feedback on this patch.

Change-Id: Ibb912e3960f1e9aec54c5ed77ade1c6744d6ca23
Reviewed-by: Alberto Mardegan <mardy@users.sourceforge.net>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Jan Kundrát 2013-04-23 16:03:36 +02:00 committed by The Qt Project
parent 4afb128d31
commit 78fc0d4872
2 changed files with 13 additions and 0 deletions

View File

@ -1492,6 +1492,11 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
connection()->setTime(event->data.data32[1]);
m_syncValue.lo = event->data.data32[2];
m_syncValue.hi = event->data.data32[3];
#ifndef QT_NO_WHATSTHIS
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_CONTEXT_HELP)) {
QEvent *e = new QEvent(QEvent::EnterWhatsThisMode);
QGuiApplication::postEvent(QGuiApplication::instance(), e);
#endif
} else {
qWarning() << "QXcbWindow: Unhandled WM_PROTOCOLS message:" << connection()->atomName(event->data.data32[0]);
}

View File

@ -72,6 +72,9 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qinputmethod.h>
#include <qpa/qplatformtheme.h>
#ifndef QT_NO_WHATSTHIS
#include <QtWidgets/QWhatsThis>
#endif
#include "private/qkeymapper_p.h"
@ -1856,6 +1859,11 @@ bool QApplication::event(QEvent *e)
} else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
d->toolTipFallAsleep.stop();
}
#ifndef QT_NO_WHATSTHIS
} else if (e->type() == QEvent::EnterWhatsThisMode) {
QWhatsThis::enterWhatsThisMode();
return true;
#endif
}
if(e->type() == QEvent::LanguageChange) {