Skip to content

Commit

Permalink
Allow Wayland sessions to start on seat0 on kernels with no VTs
Browse files Browse the repository at this point in the history
  • Loading branch information
n3rdopolis authored and robert-ancell committed Mar 20, 2024
1 parent c51e020 commit 38ad694
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lightdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,11 @@ add_login1_seat (Login1Seat *login1_seat)
set_seat_properties (seat, seat_name);

gboolean can_multi_session = login1_seat_get_can_multi_session (login1_seat);
gboolean can_tty = login1_seat_get_can_tty (login1_seat);
if (!can_multi_session)
g_debug ("Seat %s has property CanMultiSession=no", seat_name);
seat_set_supports_multi_session (seat, can_multi_session);
seat_set_can_tty (seat, can_tty);

if (is_seat0)
seat_set_property (seat, "exit-on-failure", "true");
Expand Down
13 changes: 13 additions & 0 deletions src/login1.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ typedef struct

/* TRUE if can do session switching */
gboolean can_multi_session;

/* TRUE if seat has TTYs */
gboolean can_tty;
} Login1SeatPrivate;

G_DEFINE_TYPE_WITH_PRIVATE (Login1Service, login1_service, G_TYPE_OBJECT)
Expand Down Expand Up @@ -199,6 +202,8 @@ add_seat (Login1Service *service, const gchar *id, const gchar *path)
s_priv->can_graphical = g_variant_get_boolean (value);
else if (strcmp (name, "CanMultiSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
s_priv->can_multi_session = g_variant_get_boolean (value);
else if (strcmp (name, "CanTTY") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
s_priv->can_tty = g_variant_get_boolean (value);
}
}

Expand Down Expand Up @@ -519,6 +524,14 @@ login1_seat_get_can_multi_session (Login1Seat *seat)
return priv->can_multi_session;
}

gboolean
login1_seat_get_can_tty (Login1Seat *seat)
{
Login1SeatPrivate *priv = login1_seat_get_instance_private (seat);
g_return_val_if_fail (seat != NULL, FALSE);
return priv->can_tty;
}

static void
login1_seat_init (Login1Seat *seat)
{
Expand Down
2 changes: 2 additions & 0 deletions src/login1.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ gboolean login1_seat_get_can_graphical (Login1Seat *seat);

gboolean login1_seat_get_can_multi_session (Login1Seat *seat);

gboolean login1_seat_get_can_tty (Login1Seat *seat);

G_END_DECLS

#endif /* _LOGIN1_H_ */
4 changes: 2 additions & 2 deletions src/seat-local.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ display_server_transition_plymouth_cb (DisplayServer *display_server, Seat *seat
static gint
get_vt (SeatLocal *seat, DisplayServer *display_server)
{
if (strcmp (seat_get_name (SEAT (seat)), "seat0") != 0)
if (strcmp (seat_get_name (SEAT (seat)), "seat0") != 0 || !seat_get_can_tty ( SEAT (seat)))
return -1;

/* If Plymouth is running, stop it */
Expand Down Expand Up @@ -270,7 +270,7 @@ seat_local_get_active_session (Seat *seat)
* FIXME: Use seat_get_expected_active_session even for seat0, falling back
* to VT probing if the systemd-logind service is unavailable.
*/
if (strcmp (seat_get_name (seat), "seat0") != 0)
if (strcmp (seat_get_name (seat), "seat0") != 0 || !seat_get_can_tty (seat))
return seat_get_expected_active_session (seat);

gint vt = vt_get_active ();
Expand Down
19 changes: 19 additions & 0 deletions src/seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ typedef struct
/* TRUE if this seat can run multiple sessions at once */
gboolean supports_multi_session;

/* TRUE if this seat has TTYs */
gboolean can_tty;

/* TRUE if display server can be shared for sessions */
gboolean share_display_server;

Expand Down Expand Up @@ -207,6 +210,14 @@ seat_set_share_display_server (Seat *seat, gboolean share_display_server)
priv->share_display_server = share_display_server;
}

void
seat_set_can_tty (Seat *seat, gboolean can_tty)
{
SeatPrivate *priv = seat_get_instance_private (seat);
g_return_if_fail (seat != NULL);
priv->can_tty = can_tty;
}

gboolean
seat_start (Seat *seat)
{
Expand Down Expand Up @@ -357,6 +368,14 @@ seat_get_can_switch (Seat *seat)
return seat_get_boolean_property (seat, "allow-user-switching") && priv->supports_multi_session;
}

gboolean
seat_get_can_tty (Seat *seat)
{
SeatPrivate *priv = seat_get_instance_private (seat);
g_return_val_if_fail (seat != NULL, FALSE);
return priv->can_tty;
}

gboolean
seat_get_allow_guest (Seat *seat)
{
Expand Down
4 changes: 4 additions & 0 deletions src/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void seat_set_supports_multi_session (Seat *seat, gboolean supports_multi_sessio

void seat_set_share_display_server (Seat *seat, gboolean share_display_server);

void seat_set_can_tty (Seat *seat, gboolean can_tty);

gboolean seat_start (Seat *seat);

GList *seat_get_sessions (Seat *seat);
Expand All @@ -101,6 +103,8 @@ Session *seat_find_session_by_login1_id (Seat *seat, const gchar *login1_session

gboolean seat_get_can_switch (Seat *seat);

gboolean seat_get_can_tty (Seat *seat);

gboolean seat_get_allow_guest (Seat *seat);

gboolean seat_get_greeter_allow_guest (Seat *seat);
Expand Down

0 comments on commit 38ad694

Please sign in to comment.