From 78fc0d4872bc4908d4615c3975d566fa2e1839eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 23 Apr 2013 16:03:36 +0200 Subject: [PATCH] Respond to the _NET_WM_CONTEXT_HELP WM_PROTOCOLS message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Gunnar Sletta Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 +++++ src/widgets/kernel/qapplication.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4090758d36..7d6d6a94b3 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -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]); } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index d036f6bada..b8d3117a41 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -72,6 +72,9 @@ #include #include #include +#ifndef QT_NO_WHATSTHIS +#include +#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) {