Wrong (?) usage of deprecated and usage of setActiveWindow vs. activateWindow (was: Re: kdelibs/kdecore)

Lubos Lunak l.lunak at suse.cz
Thu Oct 30 09:23:04 GMT 2003


On Wednesday 29 of October 2003 21:04, Cornelius Schumacher wrote:
> On Wednesday 29 October 2003 17:29, Lubos Lunak wrote:
> > On Wednesday 29 of October 2003 15:57, Cornelius Schumacher wrote:
> > > In KOrganizer we use setActiveWindow() when starting KOrganizer
> > > from the command line with a file name as argument. If a KOrganizer
> > > main window viewing the given file is already present, we activate
> > > it. In this case we don't have an active KOrganizer window yet.
> >
> >  This description looks a bit confusing to me.
>
> Let's make an example to make this clearer:
>
> KOrganizer is opened with two main windows, one showing calendar file
> one.ics the other the file two.ics. Now I type "korganizer two.ics"
> into konsole. At this time the konsole window is the active one. As
> result of the command the mainwindow showing file two.ics should be
> brought to front and being activated. No new window should be created.
> Don't I need setActiveWindow() for this?
>
> > > How can activateWindow work
> > > here? We do need setActiveWindow() instead, don't we?
> >
> >  If the result of starting an application is creating a new window,
> > doing nothing should be enough, KApplication or KUniqueApplication
> > should take care of handling all the needed activation and startup
> > notification stuff. If the result of starting an application is
> > reusing an existing window, you should use
> > KStartupInfo::setNewStartupId(), and pass the startup identification
> > to it (KApplication::startupId() will give you that). If it's
> > unrelated to starting applications, activateWindow() should be
> > usually right.
>
> I read the docs of KStartupInfo, but I didn't understand how it would
> apply to this problem. We don't want to startup anything, just activate
> an existing window.

 Of course you do, you have another korganizer launched. This new korganizer 
is launched, finds out there's already instance running, and tells it 'do 
this and that'. The already running instance does that, i.e. opens the new 
ics file, and probably also used to do setActiveWindow() somewhere.

 The new shiny good way of doing that is that you also pass kapp->initId() 
together with the DCOP call, and use KStartupInfo::setNewStartupId( window, 
init_id ) with the window you want to activate. KUniqueApplication already 
does the kapp->initId() passing, so you just need to ask for activating the 
window (see KUniqueApplication::newInstance()).

 As already said, if it's unrelated to any application launching, use 
activateWindow(). In the (hopefully rare) case that won't be enough, you'll 
have to read kdebase/kwin/README or ask me.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/





More information about the kde-core-devel mailing list