diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2018-01-11 15:06:59 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2018-01-11 15:06:59 +1300 |
commit | d94a6908b7a14e5eab8df27fc7f6abf41edc837a (patch) | |
tree | 636837e281e0d0b68967df2d3de32e52c8f87bb8 | |
parent | 5847d300fda3a5a7d5dabecb8dcb2af9b354f0c3 (diff) | |
download | lightdm-git-d94a6908b7a14e5eab8df27fc7f6abf41edc837a.tar.gz |
Ensure only one Xvnc server is run.
We only have one VNC connection - so make sure we don't try and use it twice.
-rw-r--r-- | src/seat-xvnc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/seat-xvnc.c b/src/seat-xvnc.c index eeb861b3..5539041d 100644 --- a/src/seat-xvnc.c +++ b/src/seat-xvnc.c @@ -21,6 +21,9 @@ struct SeatXVNCPrivate { /* VNC connection */ GSocket *connection; + + /* X server using VNC connection */ + XServerXVNC *x_server; }; SeatXVNC *seat_xvnc_new (GSocket *connection) @@ -33,6 +36,13 @@ SeatXVNC *seat_xvnc_new (GSocket *connection) return seat; } +static void +seat_xvnc_setup (Seat *seat) +{ + seat_set_supports_multi_session (seat, FALSE); + SEAT_CLASS (seat_xvnc_parent_class)->setup (seat); +} + static DisplayServer * seat_xvnc_create_display_server (Seat *seat, Session *session) { @@ -44,7 +54,11 @@ seat_xvnc_create_display_server (Seat *seat, Session *session) if (strcmp (session_get_session_type (session), "x") != 0) return NULL; - x_server = x_server_xvnc_new (); + /* Can only create one server for the lifetime of this seat (can't re-use VNC connection) */ + if (SEAT_XVNC (seat)->priv->x_server) + return NULL; + + SEAT_XVNC (seat)->priv->x_server = x_server = x_server_xvnc_new (); number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (x_server))); cookie = x_authority_new_local_cookie (number); x_server_set_authority (X_SERVER (x_server), cookie); @@ -71,7 +85,7 @@ seat_xvnc_create_display_server (Seat *seat, Session *session) x_server_xvnc_set_depth (x_server, depth); } - return DISPLAY_SERVER (x_server); + return g_object_ref (DISPLAY_SERVER (x_server)); } static void @@ -107,6 +121,7 @@ seat_xvnc_session_finalize (GObject *object) SeatXVNC *self = SEAT_XVNC (object); g_clear_object (&self->priv->connection); + g_clear_object (&self->priv->x_server); G_OBJECT_CLASS (seat_xvnc_parent_class)->finalize (object); } @@ -117,6 +132,7 @@ seat_xvnc_class_init (SeatXVNCClass *klass) SeatClass *seat_class = SEAT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); + seat_class->setup = seat_xvnc_setup; seat_class->create_display_server = seat_xvnc_create_display_server; seat_class->run_script = seat_xvnc_run_script; object_class->finalize = seat_xvnc_session_finalize; |