Re: avoiding knotify during KDE startup
Lubos Lunak <[email protected]>
| Newsgroups | gmane.comp.kde.devel.optimize |
|---|---|
| Message-ID | <[email protected]> |
On Wednesday 15 of September 2004 16:26, Lubos Lunak wrote: > On Wednesday 15 of September 2004 15:56, Waldo Bastian wrote: > > On Wednesday 15 September 2004 15:44, Lubos Lunak wrote: > > > The KNotifyDialog change checks if the ksmserver event is disabled, > > > and if yes, turns off starting knotify in startkde. Hmmmm, although > > > thinking of this right now, perhaps knotify startup could be simply > > > always avoided in startkde? KNotifyClient starts the daemon anyway if > > > necessary, and I doubt anybody would notice the delay caused by this > > > with the startkde sound. > > > > Sounds like a cleaner solution indeed. Is there anything that talks to > > KNotify directly without using KNotifyClient? > > I don't think so, and I'd consider that broken. KNotifyClient needs to > start the daemon anyway if the app is running outside of KDE, and after > all, the DCOP call is: > void notify(QString,QString,QString,QString,QString,int,int,int,int) Ok, to actually update the patches for this - this reduces the size a bit: -- Lubos Lunak KDE developer --------------------------------------------------------------------- SuSE CR, s.r.o. e-mail: [email protected] , [email protected] Drahobejlova 27 tel: +420 2 9654 2373 190 00 Praha 9 fax: +420 2 9654 2374 Czech Republic http://www.suse.cz/ _______________________________________________ Kde-optimize mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-optimize
knotifyclient.cpp.patch
(text/x-diff, 2.5 KB)
--- knotifyclient.cpp.sav 2004-01-07 10:46:51.000000000 +0100
+++ knotifyclient.cpp 2004-09-14 22:14:20.730364480 +0200
@@ -33,6 +33,40 @@
static const char daemonName[] = "knotify";
+static bool canAvoidStartupEvent( const QString& event, const QString& appname, int present )
+{
+ static int checkAvoid = -1;
+ if(( appname != "kwin" && appname != "ksmserver" ) || present > 0 ) {
+ checkAvoid = 0;
+ return false;
+ }
+ if( checkAvoid == -1 ) {
+ KConfig cfg( "knotifyrc", true );
+ cfg.setGroup( "Startup" );
+ checkAvoid = cfg.readBoolEntry( "DelayedStartup", false ) ? 1 : 0;
+ }
+ if( checkAvoid != 1 )
+ return false;
+ // startkde event is in global events file
+ static KConfig* configfile = appname != "ksmserver"
+ ? new KConfig( appname + ".eventsrc", true, false )
+ : new KConfig( "knotify.eventsrc", true, false );
+ static KConfig* eventsfile = appname != "ksmserver"
+ ? new KConfig( appname + "/eventsrc", true, false, "data" )
+ : new KConfig( "knotify/eventsrc", true, false, "data" );
+ configfile->setGroup( event );
+ eventsfile->setGroup( event );
+ int ev1 = configfile->readNumEntry( "presentation", -2 );
+ int ev2 = eventsfile->readNumEntry( "default_presentation", -2 );
+ if(( ev1 == -2 && ev2 == -2 ) // unknown
+ || ev1 > 0 // configured to have presentation
+ || ( ev1 == -2 && ev2 > 0 )) { // not configured, has default presentation
+ checkAvoid = 0;
+ return false;
+ }
+ return true;
+}
+
static int sendNotifyEvent(const QString &message, const QString &text,
int present, int level, const QString &sound,
const QString &file, int winId )
@@ -47,8 +81,13 @@ static int sendNotifyEvent(const QString
return 0;
}
+ QString appname = KNotifyClient::instance()->instanceName();
+
int uniqueId = kMax( 1, kapp->random() ); // must not be 0 -- means failure!
+ if( canAvoidStartupEvent( message, appname, present ))
+ return uniqueId; // done "successfully" - there will be no event presentation
+
// knotify daemon needs toplevel window
QWidget* widget = QWidget::find( winId );
if( widget )
@@ -56,7 +95,6 @@ static int sendNotifyEvent(const QString
QByteArray data;
QDataStream ds(data, IO_WriteOnly);
- QString appname = KNotifyClient::instance()->instanceName();
ds << message << appname << text << sound << file << present << level
<< winId << uniqueId;
knotify.cpp.patch
(text/x-diff, 1.6 KB)
--- knotify.cpp.sav 2004-09-15 17:01:55.717327320 +0200
+++ knotify.cpp 2004-09-15 17:10:05.370888664 +0200
@@ -82,6 +82,8 @@ public:
int volume;
QTimer *playTimer;
KAudioManagerPlay *audioManager;
+ bool inStartup;
+ QString startupEvents;
};
// Yes, it's ugly to put this here, but this facilitates the cautious startup
@@ -221,6 +223,7 @@ KNotify::KNotify( bool useArts )
d->useArts = useArts;
d->playObjects.setAutoDelete(true);
d->audioManager = 0;
+ d->inStartup = true;
if( useArts )
{
connect( soundServer, SIGNAL( restartedServer() ), this, SLOT( restartedArtsd() ) );
@@ -303,7 +306,10 @@ void KNotify::notify(const QString &even
int present, int level, int winId, int eventId )
{
// kdDebug() << "event=" << event << " fromApp=" << fromApp << " text=" << text << " sound=" << sound <<
- // " file=" << file << " present=" << present << " level=" << level << " winId=" << winId << " eventId=" << eventId endl;
+ // " file=" << file << " present=" << present << " level=" << level << " winId=" << winId << " eventId=" << eventId << endl;
+ if( d->inStartup ) {
+ d->startupEvents += "(" + event + ":" + fromApp + ")";
+ }
QString commandline;
@@ -746,4 +752,11 @@ void KNotify::restartedArtsd()
d->audioManager->setAutoRestoreID( "KNotify Aman Play" );
}
+void KNotify::sessionReady()
+{
+ if( d->inStartup && !d->startupEvents.isEmpty())
+ kdDebug() << "There were knotify events while startup:" << d->startupEvents << endl;
+ d->inStartup = false;
+}
+
// vim: sw=4 sts=4 ts=8 et
knotify.h.patch
(text/x-diff, 327 B)
--- knotify.h.sav 2003-09-24 13:09:14.000000000 +0200 +++ knotify.h 2004-09-14 17:07:44.068082248 +0200 @@ -67,6 +67,7 @@ k_dcop: void reconfigure(); void setVolume( int volume ); + void sessionReady(); // from ksmserver private: bool notifyBySound(const QString &sound, const QString &appname, int eventId);
server.cpp.patch
(text/x-diff, 454 B)
--- server.cpp.sav 2004-09-14 12:17:14.000000000 +0200
+++ server.cpp 2004-09-14 17:06:17.698212464 +0200
@@ -1535,7 +1535,8 @@ void KSMServer::restoreSessionDoneIntern
restoreLegacySession( KGlobal::config());
#endif
upAndRunning( "session ready" );
-
+ DCOPRef( "knotify" ).send( "sessionReady" ); // knotify startup optimization
+
// From now on handle X errors as normal shutdown.
XSetIOErrorHandler(Xio_ErrorHandler);
}
startkde.patch
(text/x-diff, 461 B)
--- startkde.sav 2004-08-03 17:03:33.000000000 +0200 +++ startkde 2004-09-15 17:06:07.319078040 +0200 @@ -200,7 +200,7 @@ ksplash --nodcop # We set LD_BIND_NOW to increase the efficiency of kdeinit. # kdeinit unsets this variable before loading applications. -LD_BIND_NOW=true kdeinit +kcminit +knotify +LD_BIND_NOW=true kdeinit +kcminit if test $? -ne 0; then # Startup error echo 'startkde: Could not start kdeinit. Check your installation.' 1>&2