]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - src/seat-surfaceflinger.c
Fix autologin use case and add a test for it
[sojka/lightdm.git] / src / seat-surfaceflinger.c
1 /*
2  * Copyright (C) 2013 Robert Ancell.
3  * Author: Robert Ancell <robert.ancell@canonical.com>
4  *
5  * This program is free software: you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License as published by the Free Software
7  * Foundation, either version 3 of the License, or (at your option) any later
8  * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
9  * license.
10  */
11
12 #include <string.h>
13
14 #include "seat-surfaceflinger.h"
15 #include "surfaceflinger-server.h"
16 #include "vt.h"
17
18 G_DEFINE_TYPE (SeatSurfaceflinger, seat_surfaceflinger, SEAT_TYPE);
19
20 static void
21 seat_surfaceflinger_setup (Seat *seat)
22 {
23     seat_set_can_switch (seat, FALSE);
24     SEAT_CLASS (seat_surfaceflinger_parent_class)->setup (seat);
25 }
26
27 static DisplayServer *
28 seat_surfaceflinger_create_display_server (Seat *seat, const gchar *session_type)
29 {
30     /* Allow mir types too, because Mir sessions usually support surfaceflinger
31        as an alternate mode, since Mir is frequently used on phones. */
32     if (strcmp (session_type, "surfaceflinger") == 0 || strcmp (session_type, "mir") == 0)
33         return DISPLAY_SERVER (surfaceflinger_server_new ());
34     else
35     {
36         l_warning (seat, "Can't create unsupported display server '%s'", session_type);
37         return NULL;
38     }
39 }
40
41 static Greeter *
42 seat_surfaceflinger_create_greeter_session (Seat *seat)
43 {
44     Greeter *greeter_session;
45
46     greeter_session = SEAT_CLASS (seat_surfaceflinger_parent_class)->create_greeter_session (seat);
47     session_set_env (SESSION (greeter_session), "XDG_SEAT", seat_get_name (seat));
48
49     /* Fake the VT */
50     session_set_env (SESSION (greeter_session), "XDG_VTNR", vt_can_multi_seat () ? "1" : "0");
51
52     return greeter_session;
53 }
54
55 static Session *
56 seat_surfaceflinger_create_session (Seat *seat)
57 {
58     Session *session;
59
60     session = SEAT_CLASS (seat_surfaceflinger_parent_class)->create_session (seat);
61     session_set_env (session, "XDG_SEAT", seat_get_name (seat));
62
63     /* Fake the VT */
64     session_set_env (session, "XDG_VTNR", vt_can_multi_seat () ? "1" : "0");
65
66     return session;
67 }
68
69 static void
70 seat_surfaceflinger_init (SeatSurfaceflinger *seat)
71 {
72 }
73
74 static void
75 seat_surfaceflinger_class_init (SeatSurfaceflingerClass *klass)
76 {
77     SeatClass *seat_class = SEAT_CLASS (klass);
78
79     seat_class->setup = seat_surfaceflinger_setup;
80     seat_class->create_display_server = seat_surfaceflinger_create_display_server;
81     seat_class->create_greeter_session = seat_surfaceflinger_create_greeter_session;
82     seat_class->create_session = seat_surfaceflinger_create_session;
83 }