How fire up and raise an application via dcop?

Alexander Kellett lypanov at kde.org
Wed Oct 16 09:52:56 BST 2002


On Tue, Oct 15, 2002 at 07:46:43PM +0200, Karl-Heinz Zimmer wrote:
> On Tuesday 15 October 2002 19:44, Karl-Heinz Zimmer wrote:
> > the following is what I tried to start an app (kdaddressbook) via dcop
> > _and_ 'raise' it to make it the top most widget on screen:
> >
> I am such a fooooool!   :-D

:)

Actually I was trying to get this working for keditbookmarks a while back
but I also wanted to change the desktop when doing so. Anyone know another
simple way of doing that? - I ended up using the following code. Maybe it 
could be in kdelibs for 3.2 if there is no alternative?

Alex

---

void continueInWindow(QString _wname) {
   DCOPClient* dcop = kapp->dcopClient();
   QCString wname = _wname.latin1();
   int id = -1;

   QCStringList apps = dcop->registeredApplications();
   for ( QCStringList::Iterator it = apps.begin(); it != apps.end(); ++it )
   {
      QCString &clientId = *it;

      if ( qstrncmp(clientId, wname, wname.length()) != 0 )
         continue;

      QByteArray data, replyData;
      QCString replyType;
      QDataStream arg(data, IO_WriteOnly);

      if ( kapp->dcopClient()->call( clientId.data(), (wname+"-mainwindow#1"), 
                                     "getWinID()", data, replyType, replyData) ) {
         QDataStream reply(replyData, IO_ReadOnly);
         if ( replyType == "int" ) {
            int ret;
            reply >> ret;
            id = ret;
            break;
         }
      }
   }

   KWin::setActiveWindow(id);
}




More information about the kde-core-devel mailing list