This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

GnomeSession (DBus based branch)

Problems and Goals

Problems with the gnome-session <= 2.22:

The big goals for the rewrite are:

Now started in the dbus_based branch of gnome-session in subversion.

Relationship to D-Bus Session Bus

With the exception of legacy XSMP clients, the session manager will require that all clients connect to the D-Bus session bus and remain connected until they are finished. Client lifecyle is tracked via session bus names and NameOwnerChanged messages. This model of operation places the session bus at the root of the session and this is consistent with its original design goals. The session bus also has the ability to launch well known application services. So, why do we need a separate session manager? Some reasons include:

Basically, the session manager is layered on top of the D-Bus session bus and provides some additional features that may not be desireable to put directly into D-Bus.

Client Lifecycle

1. Launch

The client may be started by the Session Manager via:

If an application has an AutostartCondition key in its .desktop file, the session manager checks its value. If the autostart condition is false (eg, it points to a GConf key that is unset or false), the app is not launched until the condition becomes true.

The Session Manager will set the DESKTOP_AUTOSTART_ID environment variable to a valid client ID when starting the app. The app is then expected to use that client ID when registering with the session manager. This allows the session manager to figure out which application (desktop file) the client corresponds to. The session manager will wait a while for this client to register itself before giving up.

2. Connect

The client should then connect to the either the D-Bus session bus and potentially register for a well known name. If the client is a legacy XSMP client, then it should connect to Session Manager by using SmcOpenConnection with the value of the environment variable SESSION_MANAGER. If XSMP clients are not supported then the SESSION_MANAGER variable will not be set.

3. Register

The client must explicitly register itself with the session manager. At this time it should specify the client ID that was passed to it with DESKTOP_AUTOSTART_ID if one exists. The registration indicates to the session manager that the application associated with the client has started successfully.

In the case where a startup ID is not available the session manager will attempt to match the client with an application in the autostart database.

4. Run

During this phase the application is operational.

5. QueryEndSession

The client enters this state when the session manager determines a logout is about to take place and asks all clients if they have any reason why it should not take place. The client should communicate this to the session manager. This state will either be cancelled or a transition to EndSession will occur.

The client has one second to respond to this request. If it does not respond then it is assumed that it is not OK to proceed. If any client indicates that it not OK to proceed with logout or any clients have indicated this proactively then the user is presented with a list of these clients and activities and is allowed the option of logging out anyway.

When possible, a flag will be passed with this signal to indicate whether this logout will be forceful or not. A forceful logout will not allow any applications to delay logout for more than TBD seconds. Clients may wish to use this extra information to change behavior.

It should be stressed that, even when not forced, clients should not assume that they will have the ability to block logout or shutdown.

This state may last a certain time (TBD) or until all proactively indicated tasks (aka "inhibitors") have finished.

6. EndSession

This state is used to indicate to the client that it should perform final cleanup before exiting.

The client may not delay this stage more than ten seconds.

7. Unregister

This is usually implicitly done when the client disconnects from the underlying protocol or exits.

8. Termination

The client application quits. If the application desktop file has registered X-GNOME-AutoRestart=true then the application will be automatically restarted when the client exits.

Session Manager Lifecycle

1. Startup

The session manager is in this phase while it performs internal setup and initialization. It will read and process the desktop files for each application in the autostart database. It will assign each of them to a startup phase based on the value of the X-GNOME-Autostart-Phase value in the desktop file. If this value isn't specified it is assume to be in the Applications phase.

In "failsafe" mode, the session manager only reads the desktop files from the default session directory.

2. Initialization

During this phase the session manager starts up core session services. Any service that intends to set up the environment (including setting environment variables) should be run during this phase. This can be used for things like $GTK_MODULES, $GNOME_KEYRING_SOCKET, etc.

In this phase an application can just exit with status 0 to indicate that it is done setting up.

The session manager will wait until every application in the current phase has indicated that it is ready or a maximum of ten seconds.

3. WindowManager

Will start applications that provide window/compositing management. This includes anything else that has to be running before any windows are displayed.

Applications started in this phase MUST register with the session manager when they are up and running. The session manager will wait until every application in the current phase has indicated that it is ready or a maximum of ten seconds.

4. Panel

Will start applications that create _NET_WM_WINDOW_TYPE_PANEL windows. This includes anything that permanently takes up screen real estate (via EWMH struts).

Applications started in this phase MUST register with the session manager when they are up and running. The session manager will wait until every application in the current phase has indicated that it is ready or a maximum of ten seconds.

5. Desktop

Will start applications that create _NET_WM_WINDOW_TYPE_DESKTOP windows. This includes anything that draws on the desktop (eg, nautilus).

Applications started in this phase MUST register with the session manager when they are up and running. The session manager will wait until every application in the current phase has indicated that it is ready or a maximum of ten seconds.

6. Application

Will start all applications that have not been started in any of the previous phases.

Applications started in this phase SHOULD register with the session manager when they are up and running. The session manager will wait until every application in the current phase has indicated that it is ready or a maximum of ten seconds.

7. Running

Session should be fully prepared for use.

8. QueryEndSession

The session manager enters this phase when it determines a logout is about to take place. It asks all registered clients if they have any reason why it should not take place. The client should then respond with an answer. If the client indicates that it would prefer logout to be blocked it should provide a reason for it. This state will either be explicitly cancelled or a transition to EndSession will occur.

Each client has one second to respond to this request. If it does not respond then it is assumed that it is not OK to proceed. If any client indicates that it not OK to proceed with logout or any clients have indicated this proactively (via inhibiting) then the user is presented with a list of these clients and activities and is allowed the option of logging out anyway.

9. EndSession

The session manager enters this phase when a logout is about to take place. This state is used to indicate to the client that it should perform final cleanup before exit.

This phase lasts ten seconds or until every client has responded, whichever is longer.

10. Exit

The session will terminate. All applications should exit with it.

Associating Applications and Clients

A client is a running instance of an application. The application is launched and a client should register with the session manager. For now, the way we associate Clients with Applications by requiring the Client to register using the DESKTOP_AUTOSTART_ID, if it is available, or the application identifier.

This works reasonably well for applications that are started directly but may not be ideal for D-Bus activated services. The application ID may still work in that case but it may not be ideal. In the future, we may want to support a new type of Service client for this case.

How should an application know what identifier to use?

Good question.

D-Bus API

http://www.gnome.org/~mccann/gnome-session/docs/gnome-session.html

AutostartCondition

AutostartCondition is an extension of the Desktop Application Autostart Specification proposed by Dan Winship: http://lists.freedesktop.org/archives/xdg/2007-January/007436.html

If a key specified as some application's AutostartCondition becomes true while the session is already running, the session manager will start that application when it changes. If the same key becomes false while a client is connected for that application it will be stopped.

Use Cases

Vino Server

Possible implementation:

Screen Magnifier

Possible implementation:

Desktop Tour / First login configuration tool


2024-10-23 11:37