Summary: | OSD displays over blanked screen if KDE session is locked | ||
---|---|---|---|
Product: | [Applications] konversation | Reporter: | Greg Meyer <greg> |
Component: | general | Assignee: | Konversation Developers <konversation-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | Git | ||
Target Milestone: | --- | ||
Platform: | Unlisted Binaries | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Greg Meyer
2005-08-15 20:56:58 UTC
SVN commit 450606 by shin: Don't show messages on the OSD widget when the desktop is locked BUG: 110840 I took the code to know if KDesktopLock is running from KPilot. Thank you, the kpilot team :) M +53 -1 osd.cpp M +3 -0 osd.h --- trunk/extragear/network/konversation/src/osd.cpp #450605:450606 @@ -19,6 +19,8 @@ #include <qpainter.h> #include <qregexp.h> +#include <dcopclient.h> +#include <kapplication.h> #include <kdebug.h> #include <kglobalsettings.h> //unsetColors() @@ -121,7 +123,7 @@ } -void OSDWidget::showOSD( const QString &text, bool preemptive ) +void OSDWidget::showOSD( const QString &text, bool preemptive ) // slot { if ( isEnabled() && !text.isEmpty() ) { @@ -236,6 +238,13 @@ void OSDWidget::show() { + // Don't show the OSD widget when the desktop is locked + if ( isKDesktopLockRunning() ) + { + minReached(); // don't queue the message + return; + } + if ( m_dirty ) renderOSDText( m_currentText ); QWidget::show(); @@ -388,4 +397,47 @@ } } + + +// the code was taken from pilotDaemon.cc in KPilot +OSDWidget::KDesktopLockStatus OSDWidget::isKDesktopLockRunning() // static +{ + DCOPClient *dcopptr = KApplication::kApplication()->dcopClient(); + + // Can't tell, very weird, err on the side of safety. + if (!dcopptr || !dcopptr->isAttached()) + { + kdWarning() << k_funcinfo << ": Could not make DCOP connection. " + << "Assuming screensaver is active." << endl; + return DCOPError; + } + + QByteArray data,returnValue; + QCString returnType; + + if (!dcopptr->call("kdesktop","KScreensaverIface","isBlanked()", + data,returnType,returnValue,true)) + { + kdWarning() << k_funcinfo << ": Check for screensaver failed." + << "Assuming screensaver is active." << endl; + // Err on the side of safety again. + return DCOPError; + } + + if (returnType == "bool") + { + bool b; + QDataStream reply(returnValue,IO_ReadOnly); + reply >> b; + return (b ? Locked : NotLocked); + } + else + { + kdWarning() << k_funcinfo << ": Strange return value from screensaver. " + << "Assuming screensaver is active." << endl; + // Err on the side of safety. + return DCOPError; + } +} + #include "osd.moc" --- trunk/extragear/network/konversation/src/osd.h #450605:450606 @@ -70,6 +70,9 @@ /* called after most set*() calls to update the OSD */ void refresh(); + enum KDesktopLockStatus { NotLocked=0, Locked=1, DCOPError=2 }; + static KDesktopLockStatus isKDesktopLockRunning(); + static const int MARGIN = 15; QString m_appName; |