Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let multiseat X users choose a desired X display number #350

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ config_init (Configuration *config)
g_hash_table_insert (config->priv->seat_keys, "pam-greeter-service", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->seat_keys, "xserver-backend", GINT_TO_POINTER (KEY_DEPRECATED));
g_hash_table_insert (config->priv->seat_keys, "xserver-command", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->seat_keys, "desired-display-number", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->seat_keys, "xmir-command", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->seat_keys, "xserver-config", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->seat_keys, "xserver-layout", GINT_TO_POINTER (KEY_SUPPORTED));
Expand Down
1 change: 1 addition & 0 deletions data/lightdm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
# xserver-share = True if the X server is shared for both greeter and session
# xserver-hostname = Hostname of X server (only for type=xremote)
# xserver-display-number = Display number of X server (only for type=xremote)
# desired-display-number = The display number you wish to have this seat have, if it is already used the next available will be used
# xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
# xdmcp-port = XDMCP UDP/IP port to communicate on
# xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
Expand Down
3 changes: 3 additions & 0 deletions src/seat-local.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ create_x_server (SeatLocal *seat)
{
g_autoptr(XServerLocal) x_server = x_server_local_new ();

gint desired_display_number = seat_get_integer_property_with_fallback (SEAT (seat), "desired-display-number", -1);
x_server_local_init_display_number (x_server, desired_display_number);

gint vt = get_vt (seat, DISPLAY_SERVER (x_server));
if (vt >= 0)
x_server_local_set_vt (x_server, vt);
Expand Down
11 changes: 9 additions & 2 deletions src/seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,17 @@ seat_get_boolean_property (Seat *seat, const gchar *name)
}

gint
seat_get_integer_property (Seat *seat, const gchar *name)
seat_get_integer_property_with_fallback (Seat *seat, const gchar *name, gint fallback)
{
const gchar *value = seat_get_string_property (seat, name);
return value ? atoi (value) : 0;
return value ? atoi (value) : fallback;
}


gint
seat_get_integer_property (Seat *seat, const gchar *name)
{
return seat_get_integer_property_with_fallback (seat, name, 0);
}

const gchar *
Expand Down
2 changes: 2 additions & 0 deletions src/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ gchar **seat_get_string_list_property (Seat *seat, const gchar *name);

gboolean seat_get_boolean_property (Seat *seat, const gchar *name);

gint seat_get_integer_property_with_fallback (Seat *seat, const gchar *name, gint fallback);

gint seat_get_integer_property (Seat *seat, const gchar *name);

const gchar *seat_get_name (Seat *seat);
Expand Down
23 changes: 21 additions & 2 deletions src/x-server-local.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,16 @@ display_number_in_use (guint display_number)
}

static guint
x_server_local_get_unused_display_number (void)
x_server_local_get_unused_display_number (gint desired_display_number)
{
// First attempt to use the requested display number
if (desired_display_number >= 0) {
if (!display_number_in_use (desired_display_number)) {
return desired_display_number;
}
}

// Else fall back
guint number = config_get_integer (config_get_instance (), "LightDM", "minimum-display-number");
while (display_number_in_use (number))
number++;
Expand Down Expand Up @@ -194,6 +202,16 @@ x_server_local_set_command (XServerLocal *server, const gchar *command)
priv->command = g_strdup (command);
}

void
x_server_local_init_display_number (XServerLocal *server, gint number)
{
XServerLocalPrivate *priv = x_server_local_get_instance_private (server);
g_return_if_fail (server != NULL);

priv->display_number = x_server_local_get_unused_display_number (number);
l_debug (server, "Requested display number %d, actual display number: %d", number, priv->display_number);
}

void
x_server_local_set_vt (XServerLocal *server, gint vt)
{
Expand Down Expand Up @@ -574,9 +592,10 @@ static void
x_server_local_init (XServerLocal *server)
{
XServerLocalPrivate *priv = x_server_local_get_instance_private (server);

priv->vt = -1;
priv->command = g_strdup ("X");
priv->display_number = x_server_local_get_unused_display_number ();
priv->display_number = -1;
}

static void
Expand Down
2 changes: 2 additions & 0 deletions src/x-server-local.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ XServerLocal *x_server_local_new (void);

void x_server_local_set_command (XServerLocal *server, const gchar *command);

void x_server_local_init_display_number (XServerLocal *server, gint number);

void x_server_local_set_vt (XServerLocal *server, gint vt);

void x_server_local_set_config (XServerLocal *server, const gchar *path);
Expand Down
Loading