]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - src/seat-surfaceflinger.c
Same logic for normal session
[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     if (strcmp (session_type, "surfaceflinger") == 0)
31         return DISPLAY_SERVER (surfaceflinger_server_new ());
32     else
33     {
34         l_warning (seat, "Can't create unsupported display server '%s'", session_type);
35         return NULL;
36     }
37 }
38
39 static Greeter *
40 seat_surfaceflinger_create_greeter_session (Seat *seat)
41 {
42     Greeter *greeter_session;
43     const gchar *xdg_seat;
44
45     greeter_session = SEAT_CLASS (seat_surfaceflinger_parent_class)->create_greeter_session (seat);
46     xdg_seat = seat_get_string_property (seat, "xdg-seat");
47     if (!xdg_seat)
48         xdg_seat = "seat0";
49     session_set_env (SESSION (greeter_session), "XDG_SEAT", xdg_seat);
50
51     /* Fake the VT */
52     session_set_env (SESSION (greeter_session), "XDG_VTNR", vt_can_multi_seat() ? "1" : "0");
53
54     return greeter_session;
55 }
56
57 static Session *
58 seat_surfaceflinger_create_session (Seat *seat)
59 {
60     Session *session;
61     const gchar *xdg_seat;
62
63     session = SEAT_CLASS (seat_surfaceflinger_parent_class)->create_session (seat);
64     xdg_seat = seat_get_string_property (seat, "xdg-seat");
65     if (!xdg_seat)
66         xdg_seat = "seat0";
67     session_set_env (session, "XDG_SEAT", xdg_seat);
68
69     /* Fake the VT */
70     session_set_env (session, "XDG_VTNR", vt_can_multi_seat() ? "1" : "0");
71
72     return session;
73 }
74
75 static void
76 seat_surfaceflinger_init (SeatSurfaceflinger *seat)
77 {
78 }
79
80 static void
81 seat_surfaceflinger_class_init (SeatSurfaceflingerClass *klass)
82 {
83     SeatClass *seat_class = SEAT_CLASS (klass);
84
85     seat_class->setup = seat_surfaceflinger_setup;
86     seat_class->create_display_server = seat_surfaceflinger_create_display_server;
87     seat_class->create_greeter_session = seat_surfaceflinger_create_greeter_session;
88     seat_class->create_session = seat_surfaceflinger_create_session;
89 }