diff --git a/decorations/decoratedclient.h b/decorations/decoratedclient.h --- a/decorations/decoratedclient.h +++ b/decorations/decoratedclient.h @@ -23,7 +23,9 @@ #include +#include #include +#include namespace KWin { @@ -109,6 +111,10 @@ QSize m_clientSize; Renderer *m_renderer; QMetaObject::Connection m_compositorToggledConnection; + + QString m_toolTipText; + QTimer m_toolTipWakeUp; + QDeadlineTimer m_toolTipFallAsleep; }; } diff --git a/decorations/decoratedclient.cpp b/decorations/decoratedclient.cpp --- a/decorations/decoratedclient.cpp +++ b/decorations/decoratedclient.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace KWin @@ -114,6 +115,16 @@ connect(client, &AbstractClient::hasApplicationMenuChanged, decoratedClient, &KDecoration2::DecoratedClient::hasApplicationMenuChanged); connect(client, &AbstractClient::applicationMenuActiveChanged, decoratedClient, &KDecoration2::DecoratedClient::applicationMenuActiveChanged); + + m_toolTipWakeUp.setSingleShot(true); + connect(&m_toolTipWakeUp, &QTimer::timeout, this, + [this]() { + int fallAsleepDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_FallAsleepDelay); + this->m_toolTipFallAsleep.setRemainingTime(fallAsleepDelay); + + QToolTip::showText(Cursor::pos(), this->m_toolTipText); + } + ); } DecoratedClientImpl::~DecoratedClientImpl() = default; @@ -203,12 +214,15 @@ void DecoratedClientImpl::requestShowToolTip(const QString &text) { - QPoint pos = Cursor::pos(); - QToolTip::showText(pos, text); + m_toolTipText = text; + + int wakeUpDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay); + m_toolTipWakeUp.start(m_toolTipFallAsleep.hasExpired() ? wakeUpDelay : 20); } void DecoratedClientImpl::requestHideToolTip() { + m_toolTipWakeUp.stop(); QToolTip::hideText(); }