[Konversation-devel] [Bug 110840] OSD displays over blanked screen if KDE session is locked

Shintaro Matsuoka shin at shoegazed.org
Thu Aug 18 18:25:06 CEST 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=110840         
shin shoegazed org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From shin shoegazed org  2005-08-18 18:25 -------
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;


More information about the Konversation-devel mailing list