Re: session management support



Carsten> here are some ideas about the initialization problem.

I finally found the time to read this in depth.

I think your basic plan will work.  I agree it is ugly, but that
doesn't bother me too much.  We should hide this code in a library, so
that new Gnome programs don't have to do anything complicated to make
it work.

Carsten> first case: program is started with '-init' command line
Carsten> option

Carsten> The program has to register to the session manager with the
Carsten> client id, it got on the command line.  Then it sets up the
Carsten> stuff, that it is supposed to set up (for example some mouse
Carsten> settings).  At the end adds a window property one the root
Carsten> window like: GNOME_MOUSE_PROPERTY(STRING)=<client-id>.  Than
Carsten> it exits.  If there is a GNOME_MOUSE_PROPERTY property set
Carsten> before, the program should quit without setting anything.

There's a race condition here if multiple `-init' instance of the same
program are run simultaneously.

However, I believe we can work around it using a hack like this:
instead of setting the property to our client-id, we append our
client-id (followed by a newline) to the property.

Then we re-fetch the property.  If our client-id is the first one on
the property list, we proceed -- this means we acquired the "lock".
Otherwise, we just exit.


We have to apply this trick in all the cases, I think.



Carsten> last case: program is started without '-init' and '-exit' option

Carsten> If there is no GNOME_MOUSE_PROPERTY set, it's a little bit
Carsten> tricky.  If the program got a client id one the command line,
Carsten> we can assume, that this client was restarted and that it has
Carsten> registed an "init" program, so we wait for the
Carsten> GNOME_MOUSE_PROPERTY to be set on the root window (this
Carsten> happens, if the program is started in a restarted session,
Carsten> before the 'program -init' has been started).  If we got no
Carsten> client id on the command line, we register a second time, but
Carsten> with an additional '-init' parameter and a RestartAnyway as
Carsten> restart hint.  Now we set the GNOME_MOUSE_PROPERTY to the id,
Carsten> we received for the '-init' program and close the second
Carsten> connection.

Maybe a way around the wait is to merge the `-init' case in with the
default case here.  Does this make sense?  The idea is:

If started without -init/-exit, then register with session manager.
Just before the program exits, register a new client with the session
manager; this client will be set up to run with `-init' in place.
However, if the session is saved before we exit, don't do this --
instead just handle the initialization ourselves locally next time we
start up.  Thus, no wait.


What do you think?

Tom



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]