## ExoXsessionClient

ExoXsessionClient — Lightweight session management support

## Functions

ExoXsessionClient * | exo_xsession_client_new_with_group ()
GdkWindow * | exo_xsession_client_get_group ()
void | exo_xsession_client_set_group ()
gboolean | exo_xsession_client_get_restart_command ()
void | exo_xsession_client_set_restart_command ()

## Properties

GdkWindow * | group | Read / Write
GStrv | restart-command | Read / Write

## Signals

void | save-yourself | Run First

## Types and Values

struct | ExoXsessionClient

## Object Hierarchy

        GObject
        ╰── ExoXsessionClient

## Includes

    #include <exo/exo.h>

## Description

This module provides application developers with lightweight session management functions, based on the X11R5 session management protocol. The X11R5 session management protocol is very limited in its functionality and flexibility compared to the newer X11R6 session management protocol (XSMP), but - on the other hand - offers several advantages for applications that do not need the complicated features of the XSMP. Most importantly, the setup is much easier and faster than with XSMP, because no special actions must be taken.

So, in case your application is simple in its session management requirements, e.g. it only needs to tell the session manager its restart command, you may want to use the ExoXsessionClient instead of a full featured XSMP client.

Lets say, for example, you are developing a text editor, which should provide basic session management support, limited to proper restarting all editor windows that where left open when you logged off the X session. In case the user was editing a file when logging off, the same file should be opened in the window on next startup.

Example 4. Texteditor with ExoXsessionClient

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49

    static gchar *open_file_name = NULL;

    static void
    save_yourself (ExoXsessionClient *client)
    {
      gchar *argv[2];

      if (open_file_name != NULL)
        {
          argv[0] = "myeditor";
          argv[1] = open_file_name;

          exo_xsession_client_set_restart_command (client, argv, 2);
        }
      else
        {
          argv[0] = "myeditor";

          exo_xsession_client_set_restart_command (client, argv, 1);
        }
    }

    // ...

    int
    main (int argc, char **argv)
    {
      ExoXsessionClient *client;
      GdkDisplay        *display;
      GdkWindow         *leader;
      GtkWidget         *window;

      gtk_init (&argc, &argv);

      if (argc > 1)
        open_file_name = argv[1];

      // create the main window
      window = create_window ();

      // setup the session client
      display = gtk_widget_get_display (window);
      leader = gdk_display_get_default_group (display);
      client = exo_xsession_client_new_with_group (leader);
      g_signal_connect (G_OBJECT (client), "save-yourself",
                        G_CALLBACK (save_yourself), NULL);

      // ...
    }

This example demonstrates the basic handling of ExoXsessionClient. It is oversimplified, but we hope you get the point. The rule of thumb is, use ExoXsessionClient if you can store all session data in the restart command, else use a full-featured XSMP client.

## Functions

### exo_xsession_client_new_with_group ()

    ExoXsessionClient *
    exo_xsession_client_new_with_group (GdkWindow *leader);

Creates a new ExoXsessionClient and associates it with the group, which is lead by `leader` .

#### Parameters

leader | The client leader window of the group. |

#### Returns

A newly allocated ExoXsessionClient.

### exo_xsession_client_get_group ()

    GdkWindow *
    exo_xsession_client_get_group (ExoXsessionClient *client);

Returns the client leader window of the group with which the `client` is associated or `NULL` if `client` is not associated with any group.

#### Parameters

client | An ExoXsessionClient. |

#### Returns

The client leader window of the group with which `client` is associated or `NULL`.

### exo_xsession_client_set_group ()

    void
    exo_xsession_client_set_group (ExoXsessionClient *client,
                                   GdkWindow *leader);

Sets the group according to the specified `leader` .

#### Parameters

client | An ExoXsessionClient. |
leader | The client leader window of a group or `NULL`. |

### exo_xsession_client_get_restart_command ()

    gboolean
    exo_xsession_client_get_restart_command
                                   (ExoXsessionClient *client,
                                    gchar ***argv,
                                    gint *argc);

Retrieves the restart command previously set on `client` . The result is stored in `argv` and should be freed using `g_strfreev()` when no longer needed.

See `exo_xsession_client_set_restart_command()` for further explanation.

#### Parameters

client | An ExoXsessionClient. |
argv | Pointer to the location where the pointer to the argument vector should be stored to. |
argc | Pointer to the location where the number of arguments should be stored to or `NULL`. |

#### Returns

`TRUE` on success, else `FALSE`.

### exo_xsession_client_set_restart_command ()

    void
    exo_xsession_client_set_restart_command
                                   (ExoXsessionClient *client,
                                    gchar **argv,
                                    gint argc);

Sets the `WM_COMMAND` property on the client leader window, which instructs the session manager (or session-enabled window manager) how to restart the application on next login.

This function can only be used if `client` is associated with a client leader window.

If `argc` is specify as -1, the argument vector `argv` is expected to be `NULL`-terminated and `argc` will be automatically calculated from `argv` .

Please take note, that `gtk_init()` automatically sets the `WM_COMMAND` property on all client leader windows that are implicitly created by Gtk+. So, you may only need to call this function in response to the ::save-yourself signal.

#### Parameters

client | An ExoXsessionClient. |
argv | The argument vector. |
argc | The number of arguments in `argv` or -1. |

## Types and Values

### struct ExoXsessionClient

    struct ExoXsessionClient;

The ExoXsessionClient struct contains only private fields and should not be directly accessed.

## Property Details

### The `“group”` property

      “group”                    GdkWindow *

Window group leader.

Flags: Read / Write

### The `“restart-command”` property

      “restart-command”          GStrv

Session restart command.

Flags: Read / Write

## Signal Details

### The `“save-yourself”` signal

    void
    user_function (ExoXsessionClient *client,
                   gpointer           user_data)

This signal is emitted when `client` receives a `WM_SAVE_YOURSELF` message from the session manager or the window manager on the specified client leader window.

#### Parameters

client | An ExoXsessionClient. |
user_data | user data set when the signal handler was connected. |

Flags: Run First